3 #include "../overkill/okmachinegun.qh"
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, {
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 // TODO: make a common orb state!
42 if (STAT(HEALING_ORB) > time)
44 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
45 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
48 if (STAT(ENTRAP_ORB) > time)
50 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
51 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
54 if (STAT(VEIL_ORB) > time)
56 M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color;
57 M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA);
62 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
64 entity proj = M_ARGV(0, entity);
66 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
69 proj.traileffect = EFFECT_FIREBALL.m_id;
72 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
74 setmodel(proj, MDL_PROJECTILE_NADE);
75 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
76 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
80 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
82 entity proj = M_ARGV(0, entity);
84 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
86 loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
87 proj.mins = '-16 -16 -16';
88 proj.maxs = '16 16 16';
91 entity nade_type = Nade_FromProjectile(proj.cnt);
92 if (nade_type == NADE_TYPE_Null) return;
95 proj.mins = '-8 -8 -8';
100 proj.mins = '-16 -16 -16';
101 proj.maxs = '16 16 16';
103 proj.colormod = nade_type.m_color;
104 set_movetype(proj, MOVETYPE_BOUNCE);
105 settouch(proj, func_null);
107 proj.avelocity = randomvec() * 720;
108 proj.alphamod = nade_type.m_alpha;
110 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
111 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
113 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
115 bool Projectile_isnade(int p)
117 return Nade_FromProjectile(p) != NADE_TYPE_Null;
119 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
121 float bonusNades = STAT(NADE_BONUS);
122 float bonusProgress = STAT(NADE_BONUS_SCORE);
123 float bonusType = STAT(NADE_BONUS_TYPE);
124 Nade def = Nades_from(bonusType);
125 vector nadeColor = def.m_color;
126 string nadeIcon = def.m_icon;
128 vector iconPos, textPos;
130 if(autocvar_hud_panel_ammo_iconalign)
132 iconPos = myPos + eX * 2 * mySize.y;
138 textPos = myPos + eX * mySize.y;
141 if(bonusNades > 0 || bonusProgress > 0)
143 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
145 if(autocvar_hud_panel_ammo_text)
146 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
149 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
151 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
158 #include <common/gamemodes/_mod.qh>
159 #include <common/monsters/sv_spawn.qh>
160 #include <common/monsters/sv_monsters.qh>
161 #include <server/g_subs.qh>
163 REGISTER_MUTATOR(nades, autocvar_g_nades);
165 .float nade_time_primed;
166 .float nade_lifetime;
168 .entity nade_spawnloc;
171 void nade_timer_think(entity this)
173 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
174 this.nextthink = time;
175 if(!this.owner || wasfreed(this.owner))
179 void nade_burn_spawn(entity _nade)
181 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
184 void nade_spawn(entity _nade)
186 entity timer = new(nade_timer);
187 setmodel(timer, MDL_NADE_TIMER);
188 setattachment(timer, _nade, "");
189 timer.colormap = _nade.colormap;
190 timer.glowmod = _nade.glowmod;
191 setthink(timer, nade_timer_think);
192 timer.nextthink = time;
193 timer.wait = _nade.wait;
197 _nade.effects |= EF_LOWPRECISION;
199 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
202 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
211 RandomSelection_Init();
212 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
213 if(e.takedamage == DAMAGE_AIM)
214 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
215 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
219 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
220 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
221 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
222 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
225 e.fireball_impactvec = p;
226 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
229 if(RandomSelection_chosen_ent)
231 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
232 d = damage + (edgedamage - damage) * (d / dist);
233 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
234 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
235 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
240 void napalm_ball_think(entity this)
242 if(round_handler_IsActive())
243 if(!round_handler_IsRoundStarted())
249 if(time > this.pushltime)
255 vector midpoint = ((this.absmin + this.absmax) * 0.5);
256 if(pointcontents(midpoint) == CONTENT_WATER)
258 this.velocity = this.velocity * 0.5;
260 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
261 { this.velocity_z = 200; }
264 this.angles = vectoangles(this.velocity);
266 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
267 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
269 this.nextthink = time + 0.1;
273 void nade_napalm_ball(entity this)
278 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
281 proj.owner = this.owner;
282 proj.realowner = this.realowner;
283 proj.team = this.owner.team;
284 proj.bot_dodge = true;
285 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
286 set_movetype(proj, MOVETYPE_BOUNCE);
287 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
288 PROJECTILE_MAKETRIGGER(proj);
289 setmodel(proj, MDL_Null);
290 proj.scale = 1;//0.5;
291 setsize(proj, '-4 -4 -4', '4 4 4');
292 setorigin(proj, this.origin);
293 setthink(proj, napalm_ball_think);
294 proj.nextthink = time;
295 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
296 proj.effects = EF_LOWPRECISION | EF_FLAME;
298 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
299 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
300 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
301 proj.velocity = kick;
303 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
305 proj.angles = vectoangles(proj.velocity);
306 proj.flags = FL_PROJECTILE;
307 IL_PUSH(g_projectiles, proj);
308 IL_PUSH(g_bot_dodge, proj);
309 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
311 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
315 void napalm_fountain_think(entity this)
318 if(round_handler_IsActive())
319 if(!round_handler_IsRoundStarted())
325 if(time >= this.ltime)
331 vector midpoint = ((this.absmin + this.absmax) * 0.5);
332 if(pointcontents(midpoint) == CONTENT_WATER)
334 this.velocity = this.velocity * 0.5;
336 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
337 { this.velocity_z = 200; }
339 UpdateCSQCProjectile(this);
342 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
343 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
345 this.nextthink = time + 0.1;
346 if(time >= this.nade_special_time)
348 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
349 nade_napalm_ball(this);
353 void nade_napalm_boom(entity this)
357 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
358 nade_napalm_ball(this);
362 fountain.owner = this.owner;
363 fountain.realowner = this.realowner;
364 fountain.origin = this.origin;
365 fountain.flags = FL_PROJECTILE;
366 IL_PUSH(g_projectiles, fountain);
367 IL_PUSH(g_bot_dodge, fountain);
368 setorigin(fountain, fountain.origin);
369 setthink(fountain, napalm_fountain_think);
370 fountain.nextthink = time;
371 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
372 fountain.pushltime = fountain.ltime;
373 fountain.team = this.team;
374 set_movetype(fountain, MOVETYPE_TOSS);
375 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
376 fountain.bot_dodge = true;
377 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
378 fountain.nade_special_time = time;
379 setsize(fountain, '-16 -16 -16', '16 16 16');
380 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
383 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
385 frost_target.frozen_by = freezefield.realowner;
386 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
387 Freeze(frost_target, 1 / freezetime, 3, false);
389 Drop_Special_Items(frost_target);
392 void nade_ice_think(entity this)
394 if(round_handler_IsActive())
395 if(!round_handler_IsRoundStarted())
401 if(time >= this.ltime)
403 if ( autocvar_g_nades_ice_explode )
405 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
406 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
407 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
409 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
410 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
411 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
412 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
419 this.nextthink = time+0.1;
424 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
426 randomw = random()*M_PI*2;
428 randomp.x = randomr*cos(randomw);
429 randomp.y = randomr*sin(randomw);
431 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
433 if(time >= this.nade_special_time)
435 this.nade_special_time = time+0.7;
437 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
438 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
442 float current_freeze_time = this.ltime - time - 0.1;
444 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResourceAmount(it, RESOURCE_HEALTH) > 0 && current_freeze_time > 0,
446 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
447 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
448 if(!STAT(FROZEN, it))
449 nade_ice_freeze(this, it, current_freeze_time);
453 void nade_ice_boom(entity this)
457 fountain.owner = this.owner;
458 fountain.realowner = this.realowner;
459 fountain.origin = this.origin;
460 setorigin(fountain, fountain.origin);
461 setthink(fountain, nade_ice_think);
462 fountain.nextthink = time;
463 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
464 fountain.pushltime = fountain.wait = fountain.ltime;
465 fountain.team = this.team;
466 set_movetype(fountain, MOVETYPE_TOSS);
467 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
468 fountain.bot_dodge = false;
469 setsize(fountain, '-16 -16 -16', '16 16 16');
470 fountain.nade_special_time = time+0.3;
471 fountain.angles = this.angles;
473 if ( autocvar_g_nades_ice_explode )
475 setmodel(fountain, MDL_PROJECTILE_GRENADE);
476 entity timer = new(nade_timer);
477 setmodel(timer, MDL_NADE_TIMER);
478 setattachment(timer, fountain, "");
479 timer.colormap = this.colormap;
480 timer.glowmod = this.glowmod;
481 setthink(timer, nade_timer_think);
482 timer.nextthink = time;
483 timer.wait = fountain.ltime;
484 timer.owner = fountain;
488 setmodel(fountain, MDL_Null);
491 void nade_translocate_boom(entity this)
493 if(this.realowner.vehicle)
496 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
497 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
498 locout = trace_endpos;
500 makevectors(this.realowner.angles);
502 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
504 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
507 void nade_spawn_boom(entity this)
509 entity spawnloc = spawn();
510 setorigin(spawnloc, this.origin);
511 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
512 set_movetype(spawnloc, MOVETYPE_NONE);
513 spawnloc.solid = SOLID_NOT;
514 spawnloc.drawonlytoclient = this.realowner;
515 spawnloc.effects = EF_STARDUST;
516 spawnloc.cnt = autocvar_g_nades_spawn_count;
518 if(this.realowner.nade_spawnloc)
520 delete(this.realowner.nade_spawnloc);
521 this.realowner.nade_spawnloc = NULL;
524 this.realowner.nade_spawnloc = spawnloc;
527 void nades_orb_think(entity this)
529 if(time >= this.ltime)
535 this.nextthink = time;
537 if(time >= this.nade_special_time)
539 this.nade_special_time = time+0.25;
540 this.nade_show_particles = 1;
543 this.nade_show_particles = 0;
546 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
548 // NOTE: this function merely places an orb
549 // you must add a custom touch function to the returned entity if desired
550 // also set .colormod if you wish to have it colorized
551 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
553 orb.realowner = realown;
556 orb.orb_lifetime = orb_ltime; // required for timers
557 orb.ltime = time + orb.orb_lifetime;
558 orb.bot_dodge = false;
559 orb.team = realown.team;
560 orb.solid = SOLID_TRIGGER;
562 setmodel(orb, MDL_NADE_ORB);
564 orb.orb_radius = orb_rad; // required for fading
565 vector size = '1 1 1' * orb.orb_radius / 2;
566 setsize(orb, -size, size);
568 Net_LinkEntity(orb, true, 0, orb_send);
571 setthink(orb, nades_orb_think);
572 orb.nextthink = time;
577 void nade_entrap_touch(entity this, entity toucher)
579 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
581 if (!isPushable(toucher))
584 float pushdeltatime = time - toucher.lastpushtime;
585 if (pushdeltatime > 0.15) pushdeltatime = 0;
586 toucher.lastpushtime = time;
587 if(!pushdeltatime) return;
589 // div0: ticrate independent, 1 = identity (not 20)
590 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
593 UpdateCSQCProjectile(toucher);
597 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
599 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
600 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
602 float tint_alpha = 0.75;
603 if(SAME_TEAM(toucher, this.realowner))
605 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
609 void nade_entrap_boom(entity this)
611 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
613 settouch(orb, nade_entrap_touch);
614 orb.colormod = NADE_TYPE_ENTRAP.m_color;
617 void nade_heal_touch(entity this, entity toucher)
621 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
622 if(!IS_DEAD(toucher))
623 if(!STAT(FROZEN, toucher))
625 health_factor = autocvar_g_nades_heal_rate*frametime/2;
626 if ( toucher != this.realowner )
628 if ( SAME_TEAM(toucher,this) )
629 health_factor *= autocvar_g_nades_heal_friend;
631 health_factor *= autocvar_g_nades_heal_foe;
633 if ( health_factor > 0 )
635 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
636 float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
639 if (this.nade_show_particles)
641 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
643 GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
646 else if ( health_factor < 0 )
648 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
653 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
655 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
656 STAT(HEALING_ORB, show_red) = time+0.1;
657 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
661 void nade_heal_boom(entity this)
663 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
665 settouch(orb, nade_heal_touch);
666 orb.colormod = '1 0 0';
669 void nade_monster_boom(entity this)
671 entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
673 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
674 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
675 e.monster_skill = MONSTER_SKILL_INSANE;
678 void nade_veil_touch(entity this, entity toucher)
680 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
682 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
684 float tint_alpha = 0.75;
685 if(SAME_TEAM(toucher, this.realowner))
688 if(!STAT(VEIL_ORB, show_tint))
690 toucher.nade_veil_prevalpha = toucher.alpha;
694 STAT(VEIL_ORB, show_tint) = time + 0.1;
695 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
699 void nade_veil_boom(entity this)
701 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
703 settouch(orb, nade_veil_touch);
704 orb.colormod = NADE_TYPE_VEIL.m_color;
707 void nade_boom(entity this)
710 bool nade_blast = true;
712 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
714 case NADE_TYPE_NAPALM:
715 nade_blast = autocvar_g_nades_napalm_blast;
716 expef = EFFECT_EXPLOSION_MEDIUM;
720 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
722 case NADE_TYPE_TRANSLOCATE:
725 case NADE_TYPE_MONSTER:
726 case NADE_TYPE_SPAWN:
728 switch(this.realowner.team)
730 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
731 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
732 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
733 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
734 default: expef = EFFECT_SPAWN_NEUTRAL; break;
739 expef = EFFECT_SPAWN_RED;
742 case NADE_TYPE_ENTRAP:
744 expef = EFFECT_SPAWN_YELLOW;
749 expef = EFFECT_SPAWN_NEUTRAL;
753 case NADE_TYPE_NORMAL:
754 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
759 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
761 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
762 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
764 this.event_damage = func_null; // prevent somehow calling damage in the next call
768 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
769 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
770 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);
774 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
776 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
777 case NADE_TYPE_ICE: nade_ice_boom(this); break;
778 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
779 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
780 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
781 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
782 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
783 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
786 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
794 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
795 void nade_pickup(entity this, entity thenade)
797 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
799 // set refire so player can't even
800 this.nade_refire = time + autocvar_g_nades_nade_refire;
801 STAT(NADE_TIMER, this) = 0;
804 this.nade.nade_time_primed = thenade.nade_time_primed;
807 bool CanThrowNade(entity this);
808 void nade_touch(entity this, entity toucher)
811 UpdateCSQCProjectile(this);
813 if(toucher == this.realowner)
814 return; // no this impacts
816 if(autocvar_g_nades_pickup)
817 if(time >= this.spawnshieldtime)
818 if(!toucher.nade && GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
819 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
820 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
822 nade_pickup(toucher, this);
823 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
827 /*float is_weapclip = 0;
828 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
829 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
830 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
832 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
834 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
842 PROJECTILE_TOUCH(this, toucher);
844 //setsize(this, '-2 -2 -2', '2 2 2');
845 //UpdateCSQCProjectile(this);
846 if(GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health)
848 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
852 this.enemy = toucher;
856 void nade_beep(entity this)
858 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
859 setthink(this, nade_boom);
860 this.nextthink = max(this.wait, time);
863 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
865 if(ITEM_DAMAGE_NEEDKILL(deathtype))
867 this.takedamage = DAMAGE_NO;
872 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
875 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
876 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
881 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
883 force *= 0.5; // too much
886 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
889 damage = this.max_health * 0.55;
891 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
892 damage = this.max_health * 0.1;
893 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
895 if(deathtype & HITTYPE_SECONDARY)
897 damage = this.max_health * 0.1;
901 damage = this.max_health * 1.15;
904 this.velocity += force;
905 UpdateCSQCProjectile(this);
907 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
910 float hp = GetResourceAmount(this, RESOURCE_HEALTH);
911 if(hp == this.max_health)
913 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
914 this.nextthink = max(time + this.nade_lifetime, time);
915 setthink(this, nade_beep);
919 SetResourceAmount(this, RESOURCE_HEALTH, hp);
922 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
923 this.realowner = attacker;
926 W_PrepareExplosionByDamage(this, attacker, nade_boom);
928 nade_burn_spawn(this);
931 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
936 entity _nade = e.nade;
942 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
944 makevectors(e.v_angle);
946 // NOTE: always throw from first weapon entity?
947 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
949 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
950 + (v_right * autocvar_g_nades_throw_offset.y)
951 + (v_up * autocvar_g_nades_throw_offset.z);
953 setorigin(_nade, w_shotorg + offset);
954 //setmodel(_nade, MDL_PROJECTILE_NADE);
955 //setattachment(_nade, NULL, "");
956 PROJECTILE_MAKETRIGGER(_nade);
957 if(STAT(NADES_SMALL, e))
958 setsize(_nade, '-8 -8 -8', '8 8 8');
960 setsize(_nade, '-16 -16 -16', '16 16 16');
961 set_movetype(_nade, MOVETYPE_BOUNCE);
963 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
964 if (trace_startsolid)
965 setorigin(_nade, e.origin);
967 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
968 _nade.velocity = '0 0 100';
969 else if(autocvar_g_nades_nade_newton_style == 1)
970 _nade.velocity = e.velocity + _velocity;
971 else if(autocvar_g_nades_nade_newton_style == 2)
972 _nade.velocity = _velocity;
974 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
979 settouch(_nade, nade_touch);
980 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
981 SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
982 _nade.max_health = _nade.health;
983 _nade.takedamage = DAMAGE_AIM;
984 _nade.event_damage = nade_damage;
985 setcefc(_nade, func_null);
986 _nade.exteriormodeltoclient = NULL;
987 _nade.traileffectnum = 0;
988 _nade.teleportable = true;
989 _nade.pushable = true;
991 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
992 _nade.damagedbycontents = true;
993 IL_PUSH(g_damagedbycontents, _nade);
994 _nade.angles = vectoangles(_nade.velocity);
995 _nade.flags = FL_PROJECTILE;
996 IL_PUSH(g_projectiles, _nade);
997 IL_PUSH(g_bot_dodge, _nade);
998 _nade.projectiledeathtype = DEATH_NADE.m_id;
999 _nade.toss_time = time;
1000 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1002 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1003 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1005 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1011 setthink(_nade, nade_boom);
1012 _nade.nextthink = _time;
1015 e.nade_refire = time + autocvar_g_nades_nade_refire;
1016 STAT(NADE_TIMER, e) = 0;
1019 void nades_GiveBonus(entity player, float score)
1021 if (autocvar_g_nades)
1022 if (autocvar_g_nades_bonus)
1023 if (IS_REAL_CLIENT(player))
1024 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1025 if (STAT(FROZEN, player) == 0)
1026 if (!IS_DEAD(player))
1028 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1029 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1031 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1033 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1034 play2(player, SND(KH_ALARM));
1035 STAT(NADE_BONUS, player)++;
1036 STAT(NADE_BONUS_SCORE, player) -= 1;
1041 /** Remove all bonus nades from a player */
1042 void nades_RemoveBonus(entity player)
1044 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1047 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1049 entity player = M_ARGV(0, entity);
1051 nades_RemoveBonus(player);
1054 bool nade_customize(entity this, entity client)
1056 //if(IS_SPEC(client)) { return false; }
1057 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1059 // somewhat hide the model, but keep the glow
1061 if(this.traileffectnum)
1062 this.traileffectnum = 0;
1067 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1068 if(!this.traileffectnum)
1069 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
1076 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1078 entity n = new(nade), fn = new(fake_nade);
1080 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1081 n.pokenade_type = pntype;
1083 if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1084 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1086 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1088 setmodel(n, MDL_PROJECTILE_NADE);
1089 //setattachment(n, player, "bip01 l hand");
1090 n.exteriormodeltoclient = player;
1091 setcefc(n, nade_customize);
1092 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1093 n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1094 n.realowner = nowner;
1095 n.colormap = player.colormap;
1096 n.glowmod = player.glowmod;
1097 n.wait = time + max(0, ntime);
1098 n.nade_time_primed = time;
1099 setthink(n, nade_beep);
1100 n.nextthink = max(n.wait - 3, time);
1101 n.projectiledeathtype = DEATH_NADE.m_id;
1102 n.weaponentity_fld = weaponentity;
1103 n.nade_lifetime = ntime;
1104 n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1106 setmodel(fn, MDL_NADE_VIEW);
1107 setattachment(fn, player.(weaponentity), "");
1108 fn.realowner = fn.owner = player;
1109 fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1110 fn.colormap = player.colormap;
1111 fn.glowmod = player.glowmod;
1112 setthink(fn, SUB_Remove);
1113 fn.nextthink = n.wait;
1114 fn.weaponentity_fld = weaponentity;
1115 fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1118 player.fake_nade = fn;
1121 void nade_prime(entity this)
1123 if(autocvar_g_nades_bonus_only)
1124 if(!STAT(NADE_BONUS, this))
1125 return; // only allow bonus nades
1131 delete(this.fake_nade);
1134 string pntype = this.pokenade_type;
1136 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1137 ntype = STAT(NADE_BONUS_TYPE, this);
1138 else if (STAT(NADE_BONUS, this) >= 1)
1140 ntype = STAT(NADE_BONUS_TYPE, this);
1141 pntype = this.pokenade_type;
1142 STAT(NADE_BONUS, this) -= 1;
1146 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1147 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1150 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1153 bool CanThrowNade(entity this)
1161 if (!autocvar_g_nades)
1162 return false; // allow turning them off mid match
1164 if(forbidWeaponUse(this))
1167 if (!IS_PLAYER(this))
1173 .bool nade_altbutton;
1175 void nades_CheckThrow(entity this)
1177 if(!CanThrowNade(this))
1180 entity held_nade = this.nade;
1183 this.nade_altbutton = true;
1184 if(time > this.nade_refire)
1186 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1188 this.nade_refire = time + autocvar_g_nades_nade_refire;
1193 this.nade_altbutton = false;
1194 if (time >= held_nade.nade_time_primed + 1) {
1195 makevectors(this.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.75 + v_up * 0.2 + v_right * 0.05);
1200 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1201 toss_nade(this, true, dir * _force, 0);
1206 void nades_Clear(entity player)
1209 delete(player.nade);
1210 if(player.fake_nade)
1211 delete(player.fake_nade);
1213 player.nade = player.fake_nade = NULL;
1214 STAT(NADE_TIMER, player) = 0;
1217 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1219 entity player = M_ARGV(0, entity);
1222 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1225 CLASS(NadeOffhand, OffhandWeapon)
1226 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1228 entity held_nade = player.nade;
1230 if (!CanThrowNade(player)) return;
1231 if (!(time > player.nade_refire)) return;
1235 held_nade = player.nade;
1237 } else if (time >= held_nade.nade_time_primed + 1) {
1239 makevectors(player.v_angle);
1240 float _force = time - held_nade.nade_time_primed;
1241 _force /= autocvar_g_nades_nade_lifetime;
1242 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1243 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1244 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1245 toss_nade(player, false, dir * _force, 0);
1249 ENDCLASS(NadeOffhand)
1250 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1252 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1254 entity player = M_ARGV(0, entity);
1256 if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1257 nades_CheckThrow(player);
1262 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1264 entity player = M_ARGV(0, entity);
1266 if (!IS_PLAYER(player)) { return; }
1268 if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1270 entity held_nade = player.nade;
1273 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1274 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1275 makevectors(player.angles);
1276 held_nade.velocity = player.velocity;
1277 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1278 held_nade.angles_y = player.angles.y;
1280 if (time + 0.1 >= held_nade.wait)
1281 toss_nade(player, false, '0 0 0', time + 0.05);
1284 if(IS_PLAYER(player))
1286 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1289 float key_count = 0;
1290 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1293 if(GameRules_scoring_is_vip(player))
1294 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1296 time_score = autocvar_g_nades_bonus_score_time;
1299 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1301 if(autocvar_g_nades_bonus_client_select)
1303 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1304 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1308 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1309 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1312 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1314 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1315 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1319 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1322 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1324 STAT(VEIL_ORB, player) = 0;
1326 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1328 player.alpha = player.nade_veil_prevalpha;
1334 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1336 else if(STAT(FROZEN, player) == 3)
1338 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1340 FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
1341 if(!IS_DEAD(it) && STAT(FROZEN, it) == 0 && SAME_TEAM(it, player))
1342 if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1352 if(n > 0 && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
1354 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1355 SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1357 if(STAT(REVIVE_PROGRESS, player) >= 1)
1361 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1362 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1365 FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
1366 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1367 it.reviving = false;
1372 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1374 entity player = M_ARGV(0, entity);
1375 // these automatically reset, no need to worry
1377 if(STAT(ENTRAP_ORB, player) > time)
1378 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1381 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1383 entity mon = M_ARGV(0, entity);
1385 if (STAT(ENTRAP_ORB, mon) > time)
1387 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1388 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1391 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1393 mon.alpha = mon.nade_veil_prevalpha;
1394 STAT(VEIL_ORB, mon) = 0;
1398 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1400 entity player = M_ARGV(0, entity);
1402 if(autocvar_g_nades_spawn)
1403 player.nade_refire = time + autocvar_g_spawnshieldtime;
1405 player.nade_refire = time + autocvar_g_nades_nade_refire;
1407 if(autocvar_g_nades_bonus_client_select)
1408 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1410 STAT(NADE_TIMER, player) = 0;
1412 if (!player.offhand) player.offhand = OFFHAND_NADE;
1414 if(player.nade_spawnloc)
1416 setorigin(player, player.nade_spawnloc.origin);
1417 player.nade_spawnloc.cnt -= 1;
1419 if(player.nade_spawnloc.cnt <= 0)
1421 delete(player.nade_spawnloc);
1422 player.nade_spawnloc = NULL;
1427 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1429 entity frag_attacker = M_ARGV(1, entity);
1430 entity frag_target = M_ARGV(2, entity);
1432 if(frag_target.nade)
1433 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1434 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1436 if(IS_PLAYER(frag_attacker))
1438 float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
1440 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1441 nades_RemoveBonus(frag_attacker);
1442 else if(GameRules_scoring_is_vip(frag_target))
1443 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1444 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1446 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1447 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1448 switch(CS(frag_attacker).killcount)
1451 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1456 nades_GiveBonus(frag_attacker, killcount_bonus);
1459 nades_RemoveBonus(frag_target);
1462 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1464 entity frag_inflictor = M_ARGV(0, entity);
1465 entity frag_attacker = M_ARGV(1, entity);
1466 entity frag_target = M_ARGV(2, entity);
1467 float frag_deathtype = M_ARGV(3, float);
1469 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1470 if(time - frag_inflictor.toss_time <= 0.1)
1472 Unfreeze(frag_target);
1473 SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
1474 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1475 M_ARGV(4, float) = 0;
1476 M_ARGV(6, vector) = '0 0 0';
1477 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1478 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1482 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1484 entity frag_target = M_ARGV(0, entity);
1485 entity frag_attacker = M_ARGV(1, entity);
1487 if(IS_PLAYER(frag_attacker))
1488 if(DIFF_TEAM(frag_attacker, frag_target))
1489 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1490 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1493 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1495 entity frag_target = M_ARGV(0, entity);
1497 if(frag_target.nade)
1498 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1501 void nades_RemovePlayer(entity this)
1504 nades_RemoveBonus(this);
1507 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1508 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1509 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1511 FOREACH_CLIENT(IS_PLAYER(it),
1513 nades_RemovePlayer(it);
1517 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1519 entity spectatee = M_ARGV(0, entity);
1520 entity client = M_ARGV(1, entity);
1522 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1523 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1524 client.pokenade_type = spectatee.pokenade_type;
1525 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1526 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1527 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1528 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1529 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1530 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1531 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1532 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1535 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1536 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1538 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1540 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1543 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1545 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");