4 void turret_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
6 self.velocity += vforce;
10 vector v_from, vector v_to, vector v_colormod,
12 float f_lifetime, float f_fadetime, float b_burn)
19 gib.classname = "turret_gib";
21 setorigin(gib,v_from);
22 SUB_SetFade(gib,time + f_lifetime,2);
24 gib.solid = SOLID_BBOX;
26 gib.movetype = MOVETYPE_BOUNCE;
27 gib.takedamage = DAMAGE_YES;
28 gib.event_damage = turret_gib_damage;
30 gib.effects = EF_LOWPRECISION;
31 gib.flags = FL_NOTARGET;
32 gib.colormod = v_colormod;
38 burn.effects = EF_LOWPRECISION;//|EF_FLAME;
39 setattachment(burn,gib,"");
40 setorigin(burn,(gib.mins + gib.maxs) * 0.5);
41 SUB_SetFade(burn,time + (f_lifetime * 0.5) ,2);
45 void turret_gib_boom()
51 for (i = 1; i < 5; i = i +1)
54 gib.classname = "turret_gib";
56 s = strcat("models/turrets/head-gib",ftos(i));
58 // bprint("s:",s,"\n");
61 setorigin(gib,self.origin);
63 SUB_SetFade(gib,time + 5,2);
65 gib.solid = SOLID_BBOX;
67 gib.movetype = MOVETYPE_BOUNCE;
69 gib.damageforcescale = 2;
70 gib.takedamage = DAMAGE_YES;
71 gib.event_damage = turret_gib_damage;
73 gib.effects = EF_LOWPRECISION;
74 gib.flags = FL_NOTARGET;
75 gib.velocity = self.velocity + (randomvec() * 700);
76 gib.avelocity = randomvec() * 64;
79 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
80 WriteByte (MSG_BROADCAST, 78);
81 WriteCoord (MSG_BROADCAST, self.origin_x);
82 WriteCoord (MSG_BROADCAST, self.origin_y);
83 WriteCoord (MSG_BROADCAST, self.origin_z);
89 vector v_from, vector v_to, vector v_colormod,
90 entity e_mimic, float boomtime)
96 gib.classname = "turret_gib";
97 setmodel(gib,e_mimic.model);
98 setorigin(gib,v_from);
100 gib.solid = SOLID_BBOX;
102 gib.movetype = MOVETYPE_BOUNCE;
104 gib.damageforcescale = 2;
105 gib.takedamage = DAMAGE_YES;
106 gib.event_damage = turret_gib_damage;
108 gib.effects = EF_LOWPRECISION;
109 gib.flags = FL_NOTARGET;
110 gib.colormod = v_colormod;
112 gib.avelocity = randomvec() * 32;
113 gib.think = turret_gib_boom;
114 gib.nextthink = boomtime;
115 //gib.effects = EF_FLAME;
120 * Spawn a boom, trow fake bits arround
121 * and hide the real ones.
123 void turret_stdproc_die()
128 self.deadflag = DEAD_DEAD;
129 self.tur_head.deadflag = self.deadflag;
131 sound (self, CHAN_PLAYER, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
132 org2 = self.origin + '0 0 40';
135 WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
136 WriteByte (MSG_BROADCAST, 78);
137 WriteCoord (MSG_BROADCAST, org2_x);
138 WriteCoord (MSG_BROADCAST, org2_y);
139 WriteCoord (MSG_BROADCAST, org2_z);
141 // Unsolidify and hide real parts
142 self.solid = SOLID_NOT;
143 self.tur_head.solid = self.solid;
146 self.tur_head.alpha = self.alpha;
147 self.customizeentityforclient = SUB_False;
148 self.tur_head.customizeentityforclient = SUB_False;
150 self.event_damage = SUB_Null;
151 self.tur_head.event_damage = SUB_Null;
152 self.takedamage = DAMAGE_NO;
153 self.tur_head.takedamage = self.takedamage;
156 self.tur_head.effects = self.effects;
159 // Trow fake parts arround
161 if not(self.damage_flags & TFL_DMG_DEATH_NOGIBS)
163 makevectors(self.angles);
166 turret_trowgib(self.origin, '0 0 0','1 1 1',"models/turrets/base-gib2.md3",min(self.respawntime,20),1,1);
167 t_dir = (v_up * 700) + (randomvec() * 300);
168 turret_trowgib(self.origin, t_dir,'1 1 1',"models/turrets/base-gib3.md3",min(self.respawntime,10),1,1);
169 t_dir = (v_up * 700) + (randomvec() * 300);
170 turret_trowgib(self.origin, t_dir,'1 1 1',"models/turrets/base-gib4.md3",min(self.respawntime,10),1,1);
174 turret_trowgib(self.origin, '0 0 0','1 1 1',"models/turrets/base-gib1.md3",min(self.respawntime,20),1,1);
177 // Blow the top part up into the air
178 turret_trowgib2( self.origin + (v_up * 50),
179 v_up * 150 + randomvec() * 50,
181 self.tur_head,time + 0.5 + (random() * 0.5));
185 //RadiusDamage (self,self, min(self.ammo,50),min(self.ammo,50) * 0.25,250,world,min(self.ammo,50)*5,DEATH_TURRET,world);
187 if(self.damage_flags & TFL_DMG_DEATH_NORESPAWN)
189 if (self.turret_diehook)
190 self.turret_diehook();
192 remove(self.tur_head);
198 self.nextthink = time + self.respawntime;
199 //self.think = self.turret_spawnfunc;
200 self.think = turret_stdproc_respawn;
201 if (self.turret_diehook)
202 self.turret_diehook();
207 void turret_stdproc_respawn()
209 // Make sure all parts belong to the same team since
210 // this function doubles as "teamchange" function.
212 self.tur_head.team = self.team;
215 COLOR_TEAM1 = 4; // red
216 COLOR_TEAM2 = 13; // blue
217 COLOR_TEAM3 = 12; // yellow
218 COLOR_TEAM4 = 9; // pink
221 self.colormod = '0 0 0';
225 case COLOR_TEAM1: // Red
226 self.colormod = '1.4 0.8 0.8';
229 case COLOR_TEAM2: // Blue
230 self.colormod = '0.8 0.8 1.4';
233 case COLOR_TEAM3: // Yellow
234 self.colormod = '1.4 1.4 0.6';
237 case COLOR_TEAM4: // Pink
238 self.colormod = '1.4 0.6 1.4';
242 self.deadflag = DEAD_NO;
243 self.tur_head.deadflag = self.deadflag;
245 self.tur_head.effects = self.effects;
247 self.solid = SOLID_BBOX;
248 self.tur_head.solid = self.solid;
251 self.tur_head.alpha = self.alpha;
252 self.customizeentityforclient = SUB_True;
253 self.tur_head.customizeentityforclient = SUB_True;
256 self.takedamage = DAMAGE_AIM;
257 self.tur_head.takedamage = self.takedamage;
259 self.event_damage = turret_stdproc_damage;
260 self.tur_head.event_damage = self.event_damage;
262 self.avelocity = '0 0 0';
263 self.tur_head.avelocity = self.avelocity;
264 self.tur_head.angles = self.idle_aim;
265 self.health = self.tur_health;
266 self.tur_head.health = self.tur_health;
269 self.volly_counter = self.shot_volly;
270 self.ammo = self.ammo_max;
272 self.nextthink = time + self.ticrate;
273 self.think = turret_think;
275 if (self.turret_respawnhook)
276 self.turret_respawnhook();
281 * Standard damage proc.
283 void turret_stdproc_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
288 baseent = self.owner;
293 if (self.health <= 0)
296 // Inactive turrets take no damage. (hm..)
297 if not (baseent.tur_active)
301 if (self.team == attacker.team)
303 // This does not happen anymore. Re-enable if you fix that.
304 //if(attacker.flags & FL_CLIENT)
305 if(clienttype(attacker) == CLIENTTYPE_REAL)
306 sprint(attacker, "\{1}Turret tells you: I'm on your team!\n");
308 if(cvar("g_friendlyfire"))
309 damage = damage * cvar("g_friendlyfire");
314 self.health = self.health - damage;
316 // thorw head slightly off aim when hit?
317 if (self.classname == "turret_head")
318 if (baseent.damage_flags & TFL_DMG_HEADSHAKE)
320 //baseent.tur_aimoff_x += (random() * damage);
321 //baseent.tur_aimoff_y += ((random()*0.75) * damage);
322 self.angles_x = self.angles_x + (-0.5 + random()) * damage;
323 self.angles_y = self.angles_y + (-0.5 + random()) * damage;
326 if (baseent.turrcaps_flags & TFL_TURRCAPS_MOVE)
327 baseent.velocity = baseent.velocity + vforce;
329 // FIXME: Better damage feedback
330 // Start burning when we have 10% or less health left
331 //if (self.health < (self.tur_health * 0.1))
332 // self.effects = EF_FLAME;
334 if (self.health <= 0)
336 baseent.event_damage = SUB_Null;
337 baseent.tur_head.event_damage = SUB_Null;
338 baseent.takedamage = DAMAGE_NO;
339 baseent.tur_head.takedamage = baseent.takedamage;
340 baseent.nextthink = time;
341 baseent.think = turret_stdproc_die;