4 bool autocvar_g_nades_nade_small;
5 float autocvar_g_nades_spread = 0.04;
8 REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
11 entity Nade_TrailEffect(int proj, int nade_team)
15 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
16 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
19 FOREACH(Nades, true, LAMBDA(
20 for (int j = 0; j < 2; j++)
22 if (it.m_projectile[j] == proj)
24 string trail = it.m_trail[j].eent_eff_name;
25 if (trail) return it.m_trail[j];
36 REGISTER_MUTATOR(cl_nades, true);
37 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
39 if (STAT(HEALING_ORB) > time)
41 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
42 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
45 if (STAT(ENTRAP_ORB) > time)
47 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
48 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
53 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
55 entity proj = M_ARGV(0, entity);
57 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
60 proj.traileffect = EFFECT_FIREBALL.m_id;
63 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
65 setmodel(proj, MDL_PROJECTILE_NADE);
66 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
67 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
71 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
73 entity proj = M_ARGV(0, entity);
75 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
77 loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
78 proj.mins = '-16 -16 -16';
79 proj.maxs = '16 16 16';
82 entity nade_type = Nade_FromProjectile(proj.cnt);
83 if (nade_type == NADE_TYPE_Null) return;
84 if(STAT(NADES_SMALL, NULL))
86 proj.mins = '-8 -8 -8';
91 proj.mins = '-16 -16 -16';
92 proj.maxs = '16 16 16';
94 proj.colormod = nade_type.m_color;
95 set_movetype(proj, MOVETYPE_BOUNCE);
96 settouch(proj, func_null);
98 proj.avelocity = randomvec() * 720;
100 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
101 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
103 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
105 bool Projectile_isnade(int p)
107 return Nade_FromProjectile(p) != NADE_TYPE_Null;
109 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
111 float bonusNades = STAT(NADE_BONUS);
112 float bonusProgress = STAT(NADE_BONUS_SCORE);
113 float bonusType = STAT(NADE_BONUS_TYPE);
114 Nade def = Nades_from(bonusType);
115 vector nadeColor = def.m_color;
116 string nadeIcon = def.m_icon;
118 vector iconPos, textPos;
120 if(autocvar_hud_panel_ammo_iconalign)
122 iconPos = myPos + eX * 2 * mySize.y;
128 textPos = myPos + eX * mySize.y;
131 if(bonusNades > 0 || bonusProgress > 0)
133 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
135 if(autocvar_hud_panel_ammo_text)
136 drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
139 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
141 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
148 #include <common/gamemodes/_mod.qh>
149 #include <common/monsters/spawn.qh>
150 #include <common/monsters/sv_monsters.qh>
151 #include <server/g_subs.qh>
153 REGISTER_MUTATOR(nades, cvar("g_nades"));
155 .float nade_time_primed;
157 .entity nade_spawnloc;
159 void nade_timer_think(entity this)
161 this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
162 this.nextthink = time;
163 if(!this.owner || wasfreed(this.owner))
167 void nade_burn_spawn(entity _nade)
169 CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[true], true);
172 void nade_spawn(entity _nade)
174 entity timer = new(nade_timer);
175 setmodel(timer, MDL_NADE_TIMER);
176 setattachment(timer, _nade, "");
177 timer.colormap = _nade.colormap;
178 timer.glowmod = _nade.glowmod;
179 setthink(timer, nade_timer_think);
180 timer.nextthink = time;
181 timer.wait = _nade.wait;
185 _nade.effects |= EF_LOWPRECISION;
187 CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
190 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
199 RandomSelection_Init();
200 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
201 if(e.takedamage == DAMAGE_AIM)
202 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
203 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
207 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
208 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
209 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
210 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
213 e.fireball_impactvec = p;
214 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
217 if(RandomSelection_chosen_ent)
219 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
220 d = damage + (edgedamage - damage) * (d / dist);
221 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
222 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
223 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
228 void napalm_ball_think(entity this)
230 if(round_handler_IsActive())
231 if(!round_handler_IsRoundStarted())
237 if(time > this.pushltime)
243 vector midpoint = ((this.absmin + this.absmax) * 0.5);
244 if(pointcontents(midpoint) == CONTENT_WATER)
246 this.velocity = this.velocity * 0.5;
248 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
249 { this.velocity_z = 200; }
252 this.angles = vectoangles(this.velocity);
254 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
255 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
257 this.nextthink = time + 0.1;
261 void nade_napalm_ball(entity this)
266 spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
269 proj.owner = this.owner;
270 proj.realowner = this.realowner;
271 proj.team = this.owner.team;
272 proj.bot_dodge = true;
273 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
274 set_movetype(proj, MOVETYPE_BOUNCE);
275 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
276 PROJECTILE_MAKETRIGGER(proj);
277 setmodel(proj, MDL_Null);
278 proj.scale = 1;//0.5;
279 setsize(proj, '-4 -4 -4', '4 4 4');
280 setorigin(proj, this.origin);
281 setthink(proj, napalm_ball_think);
282 proj.nextthink = time;
283 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
284 proj.effects = EF_LOWPRECISION | EF_FLAME;
286 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
287 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
288 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
289 proj.velocity = kick;
291 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
293 proj.angles = vectoangles(proj.velocity);
294 proj.flags = FL_PROJECTILE;
295 IL_PUSH(g_projectiles, proj);
296 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
298 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
302 void napalm_fountain_think(entity this)
305 if(round_handler_IsActive())
306 if(!round_handler_IsRoundStarted())
312 if(time >= this.ltime)
318 vector midpoint = ((this.absmin + this.absmax) * 0.5);
319 if(pointcontents(midpoint) == CONTENT_WATER)
321 this.velocity = this.velocity * 0.5;
323 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
324 { this.velocity_z = 200; }
326 UpdateCSQCProjectile(this);
329 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
330 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
332 this.nextthink = time + 0.1;
333 if(time >= this.nade_special_time)
335 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
336 nade_napalm_ball(this);
340 void nade_napalm_boom(entity this)
344 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
345 nade_napalm_ball(this);
349 fountain.owner = this.owner;
350 fountain.realowner = this.realowner;
351 fountain.origin = this.origin;
352 setorigin(fountain, fountain.origin);
353 setthink(fountain, napalm_fountain_think);
354 fountain.nextthink = time;
355 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
356 fountain.pushltime = fountain.ltime;
357 fountain.team = this.team;
358 set_movetype(fountain, MOVETYPE_TOSS);
359 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
360 fountain.bot_dodge = true;
361 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
362 fountain.nade_special_time = time;
363 setsize(fountain, '-16 -16 -16', '16 16 16');
364 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
367 void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
369 frost_target.frozen_by = freezefield.realowner;
370 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
371 Freeze(frost_target, 1/freeze_time, 3, false);
373 Drop_Special_Items(frost_target);
376 void nade_ice_think(entity this)
378 if(round_handler_IsActive())
379 if(!round_handler_IsRoundStarted())
385 if(time >= this.ltime)
387 if ( autocvar_g_nades_ice_explode )
389 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
390 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
391 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
393 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
394 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
395 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
396 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
403 this.nextthink = time+0.1;
408 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
410 randomw = random()*M_PI*2;
412 randomp.x = randomr*cos(randomw);
413 randomp.y = randomr*sin(randomw);
415 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
417 if(time >= this.nade_special_time)
419 this.nade_special_time = time+0.7;
421 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
422 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
426 float current_freeze_time = this.ltime - time - 0.1;
428 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0,
430 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
431 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
432 if(!STAT(FROZEN, it))
433 nade_ice_freeze(this, it, current_freeze_time);
437 void nade_ice_boom(entity this)
441 fountain.owner = this.owner;
442 fountain.realowner = this.realowner;
443 fountain.origin = this.origin;
444 setorigin(fountain, fountain.origin);
445 setthink(fountain, nade_ice_think);
446 fountain.nextthink = time;
447 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
448 fountain.pushltime = fountain.wait = fountain.ltime;
449 fountain.team = this.team;
450 set_movetype(fountain, MOVETYPE_TOSS);
451 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
452 fountain.bot_dodge = false;
453 setsize(fountain, '-16 -16 -16', '16 16 16');
454 fountain.nade_special_time = time+0.3;
455 fountain.angles = this.angles;
457 if ( autocvar_g_nades_ice_explode )
459 setmodel(fountain, MDL_PROJECTILE_GRENADE);
460 entity timer = new(nade_timer);
461 setmodel(timer, MDL_NADE_TIMER);
462 setattachment(timer, fountain, "");
463 timer.colormap = this.colormap;
464 timer.glowmod = this.glowmod;
465 setthink(timer, nade_timer_think);
466 timer.nextthink = time;
467 timer.wait = fountain.ltime;
468 timer.owner = fountain;
472 setmodel(fountain, MDL_Null);
475 void nade_translocate_boom(entity this)
477 if(this.realowner.vehicle)
480 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
481 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
482 locout = trace_endpos;
484 makevectors(this.realowner.angles);
486 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
488 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
491 void nade_spawn_boom(entity this)
493 entity spawnloc = spawn();
494 setorigin(spawnloc, this.origin);
495 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
496 set_movetype(spawnloc, MOVETYPE_NONE);
497 spawnloc.solid = SOLID_NOT;
498 spawnloc.drawonlytoclient = this.realowner;
499 spawnloc.effects = EF_STARDUST;
500 spawnloc.cnt = autocvar_g_nades_spawn_count;
502 if(this.realowner.nade_spawnloc)
504 delete(this.realowner.nade_spawnloc);
505 this.realowner.nade_spawnloc = NULL;
508 this.realowner.nade_spawnloc = spawnloc;
511 void nades_orb_think(entity this)
513 if(time >= this.ltime)
519 this.nextthink = time;
521 if(time >= this.nade_special_time)
523 this.nade_special_time = time+0.25;
524 this.nade_show_particles = 1;
527 this.nade_show_particles = 0;
530 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
532 // NOTE: this function merely places an orb
533 // you must add a custom touch function to the returned entity if desired
534 // also set .colormod if you wish to have it colorized
535 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
537 orb.realowner = realown;
540 orb.orb_lifetime = orb_ltime; // required for timers
541 orb.ltime = time + orb.orb_lifetime;
542 orb.bot_dodge = false;
543 orb.team = realown.team;
544 orb.solid = SOLID_TRIGGER;
546 setmodel(orb, MDL_NADE_ORB);
548 orb.orb_radius = orb_rad; // required for fading
549 vector size = '1 1 1' * orb.orb_radius / 2;
550 setsize(orb, -size, size);
552 Net_LinkEntity(orb, true, 0, orb_send);
555 setthink(orb, nades_orb_think);
556 orb.nextthink = time;
561 void nade_entrap_touch(entity this, entity toucher)
563 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
565 if (!isPushable(toucher))
568 float pushdeltatime = time - toucher.lastpushtime;
569 if (pushdeltatime > 0.15) pushdeltatime = 0;
570 toucher.lastpushtime = time;
571 if(!pushdeltatime) return;
573 // div0: ticrate independent, 1 = identity (not 20)
574 toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime);
577 UpdateCSQCProjectile(toucher);
581 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
583 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
584 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
586 float tint_alpha = 0.75;
587 if(SAME_TEAM(toucher, this.realowner))
589 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
593 void nade_entrap_boom(entity this)
595 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
597 settouch(orb, nade_entrap_touch);
598 orb.colormod = NADE_TYPE_ENTRAP.m_color;
601 void nade_heal_touch(entity this, entity toucher)
605 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
606 if(!IS_DEAD(toucher))
607 if(!STAT(FROZEN, toucher))
609 health_factor = autocvar_g_nades_heal_rate*frametime/2;
610 if ( toucher != this.realowner )
612 if ( SAME_TEAM(toucher,this) )
613 health_factor *= autocvar_g_nades_heal_friend;
615 health_factor *= autocvar_g_nades_heal_foe;
617 if ( health_factor > 0 )
619 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
620 if ( toucher.health < maxhealth )
622 if ( this.nade_show_particles )
623 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
624 toucher.health = min(toucher.health+health_factor, maxhealth);
626 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
628 else if ( health_factor < 0 )
630 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,toucher.origin,'0 0 0');
635 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
637 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
638 show_red.stat_healing_orb = time+0.1;
639 show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.orb_lifetime;
643 void nade_heal_boom(entity this)
645 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
647 settouch(orb, nade_heal_touch);
648 orb.colormod = '1 0 0';
651 void nade_monster_boom(entity this)
653 entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
655 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
656 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
657 e.monster_skill = MONSTER_SKILL_INSANE;
660 void nade_boom(entity this)
663 bool nade_blast = true;
665 switch ( Nades_from(this.nade_type) )
667 case NADE_TYPE_NAPALM:
668 nade_blast = autocvar_g_nades_napalm_blast;
669 expef = EFFECT_EXPLOSION_MEDIUM;
673 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
675 case NADE_TYPE_TRANSLOCATE:
678 case NADE_TYPE_MONSTER:
679 case NADE_TYPE_SPAWN:
681 switch(this.realowner.team)
683 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
684 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
685 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
686 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
687 default: expef = EFFECT_SPAWN_NEUTRAL; break;
692 expef = EFFECT_SPAWN_RED;
695 case NADE_TYPE_ENTRAP:
697 expef = EFFECT_SPAWN_YELLOW;
701 case NADE_TYPE_NORMAL:
702 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
707 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
709 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
710 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
712 this.event_damage = func_null; // prevent somehow calling damage in the next call
716 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
717 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
718 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
722 switch ( Nades_from(this.nade_type) )
724 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
725 case NADE_TYPE_ICE: nade_ice_boom(this); break;
726 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
727 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
728 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
729 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
730 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
733 FOREACH_ENTITY_ENT(aiment, this,
735 if(it.classname == "grapplinghook")
736 RemoveGrapplingHook(it.realowner);
742 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
743 void nade_pickup(entity this, entity thenade)
745 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, thenade.nade_type, thenade.pokenade_type);
747 // set refire so player can't even
748 this.nade_refire = time + autocvar_g_nades_nade_refire;
752 this.nade.nade_time_primed = thenade.nade_time_primed;
755 bool CanThrowNade(entity this);
756 void nade_touch(entity this, entity toucher)
759 UpdateCSQCProjectile(this);
761 if(toucher == this.realowner)
762 return; // no this impacts
764 if(autocvar_g_nades_pickup)
765 if(time >= this.spawnshieldtime)
766 if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much
767 if(!STAT(FROZEN, toucher))
768 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
769 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
771 nade_pickup(toucher, this);
772 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
776 /*float is_weapclip = 0;
777 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
778 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
779 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
781 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
783 FOREACH_ENTITY_ENT(aiment, this,
785 if(it.classname == "grapplinghook")
786 RemoveGrapplingHook(it.realowner);
792 PROJECTILE_TOUCH(this, toucher);
794 //setsize(this, '-2 -2 -2', '2 2 2');
795 //UpdateCSQCProjectile(this);
796 if(this.health == this.max_health)
798 spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM);
802 this.enemy = toucher;
806 void nade_beep(entity this)
808 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
809 setthink(this, nade_boom);
810 this.nextthink = max(this.wait, time);
813 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
815 if(ITEM_DAMAGE_NEEDKILL(deathtype))
817 this.takedamage = DAMAGE_NO;
822 if(this.nade_type == NADE_TYPE_TRANSLOCATE.m_id || this.nade_type == NADE_TYPE_SPAWN.m_id)
825 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
826 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
831 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
833 force *= 0.5; // too much
836 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
839 damage = this.max_health * 0.55;
841 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
842 damage = this.max_health * 0.1;
843 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
845 if(deathtype & HITTYPE_SECONDARY)
847 damage = this.max_health * 0.1;
851 damage = this.max_health * 1.15;
854 this.velocity += force;
855 UpdateCSQCProjectile(this);
857 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
860 if(this.health == this.max_health)
862 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
863 this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
864 setthink(this, nade_beep);
867 this.health -= damage;
869 if ( this.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
870 this.realowner = attacker;
873 W_PrepareExplosionByDamage(this, attacker, nade_boom);
875 nade_burn_spawn(this);
878 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
883 entity _nade = e.nade;
889 makevectors(e.v_angle);
891 // NOTE: always throw from first weapon entity?
892 W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
894 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
896 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
897 + (v_right * autocvar_g_nades_throw_offset.y)
898 + (v_up * autocvar_g_nades_throw_offset.z);
899 if(autocvar_g_nades_throw_offset == '0 0 0')
902 setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
903 //setmodel(_nade, MDL_PROJECTILE_NADE);
904 //setattachment(_nade, NULL, "");
905 PROJECTILE_MAKETRIGGER(_nade);
906 if(STAT(NADES_SMALL, e))
907 setsize(_nade, '-8 -8 -8', '8 8 8');
909 setsize(_nade, '-16 -16 -16', '16 16 16');
910 set_movetype(_nade, MOVETYPE_BOUNCE);
912 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
913 if (trace_startsolid)
914 setorigin(_nade, e.origin);
916 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
917 _nade.velocity = '0 0 100';
918 else if(autocvar_g_nades_nade_newton_style == 1)
919 _nade.velocity = e.velocity + _velocity;
920 else if(autocvar_g_nades_nade_newton_style == 2)
921 _nade.velocity = _velocity;
923 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
928 settouch(_nade, nade_touch);
929 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
930 _nade.health = autocvar_g_nades_nade_health;
931 _nade.max_health = _nade.health;
932 _nade.takedamage = DAMAGE_AIM;
933 _nade.event_damage = nade_damage;
934 setcefc(_nade, func_null);
935 _nade.exteriormodeltoclient = NULL;
936 _nade.traileffectnum = 0;
937 _nade.teleportable = true;
938 _nade.pushable = true;
940 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
941 _nade.damagedbycontents = true;
942 _nade.angles = vectoangles(_nade.velocity);
943 _nade.flags = FL_PROJECTILE;
944 IL_PUSH(g_projectiles, _nade);
945 _nade.projectiledeathtype = DEATH_NADE.m_id;
946 _nade.toss_time = time;
947 _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
949 if(_nade.nade_type == NADE_TYPE_TRANSLOCATE.m_id || _nade.nade_type == NADE_TYPE_SPAWN.m_id)
950 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
952 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
958 setthink(_nade, nade_boom);
959 _nade.nextthink = _time;
962 e.nade_refire = time + autocvar_g_nades_nade_refire;
966 void nades_GiveBonus(entity player, float score)
968 if (autocvar_g_nades)
969 if (autocvar_g_nades_bonus)
970 if (IS_REAL_CLIENT(player))
971 if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
972 if (STAT(FROZEN, player) == 0)
973 if (!IS_DEAD(player))
975 if ( player.bonus_nade_score < 1 )
976 player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
978 if ( player.bonus_nade_score >= 1 )
980 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
981 play2(player, SND(KH_ALARM));
982 player.bonus_nades++;
983 player.bonus_nade_score -= 1;
988 /** Remove all bonus nades from a player */
989 void nades_RemoveBonus(entity player)
991 player.bonus_nades = player.bonus_nade_score = 0;
994 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
996 entity player = M_ARGV(0, entity);
998 nades_RemoveBonus(player);
1001 bool nade_customize(entity this, entity client)
1003 //if(IS_SPEC(client)) { return false; }
1004 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1006 // somewhat hide the model, but keep the glow
1008 if(this.traileffectnum)
1009 this.traileffectnum = 0;
1014 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1015 if(!this.traileffectnum)
1016 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(this.nade_type).m_projectile[false], this.team).eent_eff_name);
1023 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1025 entity n = new(nade), fn = new(fake_nade);
1027 n.nade_type = max(1, ntype);
1028 n.pokenade_type = pntype;
1030 if(Nades_from(n.nade_type) == NADE_TYPE_Null)
1031 n.nade_type = NADE_TYPE_NORMAL.m_id;
1033 setmodel(n, MDL_PROJECTILE_NADE);
1034 //setattachment(n, player, "bip01 l hand");
1035 n.exteriormodeltoclient = player;
1036 setcefc(n, nade_customize);
1037 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], player.team).eent_eff_name);
1038 n.colormod = Nades_from(n.nade_type).m_color;
1039 n.realowner = nowner;
1040 n.colormap = player.colormap;
1041 n.glowmod = player.glowmod;
1042 n.wait = time + max(0, ntime);
1043 n.nade_time_primed = time;
1044 setthink(n, nade_beep);
1045 n.nextthink = max(n.wait - 3, time);
1046 n.projectiledeathtype = DEATH_NADE.m_id;
1048 setmodel(fn, MDL_NADE_VIEW);
1049 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1050 setattachment(fn, player.(weaponentity), "");
1051 fn.realowner = fn.owner = player;
1052 fn.colormod = Nades_from(n.nade_type).m_color;
1053 fn.colormap = player.colormap;
1054 fn.glowmod = player.glowmod;
1055 setthink(fn, SUB_Remove);
1056 fn.nextthink = n.wait;
1059 player.fake_nade = fn;
1062 void nade_prime(entity this)
1064 if(autocvar_g_nades_bonus_only)
1065 if(!this.bonus_nades)
1066 return; // only allow bonus nades
1072 delete(this.fake_nade);
1075 string pntype = this.pokenade_type;
1077 if(this.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
1078 ntype = this.nade_type;
1079 else if (this.bonus_nades >= 1)
1081 ntype = this.nade_type;
1082 pntype = this.pokenade_type;
1083 this.bonus_nades -= 1;
1087 ntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_nade_type : autocvar_g_nades_nade_type);
1088 pntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1091 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1094 bool CanThrowNade(entity this)
1105 if (!autocvar_g_nades)
1106 return false; // allow turning them off mid match
1108 if(forbidWeaponUse(this))
1111 if (!IS_PLAYER(this))
1117 .bool nade_altbutton;
1119 void nades_CheckThrow(entity this)
1121 if(!CanThrowNade(this))
1124 entity held_nade = this.nade;
1127 this.nade_altbutton = true;
1128 if(time > this.nade_refire)
1130 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1132 this.nade_refire = time + autocvar_g_nades_nade_refire;
1137 this.nade_altbutton = false;
1138 if (time >= held_nade.nade_time_primed + 1) {
1139 makevectors(this.v_angle);
1140 float _force = time - held_nade.nade_time_primed;
1141 _force /= autocvar_g_nades_nade_lifetime;
1142 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1143 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1144 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1145 toss_nade(this, true, dir * _force, 0);
1150 void nades_Clear(entity player)
1153 delete(player.nade);
1154 if(player.fake_nade)
1155 delete(player.fake_nade);
1157 player.nade = player.fake_nade = NULL;
1158 player.nade_timer = 0;
1161 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1163 entity player = M_ARGV(0, entity);
1166 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1169 CLASS(NadeOffhand, OffhandWeapon)
1170 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1172 entity held_nade = player.nade;
1175 player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
1176 // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
1177 makevectors(player.angles);
1178 held_nade.velocity = player.velocity;
1179 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1180 held_nade.angles_y = player.angles.y;
1182 if (time + 0.1 >= held_nade.wait)
1183 toss_nade(player, false, '0 0 0', time + 0.05);
1186 if (!CanThrowNade(player)) return;
1187 if (!(time > player.nade_refire)) return;
1191 held_nade = player.nade;
1193 } else if (time >= held_nade.nade_time_primed + 1) {
1195 makevectors(player.v_angle);
1196 float _force = time - held_nade.nade_time_primed;
1197 _force /= autocvar_g_nades_nade_lifetime;
1198 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1199 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1200 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1201 toss_nade(player, false, dir * _force, 0);
1205 ENDCLASS(NadeOffhand)
1206 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1208 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1210 entity player = M_ARGV(0, entity);
1212 if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1213 nades_CheckThrow(player);
1218 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1220 entity player = M_ARGV(0, entity);
1222 if (!IS_PLAYER(player)) { return; }
1224 if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1226 if(IS_PLAYER(player))
1228 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1231 float key_count = 0;
1232 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1235 if(player.flagcarried || player.ballcarried) // this player is important
1236 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1238 time_score = autocvar_g_nades_bonus_score_time;
1241 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1243 if(autocvar_g_nades_bonus_client_select)
1245 player.nade_type = player.cvar_cl_nade_type;
1246 player.pokenade_type = player.cvar_cl_pokenade_type;
1250 player.nade_type = autocvar_g_nades_bonus_type;
1251 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1254 player.nade_type = bound(1, player.nade_type, Nades_COUNT);
1256 if(player.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
1257 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1261 player.bonus_nades = player.bonus_nade_score = 0;
1267 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1271 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1273 FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
1275 if(STAT(FROZEN, it) == 0)
1276 if(SAME_TEAM(it, player))
1277 if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1281 if(STAT(FROZEN, player) == 1)
1288 if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
1290 player.revive_progress = bound(0, player.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1291 player.health = max(1, player.revive_progress * start_health);
1293 if(player.revive_progress >= 1)
1297 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1298 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1301 FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
1302 it.revive_progress = player.revive_progress;
1303 it.reviving = false;
1308 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics)
1310 entity player = M_ARGV(0, entity);
1312 if (STAT(ENTRAP_ORB, player) > time)
1314 player.stat_sv_maxspeed *= autocvar_g_nades_entrap_speed;
1315 player.stat_sv_airspeedlimit_nonqw *= autocvar_g_nades_entrap_speed;
1319 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1321 entity mon = M_ARGV(0, entity);
1323 if (STAT(ENTRAP_ORB, mon) > time)
1325 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1326 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1330 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1332 entity player = M_ARGV(0, entity);
1334 if(autocvar_g_nades_spawn)
1335 player.nade_refire = time + autocvar_g_spawnshieldtime;
1337 player.nade_refire = time + autocvar_g_nades_nade_refire;
1339 if(autocvar_g_nades_bonus_client_select)
1340 player.nade_type = player.cvar_cl_nade_type;
1342 player.nade_timer = 0;
1344 if (!player.offhand) player.offhand = OFFHAND_NADE;
1346 if(player.nade_spawnloc)
1348 setorigin(player, player.nade_spawnloc.origin);
1349 player.nade_spawnloc.cnt -= 1;
1351 if(player.nade_spawnloc.cnt <= 0)
1353 delete(player.nade_spawnloc);
1354 player.nade_spawnloc = NULL;
1359 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1361 entity frag_attacker = M_ARGV(1, entity);
1362 entity frag_target = M_ARGV(2, entity);
1364 if(frag_target.nade)
1365 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1366 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1368 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);
1370 if(IS_PLAYER(frag_attacker))
1372 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1373 nades_RemoveBonus(frag_attacker);
1374 else if(frag_target.flagcarried)
1375 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1376 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1378 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1379 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1380 switch(frag_attacker.killcount)
1383 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1388 nades_GiveBonus(frag_attacker, killcount_bonus);
1391 nades_RemoveBonus(frag_target);
1394 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
1396 entity frag_inflictor = M_ARGV(0, entity);
1397 entity frag_attacker = M_ARGV(1, entity);
1398 entity frag_target = M_ARGV(2, entity);
1399 float frag_deathtype = M_ARGV(3, float);
1401 if(STAT(FROZEN, frag_target))
1402 if(autocvar_g_freezetag_revive_nade)
1403 if(frag_attacker == frag_target)
1404 if(frag_deathtype == DEATH_NADE.m_id)
1405 if(time - frag_inflictor.toss_time <= 0.1)
1407 Unfreeze(frag_target);
1408 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1409 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1410 M_ARGV(4, float) = 0;
1411 M_ARGV(6, vector) = '0 0 0';
1412 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1413 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1417 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1419 entity frag_target = M_ARGV(0, entity);
1420 entity frag_attacker = M_ARGV(1, entity);
1422 if(IS_PLAYER(frag_attacker))
1423 if(DIFF_TEAM(frag_attacker, frag_target))
1424 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1425 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1428 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1430 entity frag_target = M_ARGV(0, entity);
1432 if(frag_target.nade)
1433 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1436 void nades_RemovePlayer(entity this)
1439 nades_RemoveBonus(this);
1442 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1443 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1444 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1446 FOREACH_CLIENT(IS_PLAYER(it),
1448 nades_RemovePlayer(it);
1452 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1454 entity spectatee = M_ARGV(0, entity);
1455 entity client = M_ARGV(1, entity);
1457 client.nade_timer = spectatee.nade_timer;
1458 client.nade_type = spectatee.nade_type;
1459 client.pokenade_type = spectatee.pokenade_type;
1460 client.bonus_nades = spectatee.bonus_nades;
1461 client.bonus_nade_score = spectatee.bonus_nade_score;
1462 client.stat_healing_orb = spectatee.stat_healing_orb;
1463 client.stat_healing_orb_alpha = spectatee.stat_healing_orb_alpha;
1464 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1465 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1468 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1469 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1471 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1473 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1476 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
1478 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Nades");
1481 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1483 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");