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