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 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
14 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
16 entity Nade_TrailEffect(int proj, int nade_team)
20 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
21 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
24 FOREACH(Nades, true, {
25 for (int j = 0; j < 2; j++)
27 if (it.m_projectile[j] == proj)
29 string trail = it.m_trail[j].eent_eff_name;
30 if (trail) return it.m_trail[j];
41 REGISTER_MUTATOR(cl_nades, true);
42 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
44 // TODO: make a common orb state!
45 if (STAT(HEALING_ORB) > time)
47 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
48 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
51 if (STAT(ENTRAP_ORB) > time)
53 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
54 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
57 if (STAT(VEIL_ORB) > time)
59 M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color;
60 M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA);
65 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
67 entity proj = M_ARGV(0, entity);
69 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
72 proj.traileffect = EFFECT_FIREBALL.m_id;
75 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
77 setmodel(proj, MDL_PROJECTILE_NADE);
78 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
79 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
83 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
85 entity proj = M_ARGV(0, entity);
87 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
89 loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
90 proj.mins = '-16 -16 -16';
91 proj.maxs = '16 16 16';
94 entity nade_type = Nade_FromProjectile(proj.cnt);
95 if (nade_type == NADE_TYPE_Null) return;
98 proj.mins = '-8 -8 -8';
103 proj.mins = '-16 -16 -16';
104 proj.maxs = '16 16 16';
106 proj.colormod = nade_type.m_color;
107 set_movetype(proj, MOVETYPE_BOUNCE);
108 settouch(proj, func_null);
110 proj.avelocity = randomvec() * 720;
111 proj.alphamod = nade_type.m_alpha;
113 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
114 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
116 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
118 bool Projectile_isnade(int p)
120 return Nade_FromProjectile(p) != NADE_TYPE_Null;
122 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
124 float bonusNades = STAT(NADE_BONUS);
125 float bonusProgress = STAT(NADE_BONUS_SCORE);
126 float bonusType = STAT(NADE_BONUS_TYPE);
127 Nade def = Nades_from(bonusType);
128 vector nadeColor = def.m_color;
129 string nadeIcon = def.m_icon;
131 vector iconPos, textPos;
133 if(autocvar_hud_panel_ammo_iconalign)
135 iconPos = myPos + eX * 2 * mySize.y;
141 textPos = myPos + eX * mySize.y;
144 if(bonusNades > 0 || bonusProgress > 0)
146 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
148 if(autocvar_hud_panel_ammo_text)
149 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
152 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
154 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
161 #include <common/gamemodes/_mod.qh>
162 #include <common/monsters/sv_spawn.qh>
163 #include <common/monsters/sv_monsters.qh>
165 REGISTER_MUTATOR(nades, autocvar_g_nades);
167 .float nade_time_primed;
168 .float nade_lifetime;
170 .entity nade_spawnloc;
173 void nade_timer_think(entity this)
175 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
176 this.nextthink = time;
177 if(!this.owner || wasfreed(this.owner))
181 void nade_burn_spawn(entity _nade)
183 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
186 void nade_spawn(entity _nade)
188 entity timer = new(nade_timer);
189 setmodel(timer, MDL_NADE_TIMER);
190 setattachment(timer, _nade, "");
191 timer.colormap = _nade.colormap;
192 timer.glowmod = _nade.glowmod;
193 setthink(timer, nade_timer_think);
194 timer.nextthink = time;
195 timer.wait = _nade.wait;
199 _nade.effects |= EF_LOWPRECISION;
201 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
204 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
213 RandomSelection_Init();
214 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
215 if(e.takedamage == DAMAGE_AIM)
216 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
217 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
221 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
222 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
223 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
224 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
227 e.fireball_impactvec = p;
228 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
231 if(RandomSelection_chosen_ent)
233 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
234 d = damage + (edgedamage - damage) * (d / dist);
235 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
236 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
237 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
242 void napalm_ball_think(entity this)
244 if(round_handler_IsActive())
245 if(!round_handler_IsRoundStarted())
251 if(time > this.pushltime)
257 vector midpoint = ((this.absmin + this.absmax) * 0.5);
258 if(pointcontents(midpoint) == CONTENT_WATER)
260 this.velocity = this.velocity * 0.5;
262 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
263 { this.velocity_z = 200; }
266 this.angles = vectoangles(this.velocity);
268 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
269 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
271 this.nextthink = time + 0.1;
275 void nade_napalm_ball(entity this)
280 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
283 proj.owner = this.owner;
284 proj.realowner = this.realowner;
285 proj.team = this.owner.team;
286 proj.bot_dodge = true;
287 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
288 set_movetype(proj, MOVETYPE_BOUNCE);
289 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
290 PROJECTILE_MAKETRIGGER(proj);
291 setmodel(proj, MDL_Null);
292 proj.scale = 1;//0.5;
293 setsize(proj, '-4 -4 -4', '4 4 4');
294 setorigin(proj, this.origin);
295 setthink(proj, napalm_ball_think);
296 proj.nextthink = time;
297 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
298 proj.effects = EF_LOWPRECISION | EF_FLAME;
300 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
301 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
302 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
303 proj.velocity = kick;
305 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
307 proj.angles = vectoangles(proj.velocity);
308 proj.flags = FL_PROJECTILE;
309 IL_PUSH(g_projectiles, proj);
310 IL_PUSH(g_bot_dodge, proj);
311 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
313 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
317 void napalm_fountain_think(entity this)
320 if(round_handler_IsActive())
321 if(!round_handler_IsRoundStarted())
327 if(time >= this.ltime)
333 vector midpoint = ((this.absmin + this.absmax) * 0.5);
334 if(pointcontents(midpoint) == CONTENT_WATER)
336 this.velocity = this.velocity * 0.5;
338 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
339 { this.velocity_z = 200; }
341 UpdateCSQCProjectile(this);
344 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
345 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
347 this.nextthink = time + 0.1;
348 if(time >= this.nade_special_time)
350 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
351 nade_napalm_ball(this);
355 void nade_napalm_boom(entity this)
359 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
360 nade_napalm_ball(this);
364 fountain.owner = this.owner;
365 fountain.realowner = this.realowner;
366 fountain.origin = this.origin;
367 fountain.flags = FL_PROJECTILE;
368 IL_PUSH(g_projectiles, fountain);
369 IL_PUSH(g_bot_dodge, fountain);
370 setorigin(fountain, fountain.origin);
371 setthink(fountain, napalm_fountain_think);
372 fountain.nextthink = time;
373 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
374 fountain.pushltime = fountain.ltime;
375 fountain.team = this.team;
376 set_movetype(fountain, MOVETYPE_TOSS);
377 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
378 fountain.bot_dodge = true;
379 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
380 fountain.nade_special_time = time;
381 setsize(fountain, '-16 -16 -16', '16 16 16');
382 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
385 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
387 frost_target.frozen_by = freezefield.realowner;
388 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
389 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
391 Drop_Special_Items(frost_target);
394 void nade_ice_think(entity this)
396 if(round_handler_IsActive())
397 if(!round_handler_IsRoundStarted())
403 if(time >= this.ltime)
405 if ( autocvar_g_nades_ice_explode )
407 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
408 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
409 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
411 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
412 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
413 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
414 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
421 this.nextthink = time+0.1;
426 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
428 randomw = random()*M_PI*2;
430 randomp.x = randomr*cos(randomw);
431 randomp.y = randomr*sin(randomw);
433 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
435 if(time >= this.nade_special_time)
437 this.nade_special_time = time+0.7;
439 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
440 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
444 float current_freeze_time = this.ltime - time - 0.1;
446 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,
448 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
449 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
450 if(!STAT(FROZEN, it))
451 nade_ice_freeze(this, it, current_freeze_time);
455 void nade_ice_boom(entity this)
459 fountain.owner = this.owner;
460 fountain.realowner = this.realowner;
461 fountain.origin = this.origin;
462 setorigin(fountain, fountain.origin);
463 setthink(fountain, nade_ice_think);
464 fountain.nextthink = time;
465 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
466 fountain.pushltime = fountain.wait = fountain.ltime;
467 fountain.team = this.team;
468 set_movetype(fountain, MOVETYPE_TOSS);
469 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
470 fountain.bot_dodge = false;
471 setsize(fountain, '-16 -16 -16', '16 16 16');
472 fountain.nade_special_time = time+0.3;
473 fountain.angles = this.angles;
475 if ( autocvar_g_nades_ice_explode )
477 setmodel(fountain, MDL_PROJECTILE_GRENADE);
478 entity timer = new(nade_timer);
479 setmodel(timer, MDL_NADE_TIMER);
480 setattachment(timer, fountain, "");
481 timer.colormap = this.colormap;
482 timer.glowmod = this.glowmod;
483 setthink(timer, nade_timer_think);
484 timer.nextthink = time;
485 timer.wait = fountain.ltime;
486 timer.owner = fountain;
490 setmodel(fountain, MDL_Null);
493 void nade_translocate_boom(entity this)
495 if(this.realowner.vehicle)
498 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
499 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
500 locout = trace_endpos;
502 makevectors(this.realowner.angles);
504 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
506 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
509 void nade_spawn_boom(entity this)
511 entity spawnloc = spawn();
512 setorigin(spawnloc, this.origin);
513 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
514 set_movetype(spawnloc, MOVETYPE_NONE);
515 spawnloc.solid = SOLID_NOT;
516 spawnloc.drawonlytoclient = this.realowner;
517 spawnloc.effects = EF_STARDUST;
518 spawnloc.cnt = autocvar_g_nades_spawn_count;
520 if(this.realowner.nade_spawnloc)
522 delete(this.realowner.nade_spawnloc);
523 this.realowner.nade_spawnloc = NULL;
526 this.realowner.nade_spawnloc = spawnloc;
529 void nades_orb_think(entity this)
531 if(time >= this.ltime)
537 this.nextthink = time;
539 if(time >= this.nade_special_time)
541 this.nade_special_time = time+0.25;
542 this.nade_show_particles = 1;
545 this.nade_show_particles = 0;
548 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
550 // NOTE: this function merely places an orb
551 // you must add a custom touch function to the returned entity if desired
552 // also set .colormod if you wish to have it colorized
553 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
555 orb.realowner = realown;
558 orb.orb_lifetime = orb_ltime; // required for timers
559 orb.ltime = time + orb.orb_lifetime;
560 orb.bot_dodge = false;
561 orb.team = realown.team;
562 orb.solid = SOLID_TRIGGER;
564 setmodel(orb, MDL_NADE_ORB);
566 orb.orb_radius = orb_rad; // required for fading
567 vector size = '1 1 1' * orb.orb_radius / 2;
568 setsize(orb, -size, size);
570 Net_LinkEntity(orb, true, 0, orb_send);
573 setthink(orb, nades_orb_think);
574 orb.nextthink = time;
579 void nade_entrap_touch(entity this, entity toucher)
581 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
583 if (!isPushable(toucher))
586 float pushdeltatime = time - toucher.lastpushtime;
587 if (pushdeltatime > 0.15) pushdeltatime = 0;
588 toucher.lastpushtime = time;
589 if(!pushdeltatime) return;
591 // div0: ticrate independent, 1 = identity (not 20)
592 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
595 UpdateCSQCProjectile(toucher);
599 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
601 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
602 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
604 float tint_alpha = 0.75;
605 if(SAME_TEAM(toucher, this.realowner))
607 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
611 void nade_entrap_boom(entity this)
613 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
615 settouch(orb, nade_entrap_touch);
616 orb.colormod = NADE_TYPE_ENTRAP.m_color;
619 void nade_heal_touch(entity this, entity toucher)
623 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
624 if(!IS_DEAD(toucher))
625 if(!STAT(FROZEN, toucher))
627 health_factor = autocvar_g_nades_heal_rate*frametime/2;
628 if ( toucher != this.realowner )
630 if ( SAME_TEAM(toucher,this) )
631 health_factor *= autocvar_g_nades_heal_friend;
633 health_factor *= autocvar_g_nades_heal_foe;
635 if ( health_factor > 0 )
637 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
638 float hp = GetResource(toucher, RES_HEALTH);
641 if (this.nade_show_particles)
643 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
645 GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
648 else if ( health_factor < 0 )
650 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
655 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
657 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
658 STAT(HEALING_ORB, show_red) = time+0.1;
659 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
663 void nade_heal_boom(entity this)
665 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
667 settouch(orb, nade_heal_touch);
668 orb.colormod = '1 0 0';
671 void nade_monster_boom(entity this)
673 entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
675 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
676 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
677 e.monster_skill = MONSTER_SKILL_INSANE;
680 void nade_veil_touch(entity this, entity toucher)
682 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
684 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
686 float tint_alpha = 0.75;
687 if(SAME_TEAM(toucher, this.realowner))
690 if(!STAT(VEIL_ORB, show_tint))
692 toucher.nade_veil_prevalpha = toucher.alpha;
696 STAT(VEIL_ORB, show_tint) = time + 0.1;
697 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
701 void nade_veil_boom(entity this)
703 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
705 settouch(orb, nade_veil_touch);
706 orb.colormod = NADE_TYPE_VEIL.m_color;
709 void nade_boom(entity this)
712 bool nade_blast = true;
714 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
716 case NADE_TYPE_NAPALM:
717 nade_blast = autocvar_g_nades_napalm_blast;
718 expef = EFFECT_EXPLOSION_MEDIUM;
722 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
724 case NADE_TYPE_TRANSLOCATE:
727 case NADE_TYPE_MONSTER:
728 case NADE_TYPE_SPAWN:
730 switch(this.realowner.team)
732 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
733 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
734 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
735 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
736 default: expef = EFFECT_SPAWN_NEUTRAL; break;
741 expef = EFFECT_SPAWN_RED;
744 case NADE_TYPE_ENTRAP:
746 expef = EFFECT_SPAWN_YELLOW;
751 expef = EFFECT_SPAWN_NEUTRAL;
755 case NADE_TYPE_NORMAL:
756 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
761 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
763 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
764 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
766 this.event_damage = func_null; // prevent somehow calling damage in the next call
770 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
771 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
772 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);
776 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
778 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
779 case NADE_TYPE_ICE: nade_ice_boom(this); break;
780 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
781 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
782 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
783 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
784 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
785 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
788 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
796 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
797 void nade_pickup(entity this, entity thenade)
799 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
801 // set refire so player can't even
802 this.nade_refire = time + autocvar_g_nades_nade_refire;
803 STAT(NADE_TIMER, this) = 0;
806 this.nade.nade_time_primed = thenade.nade_time_primed;
809 bool CanThrowNade(entity this);
810 void nade_touch(entity this, entity toucher)
813 UpdateCSQCProjectile(this);
815 if(toucher == this.realowner)
816 return; // no this impacts
818 if(autocvar_g_nades_pickup)
819 if(time >= this.spawnshieldtime)
820 if(!toucher.nade && GetResource(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
821 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
822 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
824 nade_pickup(toucher, this);
825 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
829 /*float is_weapclip = 0;
830 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
831 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
832 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
834 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
836 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
844 PROJECTILE_TOUCH(this, toucher);
846 //setsize(this, '-2 -2 -2', '2 2 2');
847 //UpdateCSQCProjectile(this);
848 if(GetResource(this, RES_HEALTH) == this.max_health)
850 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
854 this.enemy = toucher;
858 void nade_beep(entity this)
860 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
861 setthink(this, nade_boom);
862 this.nextthink = max(this.wait, time);
865 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
867 if(ITEM_DAMAGE_NEEDKILL(deathtype))
869 this.takedamage = DAMAGE_NO;
874 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
877 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
878 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
883 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
885 force *= 0.5; // too much
888 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
891 damage = this.max_health * 0.55;
893 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
894 damage = this.max_health * 0.1;
895 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
897 if(!(deathtype & HITTYPE_SECONDARY))
898 damage = this.max_health * 1.15;
902 entity death_weapon = DEATH_WEAPONOF(deathtype);
903 if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
905 damage = this.max_health * 0.1;
909 this.velocity += force;
910 UpdateCSQCProjectile(this);
912 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
915 float hp = GetResource(this, RES_HEALTH);
916 if(hp == this.max_health)
918 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
919 this.nextthink = max(time + this.nade_lifetime, time);
920 setthink(this, nade_beep);
924 SetResource(this, RES_HEALTH, hp);
927 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
928 this.realowner = attacker;
931 W_PrepareExplosionByDamage(this, attacker, nade_boom);
933 nade_burn_spawn(this);
936 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
941 entity _nade = e.nade;
947 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
949 makevectors(e.v_angle);
951 // NOTE: always throw from first weapon entity?
952 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
954 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
955 + (v_right * autocvar_g_nades_throw_offset.y)
956 + (v_up * autocvar_g_nades_throw_offset.z);
958 setorigin(_nade, w_shotorg + offset);
959 //setmodel(_nade, MDL_PROJECTILE_NADE);
960 //setattachment(_nade, NULL, "");
961 PROJECTILE_MAKETRIGGER(_nade);
962 if(STAT(NADES_SMALL, e))
963 setsize(_nade, '-8 -8 -8', '8 8 8');
965 setsize(_nade, '-16 -16 -16', '16 16 16');
966 set_movetype(_nade, MOVETYPE_BOUNCE);
968 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
969 if (trace_startsolid)
970 setorigin(_nade, e.origin);
972 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
973 _nade.velocity = '0 0 100';
974 else if(autocvar_g_nades_nade_newton_style == 1)
975 _nade.velocity = e.velocity + _velocity;
976 else if(autocvar_g_nades_nade_newton_style == 2)
977 _nade.velocity = _velocity;
979 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
984 settouch(_nade, nade_touch);
985 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
986 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
987 _nade.max_health = GetResource(_nade, RES_HEALTH);
988 _nade.takedamage = DAMAGE_AIM;
989 _nade.event_damage = nade_damage;
990 setcefc(_nade, func_null);
991 _nade.exteriormodeltoclient = NULL;
992 _nade.traileffectnum = 0;
993 _nade.teleportable = true;
994 _nade.pushable = true;
996 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
997 _nade.damagedbycontents = true;
998 IL_PUSH(g_damagedbycontents, _nade);
999 _nade.angles = vectoangles(_nade.velocity);
1000 _nade.flags = FL_PROJECTILE;
1001 IL_PUSH(g_projectiles, _nade);
1002 IL_PUSH(g_bot_dodge, _nade);
1003 _nade.projectiledeathtype = DEATH_NADE.m_id;
1004 _nade.toss_time = time;
1005 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1007 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1008 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1010 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1016 setthink(_nade, nade_boom);
1017 _nade.nextthink = _time;
1020 e.nade_refire = time + autocvar_g_nades_nade_refire;
1021 STAT(NADE_TIMER, e) = 0;
1024 void nades_GiveBonus(entity player, float score)
1026 if (autocvar_g_nades)
1027 if (autocvar_g_nades_bonus)
1028 if (IS_REAL_CLIENT(player))
1029 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1030 if (!STAT(FROZEN, player))
1031 if (!IS_DEAD(player))
1033 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1034 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1036 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1038 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1039 play2(player, SND(NADE_BONUS));
1040 STAT(NADE_BONUS, player)++;
1041 STAT(NADE_BONUS_SCORE, player) -= 1;
1046 /** Remove all bonus nades from a player */
1047 void nades_RemoveBonus(entity player)
1049 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1052 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1054 entity player = M_ARGV(0, entity);
1056 nades_RemoveBonus(player);
1059 bool nade_customize(entity this, entity client)
1061 //if(IS_SPEC(client)) { return false; }
1062 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1064 // somewhat hide the model, but keep the glow
1066 if(this.traileffectnum)
1067 this.traileffectnum = 0;
1072 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1073 if(!this.traileffectnum)
1074 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
1081 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1083 entity n = new(nade), fn = new(fake_nade);
1085 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1086 n.pokenade_type = pntype;
1088 if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1089 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1091 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1093 setmodel(n, MDL_PROJECTILE_NADE);
1094 //setattachment(n, player, "bip01 l hand");
1095 n.exteriormodeltoclient = player;
1096 setcefc(n, nade_customize);
1097 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1098 n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1099 n.realowner = nowner;
1100 n.colormap = player.colormap;
1101 n.glowmod = player.glowmod;
1102 n.wait = time + max(0, ntime);
1103 n.nade_time_primed = time;
1104 setthink(n, nade_beep);
1105 n.nextthink = max(n.wait - 3, time);
1106 n.projectiledeathtype = DEATH_NADE.m_id;
1107 n.weaponentity_fld = weaponentity;
1108 n.nade_lifetime = ntime;
1109 n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1111 setmodel(fn, MDL_NADE_VIEW);
1112 //setattachment(fn, player.(weaponentity), "");
1113 fn.viewmodelforclient = player;
1114 fn.realowner = fn.owner = player;
1115 fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1116 fn.colormap = player.colormap;
1117 fn.glowmod = player.glowmod;
1118 setthink(fn, SUB_Remove);
1119 fn.nextthink = n.wait;
1120 fn.weaponentity_fld = weaponentity;
1121 fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1124 player.fake_nade = fn;
1127 void nade_prime(entity this)
1129 if(autocvar_g_nades_bonus_only)
1130 if(!STAT(NADE_BONUS, this))
1131 return; // only allow bonus nades
1137 delete(this.fake_nade);
1140 string pntype = this.pokenade_type;
1142 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1143 ntype = STAT(NADE_BONUS_TYPE, this);
1144 else if (STAT(NADE_BONUS, this) >= 1)
1146 ntype = STAT(NADE_BONUS_TYPE, this);
1147 pntype = this.pokenade_type;
1148 STAT(NADE_BONUS, this) -= 1;
1152 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1153 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1156 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1159 bool CanThrowNade(entity this)
1167 if (!autocvar_g_nades)
1168 return false; // allow turning them off mid match
1170 if (weaponLocked(this))
1173 if (!IS_PLAYER(this))
1179 .bool nade_altbutton;
1181 void nades_CheckThrow(entity this)
1183 if(!CanThrowNade(this))
1186 entity held_nade = this.nade;
1189 this.nade_altbutton = true;
1190 if(time > this.nade_refire)
1192 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1194 this.nade_refire = time + autocvar_g_nades_nade_refire;
1199 this.nade_altbutton = false;
1200 if (time >= held_nade.nade_time_primed + 1) {
1201 makevectors(this.v_angle);
1202 float _force = time - held_nade.nade_time_primed;
1203 _force /= autocvar_g_nades_nade_lifetime;
1204 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1205 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1206 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1207 toss_nade(this, true, dir * _force, 0);
1212 void nades_Clear(entity player)
1215 delete(player.nade);
1216 if(player.fake_nade)
1217 delete(player.fake_nade);
1219 player.nade = player.fake_nade = NULL;
1220 STAT(NADE_TIMER, player) = 0;
1223 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1225 entity player = M_ARGV(0, entity);
1228 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1231 CLASS(NadeOffhand, OffhandWeapon)
1232 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1234 entity held_nade = player.nade;
1236 if (!CanThrowNade(player)) return;
1237 if (!(time > player.nade_refire)) return;
1241 held_nade = player.nade;
1243 } else if (time >= held_nade.nade_time_primed + 1) {
1245 makevectors(player.v_angle);
1246 float _force = time - held_nade.nade_time_primed;
1247 _force /= autocvar_g_nades_nade_lifetime;
1248 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1249 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1250 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1251 toss_nade(player, false, dir * _force, 0);
1255 ENDCLASS(NadeOffhand)
1256 NadeOffhand OFFHAND_NADE;
1257 STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1259 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1261 entity player = M_ARGV(0, entity);
1263 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1264 nades_CheckThrow(player);
1273 // returns true if player is reviving it
1274 #define IS_REVIVING(player, it, revive_extra_size) \
1275 (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
1276 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1278 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1280 entity player = M_ARGV(0, entity);
1282 if (!IS_PLAYER(player)) { return; }
1284 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1286 entity held_nade = player.nade;
1289 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1290 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1291 makevectors(player.angles);
1292 held_nade.velocity = player.velocity;
1293 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1294 held_nade.angles_y = player.angles.y;
1296 if (time + 0.1 >= held_nade.wait)
1297 toss_nade(player, false, '0 0 0', time + 0.05);
1300 if(IS_PLAYER(player))
1302 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1305 float key_count = 0;
1306 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1309 if(GameRules_scoring_is_vip(player))
1310 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1312 time_score = autocvar_g_nades_bonus_score_time;
1315 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1317 if(autocvar_g_nades_bonus_client_select)
1319 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1320 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1324 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1325 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1328 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1330 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1331 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1335 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1338 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1340 STAT(VEIL_ORB, player) = 0;
1342 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1344 player.alpha = player.nade_veil_prevalpha;
1350 IntrusiveList reviving_players = NULL;
1352 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1354 else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
1356 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1358 FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
1359 if (!reviving_players)
1360 reviving_players = IL_NEW();
1361 IL_PUSH(reviving_players, it);
1366 if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1368 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1369 SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1371 if(STAT(REVIVE_PROGRESS, player) >= 1)
1373 Unfreeze(player, false);
1375 entity first = IL_FIRST(reviving_players);
1376 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
1377 Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1380 IL_EACH(reviving_players, true, {
1381 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1384 if (reviving_players)
1385 IL_DELETE(reviving_players);
1388 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1390 entity player = M_ARGV(0, entity);
1391 // these automatically reset, no need to worry
1393 if(STAT(ENTRAP_ORB, player) > time)
1394 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1397 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1399 entity mon = M_ARGV(0, entity);
1401 if (STAT(ENTRAP_ORB, mon) > time)
1403 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1404 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1407 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1409 mon.alpha = mon.nade_veil_prevalpha;
1410 STAT(VEIL_ORB, mon) = 0;
1414 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1416 entity player = M_ARGV(0, entity);
1418 if(autocvar_g_nades_spawn)
1419 player.nade_refire = time + autocvar_g_spawnshieldtime;
1421 player.nade_refire = time + autocvar_g_nades_nade_refire;
1423 if(autocvar_g_nades_bonus_client_select)
1424 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1426 STAT(NADE_TIMER, player) = 0;
1428 if (!player.offhand) player.offhand = OFFHAND_NADE;
1430 if(player.nade_spawnloc)
1432 setorigin(player, player.nade_spawnloc.origin);
1433 player.nade_spawnloc.cnt -= 1;
1435 if(player.nade_spawnloc.cnt <= 0)
1437 delete(player.nade_spawnloc);
1438 player.nade_spawnloc = NULL;
1443 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1445 entity frag_attacker = M_ARGV(1, entity);
1446 entity frag_target = M_ARGV(2, entity);
1448 if(frag_target.nade)
1449 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1450 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1452 if(IS_PLAYER(frag_attacker))
1454 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)
1455 : autocvar_g_nades_bonus_score_minor);
1457 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1458 nades_RemoveBonus(frag_attacker);
1459 else if(GameRules_scoring_is_vip(frag_target))
1460 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1461 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1463 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1464 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1465 switch(CS(frag_attacker).killcount)
1468 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1473 nades_GiveBonus(frag_attacker, killcount_bonus);
1476 nades_RemoveBonus(frag_target);
1479 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1481 entity frag_inflictor = M_ARGV(0, entity);
1482 entity frag_attacker = M_ARGV(1, entity);
1483 entity frag_target = M_ARGV(2, entity);
1484 float frag_deathtype = M_ARGV(3, float);
1486 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1487 if(time - frag_inflictor.toss_time <= 0.1)
1489 Unfreeze(frag_target, false);
1490 SetResource(frag_target, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
1491 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1492 M_ARGV(4, float) = 0;
1493 M_ARGV(6, vector) = '0 0 0';
1494 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1495 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1499 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1501 entity frag_target = M_ARGV(0, entity);
1502 entity frag_attacker = M_ARGV(1, entity);
1504 if(IS_PLAYER(frag_attacker))
1505 if(DIFF_TEAM(frag_attacker, frag_target))
1506 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1507 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1510 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1512 entity frag_target = M_ARGV(0, entity);
1514 if(frag_target.nade)
1515 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1518 void nades_RemovePlayer(entity this)
1521 nades_RemoveBonus(this);
1524 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1525 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1526 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1528 FOREACH_CLIENT(IS_PLAYER(it),
1530 nades_RemovePlayer(it);
1534 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1536 entity spectatee = M_ARGV(0, entity);
1537 entity client = M_ARGV(1, entity);
1539 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1540 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1541 client.pokenade_type = spectatee.pokenade_type;
1542 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1543 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1544 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1545 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1546 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1547 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1548 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1549 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1552 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1554 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1557 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1559 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n");