3 #include "../overkill/okmachinegun.qh"
4 #include "../overkill/okshotgun.qh"
7 bool autocvar_g_nades_nade_small;
8 float autocvar_g_nades_spread = 0.04;
11 REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
14 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
15 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
17 entity Nade_TrailEffect(int proj, int nade_team)
21 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
22 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
25 FOREACH(Nades, true, {
26 for (int j = 0; j < 2; j++)
28 if (it.m_projectile[j] == proj)
30 string trail = it.m_trail[j].eent_eff_name;
31 if (trail) return it.m_trail[j];
42 REGISTER_MUTATOR(cl_nades, true);
43 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
45 // TODO: make a common orb state!
46 if (STAT(HEALING_ORB) > time)
48 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
49 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
52 if (STAT(ENTRAP_ORB) > time)
54 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
55 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
58 if (STAT(VEIL_ORB) > time)
60 M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color;
61 M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA);
66 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
68 entity proj = M_ARGV(0, entity);
70 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
73 proj.traileffect = EFFECT_FIREBALL.m_id;
76 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
78 setmodel(proj, MDL_PROJECTILE_NADE);
79 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
80 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
84 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
86 entity proj = M_ARGV(0, entity);
88 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
90 loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
91 proj.mins = '-16 -16 -16';
92 proj.maxs = '16 16 16';
95 entity nade_type = Nade_FromProjectile(proj.cnt);
96 if (nade_type == NADE_TYPE_Null) return;
99 proj.mins = '-8 -8 -8';
104 proj.mins = '-16 -16 -16';
105 proj.maxs = '16 16 16';
107 proj.colormod = nade_type.m_color;
108 set_movetype(proj, MOVETYPE_BOUNCE);
109 settouch(proj, func_null);
111 proj.avelocity = randomvec() * 720;
112 proj.alphamod = nade_type.m_alpha;
114 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
115 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
117 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
119 bool Projectile_isnade(int p)
121 return Nade_FromProjectile(p) != NADE_TYPE_Null;
123 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
125 float bonusNades = STAT(NADE_BONUS);
126 float bonusProgress = STAT(NADE_BONUS_SCORE);
127 float bonusType = STAT(NADE_BONUS_TYPE);
128 Nade def = REGISTRY_GET(Nades, bonusType);
129 vector nadeColor = def.m_color;
130 string nadeIcon = def.m_icon;
132 vector iconPos, textPos;
134 if(autocvar_hud_panel_ammo_iconalign)
136 iconPos = myPos + eX * 2 * mySize.y;
142 textPos = myPos + eX * mySize.y;
145 if(bonusNades > 0 || bonusProgress > 0)
147 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
149 if(autocvar_hud_panel_ammo_text)
150 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
153 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
155 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
162 #include <common/gamemodes/_mod.qh>
163 #include <common/monsters/sv_spawn.qh>
164 #include <common/monsters/sv_monsters.qh>
166 REGISTER_MUTATOR(nades, autocvar_g_nades);
168 .float nade_time_primed;
169 .float nade_lifetime;
171 .entity nade_spawnloc;
174 void nade_timer_think(entity this)
176 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
177 this.nextthink = time;
178 if(!this.owner || wasfreed(this.owner))
182 void nade_burn_spawn(entity _nade)
184 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
187 void nade_spawn(entity _nade)
189 entity timer = new(nade_timer);
190 setmodel(timer, MDL_NADE_TIMER);
191 setattachment(timer, _nade, "");
192 timer.colormap = _nade.colormap;
193 timer.glowmod = _nade.glowmod;
194 setthink(timer, nade_timer_think);
195 timer.nextthink = time;
196 timer.wait = _nade.wait;
200 _nade.effects |= EF_LOWPRECISION;
202 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
205 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
214 RandomSelection_Init();
215 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
216 if(e.takedamage == DAMAGE_AIM)
217 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
218 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
222 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
223 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
224 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
225 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
228 e.fireball_impactvec = p;
229 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
232 if(RandomSelection_chosen_ent)
234 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
235 d = damage + (edgedamage - damage) * (d / dist);
236 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
237 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
238 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
243 void napalm_ball_think(entity this)
245 if(round_handler_IsActive())
246 if(!round_handler_IsRoundStarted())
252 if(time > this.pushltime)
258 vector midpoint = ((this.absmin + this.absmax) * 0.5);
259 if(pointcontents(midpoint) == CONTENT_WATER)
261 this.velocity = this.velocity * 0.5;
263 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
264 { this.velocity_z = 200; }
267 this.angles = vectoangles(this.velocity);
269 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
270 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
272 this.nextthink = time + 0.1;
276 void nade_napalm_ball(entity this)
281 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
284 proj.owner = this.owner;
285 proj.realowner = this.realowner;
286 proj.team = this.owner.team;
287 proj.bot_dodge = true;
288 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
289 set_movetype(proj, MOVETYPE_BOUNCE);
290 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
291 PROJECTILE_MAKETRIGGER(proj);
292 setmodel(proj, MDL_Null);
293 proj.scale = 1;//0.5;
294 setsize(proj, '-4 -4 -4', '4 4 4');
295 setorigin(proj, this.origin);
296 setthink(proj, napalm_ball_think);
297 proj.nextthink = time;
298 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
299 proj.effects = EF_LOWPRECISION | EF_FLAME;
301 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
302 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
303 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
304 proj.velocity = kick;
306 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
308 proj.angles = vectoangles(proj.velocity);
309 proj.flags = FL_PROJECTILE;
310 IL_PUSH(g_projectiles, proj);
311 IL_PUSH(g_bot_dodge, proj);
312 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
314 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
318 void napalm_fountain_think(entity this)
321 if(round_handler_IsActive())
322 if(!round_handler_IsRoundStarted())
328 if(time >= this.ltime)
334 vector midpoint = ((this.absmin + this.absmax) * 0.5);
335 if(pointcontents(midpoint) == CONTENT_WATER)
337 this.velocity = this.velocity * 0.5;
339 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
340 { this.velocity_z = 200; }
342 UpdateCSQCProjectile(this);
345 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
346 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
348 this.nextthink = time + 0.1;
349 if(time >= this.nade_special_time)
351 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
352 nade_napalm_ball(this);
356 void nade_napalm_boom(entity this)
358 for (int c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
359 nade_napalm_ball(this);
361 entity fountain = new(nade_napalm_fountain);
362 fountain.owner = this.owner;
363 fountain.realowner = this.realowner;
364 fountain.origin = this.origin;
365 fountain.flags = FL_PROJECTILE;
366 IL_PUSH(g_projectiles, fountain);
367 IL_PUSH(g_bot_dodge, fountain);
368 setorigin(fountain, fountain.origin);
369 setthink(fountain, napalm_fountain_think);
370 fountain.nextthink = time;
371 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
372 fountain.pushltime = fountain.ltime;
373 fountain.team = this.team;
374 set_movetype(fountain, MOVETYPE_TOSS);
375 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
376 fountain.bot_dodge = true;
377 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
378 fountain.nade_special_time = time;
379 setsize(fountain, '-16 -16 -16', '16 16 16');
380 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
383 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
385 frost_target.frozen_by = freezefield.realowner;
386 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
387 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
389 Drop_Special_Items(frost_target);
392 void nade_ice_think(entity this)
394 if(round_handler_IsActive())
395 if(!round_handler_IsRoundStarted())
401 if(time >= this.ltime)
403 if ( autocvar_g_nades_ice_explode )
405 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
406 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
407 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
409 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
410 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
411 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
412 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
419 this.nextthink = time+0.1;
424 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
426 randomw = random()*M_PI*2;
428 randomp.x = randomr*cos(randomw);
429 randomp.y = randomr*sin(randomw);
431 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
433 if(time >= this.nade_special_time)
435 this.nade_special_time = time+0.7;
437 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
438 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
442 float current_freeze_time = this.ltime - time - 0.1;
444 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0,
446 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
447 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
448 if(!STAT(FROZEN, it))
449 nade_ice_freeze(this, it, current_freeze_time);
453 void nade_ice_boom(entity this)
455 entity fountain = new(nade_ice_fountain);
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 = new(nade_spawn_loc);
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 = new(nades_spawn_orb);
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 = GetResource(toucher, RES_HEALTH);
638 if (this.nade_show_particles)
640 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
642 GiveResourceWithLimit(toucher, RES_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)
671 e.noalign = true; // don't drop to floor
672 e = spawnmonster(e, this.pokenade_type, MON_Null, this.realowner, this.realowner, this.origin, false, false, 1);
674 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
675 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
676 e.monster_skill = MONSTER_SKILL_INSANE;
679 void nade_veil_touch(entity this, entity toucher)
681 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
683 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
685 float tint_alpha = 0.75;
686 if(SAME_TEAM(toucher, this.realowner))
689 if(!STAT(VEIL_ORB, show_tint))
691 toucher.nade_veil_prevalpha = toucher.alpha;
695 STAT(VEIL_ORB, show_tint) = time + 0.1;
696 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
700 void nade_veil_boom(entity this)
702 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
704 settouch(orb, nade_veil_touch);
705 orb.colormod = NADE_TYPE_VEIL.m_color;
708 void nade_boom(entity this)
711 bool nade_blast = true;
713 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
715 case NADE_TYPE_NAPALM:
716 nade_blast = autocvar_g_nades_napalm_blast;
717 expef = EFFECT_EXPLOSION_MEDIUM;
721 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
723 case NADE_TYPE_TRANSLOCATE:
726 case NADE_TYPE_MONSTER:
727 case NADE_TYPE_SPAWN:
729 switch(this.realowner.team)
731 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
732 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
733 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
734 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
735 default: expef = EFFECT_SPAWN_NEUTRAL; break;
740 expef = EFFECT_SPAWN_RED;
743 case NADE_TYPE_ENTRAP:
745 expef = EFFECT_SPAWN_YELLOW;
750 expef = EFFECT_SPAWN_NEUTRAL;
754 case NADE_TYPE_NORMAL:
755 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
760 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
762 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
763 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
765 this.event_damage = func_null; // prevent somehow calling damage in the next call
769 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
770 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
771 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);
775 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
777 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
778 case NADE_TYPE_ICE: nade_ice_boom(this); break;
779 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
780 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
781 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
782 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
783 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
784 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
787 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
795 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
796 void nade_pickup(entity this, entity thenade)
798 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
800 // set refire so player can't even
801 this.nade_refire = time + autocvar_g_nades_nade_refire;
802 STAT(NADE_TIMER, this) = 0;
805 this.nade.nade_time_primed = thenade.nade_time_primed;
808 bool CanThrowNade(entity this);
809 void nade_touch(entity this, entity toucher)
812 UpdateCSQCProjectile(this);
814 if(toucher == this.realowner)
815 return; // no this impacts
817 if(autocvar_g_nades_pickup)
818 if(time >= this.spawnshieldtime)
819 if(!toucher.nade && GetResource(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
820 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
821 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
823 nade_pickup(toucher, this);
824 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
828 /*float is_weapclip = 0;
829 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
830 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
831 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
833 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
835 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
843 PROJECTILE_TOUCH(this, toucher);
845 //setsize(this, '-2 -2 -2', '2 2 2');
846 //UpdateCSQCProjectile(this);
847 if(GetResource(this, RES_HEALTH) == this.max_health)
849 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
853 this.enemy = toucher;
857 void nade_beep(entity this)
859 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
860 setthink(this, nade_boom);
861 this.nextthink = max(this.wait, time);
864 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
866 if(ITEM_DAMAGE_NEEDKILL(deathtype))
868 this.takedamage = DAMAGE_NO;
873 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
876 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
877 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
882 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
884 force *= 0.5; // too much
887 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
890 damage = this.max_health * 0.55;
892 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
893 damage = this.max_health * 0.1;
894 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_SHOTGUN)) // WEAPONTODO
896 if(!(deathtype & HITTYPE_SECONDARY))
897 damage = this.max_health * 1.15;
901 entity death_weapon = DEATH_WEAPONOF(deathtype);
902 if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
904 damage = this.max_health * 0.1;
908 this.velocity += force;
909 UpdateCSQCProjectile(this);
911 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
914 float hp = GetResource(this, RES_HEALTH);
915 if(hp == this.max_health)
917 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
918 this.nextthink = max(time + this.nade_lifetime, time);
919 setthink(this, nade_beep);
923 SetResource(this, RES_HEALTH, hp);
926 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
927 this.realowner = attacker;
930 W_PrepareExplosionByDamage(this, attacker, nade_boom);
932 nade_burn_spawn(this);
935 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
940 entity _nade = e.nade;
946 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
948 makevectors(e.v_angle);
950 // NOTE: always throw from first weapon entity?
951 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
953 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
954 + (v_right * autocvar_g_nades_throw_offset.y)
955 + (v_up * autocvar_g_nades_throw_offset.z);
957 setorigin(_nade, w_shotorg + offset);
958 //setmodel(_nade, MDL_PROJECTILE_NADE);
959 //setattachment(_nade, NULL, "");
960 PROJECTILE_MAKETRIGGER(_nade);
961 if(STAT(NADES_SMALL, e))
962 setsize(_nade, '-8 -8 -8', '8 8 8');
964 setsize(_nade, '-16 -16 -16', '16 16 16');
965 set_movetype(_nade, MOVETYPE_BOUNCE);
967 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
968 if (trace_startsolid)
969 setorigin(_nade, e.origin);
971 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
972 _nade.velocity = '0 0 100';
973 else if(autocvar_g_nades_nade_newton_style == 1)
974 _nade.velocity = e.velocity + _velocity;
975 else if(autocvar_g_nades_nade_newton_style == 2)
976 _nade.velocity = _velocity;
978 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
983 settouch(_nade, nade_touch);
984 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
985 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
986 _nade.max_health = GetResource(_nade, RES_HEALTH);
987 _nade.takedamage = DAMAGE_AIM;
988 _nade.event_damage = nade_damage;
989 setcefc(_nade, func_null);
990 _nade.exteriormodeltoclient = NULL;
991 _nade.traileffectnum = 0;
992 _nade.teleportable = true;
993 _nade.pushable = true;
995 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
996 _nade.damagedbycontents = true;
997 IL_PUSH(g_damagedbycontents, _nade);
998 _nade.angles = vectoangles(_nade.velocity);
999 _nade.flags = FL_PROJECTILE;
1000 IL_PUSH(g_projectiles, _nade);
1001 IL_PUSH(g_bot_dodge, _nade);
1002 _nade.projectiledeathtype = DEATH_NADE.m_id;
1003 _nade.toss_time = time;
1004 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1006 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1007 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1009 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1015 setthink(_nade, nade_boom);
1016 _nade.nextthink = _time;
1019 e.nade_refire = time + autocvar_g_nades_nade_refire;
1020 STAT(NADE_TIMER, e) = 0;
1023 void nades_GiveBonus(entity player, float score)
1025 if (autocvar_g_nades)
1026 if (autocvar_g_nades_bonus)
1027 if (IS_REAL_CLIENT(player))
1028 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1029 if (!STAT(FROZEN, player))
1030 if (!IS_DEAD(player))
1032 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1033 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1035 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1037 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1038 play2(player, SND(NADE_BONUS));
1039 STAT(NADE_BONUS, player)++;
1040 STAT(NADE_BONUS_SCORE, player) -= 1;
1045 /** Remove all bonus nades from a player */
1046 void nades_RemoveBonus(entity player)
1048 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1051 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1053 entity player = M_ARGV(0, entity);
1055 nades_RemoveBonus(player);
1058 bool nade_customize(entity this, entity client)
1060 //if(IS_SPEC(client)) { return false; }
1061 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1063 // somewhat hide the model, but keep the glow
1065 if(this.traileffectnum)
1066 this.traileffectnum = 0;
1071 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1072 if(!this.traileffectnum)
1074 entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
1075 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[false], this.team).eent_eff_name);
1083 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1085 entity n = new(nade), fn = new(fake_nade);
1087 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1088 n.pokenade_type = pntype;
1090 if(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1091 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1093 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1095 setmodel(n, MDL_PROJECTILE_NADE);
1096 //setattachment(n, player, "bip01 l hand");
1097 n.exteriormodeltoclient = player;
1098 setcefc(n, nade_customize);
1099 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1100 n.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1101 n.realowner = nowner;
1102 n.colormap = player.colormap;
1103 n.glowmod = player.glowmod;
1104 n.wait = time + max(0, ntime);
1105 n.nade_time_primed = time;
1106 setthink(n, nade_beep);
1107 n.nextthink = max(n.wait - 3, time);
1108 n.projectiledeathtype = DEATH_NADE.m_id;
1109 n.weaponentity_fld = weaponentity;
1110 n.nade_lifetime = ntime;
1111 n.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1113 setmodel(fn, MDL_NADE_VIEW);
1114 //setattachment(fn, player.(weaponentity), "");
1115 fn.viewmodelforclient = player;
1116 fn.realowner = fn.owner = player;
1117 fn.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1118 fn.colormap = player.colormap;
1119 fn.glowmod = player.glowmod;
1120 setthink(fn, SUB_Remove);
1121 fn.nextthink = n.wait;
1122 fn.weaponentity_fld = weaponentity;
1123 fn.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1126 player.fake_nade = fn;
1129 void nade_prime(entity this)
1131 if(autocvar_g_nades_bonus_only)
1132 if(!STAT(NADE_BONUS, this))
1133 return; // only allow bonus nades
1139 delete(this.fake_nade);
1142 string pntype = this.pokenade_type;
1144 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1145 ntype = STAT(NADE_BONUS_TYPE, this);
1146 else if (STAT(NADE_BONUS, this) >= 1)
1148 ntype = STAT(NADE_BONUS_TYPE, this);
1149 pntype = this.pokenade_type;
1150 STAT(NADE_BONUS, this) -= 1;
1154 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1155 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1158 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1161 bool CanThrowNade(entity this)
1169 if (!autocvar_g_nades)
1170 return false; // allow turning them off mid match
1172 if (weaponLocked(this))
1175 if (!IS_PLAYER(this))
1181 .bool nade_altbutton;
1183 void nades_CheckThrow(entity this)
1185 if(!CanThrowNade(this))
1188 entity held_nade = this.nade;
1191 this.nade_altbutton = true;
1192 if(time > this.nade_refire)
1195 this.nade_refire = time + autocvar_g_nades_nade_refire;
1200 this.nade_altbutton = false;
1201 if (time >= held_nade.nade_time_primed + 1) {
1202 makevectors(this.v_angle);
1203 float _force = time - held_nade.nade_time_primed;
1204 _force /= autocvar_g_nades_nade_lifetime;
1205 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1206 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1207 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1208 toss_nade(this, true, dir * _force, 0);
1213 void nades_Clear(entity player)
1216 delete(player.nade);
1217 if(player.fake_nade)
1218 delete(player.fake_nade);
1220 player.nade = player.fake_nade = NULL;
1221 STAT(NADE_TIMER, player) = 0;
1224 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1226 entity player = M_ARGV(0, entity);
1229 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1232 CLASS(NadeOffhand, OffhandWeapon)
1233 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1235 entity held_nade = player.nade;
1237 if (!CanThrowNade(player)) return;
1238 if (!(time > player.nade_refire)) return;
1242 held_nade = player.nade;
1244 } else if (time >= held_nade.nade_time_primed + 1) {
1246 makevectors(player.v_angle);
1247 float _force = time - held_nade.nade_time_primed;
1248 _force /= autocvar_g_nades_nade_lifetime;
1249 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1250 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1251 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1252 toss_nade(player, false, dir * _force, 0);
1256 ENDCLASS(NadeOffhand)
1257 NadeOffhand OFFHAND_NADE;
1258 STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1260 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1262 entity player = M_ARGV(0, entity);
1264 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1265 nades_CheckThrow(player);
1274 // returns true if player is reviving it
1275 #define IS_REVIVING(player, it, revive_extra_size) \
1276 (it != player && !STAT(FROZEN, it) && !IS_DEAD(it) && SAME_TEAM(it, player) \
1277 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1279 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1281 entity player = M_ARGV(0, entity);
1283 if (!IS_PLAYER(player)) { return; }
1285 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1287 entity held_nade = player.nade;
1290 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1291 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1292 makevectors(player.angles);
1293 held_nade.velocity = player.velocity;
1294 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1295 held_nade.angles_y = player.angles.y;
1297 if (time + 0.1 >= held_nade.wait)
1299 toss_nade(player, false, '0 0 0', time + 0.05);
1300 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_THROW);
1304 if(IS_PLAYER(player))
1306 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1309 float key_count = 0;
1310 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1313 if(GameRules_scoring_is_vip(player))
1314 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1316 time_score = autocvar_g_nades_bonus_score_time;
1319 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1321 if(autocvar_g_nades_bonus_client_select)
1323 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1324 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1328 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1329 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1332 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1334 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1335 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1339 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1342 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1344 STAT(VEIL_ORB, player) = 0;
1346 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1348 player.alpha = player.nade_veil_prevalpha;
1352 if (frametime && IS_PLAYER(player))
1356 IntrusiveList reviving_players = NULL;
1358 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1360 else if (STAT(FROZEN, player) == FROZEN_TEMP_DYING)
1362 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1364 FOREACH_CLIENT(IS_PLAYER(it) && IS_REVIVING(player, it, revive_extra_size), {
1365 if (!reviving_players)
1366 reviving_players = IL_NEW();
1367 IL_PUSH(reviving_players, it);
1372 if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1374 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1375 SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1377 if(STAT(REVIVE_PROGRESS, player) >= 1)
1379 Unfreeze(player, false);
1381 entity first = IL_FIRST(reviving_players);
1382 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
1383 Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1386 IL_EACH(reviving_players, true, {
1387 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1390 if (reviving_players)
1391 IL_DELETE(reviving_players);
1395 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1397 entity player = M_ARGV(0, entity);
1398 // these automatically reset, no need to worry
1400 if(STAT(ENTRAP_ORB, player) > time)
1401 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1404 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1406 entity mon = M_ARGV(0, entity);
1408 if (STAT(ENTRAP_ORB, mon) > time)
1410 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1411 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1414 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1416 mon.alpha = mon.nade_veil_prevalpha;
1417 STAT(VEIL_ORB, mon) = 0;
1421 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1423 entity player = M_ARGV(0, entity);
1425 if(autocvar_g_nades_spawn)
1426 player.nade_refire = time + autocvar_g_spawnshieldtime;
1428 player.nade_refire = time + autocvar_g_nades_nade_refire;
1430 if(autocvar_g_nades_bonus_client_select)
1431 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1433 STAT(NADE_TIMER, player) = 0;
1435 if (!player.offhand) player.offhand = OFFHAND_NADE;
1437 if(player.nade_spawnloc)
1439 setorigin(player, player.nade_spawnloc.origin);
1440 player.nade_spawnloc.cnt -= 1;
1442 if(player.nade_spawnloc.cnt <= 0)
1444 delete(player.nade_spawnloc);
1445 player.nade_spawnloc = NULL;
1450 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1452 entity frag_attacker = M_ARGV(1, entity);
1453 entity frag_target = M_ARGV(2, entity);
1455 if(frag_target.nade)
1456 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1457 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1459 if(IS_PLAYER(frag_attacker))
1461 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)
1462 : autocvar_g_nades_bonus_score_minor);
1463 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1464 nades_RemoveBonus(frag_attacker);
1465 else if(GameRules_scoring_is_vip(frag_target))
1466 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1467 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1469 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1470 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1471 switch(CS(frag_attacker).killcount)
1474 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1479 nades_GiveBonus(frag_attacker, killcount_bonus);
1482 nades_RemoveBonus(frag_target);
1485 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1487 entity frag_inflictor = M_ARGV(0, entity);
1488 entity frag_attacker = M_ARGV(1, entity);
1489 entity frag_target = M_ARGV(2, entity);
1490 float frag_deathtype = M_ARGV(3, float);
1492 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1493 if(time - frag_inflictor.toss_time <= 0.1)
1495 Unfreeze(frag_target, false);
1496 SetResource(frag_target, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
1497 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1498 M_ARGV(4, float) = 0;
1499 M_ARGV(6, vector) = '0 0 0';
1500 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1501 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1505 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1507 entity frag_target = M_ARGV(0, entity);
1508 entity frag_attacker = M_ARGV(1, entity);
1510 if(IS_PLAYER(frag_attacker))
1511 if(DIFF_TEAM(frag_attacker, frag_target))
1512 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1513 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1516 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1518 entity frag_target = M_ARGV(0, entity);
1520 if(frag_target.nade)
1521 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1524 void nades_RemovePlayer(entity this)
1527 nades_RemoveBonus(this);
1530 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1531 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1532 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1534 FOREACH_CLIENT(IS_PLAYER(it),
1536 nades_RemovePlayer(it);
1540 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1542 entity spectatee = M_ARGV(0, entity);
1543 entity client = M_ARGV(1, entity);
1545 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1546 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1547 client.pokenade_type = spectatee.pokenade_type;
1548 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1549 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1550 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1551 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1552 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1553 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1554 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1555 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1558 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1560 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1563 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1565 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n");