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 REGISTER_MUTATOR(nades, autocvar_g_nades);
164 .float nade_time_primed;
165 .float nade_lifetime;
167 .entity nade_spawnloc;
170 void nade_timer_think(entity this)
172 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
173 this.nextthink = time;
174 if(!this.owner || wasfreed(this.owner))
178 void nade_burn_spawn(entity _nade)
180 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
183 void nade_spawn(entity _nade)
185 entity timer = new(nade_timer);
186 setmodel(timer, MDL_NADE_TIMER);
187 setattachment(timer, _nade, "");
188 timer.colormap = _nade.colormap;
189 timer.glowmod = _nade.glowmod;
190 setthink(timer, nade_timer_think);
191 timer.nextthink = time;
192 timer.wait = _nade.wait;
196 _nade.effects |= EF_LOWPRECISION;
198 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
201 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
210 RandomSelection_Init();
211 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
212 if(e.takedamage == DAMAGE_AIM)
213 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
214 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
218 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
219 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
220 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
221 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
224 e.fireball_impactvec = p;
225 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
228 if(RandomSelection_chosen_ent)
230 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
231 d = damage + (edgedamage - damage) * (d / dist);
232 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
233 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
234 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
239 void napalm_ball_think(entity this)
241 if(round_handler_IsActive())
242 if(!round_handler_IsRoundStarted())
248 if(time > this.pushltime)
254 vector midpoint = ((this.absmin + this.absmax) * 0.5);
255 if(pointcontents(midpoint) == CONTENT_WATER)
257 this.velocity = this.velocity * 0.5;
259 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
260 { this.velocity_z = 200; }
263 this.angles = vectoangles(this.velocity);
265 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
266 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
268 this.nextthink = time + 0.1;
272 void nade_napalm_ball(entity this)
277 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
280 proj.owner = this.owner;
281 proj.realowner = this.realowner;
282 proj.team = this.owner.team;
283 proj.bot_dodge = true;
284 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
285 set_movetype(proj, MOVETYPE_BOUNCE);
286 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
287 PROJECTILE_MAKETRIGGER(proj);
288 setmodel(proj, MDL_Null);
289 proj.scale = 1;//0.5;
290 setsize(proj, '-4 -4 -4', '4 4 4');
291 setorigin(proj, this.origin);
292 setthink(proj, napalm_ball_think);
293 proj.nextthink = time;
294 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
295 proj.effects = EF_LOWPRECISION | EF_FLAME;
297 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
298 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
299 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
300 proj.velocity = kick;
302 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
304 proj.angles = vectoangles(proj.velocity);
305 proj.flags = FL_PROJECTILE;
306 IL_PUSH(g_projectiles, proj);
307 IL_PUSH(g_bot_dodge, proj);
308 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
310 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
314 void napalm_fountain_think(entity this)
317 if(round_handler_IsActive())
318 if(!round_handler_IsRoundStarted())
324 if(time >= this.ltime)
330 vector midpoint = ((this.absmin + this.absmax) * 0.5);
331 if(pointcontents(midpoint) == CONTENT_WATER)
333 this.velocity = this.velocity * 0.5;
335 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
336 { this.velocity_z = 200; }
338 UpdateCSQCProjectile(this);
341 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
342 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
344 this.nextthink = time + 0.1;
345 if(time >= this.nade_special_time)
347 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
348 nade_napalm_ball(this);
352 void nade_napalm_boom(entity this)
356 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
357 nade_napalm_ball(this);
361 fountain.owner = this.owner;
362 fountain.realowner = this.realowner;
363 fountain.origin = this.origin;
364 fountain.flags = FL_PROJECTILE;
365 IL_PUSH(g_projectiles, fountain);
366 IL_PUSH(g_bot_dodge, fountain);
367 setorigin(fountain, fountain.origin);
368 setthink(fountain, napalm_fountain_think);
369 fountain.nextthink = time;
370 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
371 fountain.pushltime = fountain.ltime;
372 fountain.team = this.team;
373 set_movetype(fountain, MOVETYPE_TOSS);
374 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
375 fountain.bot_dodge = true;
376 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
377 fountain.nade_special_time = time;
378 setsize(fountain, '-16 -16 -16', '16 16 16');
379 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
382 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
384 frost_target.frozen_by = freezefield.realowner;
385 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
386 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
388 Drop_Special_Items(frost_target);
391 void nade_ice_think(entity this)
393 if(round_handler_IsActive())
394 if(!round_handler_IsRoundStarted())
400 if(time >= this.ltime)
402 if ( autocvar_g_nades_ice_explode )
404 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
405 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
406 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
408 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
409 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
410 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
411 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
418 this.nextthink = time+0.1;
423 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
425 randomw = random()*M_PI*2;
427 randomp.x = randomr*cos(randomw);
428 randomp.y = randomr*sin(randomw);
430 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
432 if(time >= this.nade_special_time)
434 this.nade_special_time = time+0.7;
436 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
437 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
441 float current_freeze_time = this.ltime - time - 0.1;
443 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,
445 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
446 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
447 if(!STAT(FROZEN, it))
448 nade_ice_freeze(this, it, current_freeze_time);
452 void nade_ice_boom(entity this)
456 fountain.owner = this.owner;
457 fountain.realowner = this.realowner;
458 fountain.origin = this.origin;
459 setorigin(fountain, fountain.origin);
460 setthink(fountain, nade_ice_think);
461 fountain.nextthink = time;
462 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
463 fountain.pushltime = fountain.wait = fountain.ltime;
464 fountain.team = this.team;
465 set_movetype(fountain, MOVETYPE_TOSS);
466 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
467 fountain.bot_dodge = false;
468 setsize(fountain, '-16 -16 -16', '16 16 16');
469 fountain.nade_special_time = time+0.3;
470 fountain.angles = this.angles;
472 if ( autocvar_g_nades_ice_explode )
474 setmodel(fountain, MDL_PROJECTILE_GRENADE);
475 entity timer = new(nade_timer);
476 setmodel(timer, MDL_NADE_TIMER);
477 setattachment(timer, fountain, "");
478 timer.colormap = this.colormap;
479 timer.glowmod = this.glowmod;
480 setthink(timer, nade_timer_think);
481 timer.nextthink = time;
482 timer.wait = fountain.ltime;
483 timer.owner = fountain;
487 setmodel(fountain, MDL_Null);
490 void nade_translocate_boom(entity this)
492 if(this.realowner.vehicle)
495 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
496 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
497 locout = trace_endpos;
499 makevectors(this.realowner.angles);
501 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
503 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
506 void nade_spawn_boom(entity this)
508 entity spawnloc = spawn();
509 setorigin(spawnloc, this.origin);
510 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
511 set_movetype(spawnloc, MOVETYPE_NONE);
512 spawnloc.solid = SOLID_NOT;
513 spawnloc.drawonlytoclient = this.realowner;
514 spawnloc.effects = EF_STARDUST;
515 spawnloc.cnt = autocvar_g_nades_spawn_count;
517 if(this.realowner.nade_spawnloc)
519 delete(this.realowner.nade_spawnloc);
520 this.realowner.nade_spawnloc = NULL;
523 this.realowner.nade_spawnloc = spawnloc;
526 void nades_orb_think(entity this)
528 if(time >= this.ltime)
534 this.nextthink = time;
536 if(time >= this.nade_special_time)
538 this.nade_special_time = time+0.25;
539 this.nade_show_particles = 1;
542 this.nade_show_particles = 0;
545 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
547 // NOTE: this function merely places an orb
548 // you must add a custom touch function to the returned entity if desired
549 // also set .colormod if you wish to have it colorized
550 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
552 orb.realowner = realown;
555 orb.orb_lifetime = orb_ltime; // required for timers
556 orb.ltime = time + orb.orb_lifetime;
557 orb.bot_dodge = false;
558 orb.team = realown.team;
559 orb.solid = SOLID_TRIGGER;
561 setmodel(orb, MDL_NADE_ORB);
563 orb.orb_radius = orb_rad; // required for fading
564 vector size = '1 1 1' * orb.orb_radius / 2;
565 setsize(orb, -size, size);
567 Net_LinkEntity(orb, true, 0, orb_send);
570 setthink(orb, nades_orb_think);
571 orb.nextthink = time;
576 void nade_entrap_touch(entity this, entity toucher)
578 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
580 if (!isPushable(toucher))
583 float pushdeltatime = time - toucher.lastpushtime;
584 if (pushdeltatime > 0.15) pushdeltatime = 0;
585 toucher.lastpushtime = time;
586 if(!pushdeltatime) return;
588 // div0: ticrate independent, 1 = identity (not 20)
589 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
592 UpdateCSQCProjectile(toucher);
596 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
598 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
599 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
601 float tint_alpha = 0.75;
602 if(SAME_TEAM(toucher, this.realowner))
604 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
608 void nade_entrap_boom(entity this)
610 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
612 settouch(orb, nade_entrap_touch);
613 orb.colormod = NADE_TYPE_ENTRAP.m_color;
616 void nade_heal_touch(entity this, entity toucher)
620 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
621 if(!IS_DEAD(toucher))
622 if(!STAT(FROZEN, toucher))
624 health_factor = autocvar_g_nades_heal_rate*frametime/2;
625 if ( toucher != this.realowner )
627 if ( SAME_TEAM(toucher,this) )
628 health_factor *= autocvar_g_nades_heal_friend;
630 health_factor *= autocvar_g_nades_heal_foe;
632 if ( health_factor > 0 )
634 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
635 float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
638 if (this.nade_show_particles)
640 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
642 GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
645 else if ( health_factor < 0 )
647 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
652 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
654 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
655 STAT(HEALING_ORB, show_red) = time+0.1;
656 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
660 void nade_heal_boom(entity this)
662 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
664 settouch(orb, nade_heal_touch);
665 orb.colormod = '1 0 0';
668 void nade_monster_boom(entity this)
670 entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
672 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
673 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
674 e.monster_skill = MONSTER_SKILL_INSANE;
677 void nade_veil_touch(entity this, entity toucher)
679 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
681 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
683 float tint_alpha = 0.75;
684 if(SAME_TEAM(toucher, this.realowner))
687 if(!STAT(VEIL_ORB, show_tint))
689 toucher.nade_veil_prevalpha = toucher.alpha;
693 STAT(VEIL_ORB, show_tint) = time + 0.1;
694 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
698 void nade_veil_boom(entity this)
700 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
702 settouch(orb, nade_veil_touch);
703 orb.colormod = NADE_TYPE_VEIL.m_color;
706 void nade_boom(entity this)
709 bool nade_blast = true;
711 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
713 case NADE_TYPE_NAPALM:
714 nade_blast = autocvar_g_nades_napalm_blast;
715 expef = EFFECT_EXPLOSION_MEDIUM;
719 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
721 case NADE_TYPE_TRANSLOCATE:
724 case NADE_TYPE_MONSTER:
725 case NADE_TYPE_SPAWN:
727 switch(this.realowner.team)
729 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
730 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
731 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
732 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
733 default: expef = EFFECT_SPAWN_NEUTRAL; break;
738 expef = EFFECT_SPAWN_RED;
741 case NADE_TYPE_ENTRAP:
743 expef = EFFECT_SPAWN_YELLOW;
748 expef = EFFECT_SPAWN_NEUTRAL;
752 case NADE_TYPE_NORMAL:
753 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
758 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
760 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
761 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
763 this.event_damage = func_null; // prevent somehow calling damage in the next call
767 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
768 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
769 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);
773 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
775 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
776 case NADE_TYPE_ICE: nade_ice_boom(this); break;
777 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
778 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
779 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
780 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
781 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
782 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
785 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
793 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
794 void nade_pickup(entity this, entity thenade)
796 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
798 // set refire so player can't even
799 this.nade_refire = time + autocvar_g_nades_nade_refire;
800 STAT(NADE_TIMER, this) = 0;
803 this.nade.nade_time_primed = thenade.nade_time_primed;
806 bool CanThrowNade(entity this);
807 void nade_touch(entity this, entity toucher)
810 UpdateCSQCProjectile(this);
812 if(toucher == this.realowner)
813 return; // no this impacts
815 if(autocvar_g_nades_pickup)
816 if(time >= this.spawnshieldtime)
817 if(!toucher.nade && GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
818 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
819 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
821 nade_pickup(toucher, this);
822 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
826 /*float is_weapclip = 0;
827 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
828 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
829 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
831 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
833 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
841 PROJECTILE_TOUCH(this, toucher);
843 //setsize(this, '-2 -2 -2', '2 2 2');
844 //UpdateCSQCProjectile(this);
845 if(GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health)
847 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
851 this.enemy = toucher;
855 void nade_beep(entity this)
857 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
858 setthink(this, nade_boom);
859 this.nextthink = max(this.wait, time);
862 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
864 if(ITEM_DAMAGE_NEEDKILL(deathtype))
866 this.takedamage = DAMAGE_NO;
871 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
874 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
875 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
880 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
882 force *= 0.5; // too much
885 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
888 damage = this.max_health * 0.55;
890 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
891 damage = this.max_health * 0.1;
892 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
894 if(deathtype & HITTYPE_SECONDARY)
896 damage = this.max_health * 0.1;
900 damage = this.max_health * 1.15;
903 this.velocity += force;
904 UpdateCSQCProjectile(this);
906 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
909 float hp = GetResourceAmount(this, RESOURCE_HEALTH);
910 if(hp == this.max_health)
912 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
913 this.nextthink = max(time + this.nade_lifetime, time);
914 setthink(this, nade_beep);
918 SetResourceAmount(this, RESOURCE_HEALTH, hp);
921 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
922 this.realowner = attacker;
925 W_PrepareExplosionByDamage(this, attacker, nade_boom);
927 nade_burn_spawn(this);
930 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
935 entity _nade = e.nade;
941 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
943 makevectors(e.v_angle);
945 // NOTE: always throw from first weapon entity?
946 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
948 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
949 + (v_right * autocvar_g_nades_throw_offset.y)
950 + (v_up * autocvar_g_nades_throw_offset.z);
952 setorigin(_nade, w_shotorg + offset);
953 //setmodel(_nade, MDL_PROJECTILE_NADE);
954 //setattachment(_nade, NULL, "");
955 PROJECTILE_MAKETRIGGER(_nade);
956 if(STAT(NADES_SMALL, e))
957 setsize(_nade, '-8 -8 -8', '8 8 8');
959 setsize(_nade, '-16 -16 -16', '16 16 16');
960 set_movetype(_nade, MOVETYPE_BOUNCE);
962 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
963 if (trace_startsolid)
964 setorigin(_nade, e.origin);
966 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
967 _nade.velocity = '0 0 100';
968 else if(autocvar_g_nades_nade_newton_style == 1)
969 _nade.velocity = e.velocity + _velocity;
970 else if(autocvar_g_nades_nade_newton_style == 2)
971 _nade.velocity = _velocity;
973 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
978 settouch(_nade, nade_touch);
979 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
980 SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
981 _nade.max_health = GetResourceAmount(_nade, RESOURCE_HEALTH);
982 _nade.takedamage = DAMAGE_AIM;
983 _nade.event_damage = nade_damage;
984 setcefc(_nade, func_null);
985 _nade.exteriormodeltoclient = NULL;
986 _nade.traileffectnum = 0;
987 _nade.teleportable = true;
988 _nade.pushable = true;
990 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
991 _nade.damagedbycontents = true;
992 IL_PUSH(g_damagedbycontents, _nade);
993 _nade.angles = vectoangles(_nade.velocity);
994 _nade.flags = FL_PROJECTILE;
995 IL_PUSH(g_projectiles, _nade);
996 IL_PUSH(g_bot_dodge, _nade);
997 _nade.projectiledeathtype = DEATH_NADE.m_id;
998 _nade.toss_time = time;
999 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1001 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1002 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1004 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1010 setthink(_nade, nade_boom);
1011 _nade.nextthink = _time;
1014 e.nade_refire = time + autocvar_g_nades_nade_refire;
1015 STAT(NADE_TIMER, e) = 0;
1018 void nades_GiveBonus(entity player, float score)
1020 if (autocvar_g_nades)
1021 if (autocvar_g_nades_bonus)
1022 if (IS_REAL_CLIENT(player))
1023 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1024 if (!STAT(FROZEN, player))
1025 if (!IS_DEAD(player))
1027 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1028 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1030 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1032 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1033 play2(player, SND(KH_ALARM));
1034 STAT(NADE_BONUS, player)++;
1035 STAT(NADE_BONUS_SCORE, player) -= 1;
1040 /** Remove all bonus nades from a player */
1041 void nades_RemoveBonus(entity player)
1043 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1046 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1048 entity player = M_ARGV(0, entity);
1050 nades_RemoveBonus(player);
1053 bool nade_customize(entity this, entity client)
1055 //if(IS_SPEC(client)) { return false; }
1056 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1058 // somewhat hide the model, but keep the glow
1060 if(this.traileffectnum)
1061 this.traileffectnum = 0;
1066 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1067 if(!this.traileffectnum)
1068 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
1075 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1077 entity n = new(nade), fn = new(fake_nade);
1079 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1080 n.pokenade_type = pntype;
1082 if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1083 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1085 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1087 setmodel(n, MDL_PROJECTILE_NADE);
1088 //setattachment(n, player, "bip01 l hand");
1089 n.exteriormodeltoclient = player;
1090 setcefc(n, nade_customize);
1091 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1092 n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1093 n.realowner = nowner;
1094 n.colormap = player.colormap;
1095 n.glowmod = player.glowmod;
1096 n.wait = time + max(0, ntime);
1097 n.nade_time_primed = time;
1098 setthink(n, nade_beep);
1099 n.nextthink = max(n.wait - 3, time);
1100 n.projectiledeathtype = DEATH_NADE.m_id;
1101 n.weaponentity_fld = weaponentity;
1102 n.nade_lifetime = ntime;
1103 n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1105 setmodel(fn, MDL_NADE_VIEW);
1106 setattachment(fn, player.(weaponentity), "");
1107 fn.realowner = fn.owner = player;
1108 fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1109 fn.colormap = player.colormap;
1110 fn.glowmod = player.glowmod;
1111 setthink(fn, SUB_Remove);
1112 fn.nextthink = n.wait;
1113 fn.weaponentity_fld = weaponentity;
1114 fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1117 player.fake_nade = fn;
1120 void nade_prime(entity this)
1122 if(autocvar_g_nades_bonus_only)
1123 if(!STAT(NADE_BONUS, this))
1124 return; // only allow bonus nades
1130 delete(this.fake_nade);
1133 string pntype = this.pokenade_type;
1135 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1136 ntype = STAT(NADE_BONUS_TYPE, this);
1137 else if (STAT(NADE_BONUS, this) >= 1)
1139 ntype = STAT(NADE_BONUS_TYPE, this);
1140 pntype = this.pokenade_type;
1141 STAT(NADE_BONUS, this) -= 1;
1145 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1146 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1149 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1152 bool CanThrowNade(entity this)
1160 if (!autocvar_g_nades)
1161 return false; // allow turning them off mid match
1163 if(forbidWeaponUse(this))
1166 if (!IS_PLAYER(this))
1172 .bool nade_altbutton;
1174 void nades_CheckThrow(entity this)
1176 if(!CanThrowNade(this))
1179 entity held_nade = this.nade;
1182 this.nade_altbutton = true;
1183 if(time > this.nade_refire)
1185 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1187 this.nade_refire = time + autocvar_g_nades_nade_refire;
1192 this.nade_altbutton = false;
1193 if (time >= held_nade.nade_time_primed + 1) {
1194 makevectors(this.v_angle);
1195 float _force = time - held_nade.nade_time_primed;
1196 _force /= autocvar_g_nades_nade_lifetime;
1197 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1198 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1199 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1200 toss_nade(this, true, dir * _force, 0);
1205 void nades_Clear(entity player)
1208 delete(player.nade);
1209 if(player.fake_nade)
1210 delete(player.fake_nade);
1212 player.nade = player.fake_nade = NULL;
1213 STAT(NADE_TIMER, player) = 0;
1216 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1218 entity player = M_ARGV(0, entity);
1221 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1224 CLASS(NadeOffhand, OffhandWeapon)
1225 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1227 entity held_nade = player.nade;
1229 if (!CanThrowNade(player)) return;
1230 if (!(time > player.nade_refire)) return;
1234 held_nade = player.nade;
1236 } else if (time >= held_nade.nade_time_primed + 1) {
1238 makevectors(player.v_angle);
1239 float _force = time - held_nade.nade_time_primed;
1240 _force /= autocvar_g_nades_nade_lifetime;
1241 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1242 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1243 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1244 toss_nade(player, false, dir * _force, 0);
1248 ENDCLASS(NadeOffhand)
1249 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1251 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1253 entity player = M_ARGV(0, entity);
1255 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1256 nades_CheckThrow(player);
1265 // returns true if player is reviving it
1266 #define IS_REVIVING(player, it, revive_extra_size) \
1267 (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
1268 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1270 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1272 entity player = M_ARGV(0, entity);
1274 if (!IS_PLAYER(player)) { return; }
1276 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1278 entity held_nade = player.nade;
1281 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1282 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1283 makevectors(player.angles);
1284 held_nade.velocity = player.velocity;
1285 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1286 held_nade.angles_y = player.angles.y;
1288 if (time + 0.1 >= held_nade.wait)
1289 toss_nade(player, false, '0 0 0', time + 0.05);
1292 if(IS_PLAYER(player))
1294 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1297 float key_count = 0;
1298 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1301 if(GameRules_scoring_is_vip(player))
1302 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1304 time_score = autocvar_g_nades_bonus_score_time;
1307 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1309 if(autocvar_g_nades_bonus_client_select)
1311 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1312 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1316 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1317 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1320 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1322 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1323 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1327 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1330 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1332 STAT(VEIL_ORB, player) = 0;
1334 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1336 player.alpha = player.nade_veil_prevalpha;
1342 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1343 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1345 else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
1348 FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
1355 if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1357 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1358 SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1360 if(STAT(REVIVE_PROGRESS, player) >= 1)
1362 Unfreeze(player, false);
1364 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1365 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1368 FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
1369 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1374 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1376 entity player = M_ARGV(0, entity);
1377 // these automatically reset, no need to worry
1379 if(STAT(ENTRAP_ORB, player) > time)
1380 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1383 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1385 entity mon = M_ARGV(0, entity);
1387 if (STAT(ENTRAP_ORB, mon) > time)
1389 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1390 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1393 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1395 mon.alpha = mon.nade_veil_prevalpha;
1396 STAT(VEIL_ORB, mon) = 0;
1400 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1402 entity player = M_ARGV(0, entity);
1404 if(autocvar_g_nades_spawn)
1405 player.nade_refire = time + autocvar_g_spawnshieldtime;
1407 player.nade_refire = time + autocvar_g_nades_nade_refire;
1409 if(autocvar_g_nades_bonus_client_select)
1410 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1412 STAT(NADE_TIMER, player) = 0;
1414 if (!player.offhand) player.offhand = OFFHAND_NADE;
1416 if(player.nade_spawnloc)
1418 setorigin(player, player.nade_spawnloc.origin);
1419 player.nade_spawnloc.cnt -= 1;
1421 if(player.nade_spawnloc.cnt <= 0)
1423 delete(player.nade_spawnloc);
1424 player.nade_spawnloc = NULL;
1429 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1431 entity frag_attacker = M_ARGV(1, entity);
1432 entity frag_target = M_ARGV(2, entity);
1434 if(frag_target.nade)
1435 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1436 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1438 if(IS_PLAYER(frag_attacker))
1440 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);
1442 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1443 nades_RemoveBonus(frag_attacker);
1444 else if(GameRules_scoring_is_vip(frag_target))
1445 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1446 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1448 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1449 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1450 switch(CS(frag_attacker).killcount)
1453 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1458 nades_GiveBonus(frag_attacker, killcount_bonus);
1461 nades_RemoveBonus(frag_target);
1464 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1466 entity frag_inflictor = M_ARGV(0, entity);
1467 entity frag_attacker = M_ARGV(1, entity);
1468 entity frag_target = M_ARGV(2, entity);
1469 float frag_deathtype = M_ARGV(3, float);
1471 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1472 if(time - frag_inflictor.toss_time <= 0.1)
1474 Unfreeze(frag_target, false);
1475 SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
1476 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1477 M_ARGV(4, float) = 0;
1478 M_ARGV(6, vector) = '0 0 0';
1479 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1480 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1484 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1486 entity frag_target = M_ARGV(0, entity);
1487 entity frag_attacker = M_ARGV(1, entity);
1489 if(IS_PLAYER(frag_attacker))
1490 if(DIFF_TEAM(frag_attacker, frag_target))
1491 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1492 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1495 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1497 entity frag_target = M_ARGV(0, entity);
1499 if(frag_target.nade)
1500 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1503 void nades_RemovePlayer(entity this)
1506 nades_RemoveBonus(this);
1509 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1510 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1511 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1513 FOREACH_CLIENT(IS_PLAYER(it),
1515 nades_RemovePlayer(it);
1519 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1521 entity spectatee = M_ARGV(0, entity);
1522 entity client = M_ARGV(1, entity);
1524 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1525 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1526 client.pokenade_type = spectatee.pokenade_type;
1527 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1528 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1529 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1530 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1531 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1532 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1533 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1534 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1537 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1538 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1540 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1542 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1545 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1547 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");