7 void turrets_precache()
9 precache_model ("models/turrets/ewheel-base2.md3");
10 precache_model ("models/turrets/ewheel-gun1.md3");
11 precache_model ("models/turrets/base.md3");
12 precache_model ("models/turrets/flac.md3");
13 precache_model ("models/turrets/reactor.md3");
14 precache_model ("models/turrets/hellion.md3");
15 precache_model ("models/turrets/hk.md3");
16 precache_model ("models/turrets/machinegun.md3");
17 precache_model ("models/turrets/mlrs.md3");
18 precache_model ("models/turrets/phaser.md3");
19 precache_model ("models/turrets/phaser_beam.md3");
20 precache_model ("models/turrets/plasma.md3");
21 precache_model ("models/turrets/plasmad.md3");
22 precache_model ("models/turrets/tesla_head.md3");
23 precache_model ("models/turrets/tesla_base.md3");
24 precache_model ("models/turrets/walker_head_minigun.md3");
25 precache_model ("models/turrets/walker_body.md3");
26 precache_model ("models/turrets/rocket.md3");
28 precache_sound ("turrets/phaser.wav");
29 precache_sound ("weapons/rocket_impact.wav");
30 precache_sound ("weapons/uzi_fire.wav");
33 void turret_tid2info(float _tid)
35 tid2info_base = "models/turrets/base.md3";
36 tid2info_min = '-32 -32 0';
37 tid2info_max = '32 32 64';
42 tid2info_base = "models/turrets/ewheel-base2.md3";
43 tid2info_head = "models/turrets/ewheel-gun1.md3";
44 tid2info_name = "eWheel";
47 tid2info_head = "models/turrets/flac.md3";
48 tid2info_name = "Flac Cannon";
51 tid2info_head = "models/turrets/reactor.md3";
52 tid2info_name = "Fusion Reactor";
53 tid2info_min = '-34 -34 0';
54 tid2info_max = '34 34 90';
57 tid2info_head = "models/turrets/hellion.md3";
58 tid2info_name = "Hellion";
61 tid2info_head = "models/turrets/hk.md3";
62 tid2info_name = "Hunter-Killer";
65 tid2info_head = "models/turrets/machinegun.md3";
66 tid2info_name = "Machinegun";
69 tid2info_head = "models/turrets/mlrs.md3";
70 tid2info_name = "MLRS";
73 tid2info_head = "models/turrets/phaser.md3";
74 tid2info_name = "Phaser";
77 tid2info_head = "models/turrets/plasma.md3";
78 tid2info_name = "Plasma";
81 tid2info_head = "models/turrets/plasmad.md3";
82 tid2info_name = "Dual Plasma";
85 tid2info_base = "models/turrets/tesla_base.md3";
86 tid2info_head = "models/turrets/tesla_head.md3";
87 tid2info_name = "Tesla coil";
88 tid2info_min = '-60 -60 0';
89 tid2info_max ='60 60 128';
92 tid2info_base = "models/turrets/walker_body.md3";
93 tid2info_head = "models/turrets/walker_head_minigun.md3";
94 tid2info_name = "Walker";
95 tid2info_min = '-70 -70 0';
96 tid2info_max = '70 70 95';
103 turret_tid2info(self.turret_type);
104 dprint("Removing ", tid2info_name, " turrret.\n");
106 remove(self.tur_head);
107 self.tur_head = world;
110 void turret_changeteam()
112 self.colormod = '0 0 0';
116 case COLOR_TEAM1: // Red
117 self.colormod = '2 0.5 0.5';
120 case COLOR_TEAM2: // Blue
121 self.colormod = '0.5 0.5 2';
124 case COLOR_TEAM3: // Yellow
125 self.colormod = '1.4 1.4 0.6';
128 case COLOR_TEAM4: // Pink
129 self.colormod = '1.4 0.6 1.4';
133 self.tur_head.colormod = self.colormod;
136 void turret_head_draw()
138 self.drawmask = MASK_NORMAL;
145 dt = time - self.move_time;
146 self.move_time = time;
150 self.tur_head.angles += dt * self.tur_head.move_avelocity;
152 if (self.health < 127)
154 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
158 void turret_moving_draw()
162 dt = time - self.move_time;
163 self.move_time = time;
167 fixedmakevectors(self.angles);
168 movelib_groundalign4point(300, 100, 0.25);
170 setorigin(self, self.origin + self.velocity * dt);
171 if(self.turret_type == TID_WALKER)
172 setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
174 setorigin(self.tur_head, self.origin);
176 self.tur_head.angles += dt * self.tur_head.move_avelocity;
178 self.angles_y = self.move_angles_y;
180 if (self.health < 127)
182 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
185 void turret_construct()
187 if(self.tur_head == world)
188 self.tur_head = spawn();
190 turret_tid2info(self.turret_type);
191 dprint("Constructing ", tid2info_name , " turret (", ftos(self.turret_type), ")\n");
193 setorigin(self, self.origin);
194 setmodel(self, tid2info_base);
195 setmodel(self.tur_head, tid2info_head);
196 setsize(self, tid2info_min, tid2info_max);
197 setsize(self.tur_head, '0 0 0', '0 0 0');
198 setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
200 self.tur_head.classname = "turret_head";
201 self.tur_head.owner = self;
202 self.tur_head.move_movetype = MOVETYPE_NOCLIP;
203 self.move_movetype = MOVETYPE_NOCLIP;
204 self.tur_head.angles = self.angles;
206 self.solid = SOLID_BBOX;
207 self.tur_head.solid = SOLID_NOT;
208 self.movetype = MOVETYPE_NOCLIP;
209 self.tur_head.movetype = MOVETYPE_NOCLIP;
210 //self.draw = turret_draw;
211 self.entremove = turret_remove;
212 self.drawmask = MASK_NORMAL;
213 self.tur_head.drawmask = MASK_NORMAL;
215 if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
218 self.movetype = MOVETYPE_BOUNCE;
219 self.move_movetype = MOVETYPE_BOUNCE;
220 self.move_origin = self.origin;
221 self.move_time = time;
222 self.draw = turret_moving_draw;
226 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
227 void turret_gibboom();
228 void turret_gib_draw()
230 Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
232 self.drawmask = MASK_NORMAL;
236 if(time >= self.nextthink)
244 self.alpha = bound(0, self.nextthink - time, 1);
245 if(self.alpha < ALPHA_MIN_VISIBLE)
250 void turret_gibboom()
254 sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
255 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
257 for (i = 1; i < 5; i = i + 1)
258 turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin, self.velocity + randomvec() * 700, '0 0 0', FALSE);
261 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
266 setorigin(gib, _from);
267 setmodel(gib, _model);
268 gib.colormod = _cmod;
269 gib.solid = SOLID_CORPSE;
270 gib.draw = turret_gib_draw;
275 gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
276 gib.effects = EF_FLAME;
279 gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
282 gib.move_movetype = MOVETYPE_BOUNCE;
283 gib.move_origin = gib.origin = _from;
284 gib.move_velocity = _to;
285 gib.move_avelocity = prandomvec() * 32;
286 gib.move_time = time;
287 gib.damageforcescale = 1;
297 setmodel(self.tur_head, "");
298 sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
299 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
300 turret_tid2info(self.turret_type);
301 dprint("Turret ", tid2info_name, " dies.\n");
304 if(self.turret_type == TID_EWHEEL)
305 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
306 else if (self.turret_type == TID_WALKER)
307 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
308 else if (self.turret_type == TID_TESLA)
309 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
314 turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
315 turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
316 turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
319 turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 4', '0 0 0', '0 0 0', TRUE);
322 headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', TRUE);
323 headgib.angles = headgib.move_angles = self.tur_head.angles;
324 headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
325 headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
326 headgib.gravity = 0.5;
336 self.turret_type = ReadByte();
338 self.origin_x = ReadCoord();
339 self.origin_y = ReadCoord();
340 self.origin_z = ReadCoord();
342 self.angles_x = ReadAngle();
343 self.angles_y = ReadAngle();
350 self.tur_head.move_angles_x = ReadShort();
351 self.tur_head.move_angles_y = ReadShort();
352 self.tur_head.angles = self.angles + self.tur_head.move_angles;
357 self.tur_head.move_avelocity_x = ReadShort();
358 self.tur_head.move_avelocity_y = ReadShort();
363 self.origin_x = ReadShort();
364 self.origin_y = ReadShort();
365 self.origin_z = ReadShort();
366 setorigin(self, self.origin);
368 self.velocity_x = ReadShort();
369 self.velocity_y = ReadShort();
370 self.velocity_z = ReadShort();
372 self.move_angles_y = ReadShort();
374 self.move_time = time;
375 self.move_velocity = self.velocity;
376 self.move_origin = self.origin;
381 self.frame1time = ReadCoord();
382 self.frame = ReadByte();
389 _team -= 1; // /&)=(%&#)&%)/#&)=½!!!½!!". thanks.
390 self.health = ReadByte();
391 if(_team != self.team)