6 bool autocvar_g_nades_nade_small;
7 float autocvar_g_nades_spread = 0.04;
10 REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
13 entity Nade_TrailEffect(int proj, int nade_team)
17 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
18 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
21 FOREACH(Nades, true, LAMBDA(
22 for (int j = 0; j < 2; j++)
24 if (it.m_projectile[j] == proj)
26 string trail = it.m_trail[j].eent_eff_name;
27 if (trail) return it.m_trail[j];
38 REGISTER_MUTATOR(cl_nades, true);
39 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
41 if (STAT(HEALING_ORB) > time)
43 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
44 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
47 if (STAT(ENTRAP_ORB) > time)
49 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
50 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
55 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
57 entity proj = M_ARGV(0, entity);
59 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
62 proj.traileffect = EFFECT_FIREBALL.m_id;
65 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
67 setmodel(proj, MDL_PROJECTILE_NADE);
68 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
69 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
73 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
75 entity proj = M_ARGV(0, entity);
77 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
79 loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
80 proj.mins = '-16 -16 -16';
81 proj.maxs = '16 16 16';
84 entity nade_type = Nade_FromProjectile(proj.cnt);
85 if (nade_type == NADE_TYPE_Null) return;
86 if(STAT(NADES_SMALL, NULL))
88 proj.mins = '-8 -8 -8';
93 proj.mins = '-16 -16 -16';
94 proj.maxs = '16 16 16';
96 proj.colormod = nade_type.m_color;
97 set_movetype(proj, MOVETYPE_BOUNCE);
98 settouch(proj, func_null);
100 proj.avelocity = randomvec() * 720;
102 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
103 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
105 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
107 bool Projectile_isnade(int p)
109 return Nade_FromProjectile(p) != NADE_TYPE_Null;
111 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
113 float bonusNades = STAT(NADE_BONUS);
114 float bonusProgress = STAT(NADE_BONUS_SCORE);
115 float bonusType = STAT(NADE_BONUS_TYPE);
116 Nade def = Nades_from(bonusType);
117 vector nadeColor = def.m_color;
118 string nadeIcon = def.m_icon;
120 vector iconPos, textPos;
122 if(autocvar_hud_panel_ammo_iconalign)
124 iconPos = myPos + eX * 2 * mySize.y;
130 textPos = myPos + eX * mySize.y;
133 if(bonusNades > 0 || bonusProgress > 0)
135 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
137 if(autocvar_hud_panel_ammo_text)
138 drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
141 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
143 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
150 #include <common/gamemodes/all.qh>
151 #include <common/monsters/spawn.qh>
152 #include <common/monsters/sv_monsters.qh>
153 #include <server/g_subs.qh>
155 REGISTER_MUTATOR(nades, cvar("g_nades"));
157 .float nade_time_primed;
159 .entity nade_spawnloc;
161 void nade_timer_think(entity this)
163 this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
164 this.nextthink = time;
165 if(!this.owner || wasfreed(this.owner))
169 void nade_burn_spawn(entity _nade)
171 CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[true], true);
174 void nade_spawn(entity _nade)
176 entity timer = new(nade_timer);
177 setmodel(timer, MDL_NADE_TIMER);
178 setattachment(timer, _nade, "");
179 timer.colormap = _nade.colormap;
180 timer.glowmod = _nade.glowmod;
181 setthink(timer, nade_timer_think);
182 timer.nextthink = time;
183 timer.wait = _nade.wait;
187 _nade.effects |= EF_LOWPRECISION;
189 CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
192 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
201 RandomSelection_Init();
202 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
203 if(e.takedamage == DAMAGE_AIM)
204 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
205 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
209 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
210 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
211 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
212 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
215 e.fireball_impactvec = p;
216 RandomSelection_Add(e, 0, string_null, 1 / (1 + d), !Fire_IsBurning(e));
219 if(RandomSelection_chosen_ent)
221 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
222 d = damage + (edgedamage - damage) * (d / dist);
223 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
224 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
225 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
230 void napalm_ball_think(entity this)
232 if(round_handler_IsActive())
233 if(!round_handler_IsRoundStarted())
239 if(time > this.pushltime)
245 vector midpoint = ((this.absmin + this.absmax) * 0.5);
246 if(pointcontents(midpoint) == CONTENT_WATER)
248 this.velocity = this.velocity * 0.5;
250 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
251 { this.velocity_z = 200; }
254 this.angles = vectoangles(this.velocity);
256 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
257 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
259 this.nextthink = time + 0.1;
263 void nade_napalm_ball(entity this)
268 spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
271 proj.owner = this.owner;
272 proj.realowner = this.realowner;
273 proj.team = this.owner.team;
274 proj.bot_dodge = true;
275 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
276 set_movetype(proj, MOVETYPE_BOUNCE);
277 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
278 PROJECTILE_MAKETRIGGER(proj);
279 setmodel(proj, MDL_Null);
280 proj.scale = 1;//0.5;
281 setsize(proj, '-4 -4 -4', '4 4 4');
282 setorigin(proj, this.origin);
283 setthink(proj, napalm_ball_think);
284 proj.nextthink = time;
285 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
286 proj.effects = EF_LOWPRECISION | EF_FLAME;
288 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
289 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
290 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
291 proj.velocity = kick;
293 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
295 proj.angles = vectoangles(proj.velocity);
296 proj.flags = FL_PROJECTILE;
297 IL_PUSH(g_projectiles, proj);
298 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
300 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
304 void napalm_fountain_think(entity this)
307 if(round_handler_IsActive())
308 if(!round_handler_IsRoundStarted())
314 if(time >= this.ltime)
320 vector midpoint = ((this.absmin + this.absmax) * 0.5);
321 if(pointcontents(midpoint) == CONTENT_WATER)
323 this.velocity = this.velocity * 0.5;
325 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
326 { this.velocity_z = 200; }
328 UpdateCSQCProjectile(this);
331 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
332 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
334 this.nextthink = time + 0.1;
335 if(time >= this.nade_special_time)
337 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
338 nade_napalm_ball(this);
342 void nade_napalm_boom(entity this)
346 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
347 nade_napalm_ball(this);
351 fountain.owner = this.owner;
352 fountain.realowner = this.realowner;
353 fountain.origin = this.origin;
354 setorigin(fountain, fountain.origin);
355 setthink(fountain, napalm_fountain_think);
356 fountain.nextthink = time;
357 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
358 fountain.pushltime = fountain.ltime;
359 fountain.team = this.team;
360 set_movetype(fountain, MOVETYPE_TOSS);
361 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
362 fountain.bot_dodge = true;
363 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
364 fountain.nade_special_time = time;
365 setsize(fountain, '-16 -16 -16', '16 16 16');
366 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
369 void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
371 frost_target.frozen_by = freezefield.realowner;
372 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
373 Freeze(frost_target, 1/freeze_time, 3, false);
375 Drop_Special_Items(frost_target);
378 void nade_ice_think(entity this)
380 if(round_handler_IsActive())
381 if(!round_handler_IsRoundStarted())
387 if(time >= this.ltime)
389 if ( autocvar_g_nades_ice_explode )
391 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
392 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
393 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
395 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
396 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
397 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
398 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
405 this.nextthink = time+0.1;
410 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
412 randomw = random()*M_PI*2;
414 randomp.x = randomr*cos(randomw);
415 randomp.y = randomr*sin(randomw);
417 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
419 if(time >= this.nade_special_time)
421 this.nade_special_time = time+0.7;
423 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
424 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
428 float current_freeze_time = this.ltime - time - 0.1;
430 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0,
432 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
433 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
434 if(!STAT(FROZEN, it))
435 nade_ice_freeze(this, it, current_freeze_time);
439 void nade_ice_boom(entity this)
443 fountain.owner = this.owner;
444 fountain.realowner = this.realowner;
445 fountain.origin = this.origin;
446 setorigin(fountain, fountain.origin);
447 setthink(fountain, nade_ice_think);
448 fountain.nextthink = time;
449 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
450 fountain.pushltime = fountain.wait = fountain.ltime;
451 fountain.team = this.team;
452 set_movetype(fountain, MOVETYPE_TOSS);
453 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
454 fountain.bot_dodge = false;
455 setsize(fountain, '-16 -16 -16', '16 16 16');
456 fountain.nade_special_time = time+0.3;
457 fountain.angles = this.angles;
459 if ( autocvar_g_nades_ice_explode )
461 setmodel(fountain, MDL_PROJECTILE_GRENADE);
462 entity timer = new(nade_timer);
463 setmodel(timer, MDL_NADE_TIMER);
464 setattachment(timer, fountain, "");
465 timer.colormap = this.colormap;
466 timer.glowmod = this.glowmod;
467 setthink(timer, nade_timer_think);
468 timer.nextthink = time;
469 timer.wait = fountain.ltime;
470 timer.owner = fountain;
474 setmodel(fountain, MDL_Null);
477 void nade_translocate_boom(entity this)
479 if(this.realowner.vehicle)
482 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
483 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
484 locout = trace_endpos;
486 makevectors(this.realowner.angles);
488 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
490 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
493 void nade_spawn_boom(entity this)
495 entity spawnloc = spawn();
496 setorigin(spawnloc, this.origin);
497 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
498 set_movetype(spawnloc, MOVETYPE_NONE);
499 spawnloc.solid = SOLID_NOT;
500 spawnloc.drawonlytoclient = this.realowner;
501 spawnloc.effects = EF_STARDUST;
502 spawnloc.cnt = autocvar_g_nades_spawn_count;
504 if(this.realowner.nade_spawnloc)
506 delete(this.realowner.nade_spawnloc);
507 this.realowner.nade_spawnloc = NULL;
510 this.realowner.nade_spawnloc = spawnloc;
513 void nades_orb_think(entity this)
515 if(time >= this.ltime)
521 this.nextthink = time;
523 if(time >= this.nade_special_time)
525 this.nade_special_time = time+0.25;
526 this.nade_show_particles = 1;
529 this.nade_show_particles = 0;
532 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
534 // NOTE: this function merely places an orb
535 // you must add a custom touch function to the returned entity if desired
536 // also set .colormod if you wish to have it colorized
537 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
539 orb.realowner = realown;
542 orb.orb_lifetime = orb_ltime; // required for timers
543 orb.ltime = time + orb.orb_lifetime;
544 orb.bot_dodge = false;
545 orb.team = realown.team;
546 orb.solid = SOLID_TRIGGER;
548 setmodel(orb, MDL_NADE_ORB);
550 orb.orb_radius = orb_rad; // required for fading
551 vector size = '1 1 1' * orb.orb_radius / 2;
552 setsize(orb, -size, size);
554 Net_LinkEntity(orb, true, 0, orb_send);
557 setthink(orb, nades_orb_think);
558 orb.nextthink = time;
563 void nade_entrap_touch(entity this, entity toucher)
565 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
567 if (!isPushable(toucher))
570 float pushdeltatime = time - toucher.lastpushtime;
571 if (pushdeltatime > 0.15) pushdeltatime = 0;
572 toucher.lastpushtime = time;
573 if(!pushdeltatime) return;
575 // div0: ticrate independent, 1 = identity (not 20)
576 toucher.velocity = toucher.velocity * pow(autocvar_g_nades_entrap_strength, pushdeltatime);
579 UpdateCSQCProjectile(toucher);
583 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
585 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
586 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
588 float tint_alpha = 0.75;
589 if(SAME_TEAM(toucher, this.realowner))
591 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
595 void nade_entrap_boom(entity this)
597 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
599 settouch(orb, nade_entrap_touch);
600 orb.colormod = NADE_TYPE_ENTRAP.m_color;
603 void nade_heal_touch(entity this, entity toucher)
607 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
608 if(!IS_DEAD(toucher))
609 if(!STAT(FROZEN, toucher))
611 health_factor = autocvar_g_nades_heal_rate*frametime/2;
612 if ( toucher != this.realowner )
614 if ( SAME_TEAM(toucher,this) )
615 health_factor *= autocvar_g_nades_heal_friend;
617 health_factor *= autocvar_g_nades_heal_foe;
619 if ( health_factor > 0 )
621 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
622 if ( toucher.health < maxhealth )
624 if ( this.nade_show_particles )
625 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
626 toucher.health = min(toucher.health+health_factor, maxhealth);
628 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
630 else if ( health_factor < 0 )
632 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,toucher.origin,'0 0 0');
637 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
639 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
640 show_red.stat_healing_orb = time+0.1;
641 show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.orb_lifetime;
645 void nade_heal_boom(entity this)
647 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
649 settouch(orb, nade_heal_touch);
650 orb.colormod = '1 0 0';
653 void nade_monster_boom(entity this)
655 entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
657 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
658 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
659 e.monster_skill = MONSTER_SKILL_INSANE;
662 void nade_boom(entity this)
665 bool nade_blast = true;
667 switch ( Nades_from(this.nade_type) )
669 case NADE_TYPE_NAPALM:
670 nade_blast = autocvar_g_nades_napalm_blast;
671 expef = EFFECT_EXPLOSION_MEDIUM;
675 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
677 case NADE_TYPE_TRANSLOCATE:
680 case NADE_TYPE_MONSTER:
681 case NADE_TYPE_SPAWN:
683 switch(this.realowner.team)
685 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
686 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
687 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
688 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
689 default: expef = EFFECT_SPAWN_NEUTRAL; break;
694 expef = EFFECT_SPAWN_RED;
697 case NADE_TYPE_ENTRAP:
699 expef = EFFECT_SPAWN_YELLOW;
703 case NADE_TYPE_NORMAL:
704 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
709 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
711 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
712 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
714 this.event_damage = func_null; // prevent somehow calling damage in the next call
718 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
719 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
720 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);
724 switch ( Nades_from(this.nade_type) )
726 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
727 case NADE_TYPE_ICE: nade_ice_boom(this); break;
728 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
729 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
730 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
731 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
732 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
735 FOREACH_ENTITY_ENT(aiment, this,
737 if(it.classname == "grapplinghook")
738 RemoveGrapplingHook(it.realowner);
744 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
745 void nade_pickup(entity this, entity thenade)
747 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, thenade.nade_type, thenade.pokenade_type);
749 // set refire so player can't even
750 this.nade_refire = time + autocvar_g_nades_nade_refire;
754 this.nade.nade_time_primed = thenade.nade_time_primed;
757 bool CanThrowNade(entity this);
758 void nade_touch(entity this, entity toucher)
761 UpdateCSQCProjectile(this);
763 if(toucher == this.realowner)
764 return; // no this impacts
766 if(autocvar_g_nades_pickup)
767 if(time >= this.spawnshieldtime)
768 if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much
769 if(!STAT(FROZEN, toucher))
770 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
771 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
773 nade_pickup(toucher, this);
774 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
778 /*float is_weapclip = 0;
779 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
780 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
781 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
783 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
785 FOREACH_ENTITY_ENT(aiment, this,
787 if(it.classname == "grapplinghook")
788 RemoveGrapplingHook(it.realowner);
794 PROJECTILE_TOUCH(this, toucher);
796 //setsize(this, '-2 -2 -2', '2 2 2');
797 //UpdateCSQCProjectile(this);
798 if(this.health == this.max_health)
800 spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM);
804 this.enemy = toucher;
808 void nade_beep(entity this)
810 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
811 setthink(this, nade_boom);
812 this.nextthink = max(this.wait, time);
815 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
817 if(ITEM_DAMAGE_NEEDKILL(deathtype))
819 this.takedamage = DAMAGE_NO;
824 if(this.nade_type == NADE_TYPE_TRANSLOCATE.m_id || this.nade_type == NADE_TYPE_SPAWN.m_id)
827 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
828 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
833 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
835 force *= 0.5; // too much
838 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
841 damage = this.max_health * 0.55;
843 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
844 damage = this.max_health * 0.1;
845 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
847 if(deathtype & HITTYPE_SECONDARY)
849 damage = this.max_health * 0.1;
853 damage = this.max_health * 1.15;
856 this.velocity += force;
857 UpdateCSQCProjectile(this);
859 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
862 if(this.health == this.max_health)
864 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
865 this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
866 setthink(this, nade_beep);
869 this.health -= damage;
871 if ( this.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
872 this.realowner = attacker;
875 W_PrepareExplosionByDamage(this, attacker, nade_boom);
877 nade_burn_spawn(this);
880 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
885 entity _nade = e.nade;
891 makevectors(e.v_angle);
893 // NOTE: always throw from first weapon entity?
894 W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
896 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
898 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
899 + (v_right * autocvar_g_nades_throw_offset.y)
900 + (v_up * autocvar_g_nades_throw_offset.z);
901 if(autocvar_g_nades_throw_offset == '0 0 0')
904 setorigin(_nade, w_shotorg + offset + (v_right * 25) * -1);
905 //setmodel(_nade, MDL_PROJECTILE_NADE);
906 //setattachment(_nade, NULL, "");
907 PROJECTILE_MAKETRIGGER(_nade);
908 if(STAT(NADES_SMALL, e))
909 setsize(_nade, '-8 -8 -8', '8 8 8');
911 setsize(_nade, '-16 -16 -16', '16 16 16');
912 set_movetype(_nade, MOVETYPE_BOUNCE);
914 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
915 if (trace_startsolid)
916 setorigin(_nade, e.origin);
918 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
919 _nade.velocity = '0 0 100';
920 else if(autocvar_g_nades_nade_newton_style == 1)
921 _nade.velocity = e.velocity + _velocity;
922 else if(autocvar_g_nades_nade_newton_style == 2)
923 _nade.velocity = _velocity;
925 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
930 settouch(_nade, nade_touch);
931 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
932 _nade.health = autocvar_g_nades_nade_health;
933 _nade.max_health = _nade.health;
934 _nade.takedamage = DAMAGE_AIM;
935 _nade.event_damage = nade_damage;
936 setcefc(_nade, func_null);
937 _nade.exteriormodeltoclient = NULL;
938 _nade.traileffectnum = 0;
939 _nade.teleportable = true;
940 _nade.pushable = true;
942 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
943 _nade.damagedbycontents = true;
944 _nade.angles = vectoangles(_nade.velocity);
945 _nade.flags = FL_PROJECTILE;
946 IL_PUSH(g_projectiles, _nade);
947 _nade.projectiledeathtype = DEATH_NADE.m_id;
948 _nade.toss_time = time;
949 _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
951 if(_nade.nade_type == NADE_TYPE_TRANSLOCATE.m_id || _nade.nade_type == NADE_TYPE_SPAWN.m_id)
952 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
954 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
960 setthink(_nade, nade_boom);
961 _nade.nextthink = _time;
964 e.nade_refire = time + autocvar_g_nades_nade_refire;
968 void nades_GiveBonus(entity player, float score)
970 if (autocvar_g_nades)
971 if (autocvar_g_nades_bonus)
972 if (IS_REAL_CLIENT(player))
973 if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
974 if (STAT(FROZEN, player) == 0)
975 if (!IS_DEAD(player))
977 if ( player.bonus_nade_score < 1 )
978 player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
980 if ( player.bonus_nade_score >= 1 )
982 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
983 play2(player, SND(KH_ALARM));
984 player.bonus_nades++;
985 player.bonus_nade_score -= 1;
990 /** Remove all bonus nades from a player */
991 void nades_RemoveBonus(entity player)
993 player.bonus_nades = player.bonus_nade_score = 0;
996 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
998 entity player = M_ARGV(0, entity);
1000 nades_RemoveBonus(player);
1003 bool nade_customize(entity this, entity client)
1005 //if(IS_SPEC(client)) { return false; }
1006 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1008 // somewhat hide the model, but keep the glow
1010 if(this.traileffectnum)
1011 this.traileffectnum = 0;
1016 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1017 if(!this.traileffectnum)
1018 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(this.nade_type).m_projectile[false], this.team).eent_eff_name);
1025 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1027 entity n = new(nade), fn = new(fake_nade);
1029 n.nade_type = max(1, ntype);
1030 n.pokenade_type = pntype;
1032 if(Nades_from(n.nade_type) == NADE_TYPE_Null)
1033 n.nade_type = NADE_TYPE_NORMAL.m_id;
1035 setmodel(n, MDL_PROJECTILE_NADE);
1036 //setattachment(n, player, "bip01 l hand");
1037 n.exteriormodeltoclient = player;
1038 setcefc(n, nade_customize);
1039 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], player.team).eent_eff_name);
1040 n.colormod = Nades_from(n.nade_type).m_color;
1041 n.realowner = nowner;
1042 n.colormap = player.colormap;
1043 n.glowmod = player.glowmod;
1044 n.wait = time + max(0, ntime);
1045 n.nade_time_primed = time;
1046 setthink(n, nade_beep);
1047 n.nextthink = max(n.wait - 3, time);
1048 n.projectiledeathtype = DEATH_NADE.m_id;
1050 setmodel(fn, MDL_NADE_VIEW);
1051 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1052 setattachment(fn, player.(weaponentity), "");
1053 fn.realowner = fn.owner = player;
1054 fn.colormod = Nades_from(n.nade_type).m_color;
1055 fn.colormap = player.colormap;
1056 fn.glowmod = player.glowmod;
1057 setthink(fn, SUB_Remove);
1058 fn.nextthink = n.wait;
1061 player.fake_nade = fn;
1064 void nade_prime(entity this)
1066 if(autocvar_g_nades_bonus_only)
1067 if(!this.bonus_nades)
1068 return; // only allow bonus nades
1074 delete(this.fake_nade);
1077 string pntype = this.pokenade_type;
1079 if(this.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
1080 ntype = this.nade_type;
1081 else if (this.bonus_nades >= 1)
1083 ntype = this.nade_type;
1084 pntype = this.pokenade_type;
1085 this.bonus_nades -= 1;
1089 ntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_nade_type : autocvar_g_nades_nade_type);
1090 pntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1093 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1096 bool CanThrowNade(entity this)
1107 if (!autocvar_g_nades)
1108 return false; // allow turning them off mid match
1110 if(forbidWeaponUse(this))
1113 if (!IS_PLAYER(this))
1119 .bool nade_altbutton;
1121 void nades_CheckThrow(entity this)
1123 if(!CanThrowNade(this))
1126 entity held_nade = this.nade;
1129 this.nade_altbutton = true;
1130 if(time > this.nade_refire)
1132 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1134 this.nade_refire = time + autocvar_g_nades_nade_refire;
1139 this.nade_altbutton = false;
1140 if (time >= held_nade.nade_time_primed + 1) {
1141 makevectors(this.v_angle);
1142 float _force = time - held_nade.nade_time_primed;
1143 _force /= autocvar_g_nades_nade_lifetime;
1144 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1145 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1146 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1147 toss_nade(this, true, dir * _force, 0);
1152 void nades_Clear(entity player)
1155 delete(player.nade);
1156 if(player.fake_nade)
1157 delete(player.fake_nade);
1159 player.nade = player.fake_nade = NULL;
1160 player.nade_timer = 0;
1163 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1165 entity player = M_ARGV(0, entity);
1168 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1171 CLASS(NadeOffhand, OffhandWeapon)
1172 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1174 entity held_nade = player.nade;
1177 player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
1178 // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
1179 makevectors(player.angles);
1180 held_nade.velocity = player.velocity;
1181 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1182 held_nade.angles_y = player.angles.y;
1184 if (time + 0.1 >= held_nade.wait)
1185 toss_nade(player, false, '0 0 0', time + 0.05);
1188 if (!CanThrowNade(player)) return;
1189 if (!(time > player.nade_refire)) return;
1193 held_nade = player.nade;
1195 } else if (time >= held_nade.nade_time_primed + 1) {
1197 makevectors(player.v_angle);
1198 float _force = time - held_nade.nade_time_primed;
1199 _force /= autocvar_g_nades_nade_lifetime;
1200 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1201 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1202 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1203 toss_nade(player, false, dir * _force, 0);
1207 ENDCLASS(NadeOffhand)
1208 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1210 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1212 entity player = M_ARGV(0, entity);
1214 if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1215 nades_CheckThrow(player);
1220 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1222 entity player = M_ARGV(0, entity);
1224 if (!IS_PLAYER(player)) { return; }
1226 if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1228 if(IS_PLAYER(player))
1230 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1233 float key_count = 0;
1234 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1237 if(player.flagcarried || player.ballcarried) // this player is important
1238 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1240 time_score = autocvar_g_nades_bonus_score_time;
1243 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1245 if(autocvar_g_nades_bonus_client_select)
1247 player.nade_type = player.cvar_cl_nade_type;
1248 player.pokenade_type = player.cvar_cl_pokenade_type;
1252 player.nade_type = autocvar_g_nades_bonus_type;
1253 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1256 player.nade_type = bound(1, player.nade_type, Nades_COUNT);
1258 if(player.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
1259 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1263 player.bonus_nades = player.bonus_nade_score = 0;
1269 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1273 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1275 FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA(
1277 if(STAT(FROZEN, it) == 0)
1278 if(SAME_TEAM(it, player))
1279 if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1283 if(STAT(FROZEN, player) == 1)
1290 if(n && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
1292 player.revive_progress = bound(0, player.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1293 player.health = max(1, player.revive_progress * start_health);
1295 if(player.revive_progress >= 1)
1299 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1300 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1303 FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
1304 it.revive_progress = player.revive_progress;
1305 it.reviving = false;
1310 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics)
1312 entity player = M_ARGV(0, entity);
1314 if (STAT(ENTRAP_ORB, player) > time)
1316 player.stat_sv_maxspeed *= autocvar_g_nades_entrap_speed;
1317 player.stat_sv_airspeedlimit_nonqw *= autocvar_g_nades_entrap_speed;
1321 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1323 entity mon = M_ARGV(0, entity);
1325 if (STAT(ENTRAP_ORB, mon) > time)
1327 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1328 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1332 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1334 entity player = M_ARGV(0, entity);
1336 if(autocvar_g_nades_spawn)
1337 player.nade_refire = time + autocvar_g_spawnshieldtime;
1339 player.nade_refire = time + autocvar_g_nades_nade_refire;
1341 if(autocvar_g_nades_bonus_client_select)
1342 player.nade_type = player.cvar_cl_nade_type;
1344 player.nade_timer = 0;
1346 if (!player.offhand) player.offhand = OFFHAND_NADE;
1348 if(player.nade_spawnloc)
1350 setorigin(player, player.nade_spawnloc.origin);
1351 player.nade_spawnloc.cnt -= 1;
1353 if(player.nade_spawnloc.cnt <= 0)
1355 delete(player.nade_spawnloc);
1356 player.nade_spawnloc = NULL;
1361 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1363 entity frag_attacker = M_ARGV(1, entity);
1364 entity frag_target = M_ARGV(2, entity);
1366 if(frag_target.nade)
1367 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1368 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1370 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);
1372 if(IS_PLAYER(frag_attacker))
1374 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1375 nades_RemoveBonus(frag_attacker);
1376 else if(frag_target.flagcarried)
1377 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1378 else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1)
1380 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1381 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1382 switch(frag_attacker.killcount)
1385 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1390 nades_GiveBonus(frag_attacker, killcount_bonus);
1393 nades_RemoveBonus(frag_target);
1396 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
1398 entity frag_inflictor = M_ARGV(0, entity);
1399 entity frag_attacker = M_ARGV(1, entity);
1400 entity frag_target = M_ARGV(2, entity);
1401 float frag_deathtype = M_ARGV(3, float);
1403 if(STAT(FROZEN, frag_target))
1404 if(autocvar_g_freezetag_revive_nade)
1405 if(frag_attacker == frag_target)
1406 if(frag_deathtype == DEATH_NADE.m_id)
1407 if(time - frag_inflictor.toss_time <= 0.1)
1409 Unfreeze(frag_target);
1410 frag_target.health = autocvar_g_freezetag_revive_nade_health;
1411 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1412 M_ARGV(4, float) = 0;
1413 M_ARGV(6, vector) = '0 0 0';
1414 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1415 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1419 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1421 entity frag_target = M_ARGV(0, entity);
1422 entity frag_attacker = M_ARGV(1, entity);
1424 if(IS_PLAYER(frag_attacker))
1425 if(DIFF_TEAM(frag_attacker, frag_target))
1426 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1427 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1430 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1432 entity frag_target = M_ARGV(0, entity);
1434 if(frag_target.nade)
1435 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1438 void nades_RemovePlayer(entity this)
1441 nades_RemoveBonus(this);
1444 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1445 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1446 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1448 FOREACH_CLIENT(IS_PLAYER(it),
1450 nades_RemovePlayer(it);
1454 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1456 entity spectatee = M_ARGV(0, entity);
1457 entity client = M_ARGV(1, entity);
1459 client.nade_timer = spectatee.nade_timer;
1460 client.nade_type = spectatee.nade_type;
1461 client.pokenade_type = spectatee.pokenade_type;
1462 client.bonus_nades = spectatee.bonus_nades;
1463 client.bonus_nade_score = spectatee.bonus_nade_score;
1464 client.stat_healing_orb = spectatee.stat_healing_orb;
1465 client.stat_healing_orb_alpha = spectatee.stat_healing_orb_alpha;
1466 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1467 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1470 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1471 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1473 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1475 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1478 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
1480 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Nades");
1483 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1485 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");