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.takedamage = DAMAGE_NO;
154 self.tur_head.effects = self.effects;
157 // Trow fake parts arround
159 if not(self.damage_flags & TFL_DMG_DEATH_NOGIBS)
161 makevectors(self.angles);
164 turret_trowgib(self.origin, '0 0 0','1 1 1',"models/turrets/base-gib2.md3",min(self.respawntime,20),1,1);
165 t_dir = (v_up * 700) + (randomvec() * 300);
166 turret_trowgib(self.origin, t_dir,'1 1 1',"models/turrets/base-gib3.md3",min(self.respawntime,10),1,1);
167 t_dir = (v_up * 700) + (randomvec() * 300);
168 turret_trowgib(self.origin, t_dir,'1 1 1',"models/turrets/base-gib4.md3",min(self.respawntime,10),1,1);
172 turret_trowgib(self.origin, '0 0 0','1 1 1',"models/turrets/base-gib1.md3",min(self.respawntime,20),1,1);
175 // Blow the top part up into the air
176 turret_trowgib2( self.origin + (v_up * 50),
177 v_up * 150 + randomvec() * 50,
179 self.tur_head,time + 0.5 + (random() * 0.5));
183 //RadiusDamage (self,self, min(self.ammo,50),min(self.ammo,50) * 0.25,250,world,min(self.ammo,50)*5,DEATH_TURRET,world);
185 if(self.damage_flags & TFL_DMG_DEATH_NORESPAWN)
187 if (self.turret_diehook)
188 self.turret_diehook();
190 remove(self.tur_head);
196 self.nextthink = time + self.respawntime;
197 //self.think = self.turret_spawnfunc;
198 self.think = turret_stdproc_respawn;
199 if (self.turret_diehook)
200 self.turret_diehook();
205 void turret_stdproc_respawn()
207 // Make sure all parts belong to the same team since
208 // this function doubles as "teamchange" function.
210 self.tur_head.team = self.team;
213 COLOR_TEAM1 = 4; // red
214 COLOR_TEAM2 = 13; // blue
215 COLOR_TEAM3 = 12; // yellow
216 COLOR_TEAM4 = 9; // pink
219 self.colormod = '0 0 0';
223 case COLOR_TEAM1: // Red
224 self.colormod = '1.4 0.8 0.8';
227 case COLOR_TEAM2: // Blue
228 self.colormod = '0.8 0.8 1.4';
231 case COLOR_TEAM3: // Yellow
232 self.colormod = '1.4 1.4 0.6';
235 case COLOR_TEAM4: // Pink
236 self.colormod = '1.4 0.6 1.4';
240 self.deadflag = DEAD_NO;
242 self.tur_head.effects = self.effects;
244 self.solid = SOLID_BBOX;
247 self.tur_head.alpha = self.alpha;
248 self.customizeentityforclient = SUB_True;
249 self.tur_head.customizeentityforclient = SUB_True;
251 self.takedamage = DAMAGE_AIM;
252 self.event_damage = turret_stdproc_damage;
254 self.avelocity = '0 0 0';
255 self.tur_head.avelocity = self.avelocity;
256 self.tur_head.angles = self.idle_aim;
257 self.health = self.tur_health;
260 self.volly_counter = self.shot_volly;
261 self.ammo = self.ammo_max;
263 self.nextthink = time + self.ticrate;
264 self.think = turret_think;
266 if (self.turret_respawnhook)
267 self.turret_respawnhook();
272 * Standard damage proc.
274 void turret_stdproc_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
278 if (self.health <= 0)
281 // Inactive turrets take no damage. (hm..)
282 if not (self.tur_active)
286 if (self.team == attacker.team)
288 // This does not happen anymore. Re-enable if you fix that.
289 if(clienttype(attacker) == CLIENTTYPE_REAL)
290 sprint(attacker, "\{1}Turret tells you: I'm on your team!\n");
292 if(cvar("g_friendlyfire"))
293 damage = damage * cvar("g_friendlyfire");
298 self.health = self.health - damage;
300 // thorw head slightly off aim when hit?
301 if (self.damage_flags & TFL_DMG_HEADSHAKE)
303 //baseent.tur_aimoff_x += (random() * damage);
304 //baseent.tur_aimoff_y += ((random()*0.75) * damage);
305 self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
306 self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
309 if (self.turrcaps_flags & TFL_TURRCAPS_MOVE)
310 self.velocity = self.velocity + vforce;
312 // FIXME: Better damage feedback
313 // Start burning when we have 10% or less health left
314 //if (self.health < (self.tur_health * 0.1))
315 // self.effects = EF_FLAME;
317 if (self.health <= 0)
319 self.event_damage = SUB_Null;
320 self.tur_head.event_damage = SUB_Null;
321 self.takedamage = DAMAGE_NO;
322 self.nextthink = time;
323 self.think = turret_stdproc_die;