]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/nades/nades.qc
Port another 10 stats
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / nades.qc
1 #ifndef MUTATOR_NADES_H
2 #define MUTATOR_NADES_H
3
4 #ifdef SVQC
5 #include "../../../../server/mutators/mutator/gamemode_freezetag.qc"
6 #endif
7
8 .entity nade;
9 .entity fake_nade;
10 .float nade_timer = _STAT(NADE_TIMER);
11 .float nade_refire;
12 .float bonus_nades;
13 .float nade_special_time;
14 .float bonus_nade_score;
15 .float nade_type;
16 .string pokenade_type;
17 .entity nade_damage_target;
18 .float cvar_cl_nade_type;
19 .string cvar_cl_pokenade_type;
20 .float toss_time;
21 .float stat_healing_orb;
22 .float stat_healing_orb_alpha;
23 .float nade_show_particles;
24
25 // Remove nades that are being thrown
26 void nades_Clear(entity player);
27
28 // Give a bonus grenade to a player
29 void(entity player, float score) nades_GiveBonus;
30
31 /**
32  * called to adjust nade damage and force on hit
33  */
34 #define EV_Nade_Damage(i, o) \
35         /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \
36     /** force */  i(vector, MUTATOR_ARGV_0_vector) \
37     /**/          o(vector, MUTATOR_ARGV_0_vector) \
38         /** damage */ i(float,  MUTATOR_ARGV_0_float) \
39     /**/          o(float,  MUTATOR_ARGV_0_float) \
40     /**/
41 MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage);
42
43 #endif
44
45 #ifdef IMPLEMENTATION
46
47 #include "../../../nades/all.qh"
48 #include "../../../gamemodes/all.qh"
49 #include "../../../monsters/spawn.qh"
50 #include "../../../monsters/sv_monsters.qh"
51 #include "../../../../server/g_subs.qh"
52
53 REGISTER_MUTATOR(nades, cvar("g_nades"))
54 {
55         MUTATOR_ONADD
56         {
57                 addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
58                 addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
59                 addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
60                 addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
61                 addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
62         }
63
64         return false;
65 }
66
67 .float nade_time_primed;
68
69 .entity nade_spawnloc;
70
71 void nade_timer_think()
72 {SELFPARAM();
73         self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
74         self.nextthink = time;
75         if(!self.owner || wasfreed(self.owner))
76                 remove(self);
77 }
78
79 void nade_burn_spawn(entity _nade)
80 {
81         CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[true], true);
82 }
83
84 void nade_spawn(entity _nade)
85 {
86         entity timer = new(nade_timer);
87         setmodel(timer, MDL_NADE_TIMER);
88         setattachment(timer, _nade, "");
89         timer.colormap = _nade.colormap;
90         timer.glowmod = _nade.glowmod;
91         timer.think = nade_timer_think;
92         timer.nextthink = time;
93         timer.wait = _nade.wait;
94         timer.owner = _nade;
95         timer.skin = 10;
96
97         _nade.effects |= EF_LOWPRECISION;
98
99         CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
100 }
101
102 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
103 {SELFPARAM();
104         entity e;
105         float d;
106         vector p;
107
108         if ( damage < 0 )
109                 return;
110
111         RandomSelection_Init();
112         for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
113                 if(e.takedamage == DAMAGE_AIM)
114                 if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
115                 if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
116                 if(!e.frozen)
117                 {
118                         p = e.origin;
119                         p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
120                         p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
121                         p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
122                         d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
123                         if(d < dist)
124                         {
125                                 e.fireball_impactvec = p;
126                                 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
127                         }
128                 }
129         if(RandomSelection_chosen_ent)
130         {
131                 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
132                 d = damage + (edgedamage - damage) * (d / dist);
133                 Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
134                 //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
135                 Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
136         }
137 }
138
139
140 void napalm_ball_think()
141 {SELFPARAM();
142         if(round_handler_IsActive())
143         if(!round_handler_IsRoundStarted())
144         {
145                 remove(self);
146                 return;
147         }
148
149         if(time > self.pushltime)
150         {
151                 remove(self);
152                 return;
153         }
154
155         vector midpoint = ((self.absmin + self.absmax) * 0.5);
156         if(pointcontents(midpoint) == CONTENT_WATER)
157         {
158                 self.velocity = self.velocity * 0.5;
159
160                 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
161                         { self.velocity_z = 200; }
162         }
163
164         self.angles = vectoangles(self.velocity);
165
166         napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
167                                   autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
168
169         self.nextthink = time + 0.1;
170 }
171
172
173 void nade_napalm_ball()
174 {SELFPARAM();
175         entity proj;
176         vector kick;
177
178         spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
179
180         proj = new(grenade);
181         proj.owner = self.owner;
182         proj.realowner = self.realowner;
183         proj.team = self.owner.team;
184         proj.bot_dodge = true;
185         proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
186         proj.movetype = MOVETYPE_BOUNCE;
187         proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
188         PROJECTILE_MAKETRIGGER(proj);
189         setmodel(proj, MDL_Null);
190         proj.scale = 1;//0.5;
191         setsize(proj, '-4 -4 -4', '4 4 4');
192         setorigin(proj, self.origin);
193         proj.think = napalm_ball_think;
194         proj.nextthink = time;
195         proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
196         proj.effects = EF_LOWPRECISION | EF_FLAME;
197
198         kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
199         kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
200         kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
201         proj.velocity = kick;
202
203         proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
204
205         proj.angles = vectoangles(proj.velocity);
206         proj.flags = FL_PROJECTILE;
207         proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
208
209         //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
210 }
211
212
213 void napalm_fountain_think()
214 {SELFPARAM();
215
216         if(round_handler_IsActive())
217         if(!round_handler_IsRoundStarted())
218         {
219                 remove(self);
220                 return;
221         }
222
223         if(time >= self.ltime)
224         {
225                 remove(self);
226                 return;
227         }
228
229         vector midpoint = ((self.absmin + self.absmax) * 0.5);
230         if(pointcontents(midpoint) == CONTENT_WATER)
231         {
232                 self.velocity = self.velocity * 0.5;
233
234                 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
235                         { self.velocity_z = 200; }
236
237                 UpdateCSQCProjectile(self);
238         }
239
240         napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
241                 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
242
243         self.nextthink = time + 0.1;
244         if(time >= self.nade_special_time)
245         {
246                 self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
247                 nade_napalm_ball();
248         }
249 }
250
251 void nade_napalm_boom()
252 {SELFPARAM();
253         entity fountain;
254         int c;
255         for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
256                 nade_napalm_ball();
257
258
259         fountain = spawn();
260         fountain.owner = self.owner;
261         fountain.realowner = self.realowner;
262         fountain.origin = self.origin;
263         setorigin(fountain, fountain.origin);
264         fountain.think = napalm_fountain_think;
265         fountain.nextthink = time;
266         fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
267         fountain.pushltime = fountain.ltime;
268         fountain.team = self.team;
269         fountain.movetype = MOVETYPE_TOSS;
270         fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
271         fountain.bot_dodge = true;
272         fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
273         fountain.nade_special_time = time;
274         setsize(fountain, '-16 -16 -16', '16 16 16');
275         CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
276 }
277
278 void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
279 {
280         frost_target.frozen_by = freezefield.realowner;
281         Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
282         Freeze(frost_target, 1/freeze_time, 3, false);
283
284         Drop_Special_Items(frost_target);
285 }
286
287 void nade_ice_think()
288 {SELFPARAM();
289
290         if(round_handler_IsActive())
291         if(!round_handler_IsRoundStarted())
292         {
293                 remove(self);
294                 return;
295         }
296
297         if(time >= self.ltime)
298         {
299                 if ( autocvar_g_nades_ice_explode )
300                 {
301                         entity expef = EFFECT_NADE_EXPLODE(self.realowner.team);
302                         Send_Effect(expef, self.origin + '0 0 1', '0 0 0', 1);
303                         sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
304
305                         RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
306                                 autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
307                         Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
308                                 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
309                 }
310                 remove(self);
311                 return;
312         }
313
314
315         self.nextthink = time+0.1;
316
317         // gaussian
318         float randomr;
319         randomr = random();
320         randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
321         float randomw;
322         randomw = random()*M_PI*2;
323         vector randomp;
324         randomp.x = randomr*cos(randomw);
325         randomp.y = randomr*sin(randomw);
326         randomp.z = 1;
327         Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, self.origin + randomp, '0 0 0', 1);
328
329         if(time >= self.nade_special_time)
330         {
331                 self.nade_special_time = time+0.7;
332
333                 Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1);
334                 Send_Effect(EFFECT_ICEFIELD, self.origin, '0 0 0', 1);
335         }
336
337
338         float current_freeze_time = self.ltime - time - 0.1;
339
340         entity e;
341         for(e = findradius(self.origin, autocvar_g_nades_nade_radius); e; e = e.chain)
342         if(e != self)
343         if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, self.realowner) || e == self.realowner))
344         if(e.takedamage && e.deadflag == DEAD_NO)
345         if(e.health > 0)
346         if(!e.revival_time || ((time - e.revival_time) >= 1.5))
347         if(!e.frozen)
348         if(current_freeze_time > 0)
349                 nade_ice_freeze(self, e, current_freeze_time);
350 }
351
352 void nade_ice_boom()
353 {SELFPARAM();
354         entity fountain;
355         fountain = spawn();
356         fountain.owner = self.owner;
357         fountain.realowner = self.realowner;
358         fountain.origin = self.origin;
359         setorigin(fountain, fountain.origin);
360         fountain.think = nade_ice_think;
361         fountain.nextthink = time;
362         fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
363         fountain.pushltime = fountain.wait = fountain.ltime;
364         fountain.team = self.team;
365         fountain.movetype = MOVETYPE_TOSS;
366         fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
367         fountain.bot_dodge = false;
368         setsize(fountain, '-16 -16 -16', '16 16 16');
369         fountain.nade_special_time = time+0.3;
370         fountain.angles = self.angles;
371
372         if ( autocvar_g_nades_ice_explode )
373         {
374                 setmodel(fountain, MDL_PROJECTILE_GRENADE);
375                 entity timer = new(nade_timer);
376                 setmodel(timer, MDL_NADE_TIMER);
377                 setattachment(timer, fountain, "");
378                 timer.colormap = self.colormap;
379                 timer.glowmod = self.glowmod;
380                 timer.think = nade_timer_think;
381                 timer.nextthink = time;
382                 timer.wait = fountain.ltime;
383                 timer.owner = fountain;
384                 timer.skin = 10;
385         }
386         else
387                 setmodel(fountain, MDL_Null);
388 }
389
390 void nade_translocate_boom()
391 {SELFPARAM();
392         if(self.realowner.vehicle)
393                 return;
394
395         vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
396         tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
397         locout = trace_endpos;
398
399         makevectors(self.realowner.angles);
400
401         MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
402
403         TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
404 }
405
406 void nade_spawn_boom()
407 {SELFPARAM();
408         entity spawnloc = spawn();
409         setorigin(spawnloc, self.origin);
410         setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
411         spawnloc.movetype = MOVETYPE_NONE;
412         spawnloc.solid = SOLID_NOT;
413         spawnloc.drawonlytoclient = self.realowner;
414         spawnloc.effects = EF_STARDUST;
415         spawnloc.cnt = autocvar_g_nades_spawn_count;
416
417         if(self.realowner.nade_spawnloc)
418         {
419                 remove(self.realowner.nade_spawnloc);
420                 self.realowner.nade_spawnloc = world;
421         }
422
423         self.realowner.nade_spawnloc = spawnloc;
424 }
425
426 void nade_heal_think()
427 {SELFPARAM();
428         if(time >= self.ltime)
429         {
430                 remove(self);
431                 return;
432         }
433
434         self.nextthink = time;
435
436         if(time >= self.nade_special_time)
437         {
438                 self.nade_special_time = time+0.25;
439                 self.nade_show_particles = 1;
440         }
441         else
442                 self.nade_show_particles = 0;
443 }
444
445 void nade_heal_touch()
446 {SELFPARAM();
447         float maxhealth;
448         float health_factor;
449         if(IS_PLAYER(other) || IS_MONSTER(other))
450         if(other.deadflag == DEAD_NO)
451         if(!other.frozen)
452         {
453                 health_factor = autocvar_g_nades_heal_rate*frametime/2;
454                 if ( other != self.realowner )
455                 {
456                         if ( SAME_TEAM(other,self) )
457                                 health_factor *= autocvar_g_nades_heal_friend;
458                         else
459                                 health_factor *= autocvar_g_nades_heal_foe;
460                 }
461                 if ( health_factor > 0 )
462                 {
463                         maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max;
464                         if ( other.health < maxhealth )
465                         {
466                                 if ( self.nade_show_particles )
467                                         Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1);
468                                 other.health = min(other.health+health_factor, maxhealth);
469                         }
470                         other.pauserothealth_finished = max(other.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
471                 }
472                 else if ( health_factor < 0 )
473                 {
474                         Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0');
475                 }
476
477         }
478
479         if ( IS_REAL_CLIENT(other) || IS_VEHICLE(other) )
480         {
481                 entity show_red = (IS_VEHICLE(other)) ? other.owner : other;
482                 show_red.stat_healing_orb = time+0.1;
483                 show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime;
484         }
485 }
486
487 void nade_heal_boom()
488 {SELFPARAM();
489         entity healer;
490         healer = spawn();
491         healer.owner = self.owner;
492         healer.realowner = self.realowner;
493         setorigin(healer, self.origin);
494         healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
495         healer.ltime = time + healer.healer_lifetime;
496         healer.team = self.realowner.team;
497         healer.bot_dodge = false;
498         healer.solid = SOLID_TRIGGER;
499         healer.touch = nade_heal_touch;
500
501         setmodel(healer, MDL_NADE_HEAL);
502         healer.healer_radius = autocvar_g_nades_nade_radius;
503         vector size = '1 1 1' * healer.healer_radius / 2;
504         setsize(healer,-size,size);
505
506         Net_LinkEntity(healer, true, 0, healer_send);
507
508         healer.think = nade_heal_think;
509         healer.nextthink = time;
510         healer.SendFlags |= 1;
511 }
512
513 void nade_monster_boom()
514 {SELFPARAM();
515         entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
516
517         if(autocvar_g_nades_pokenade_monster_lifetime > 0)
518                 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
519         e.monster_skill = MONSTER_SKILL_INSANE;
520 }
521
522 void nade_boom()
523 {SELFPARAM();
524         entity expef = NULL;
525         bool nade_blast = true;
526
527         switch ( Nades_from(self.nade_type) )
528         {
529                 case NADE_TYPE_NAPALM:
530                         nade_blast = autocvar_g_nades_napalm_blast;
531                         expef = EFFECT_EXPLOSION_MEDIUM;
532                         break;
533                 case NADE_TYPE_ICE:
534                         nade_blast = false;
535                         expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
536                         break;
537                 case NADE_TYPE_TRANSLOCATE:
538                         nade_blast = false;
539                         break;
540                 case NADE_TYPE_MONSTER:
541                 case NADE_TYPE_SPAWN:
542                         nade_blast = false;
543                         switch(self.realowner.team)
544                         {
545                                 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
546                                 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
547                                 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
548                                 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
549                                 default: expef = EFFECT_SPAWN_NEUTRAL; break;
550                         }
551                         break;
552                 case NADE_TYPE_HEAL:
553                         nade_blast = false;
554                         expef = EFFECT_SPAWN_RED;
555                         break;
556
557                 default:
558                 case NADE_TYPE_NORMAL:
559                         expef = EFFECT_NADE_EXPLODE(self.realowner.team);
560                         break;
561         }
562
563         if(expef)
564                 Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1);
565
566         sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
567         sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
568
569         self.event_damage = func_null; // prevent somehow calling damage in the next call
570
571         if(nade_blast)
572         {
573                 RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
574                                  autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
575                 Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
576         }
577
578         if(self.takedamage)
579         switch ( Nades_from(self.nade_type) )
580         {
581                 case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
582                 case NADE_TYPE_ICE: nade_ice_boom(); break;
583                 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
584                 case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
585                 case NADE_TYPE_HEAL: nade_heal_boom(); break;
586                 case NADE_TYPE_MONSTER: nade_monster_boom(); break;
587         }
588
589         entity head;
590         for(head = world; (head = find(head, classname, "grapplinghook")); )
591         if(head.aiment == self)
592                 RemoveGrapplingHook(head.realowner);
593
594         remove(self);
595 }
596
597 void nade_touch()
598 {SELFPARAM();
599         /*float is_weapclip = 0;
600         if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
601         if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
602         if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
603                 is_weapclip = 1;*/
604         if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
605         {
606                 entity head;
607                 for(head = world; (head = find(head, classname, "grapplinghook")); )
608                 if(head.aiment == self)
609                         RemoveGrapplingHook(head.realowner);
610                 remove(self);
611                 return;
612         }
613
614         PROJECTILE_TOUCH;
615
616         //setsize(self, '-2 -2 -2', '2 2 2');
617         //UpdateCSQCProjectile(self);
618         if(self.health == self.max_health)
619         {
620                 spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM);
621                 return;
622         }
623
624         self.enemy = other;
625         nade_boom();
626 }
627
628 void nade_beep()
629 {SELFPARAM();
630         sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
631         self.think = nade_boom;
632         self.nextthink = max(self.wait, time);
633 }
634
635 void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
636 {SELFPARAM();
637         if(ITEM_DAMAGE_NEEDKILL(deathtype))
638         {
639                 self.takedamage = DAMAGE_NO;
640                 nade_boom();
641                 return;
642         }
643
644         if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id)
645                 return;
646
647         if (MUTATOR_CALLHOOK(Nade_Damage, DEATH_WEAPONOF(deathtype), force, damage)) {}
648         else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
649         {
650                 force *= 1.5;
651                 damage = 0;
652         }
653         else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
654         {
655                 force *= 0.5; // too much
656                 damage = 0;
657         }
658         else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
659         {
660                 force *= 6;
661                 damage = self.max_health * 0.55;
662         }
663         else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
664                 damage = self.max_health * 0.1;
665         else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
666         {
667                 if(deathtype & HITTYPE_SECONDARY)
668                 {
669                         damage = self.max_health * 0.1;
670                         force *= 10;
671                 }
672                 else
673                         damage = self.max_health * 1.15;
674         }
675
676         self.velocity += force;
677         UpdateCSQCProjectile(self);
678
679         if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker)))
680                 return;
681
682         if(self.health == self.max_health)
683         {
684                 sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
685                 self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
686                 self.think = nade_beep;
687         }
688
689         self.health -= damage;
690
691         if ( self.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
692                 self.realowner = attacker;
693
694         if(self.health <= 0)
695                 W_PrepareExplosionByDamage(attacker, nade_boom);
696         else
697                 nade_burn_spawn(self);
698 }
699
700 void toss_nade(entity e, vector _velocity, float _time)
701 {SELFPARAM();
702         if(e.nade == world)
703                 return;
704
705         entity _nade = e.nade;
706         e.nade = world;
707
708         remove(e.fake_nade);
709         e.fake_nade = world;
710
711         makevectors(e.v_angle);
712
713         W_SetupShot(e, false, false, "", CH_WEAPON_A, 0);
714
715         Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
716
717         vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
718                                   + (v_right * autocvar_g_nades_throw_offset.y)
719                                   + (v_up * autocvar_g_nades_throw_offset.z);
720         if(autocvar_g_nades_throw_offset == '0 0 0')
721                 offset = '0 0 0';
722
723         setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
724         //setmodel(_nade, MDL_PROJECTILE_NADE);
725         //setattachment(_nade, world, "");
726         PROJECTILE_MAKETRIGGER(_nade);
727         setsize(_nade, '-16 -16 -16', '16 16 16');
728         _nade.movetype = MOVETYPE_BOUNCE;
729
730         tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
731         if (trace_startsolid)
732                 setorigin(_nade, e.origin);
733
734         if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH)
735                 _nade.velocity = '0 0 100';
736         else if(autocvar_g_nades_nade_newton_style == 1)
737                 _nade.velocity = e.velocity + _velocity;
738         else if(autocvar_g_nades_nade_newton_style == 2)
739                 _nade.velocity = _velocity;
740         else
741                 _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true);
742
743         _nade.touch = nade_touch;
744         _nade.health = autocvar_g_nades_nade_health;
745         _nade.max_health = _nade.health;
746         _nade.takedamage = DAMAGE_AIM;
747         _nade.event_damage = nade_damage;
748         _nade.customizeentityforclient = func_null;
749         _nade.exteriormodeltoclient = world;
750         _nade.traileffectnum = 0;
751         _nade.teleportable = true;
752         _nade.pushable = true;
753         _nade.gravity = 1;
754         _nade.missile_flags = MIF_SPLASH | MIF_ARC;
755         _nade.damagedbycontents = true;
756         _nade.angles = vectoangles(_nade.velocity);
757         _nade.flags = FL_PROJECTILE;
758         _nade.projectiledeathtype = DEATH_NADE.m_id;
759         _nade.toss_time = time;
760         _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
761
762         if(_nade.nade_type == NADE_TYPE_TRANSLOCATE.m_id || _nade.nade_type == NADE_TYPE_SPAWN.m_id)
763                 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
764         else
765                 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
766
767         nade_spawn(_nade);
768
769         if(_time)
770         {
771                 _nade.think = nade_boom;
772                 _nade.nextthink = _time;
773         }
774
775         e.nade_refire = time + autocvar_g_nades_nade_refire;
776         e.nade_timer = 0;
777 }
778
779 void nades_GiveBonus(entity player, float score)
780 {
781         if (autocvar_g_nades)
782         if (autocvar_g_nades_bonus)
783         if (IS_REAL_CLIENT(player))
784         if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
785         if (player.frozen == 0)
786         if (player.deadflag == DEAD_NO)
787         {
788                 if ( player.bonus_nade_score < 1 )
789                         player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
790
791                 if ( player.bonus_nade_score >= 1 )
792                 {
793                         Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
794                         play2(player, SND(KH_ALARM));
795                         player.bonus_nades++;
796                         player.bonus_nade_score -= 1;
797                 }
798         }
799 }
800
801 /** Remove all bonus nades from a player */
802 void nades_RemoveBonus(entity player)
803 {
804         player.bonus_nades = player.bonus_nade_score = 0;
805 }
806
807 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
808 {
809         nades_RemoveBonus(self);
810 }
811
812 float nade_customize()
813 {SELFPARAM();
814         //if(IS_SPEC(other)) { return false; }
815         if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
816         {
817                 // somewhat hide the model, but keep the glow
818                 //self.effects = 0;
819                 if(self.traileffectnum)
820                         self.traileffectnum = 0;
821                 self.alpha = -1;
822         }
823         else
824         {
825                 //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
826                 if(!self.traileffectnum)
827                         self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(self.nade_type).m_projectile[false], self.team).eent_eff_name);
828                 self.alpha = 1;
829         }
830
831         return true;
832 }
833
834 void nade_prime()
835 {SELFPARAM();
836         if(autocvar_g_nades_bonus_only)
837         if(!self.bonus_nades)
838                 return; // only allow bonus nades
839
840         if(self.nade)
841                 remove(self.nade);
842
843         if(self.fake_nade)
844                 remove(self.fake_nade);
845
846         entity n = new(nade), fn = new(fake_nade);
847
848         if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
849                 n.nade_type = self.nade_type;
850         else if (self.bonus_nades >= 1)
851         {
852                 n.nade_type = self.nade_type;
853                 n.pokenade_type = self.pokenade_type;
854                 self.bonus_nades -= 1;
855         }
856         else
857         {
858                 n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
859                 n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
860         }
861
862         n.nade_type = bound(1, n.nade_type, Nades_COUNT);
863
864         setmodel(n, MDL_PROJECTILE_NADE);
865         //setattachment(n, self, "bip01 l hand");
866         n.exteriormodeltoclient = self;
867         n.customizeentityforclient = nade_customize;
868         n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], self.team).eent_eff_name);
869         n.colormod = Nades_from(n.nade_type).m_color;
870         n.realowner = self;
871         n.colormap = self.colormap;
872         n.glowmod = self.glowmod;
873         n.wait = time + autocvar_g_nades_nade_lifetime;
874         n.nade_time_primed = time;
875         n.think = nade_beep;
876         n.nextthink = max(n.wait - 3, time);
877         n.projectiledeathtype = DEATH_NADE.m_id;
878
879         setmodel(fn, MDL_NADE_VIEW);
880         .entity weaponentity = weaponentities[0]; // TODO: unhardcode
881         setattachment(fn, self.(weaponentity), "");
882         fn.realowner = fn.owner = self;
883         fn.colormod = Nades_from(n.nade_type).m_color;
884         fn.colormap = self.colormap;
885         fn.glowmod = self.glowmod;
886         fn.think = SUB_Remove;
887         fn.nextthink = n.wait;
888
889         self.nade = n;
890         self.fake_nade = fn;
891 }
892
893 float CanThrowNade()
894 {SELFPARAM();
895         if(self.vehicle)
896                 return false;
897
898         if(gameover)
899                 return false;
900
901         if(self.deadflag != DEAD_NO)
902                 return false;
903
904         if (!autocvar_g_nades)
905                 return false; // allow turning them off mid match
906
907         if(forbidWeaponUse(self))
908                 return false;
909
910         if (!IS_PLAYER(self))
911                 return false;
912
913         return true;
914 }
915
916 .bool nade_altbutton;
917
918 void nades_CheckThrow()
919 {SELFPARAM();
920         if(!CanThrowNade())
921                 return;
922
923         entity held_nade = self.nade;
924         if (!held_nade)
925         {
926                 self.nade_altbutton = true;
927                 if(time > self.nade_refire)
928                 {
929                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW);
930                         nade_prime();
931                         self.nade_refire = time + autocvar_g_nades_nade_refire;
932                 }
933         }
934         else
935         {
936                 self.nade_altbutton = false;
937                 if (time >= held_nade.nade_time_primed + 1) {
938                         makevectors(self.v_angle);
939                         float _force = time - held_nade.nade_time_primed;
940                         _force /= autocvar_g_nades_nade_lifetime;
941                         _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
942                         toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
943                 }
944         }
945 }
946
947 void nades_Clear(entity player)
948 {
949         if(player.nade)
950                 remove(player.nade);
951         if(player.fake_nade)
952                 remove(player.fake_nade);
953
954         player.nade = player.fake_nade = world;
955         player.nade_timer = 0;
956 }
957
958 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
959 {
960         if(vh_player.nade)
961                 toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
962
963         return false;
964 }
965
966 CLASS(NadeOffhand, OffhandWeapon)
967     METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
968     {
969         entity held_nade = player.nade;
970                 if (held_nade)
971                 {
972                         player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
973                         // LOG_TRACEF("%d %d\n", player.nade_timer, time - held_nade.nade_time_primed);
974                         makevectors(player.angles);
975                         held_nade.velocity = player.velocity;
976                         setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
977                         held_nade.angles_y = player.angles.y;
978
979                         if (time + 0.1 >= held_nade.wait)
980                                 toss_nade(player, '0 0 0', time + 0.05);
981                 }
982
983         if (!CanThrowNade()) return;
984         if (!(time > player.nade_refire)) return;
985                 if (key_pressed) {
986                         if (!held_nade) {
987                                 nade_prime();
988                                 held_nade = player.nade;
989                         }
990                 } else if (time >= held_nade.nade_time_primed + 1) {
991                         if (held_nade) {
992                                 makevectors(player.v_angle);
993                                 float _force = time - held_nade.nade_time_primed;
994                                 _force /= autocvar_g_nades_nade_lifetime;
995                                 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
996                                 toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
997                         }
998                 }
999     }
1000 ENDCLASS(NadeOffhand)
1001 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1002
1003 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1004 {
1005         if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1006                 nades_CheckThrow();
1007                 return true;
1008         }
1009         return false;
1010 }
1011
1012 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1013 {SELFPARAM();
1014         if (!IS_PLAYER(self)) { return false; }
1015
1016         if (self.nade && (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, self, self.nade_altbutton);
1017
1018         if(IS_PLAYER(self))
1019         {
1020                 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1021                 {
1022                         entity key;
1023                         float key_count = 0;
1024                         FOR_EACH_KH_KEY(key) if(key.owner == self) { ++key_count; }
1025
1026                         float time_score;
1027                         if(self.flagcarried || self.ballcarried) // this player is important
1028                                 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1029                         else
1030                                 time_score = autocvar_g_nades_bonus_score_time;
1031
1032                         if(key_count)
1033                                 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1034
1035                         if(autocvar_g_nades_bonus_client_select)
1036                         {
1037                                 self.nade_type = self.cvar_cl_nade_type;
1038                                 self.pokenade_type = self.cvar_cl_pokenade_type;
1039                         }
1040                         else
1041                         {
1042                                 self.nade_type = autocvar_g_nades_bonus_type;
1043                                 self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1044                         }
1045
1046                         self.nade_type = bound(1, self.nade_type, Nades_COUNT);
1047
1048                         if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
1049                                 nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max);
1050                 }
1051                 else
1052                 {
1053                         self.bonus_nades = self.bonus_nade_score = 0;
1054                 }
1055         }
1056
1057         float n = 0;
1058         entity o = world;
1059         if(self.freezetag_frozen_timeout > 0 && time >= self.freezetag_frozen_timeout)
1060                 n = -1;
1061         else
1062         {
1063                 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1064                 n = 0;
1065                 FOR_EACH_PLAYER(other) if(self != other)
1066                 {
1067                         if(other.deadflag == DEAD_NO)
1068                         if(other.frozen == 0)
1069                         if(SAME_TEAM(other, self))
1070                         if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
1071                         {
1072                                 if(!o)
1073                                         o = other;
1074                                 if(self.frozen == 1)
1075                                         other.reviving = true;
1076                                 ++n;
1077                         }
1078                 }
1079         }
1080
1081         if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
1082         {
1083                 self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1084                 self.health = max(1, self.revive_progress * start_health);
1085
1086                 if(self.revive_progress >= 1)
1087                 {
1088                         Unfreeze(self);
1089
1090                         Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1091                         Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
1092                 }
1093
1094                 FOR_EACH_PLAYER(other) if(other.reviving)
1095                 {
1096                         other.revive_progress = self.revive_progress;
1097                         other.reviving = false;
1098                 }
1099         }
1100
1101         return false;
1102 }
1103
1104 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1105 {SELFPARAM();
1106         if(autocvar_g_nades_spawn)
1107                 self.nade_refire = time + autocvar_g_spawnshieldtime;
1108         else
1109                 self.nade_refire  = time + autocvar_g_nades_nade_refire;
1110
1111         if(autocvar_g_nades_bonus_client_select)
1112                 self.nade_type = self.cvar_cl_nade_type;
1113
1114         self.nade_timer = 0;
1115
1116         if (!self.offhand) self.offhand = OFFHAND_NADE;
1117
1118         if(self.nade_spawnloc)
1119         {
1120                 setorigin(self, self.nade_spawnloc.origin);
1121                 self.nade_spawnloc.cnt -= 1;
1122
1123                 if(self.nade_spawnloc.cnt <= 0)
1124                 {
1125                         remove(self.nade_spawnloc);
1126                         self.nade_spawnloc = world;
1127                 }
1128         }
1129
1130         return false;
1131 }
1132
1133 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1134 {
1135         if(frag_target.nade)
1136         if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade)
1137                 toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1138
1139         float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
1140
1141         if(IS_PLAYER(frag_attacker))
1142         {
1143                 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1144                         nades_RemoveBonus(frag_attacker);
1145                 else if(frag_target.flagcarried)
1146                         nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1147                 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1148                 {
1149                         #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1150                                 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1151                         switch(frag_attacker.killcount)
1152                         {
1153                                 KILL_SPREE_LIST
1154                                 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1155                         }
1156                         #undef SPREE_ITEM
1157                 }
1158                 else
1159                         nades_GiveBonus(frag_attacker, killcount_bonus);
1160         }
1161
1162         nades_RemoveBonus(frag_target);
1163
1164         return false;
1165 }
1166
1167 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
1168 {
1169         if(frag_target.frozen)
1170         if(autocvar_g_freezetag_revive_nade)
1171         if(frag_attacker == frag_target)
1172         if(frag_deathtype == DEATH_NADE.m_id)
1173         if(time - frag_inflictor.toss_time <= 0.1)
1174         {
1175                 Unfreeze(frag_target);
1176                 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1177                 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1178                 frag_damage = 0;
1179                 frag_force = '0 0 0';
1180                 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1181                 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1182         }
1183
1184         return false;
1185 }
1186
1187 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1188 {SELFPARAM();
1189         if(IS_PLAYER(frag_attacker))
1190         if(DIFF_TEAM(frag_attacker, self))
1191         if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
1192                 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1193
1194         return false;
1195 }
1196
1197 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1198 {
1199         if(frag_target.nade)
1200                 toss_nade(frag_target, '0 0 0', time + 0.05);
1201
1202         return false;
1203 }
1204
1205 bool nades_RemovePlayer()
1206 {SELFPARAM();
1207         nades_Clear(self);
1208         nades_RemoveBonus(self);
1209         return false;
1210 }
1211
1212 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { nades_RemovePlayer(); }
1213 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { nades_RemovePlayer(); }
1214 MUTATOR_HOOKFUNCTION(nades, reset_map_global) { nades_RemovePlayer(); }
1215
1216 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1217 {SELFPARAM();
1218         self.nade_timer = other.nade_timer;
1219         self.nade_type = other.nade_type;
1220         self.pokenade_type = other.pokenade_type;
1221         self.bonus_nades = other.bonus_nades;
1222         self.bonus_nade_score = other.bonus_nade_score;
1223         self.stat_healing_orb = other.stat_healing_orb;
1224         self.stat_healing_orb_alpha = other.stat_healing_orb_alpha;
1225         return false;
1226 }
1227
1228 MUTATOR_HOOKFUNCTION(nades, GetCvars)
1229 {
1230         GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type");
1231         GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type");
1232
1233         return false;
1234 }
1235
1236 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1237 {
1238         ret_string = strcat(ret_string, ":Nades");
1239         return false;
1240 }
1241
1242 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
1243 {
1244         ret_string = strcat(ret_string, ", Nades");
1245         return false;
1246 }
1247 #endif