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