Include gmqcc binaries for Windows and Linux
[voretournament/voretournament.git] / data / qcsrc / client / casings.qc
1 .float silent;\r
2 \r
3 void Casing_Delete()\r
4 {\r
5     remove(self);\r
6 }\r
7 \r
8 void Casing_Draw()\r
9 {\r
10         if(self.move_flags & FL_ONGROUND)\r
11         {\r
12                 self.move_angles_x = 0;\r
13                 self.move_angles_z = 0;\r
14                 self.flags &~= FL_ONGROUND;\r
15         }\r
16 \r
17         Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);\r
18 \r
19         self.renderflags = 0;\r
20         self.alpha = bound(0, self.cnt - time, 1);\r
21 \r
22         if(self.alpha < ALPHA_MIN_VISIBLE)\r
23                 Casing_Delete();\r
24         else\r
25                 R_AddEntity(self);\r
26 }\r
27 \r
28 void Casing_Touch()\r
29 {\r
30         if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)\r
31         {\r
32                 Casing_Delete();\r
33                 return;\r
34         }\r
35 \r
36         if(!self.silent)\r
37         if(!trace_ent || trace_ent.solid == SOLID_BSP)\r
38         {\r
39                 if(vlen(self.velocity) > 50)\r
40                 {\r
41                         if(time >= self.nextthink)\r
42                         {\r
43                                 string s;\r
44                                 float f;\r
45 \r
46                                 f = floor(prandom() * 3) + 1;\r
47                                 switch(self.state)\r
48                                 {\r
49                                         case 1:\r
50                                                 s = strcat("casings/fuel_casing", ftos(f), ".wav");\r
51                                                 break;\r
52                                         default:\r
53                                                 break;\r
54                                 }\r
55 \r
56                                 sound (self, CHAN_PROJECTILE, s, VOL_BASE, ATTN_NORM);\r
57                         }\r
58                 }\r
59         }\r
60 \r
61         self.nextthink = time + 0.2;\r
62 }\r
63 \r
64 void Casing_Damage(float thisdmg, float hittype, vector org, vector thisforce)\r
65 {\r
66         if(thisforce_z < 0)\r
67                 thisforce_z = 0;\r
68         self.move_velocity = self.move_velocity + thisforce + '0 0 100';\r
69         self.move_flags &~= FL_ONGROUND;\r
70 }\r
71 \r
72 void Ent_Casing(float isNew)\r
73 {\r
74         entity casing;\r
75 \r
76         casing = RubbleNew("casing");\r
77         casing.state = ReadByte();\r
78         casing.silent = (casing.state & 0x80);\r
79         casing.state = (casing.state & 0x7F);\r
80         casing.origin_x = ReadCoord();\r
81         casing.origin_y = ReadCoord();\r
82         casing.origin_z = ReadCoord();\r
83         casing.velocity = decompressShortVector(ReadShort());\r
84         casing.angles_x = ReadByte() * 360 / 256;\r
85         casing.angles_y = ReadByte() * 360 / 256;\r
86         casing.angles_z = ReadByte() * 360 / 256;\r
87 \r
88         if(cvar("cl_casings") && isNew) {\r
89                 casing.draw = Casing_Draw;\r
90                 casing.move_origin = casing.origin;\r
91                 casing.move_velocity = casing.velocity + 2 * prandomvec();\r
92                 casing.move_angles = casing.angles;\r
93                 casing.move_avelocity = '0 250 0' + 100 * prandomvec();\r
94                 casing.move_movetype = MOVETYPE_BOUNCE;\r
95                 casing.move_touch = Casing_Touch;\r
96                 casing.move_time = time;\r
97                 casing.event_damage = Casing_Damage;\r
98                 casing.solid = SOLID_TRIGGER;\r
99                 casing.cnt = time + cvar("cl_casings_time");\r
100 \r
101                 switch(casing.state)\r
102                 {\r
103                         case 1:\r
104                                 setmodel(casing, "models/casings/fuel_casing.md3");\r
105                                 break;\r
106                         default:\r
107                                 break;\r
108                 }\r
109 \r
110                 setsize(casing, '0 0 -1', '0 0 -1');\r
111         }\r
112     else\r
113         Casing_Delete();\r
114 \r
115         RubbleLimit("casing", cvar_or("cl_casings_maxcount",100), Casing_Delete);\r
116 }\r
117 \r
118 void Casings_Precache()\r
119 {\r
120         precache_model("models/casings/fuel_casing.md3");\r
121         precache_sound("casings/fuel_casing1.wav");\r
122         precache_sound("casings/fuel_casing2.wav");\r
123         precache_sound("casings/fuel_casing3.wav");\r
124 }\r