7 void turret_tid2info(float _tid);
8 void turret_precache(float _tid);
9 float turret_is_precache[TID_LAST];
11 void turrets_precache()
13 turret_precache(TID_COMMON);
16 void turret_precache(float _tid)
18 if (!turret_is_precache[TID_COMMON])
20 dprint("turret_precache TID_COMMON\n");
21 precache_sound ("weapons/rocket_impact.wav");
22 precache_model ("models/turrets/base-gib1.md3");
23 precache_model ("models/turrets/base-gib2.md3");
24 precache_model ("models/turrets/base-gib3.md3");
25 precache_model ("models/turrets/base-gib4.md3");
26 precache_model ("models/turrets/head-gib1.md3");
27 precache_model ("models/turrets/head-gib2.md3");
28 precache_model ("models/turrets/head-gib3.md3");
29 precache_model ("models/turrets/head-gib4.md3");
30 precache_model ("models/turrets/terrainbase.md3");
31 precache_model ("models/turrets/base.md3");
32 precache_model ("models/turrets/rocket.md3");
34 turret_tid2info(_tid);
35 if(turret_is_precache[_tid])
37 dprint("turret_precache: ", tid2info_name, " allready precachd, skipping.\n");
41 dprint("turret_precache: ", tid2info_name, " precaching.\n");
46 precache_model ("models/turrets/ewheel-base2.md3");
47 precache_model ("models/turrets/ewheel-gun1.md3");
50 precache_model ("models/turrets/flac.md3");
53 precache_model ("models/turrets/reactor.md3");
56 precache_model ("models/turrets/hellion.md3");
59 precache_model ("models/turrets/hk.md3");
62 precache_model ("models/turrets/machinegun.md3");
63 precache_sound ("weapons/uzi_fire.wav");
66 precache_model ("models/turrets/mlrs.md3");
69 precache_model ("models/turrets/phaser.md3");
70 precache_model ("models/turrets/phaser_beam.md3");
71 precache_sound ("turrets/phaser.wav");
74 precache_model ("models/turrets/plasma.md3");
77 precache_model ("models/turrets/plasmad.md3");
80 precache_model ("models/turrets/tesla_head.md3");
81 precache_model ("models/turrets/tesla_base.md3");
84 precache_model ("models/turrets/walker_head_minigun.md3");
85 precache_model ("models/turrets/walker_body.md3");
86 precache_sound ("weapons/uzi_fire.wav");
89 turret_is_precache[_tid] = TRUE;
92 void turret_tid2info(float _tid)
94 tid2info_base = "models/turrets/base.md3";
95 tid2info_min = '-32 -32 0';
96 tid2info_max = '32 32 64';
101 tid2info_base = "models/turrets/ewheel-base2.md3";
102 tid2info_head = "models/turrets/ewheel-gun1.md3";
103 tid2info_name = "eWheel";
106 tid2info_head = "models/turrets/flac.md3";
107 tid2info_name = "Flac Cannon";
110 tid2info_head = "models/turrets/reactor.md3";
111 tid2info_name = "Fusion Reactor";
112 tid2info_min = '-34 -34 0';
113 tid2info_max = '34 34 90';
116 tid2info_head = "models/turrets/hellion.md3";
117 tid2info_name = "Hellion";
120 tid2info_head = "models/turrets/hk.md3";
121 tid2info_name = "Hunter-Killer";
124 tid2info_head = "models/turrets/machinegun.md3";
125 tid2info_name = "Machinegun";
128 tid2info_head = "models/turrets/mlrs.md3";
129 tid2info_name = "MLRS";
132 tid2info_head = "models/turrets/phaser.md3";
133 tid2info_name = "Phaser";
136 tid2info_head = "models/turrets/plasma.md3";
137 tid2info_name = "Plasma";
139 case TID_PLASMA_DUAL:
140 tid2info_head = "models/turrets/plasmad.md3";
141 tid2info_name = "Dual Plasma";
144 tid2info_base = "models/turrets/tesla_base.md3";
145 tid2info_head = "models/turrets/tesla_head.md3";
146 tid2info_name = "Tesla coil";
147 tid2info_min = '-60 -60 0';
148 tid2info_max ='60 60 128';
151 tid2info_base = "models/turrets/walker_body.md3";
152 tid2info_head = "models/turrets/walker_head_minigun.md3";
153 tid2info_name = "Walker";
154 tid2info_min = '-70 -70 0';
155 tid2info_max = '70 70 95';
162 turret_tid2info(self.turret_type);
163 dprint("Removing ", tid2info_name, " turrret.\n");
165 remove(self.tur_head);
166 self.tur_head = world;
169 void turret_changeteam()
171 self.colormod = '0 0 0';
175 case COLOR_TEAM1: // Red
176 self.colormod = '2 0.5 0.5';
179 case COLOR_TEAM2: // Blue
180 self.colormod = '0.5 0.5 2';
183 case COLOR_TEAM3: // Yellow
184 self.colormod = '1.4 1.4 0.6';
187 case COLOR_TEAM4: // Pink
188 self.colormod = '1.4 0.6 1.4';
192 self.tur_head.colormod = self.colormod;
195 void turret_head_draw()
197 self.drawmask = MASK_NORMAL;
204 dt = time - self.move_time;
205 self.move_time = time;
209 self.tur_head.angles += dt * self.tur_head.move_avelocity;
211 if (self.health < 127)
216 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
222 pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
226 pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
230 void turret_walker_draw()
234 dt = time - self.move_time;
235 self.move_time = time;
239 fixedmakevectors(self.angles);
240 movelib_groundalign4point(300, 100, 0.25);
242 setorigin(self, self.origin + self.velocity * dt);
243 setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
245 self.tur_head.angles += dt * self.tur_head.move_avelocity;
247 self.angles_y = self.move_angles_y;
249 if (self.health < 127)
251 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
254 void turret_ewheel_draw()
258 dt = time - self.move_time;
259 self.move_time = time;
263 fixedmakevectors(self.angles);
264 movelib_groundalign4point(300, 100, 0.25);
266 setorigin(self, self.origin + self.velocity * dt);
267 setorigin(self.tur_head, self.origin);
269 self.tur_head.angles += dt * self.tur_head.move_avelocity;
272 //self.angles_z -= self.angles_z * dt * 2;
273 //self.angles_z = bound(-45, self.angles_z + ((self.move_angles_y - self.angles_y * -25) * dt), 45);
275 self.angles_y = self.move_angles_y;
277 if (self.health < 127)
279 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
282 void turret_construct()
284 if(self.tur_head == world)
285 self.tur_head = spawn();
287 turret_tid2info(self.turret_type);
288 dprint("Constructing ", tid2info_name , " turret (", ftos(self.turret_type), ")\n");
290 setorigin(self, self.origin);
291 setmodel(self, tid2info_base);
292 setmodel(self.tur_head, tid2info_head);
293 setsize(self, tid2info_min, tid2info_max);
294 setsize(self.tur_head, '0 0 0', '0 0 0');
295 setorigin(self.tur_head, gettaginfo(self, gettagindex(self, "tag_head")));
297 self.tur_head.classname = "turret_head";
298 self.tur_head.owner = self;
299 self.tur_head.move_movetype = MOVETYPE_NOCLIP;
300 self.move_movetype = MOVETYPE_NOCLIP;
301 self.tur_head.angles = self.angles;
303 self.solid = SOLID_BBOX;
304 self.tur_head.solid = SOLID_NOT;
305 self.movetype = MOVETYPE_NOCLIP;
306 self.tur_head.movetype = MOVETYPE_NOCLIP;
307 self.draw = turret_draw;
308 self.entremove = turret_remove;
309 self.drawmask = MASK_NORMAL;
310 self.tur_head.drawmask = MASK_NORMAL;
312 if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
315 self.movetype = MOVETYPE_BOUNCE;
316 self.move_movetype = MOVETYPE_BOUNCE;
317 self.move_origin = self.origin;
318 self.move_time = time;
319 switch(self.turret_type)
322 self.draw = turret_ewheel_draw;
325 self.draw = turret_walker_draw;
330 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
331 void turret_gibboom();
332 void turret_gib_draw()
334 Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
336 self.drawmask = MASK_NORMAL;
340 if(time >= self.nextthink)
348 self.alpha = bound(0, self.nextthink - time, 1);
349 if(self.alpha < ALPHA_MIN_VISIBLE)
354 void turret_gibboom()
358 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
359 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
361 for (i = 1; i < 5; i = i + 1)
362 turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin, self.velocity + randomvec() * 700, '0 0 0', FALSE);
365 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
370 setorigin(gib, _from);
371 setmodel(gib, _model);
372 gib.colormod = _cmod;
373 gib.solid = SOLID_CORPSE;
374 gib.draw = turret_gib_draw;
379 gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
380 gib.effects = EF_FLAME;
383 gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
386 gib.move_movetype = MOVETYPE_BOUNCE;
387 gib.move_origin = gib.origin = _from;
388 gib.move_velocity = _to;
389 gib.move_avelocity = prandomvec() * 32;
390 gib.move_time = time;
391 gib.damageforcescale = 1;
401 setmodel(self.tur_head, "");
402 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
403 pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
404 turret_tid2info(self.turret_type);
405 dprint("Turret ", tid2info_name, " dies.\n");
408 if(self.turret_type == TID_EWHEEL)
409 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
410 else if (self.turret_type == TID_WALKER)
411 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
412 else if (self.turret_type == TID_TESLA)
413 turret_gibtoss(tid2info_base, self.origin, self.velocity, '-1 -1 -1', FALSE);
418 turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
419 turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
420 turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 2', '0 0 50' + randomvec() * 150, '0 0 0', FALSE);
423 turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 4', '0 0 0', '0 0 0', TRUE);
426 headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', TRUE);
427 headgib.angles = headgib.move_angles = self.tur_head.angles;
428 headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
429 headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
430 headgib.gravity = 0.5;
440 self.turret_type = ReadByte();
442 self.origin_x = ReadCoord();
443 self.origin_y = ReadCoord();
444 self.origin_z = ReadCoord();
446 self.angles_x = ReadAngle();
447 self.angles_y = ReadAngle();
449 turret_precache(self.turret_type);
455 self.tur_head.move_angles_x = ReadShort();
456 self.tur_head.move_angles_y = ReadShort();
457 self.tur_head.angles = self.angles + self.tur_head.move_angles;
462 self.tur_head.move_avelocity_x = ReadShort();
463 self.tur_head.move_avelocity_y = ReadShort();
468 self.origin_x = ReadShort();
469 self.origin_y = ReadShort();
470 self.origin_z = ReadShort();
471 setorigin(self, self.origin);
473 self.velocity_x = ReadShort();
474 self.velocity_y = ReadShort();
475 self.velocity_z = ReadShort();
477 self.move_angles_y = ReadShort();
479 self.move_time = time;
480 self.move_velocity = self.velocity;
481 self.move_origin = self.origin;
486 self.frame1time = ReadCoord();
487 self.frame = ReadByte();
494 _team -= 1; // /&)=(%&#)&%)/#&)=½!!!½!!". thanks.
495 self.health = ReadByte();
496 if(_team != self.team)