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>
162 .float nade_time_primed;
163 .float nade_lifetime;
165 .entity nade_spawnloc;
168 void nade_timer_think(entity this)
170 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
171 this.nextthink = time;
172 if(!this.owner || wasfreed(this.owner))
176 void nade_burn_spawn(entity _nade)
178 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
181 void nade_spawn(entity _nade)
183 entity timer = new(nade_timer);
184 setmodel(timer, MDL_NADE_TIMER);
185 setattachment(timer, _nade, "");
186 timer.colormap = _nade.colormap;
187 timer.glowmod = _nade.glowmod;
188 setthink(timer, nade_timer_think);
189 timer.nextthink = time;
190 timer.wait = _nade.wait;
194 _nade.effects |= EF_LOWPRECISION;
196 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
199 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
208 RandomSelection_Init();
209 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
210 if(e.takedamage == DAMAGE_AIM)
211 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
212 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
216 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
217 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
218 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
219 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
222 e.fireball_impactvec = p;
223 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
226 if(RandomSelection_chosen_ent)
228 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
229 d = damage + (edgedamage - damage) * (d / dist);
230 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
231 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
232 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
237 void napalm_ball_think(entity this)
239 if(round_handler_IsActive())
240 if(!round_handler_IsRoundStarted())
246 if(time > this.pushltime)
252 vector midpoint = ((this.absmin + this.absmax) * 0.5);
253 if(pointcontents(midpoint) == CONTENT_WATER)
255 this.velocity = this.velocity * 0.5;
257 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
258 { this.velocity_z = 200; }
261 this.angles = vectoangles(this.velocity);
263 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
264 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
266 this.nextthink = time + 0.1;
270 void nade_napalm_ball(entity this)
275 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
278 proj.owner = this.owner;
279 proj.realowner = this.realowner;
280 proj.team = this.owner.team;
281 proj.bot_dodge = true;
282 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
283 set_movetype(proj, MOVETYPE_BOUNCE);
284 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
285 PROJECTILE_MAKETRIGGER(proj);
286 setmodel(proj, MDL_Null);
287 proj.scale = 1;//0.5;
288 setsize(proj, '-4 -4 -4', '4 4 4');
289 setorigin(proj, this.origin);
290 setthink(proj, napalm_ball_think);
291 proj.nextthink = time;
292 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
293 proj.effects = EF_LOWPRECISION | EF_FLAME;
295 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
296 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
297 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
298 proj.velocity = kick;
300 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
302 proj.angles = vectoangles(proj.velocity);
303 proj.flags = FL_PROJECTILE;
304 IL_PUSH(g_projectiles, proj);
305 IL_PUSH(g_bot_dodge, proj);
306 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
308 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
312 void napalm_fountain_think(entity this)
315 if(round_handler_IsActive())
316 if(!round_handler_IsRoundStarted())
322 if(time >= this.ltime)
328 vector midpoint = ((this.absmin + this.absmax) * 0.5);
329 if(pointcontents(midpoint) == CONTENT_WATER)
331 this.velocity = this.velocity * 0.5;
333 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
334 { this.velocity_z = 200; }
336 UpdateCSQCProjectile(this);
339 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
340 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
342 this.nextthink = time + 0.1;
343 if(time >= this.nade_special_time)
345 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
346 nade_napalm_ball(this);
350 void nade_napalm_boom(entity this)
354 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
355 nade_napalm_ball(this);
359 fountain.owner = this.owner;
360 fountain.realowner = this.realowner;
361 fountain.origin = this.origin;
362 fountain.flags = FL_PROJECTILE;
363 IL_PUSH(g_projectiles, fountain);
364 IL_PUSH(g_bot_dodge, fountain);
365 setorigin(fountain, fountain.origin);
366 setthink(fountain, napalm_fountain_think);
367 fountain.nextthink = time;
368 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
369 fountain.pushltime = fountain.ltime;
370 fountain.team = this.team;
371 set_movetype(fountain, MOVETYPE_TOSS);
372 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
373 fountain.bot_dodge = true;
374 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
375 fountain.nade_special_time = time;
376 setsize(fountain, '-16 -16 -16', '16 16 16');
377 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
380 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
382 frost_target.frozen_by = freezefield.realowner;
383 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
384 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
386 Drop_Special_Items(frost_target);
389 void nade_ice_think(entity this)
391 if(round_handler_IsActive())
392 if(!round_handler_IsRoundStarted())
398 if(time >= this.ltime)
400 if ( autocvar_g_nades_ice_explode )
402 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
403 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
404 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
406 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
407 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
408 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
409 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
416 this.nextthink = time+0.1;
421 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
423 randomw = random()*M_PI*2;
425 randomp.x = randomr*cos(randomw);
426 randomp.y = randomr*sin(randomw);
428 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
430 if(time >= this.nade_special_time)
432 this.nade_special_time = time+0.7;
434 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
435 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
439 float current_freeze_time = this.ltime - time - 0.1;
441 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0,
443 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
444 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
445 if(!STAT(FROZEN, it))
446 nade_ice_freeze(this, it, current_freeze_time);
450 void nade_ice_boom(entity this)
454 fountain.owner = this.owner;
455 fountain.realowner = this.realowner;
456 fountain.origin = this.origin;
457 setorigin(fountain, fountain.origin);
458 setthink(fountain, nade_ice_think);
459 fountain.nextthink = time;
460 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
461 fountain.pushltime = fountain.wait = fountain.ltime;
462 fountain.team = this.team;
463 set_movetype(fountain, MOVETYPE_TOSS);
464 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
465 fountain.bot_dodge = false;
466 setsize(fountain, '-16 -16 -16', '16 16 16');
467 fountain.nade_special_time = time+0.3;
468 fountain.angles = this.angles;
470 if ( autocvar_g_nades_ice_explode )
472 setmodel(fountain, MDL_PROJECTILE_GRENADE);
473 entity timer = new(nade_timer);
474 setmodel(timer, MDL_NADE_TIMER);
475 setattachment(timer, fountain, "");
476 timer.colormap = this.colormap;
477 timer.glowmod = this.glowmod;
478 setthink(timer, nade_timer_think);
479 timer.nextthink = time;
480 timer.wait = fountain.ltime;
481 timer.owner = fountain;
485 setmodel(fountain, MDL_Null);
488 void nade_translocate_boom(entity this)
490 if(this.realowner.vehicle)
493 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
494 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
495 locout = trace_endpos;
497 makevectors(this.realowner.angles);
499 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
501 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
504 void nade_spawn_boom(entity this)
506 entity spawnloc = spawn();
507 setorigin(spawnloc, this.origin);
508 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
509 set_movetype(spawnloc, MOVETYPE_NONE);
510 spawnloc.solid = SOLID_NOT;
511 spawnloc.drawonlytoclient = this.realowner;
512 spawnloc.effects = EF_STARDUST;
513 spawnloc.cnt = autocvar_g_nades_spawn_count;
515 if(this.realowner.nade_spawnloc)
517 delete(this.realowner.nade_spawnloc);
518 this.realowner.nade_spawnloc = NULL;
521 this.realowner.nade_spawnloc = spawnloc;
524 void nades_orb_think(entity this)
526 if(time >= this.ltime)
532 this.nextthink = time;
534 if(time >= this.nade_special_time)
536 this.nade_special_time = time+0.25;
537 this.nade_show_particles = 1;
540 this.nade_show_particles = 0;
543 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
545 // NOTE: this function merely places an orb
546 // you must add a custom touch function to the returned entity if desired
547 // also set .colormod if you wish to have it colorized
548 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
550 orb.realowner = realown;
553 orb.orb_lifetime = orb_ltime; // required for timers
554 orb.ltime = time + orb.orb_lifetime;
555 orb.bot_dodge = false;
556 orb.team = realown.team;
557 orb.solid = SOLID_TRIGGER;
559 setmodel(orb, MDL_NADE_ORB);
561 orb.orb_radius = orb_rad; // required for fading
562 vector size = '1 1 1' * orb.orb_radius / 2;
563 setsize(orb, -size, size);
565 Net_LinkEntity(orb, true, 0, orb_send);
568 setthink(orb, nades_orb_think);
569 orb.nextthink = time;
574 void nade_entrap_touch(entity this, entity toucher)
576 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
578 if (!isPushable(toucher))
581 float pushdeltatime = time - toucher.lastpushtime;
582 if (pushdeltatime > 0.15) pushdeltatime = 0;
583 toucher.lastpushtime = time;
584 if(!pushdeltatime) return;
586 // div0: ticrate independent, 1 = identity (not 20)
587 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
590 UpdateCSQCProjectile(toucher);
594 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
596 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
597 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
599 float tint_alpha = 0.75;
600 if(SAME_TEAM(toucher, this.realowner))
602 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
606 void nade_entrap_boom(entity this)
608 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
610 settouch(orb, nade_entrap_touch);
611 orb.colormod = NADE_TYPE_ENTRAP.m_color;
614 void nade_heal_touch(entity this, entity toucher)
618 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
619 if(!IS_DEAD(toucher))
620 if(!STAT(FROZEN, toucher))
622 health_factor = autocvar_g_nades_heal_rate*frametime/2;
623 if ( toucher != this.realowner )
625 if ( SAME_TEAM(toucher,this) )
626 health_factor *= autocvar_g_nades_heal_friend;
628 health_factor *= autocvar_g_nades_heal_foe;
630 if ( health_factor > 0 )
632 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
633 float hp = GetResource(toucher, RES_HEALTH);
636 if (this.nade_show_particles)
638 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
640 GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
643 else if ( health_factor < 0 )
645 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
650 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
652 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
653 STAT(HEALING_ORB, show_red) = time+0.1;
654 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
658 void nade_heal_boom(entity this)
660 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
662 settouch(orb, nade_heal_touch);
663 orb.colormod = '1 0 0';
666 void nade_monster_boom(entity this)
668 entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
670 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
671 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
672 e.monster_skill = MONSTER_SKILL_INSANE;
675 void nade_veil_touch(entity this, entity toucher)
677 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
679 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
681 float tint_alpha = 0.75;
682 if(SAME_TEAM(toucher, this.realowner))
685 if(!STAT(VEIL_ORB, show_tint))
687 toucher.nade_veil_prevalpha = toucher.alpha;
691 STAT(VEIL_ORB, show_tint) = time + 0.1;
692 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
696 void nade_veil_boom(entity this)
698 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
700 settouch(orb, nade_veil_touch);
701 orb.colormod = NADE_TYPE_VEIL.m_color;
704 void nade_boom(entity this)
707 bool nade_blast = true;
709 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
711 case NADE_TYPE_NAPALM:
712 nade_blast = autocvar_g_nades_napalm_blast;
713 expef = EFFECT_EXPLOSION_MEDIUM;
717 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
719 case NADE_TYPE_TRANSLOCATE:
722 case NADE_TYPE_MONSTER:
723 case NADE_TYPE_SPAWN:
725 switch(this.realowner.team)
727 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
728 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
729 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
730 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
731 default: expef = EFFECT_SPAWN_NEUTRAL; break;
736 expef = EFFECT_SPAWN_RED;
739 case NADE_TYPE_ENTRAP:
741 expef = EFFECT_SPAWN_YELLOW;
746 expef = EFFECT_SPAWN_NEUTRAL;
750 case NADE_TYPE_NORMAL:
751 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
756 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
758 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
759 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
761 this.event_damage = func_null; // prevent somehow calling damage in the next call
765 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
766 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
767 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);
771 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
773 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
774 case NADE_TYPE_ICE: nade_ice_boom(this); break;
775 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
776 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
777 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
778 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
779 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
780 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
783 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
791 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
792 void nade_pickup(entity this, entity thenade)
794 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
796 // set refire so player can't even
797 this.nade_refire = time + autocvar_g_nades_nade_refire;
798 STAT(NADE_TIMER, this) = 0;
801 this.nade.nade_time_primed = thenade.nade_time_primed;
804 bool CanThrowNade(entity this);
805 void nade_touch(entity this, entity toucher)
808 UpdateCSQCProjectile(this);
810 if(toucher == this.realowner)
811 return; // no this impacts
813 if(autocvar_g_nades_pickup)
814 if(time >= this.spawnshieldtime)
815 if(!toucher.nade && GetResource(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
816 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
817 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
819 nade_pickup(toucher, this);
820 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
824 /*float is_weapclip = 0;
825 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
826 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
827 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
829 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
831 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
839 PROJECTILE_TOUCH(this, toucher);
841 //setsize(this, '-2 -2 -2', '2 2 2');
842 //UpdateCSQCProjectile(this);
843 if(GetResource(this, RES_HEALTH) == this.max_health)
845 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
849 this.enemy = toucher;
853 void nade_beep(entity this)
855 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
856 setthink(this, nade_boom);
857 this.nextthink = max(this.wait, time);
860 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
862 if(ITEM_DAMAGE_NEEDKILL(deathtype))
864 this.takedamage = DAMAGE_NO;
869 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
872 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
873 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
878 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
880 force *= 0.5; // too much
883 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
886 damage = this.max_health * 0.55;
888 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
889 damage = this.max_health * 0.1;
890 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
892 if(!(deathtype & HITTYPE_SECONDARY))
893 damage = this.max_health * 1.15;
897 entity death_weapon = DEATH_WEAPONOF(deathtype);
898 if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
900 damage = this.max_health * 0.1;
904 this.velocity += force;
905 UpdateCSQCProjectile(this);
907 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
910 float hp = GetResource(this, RES_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 SetResource(this, RES_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 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
982 _nade.max_health = GetResource(_nade, RES_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))
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(NADE_BONUS));
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.viewmodelforclient = player;
1109 fn.realowner = fn.owner = player;
1110 fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1111 fn.colormap = player.colormap;
1112 fn.glowmod = player.glowmod;
1113 setthink(fn, SUB_Remove);
1114 fn.nextthink = n.wait;
1115 fn.weaponentity_fld = weaponentity;
1116 fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1119 player.fake_nade = fn;
1122 void nade_prime(entity this)
1124 if(autocvar_g_nades_bonus_only)
1125 if(!STAT(NADE_BONUS, this))
1126 return; // only allow bonus nades
1132 delete(this.fake_nade);
1135 string pntype = this.pokenade_type;
1137 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1138 ntype = STAT(NADE_BONUS_TYPE, this);
1139 else if (STAT(NADE_BONUS, this) >= 1)
1141 ntype = STAT(NADE_BONUS_TYPE, this);
1142 pntype = this.pokenade_type;
1143 STAT(NADE_BONUS, this) -= 1;
1147 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1148 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1151 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1154 bool CanThrowNade(entity this)
1162 if (!autocvar_g_nades)
1163 return false; // allow turning them off mid match
1165 if (weaponLocked(this))
1168 if (!IS_PLAYER(this))
1174 .bool nade_altbutton;
1176 void nades_CheckThrow(entity this)
1178 if(!CanThrowNade(this))
1181 entity held_nade = this.nade;
1184 this.nade_altbutton = true;
1185 if(time > this.nade_refire)
1187 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1189 this.nade_refire = time + autocvar_g_nades_nade_refire;
1194 this.nade_altbutton = false;
1195 if (time >= held_nade.nade_time_primed + 1) {
1196 makevectors(this.v_angle);
1197 float _force = time - held_nade.nade_time_primed;
1198 _force /= autocvar_g_nades_nade_lifetime;
1199 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1200 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1201 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1202 toss_nade(this, true, dir * _force, 0);
1207 void nades_Clear(entity player)
1210 delete(player.nade);
1211 if(player.fake_nade)
1212 delete(player.fake_nade);
1214 player.nade = player.fake_nade = NULL;
1215 STAT(NADE_TIMER, player) = 0;
1218 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1220 entity player = M_ARGV(0, entity);
1223 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1226 CLASS(NadeOffhand, OffhandWeapon)
1227 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1229 entity held_nade = player.nade;
1231 if (!CanThrowNade(player)) return;
1232 if (!(time > player.nade_refire)) return;
1236 held_nade = player.nade;
1238 } else if (time >= held_nade.nade_time_primed + 1) {
1240 makevectors(player.v_angle);
1241 float _force = time - held_nade.nade_time_primed;
1242 _force /= autocvar_g_nades_nade_lifetime;
1243 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1244 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1245 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1246 toss_nade(player, false, dir * _force, 0);
1250 ENDCLASS(NadeOffhand)
1251 NadeOffhand OFFHAND_NADE;
1252 REGISTER_MUTATOR(nades, autocvar_g_nades)
1256 OFFHAND_NADE = NEW(NadeOffhand);
1261 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1263 entity player = M_ARGV(0, entity);
1265 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1266 nades_CheckThrow(player);
1275 // returns true if player is reviving it
1276 #define IS_REVIVING(player, it, revive_extra_size) \
1277 (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
1278 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1280 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1282 entity player = M_ARGV(0, entity);
1284 if (!IS_PLAYER(player)) { return; }
1286 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1288 entity held_nade = player.nade;
1291 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1292 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1293 makevectors(player.angles);
1294 held_nade.velocity = player.velocity;
1295 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1296 held_nade.angles_y = player.angles.y;
1298 if (time + 0.1 >= held_nade.wait)
1299 toss_nade(player, false, '0 0 0', time + 0.05);
1302 if(IS_PLAYER(player))
1304 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1307 float key_count = 0;
1308 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1311 if(GameRules_scoring_is_vip(player))
1312 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1314 time_score = autocvar_g_nades_bonus_score_time;
1317 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1319 if(autocvar_g_nades_bonus_client_select)
1321 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1322 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1326 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1327 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1330 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1332 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1333 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1337 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1340 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1342 STAT(VEIL_ORB, player) = 0;
1344 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1346 player.alpha = player.nade_veil_prevalpha;
1352 IntrusiveList reviving_players = NULL;
1354 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1356 else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
1358 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1360 FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
1361 if (!reviving_players)
1362 reviving_players = IL_NEW();
1363 IL_PUSH(reviving_players, it);
1368 if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1370 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1371 SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1373 if(STAT(REVIVE_PROGRESS, player) >= 1)
1375 Unfreeze(player, false);
1377 entity first = IL_FIRST(reviving_players);
1378 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
1379 Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1382 IL_EACH(reviving_players, true, {
1383 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1386 if (reviving_players)
1387 IL_DELETE(reviving_players);
1390 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1392 entity player = M_ARGV(0, entity);
1393 // these automatically reset, no need to worry
1395 if(STAT(ENTRAP_ORB, player) > time)
1396 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1399 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1401 entity mon = M_ARGV(0, entity);
1403 if (STAT(ENTRAP_ORB, mon) > time)
1405 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1406 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1409 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1411 mon.alpha = mon.nade_veil_prevalpha;
1412 STAT(VEIL_ORB, mon) = 0;
1416 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1418 entity player = M_ARGV(0, entity);
1420 if(autocvar_g_nades_spawn)
1421 player.nade_refire = time + autocvar_g_spawnshieldtime;
1423 player.nade_refire = time + autocvar_g_nades_nade_refire;
1425 if(autocvar_g_nades_bonus_client_select)
1426 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1428 STAT(NADE_TIMER, player) = 0;
1430 if (!player.offhand) player.offhand = OFFHAND_NADE;
1432 if(player.nade_spawnloc)
1434 setorigin(player, player.nade_spawnloc.origin);
1435 player.nade_spawnloc.cnt -= 1;
1437 if(player.nade_spawnloc.cnt <= 0)
1439 delete(player.nade_spawnloc);
1440 player.nade_spawnloc = NULL;
1445 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1447 entity frag_attacker = M_ARGV(1, entity);
1448 entity frag_target = M_ARGV(2, entity);
1450 if(frag_target.nade)
1451 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1452 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1454 if(IS_PLAYER(frag_attacker))
1456 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)
1457 : autocvar_g_nades_bonus_score_minor);
1459 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1460 nades_RemoveBonus(frag_attacker);
1461 else if(GameRules_scoring_is_vip(frag_target))
1462 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1463 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1465 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1466 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1467 switch(CS(frag_attacker).killcount)
1470 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1475 nades_GiveBonus(frag_attacker, killcount_bonus);
1478 nades_RemoveBonus(frag_target);
1481 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1483 entity frag_inflictor = M_ARGV(0, entity);
1484 entity frag_attacker = M_ARGV(1, entity);
1485 entity frag_target = M_ARGV(2, entity);
1486 float frag_deathtype = M_ARGV(3, float);
1488 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1489 if(time - frag_inflictor.toss_time <= 0.1)
1491 Unfreeze(frag_target, false);
1492 SetResource(frag_target, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
1493 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1494 M_ARGV(4, float) = 0;
1495 M_ARGV(6, vector) = '0 0 0';
1496 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1497 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1501 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1503 entity frag_target = M_ARGV(0, entity);
1504 entity frag_attacker = M_ARGV(1, entity);
1506 if(IS_PLAYER(frag_attacker))
1507 if(DIFF_TEAM(frag_attacker, frag_target))
1508 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1509 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1512 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1514 entity frag_target = M_ARGV(0, entity);
1516 if(frag_target.nade)
1517 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1520 void nades_RemovePlayer(entity this)
1523 nades_RemoveBonus(this);
1526 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1527 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1528 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1530 FOREACH_CLIENT(IS_PLAYER(it),
1532 nades_RemovePlayer(it);
1536 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1538 entity spectatee = M_ARGV(0, entity);
1539 entity client = M_ARGV(1, entity);
1541 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1542 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1543 client.pokenade_type = spectatee.pokenade_type;
1544 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1545 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1546 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1547 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1548 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1549 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1550 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1551 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1554 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1555 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1557 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1559 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1562 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1564 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n");