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 .float nade_time_primed;
167 .float nade_lifetime;
169 .entity nade_spawnloc;
172 void nade_timer_think(entity this)
174 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
175 this.nextthink = time;
176 if(!this.owner || wasfreed(this.owner))
180 void nade_burn_spawn(entity _nade)
182 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
185 void nade_spawn(entity _nade)
187 entity timer = new(nade_timer);
188 setmodel(timer, MDL_NADE_TIMER);
189 setattachment(timer, _nade, "");
190 timer.colormap = _nade.colormap;
191 timer.glowmod = _nade.glowmod;
192 setthink(timer, nade_timer_think);
193 timer.nextthink = time;
194 timer.wait = _nade.wait;
198 _nade.effects |= EF_LOWPRECISION;
200 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
203 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
212 RandomSelection_Init();
213 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
214 if(e.takedamage == DAMAGE_AIM)
215 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
216 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
220 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
221 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
222 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
223 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
226 e.fireball_impactvec = p;
227 RandomSelection_AddEnt(e, 1 / (1 + d), !StatusEffects_active(STATUSEFFECT_Burning, e));
230 if(RandomSelection_chosen_ent)
232 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
233 d = damage + (edgedamage - damage) * (d / dist);
234 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
235 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
236 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
241 void napalm_ball_think(entity this)
243 if(round_handler_IsActive())
244 if(!round_handler_IsRoundStarted())
250 if(time > this.pushltime)
256 vector midpoint = ((this.absmin + this.absmax) * 0.5);
257 if(pointcontents(midpoint) == CONTENT_WATER)
259 this.velocity = this.velocity * 0.5;
261 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
262 { this.velocity_z = 200; }
265 this.angles = vectoangles(this.velocity);
267 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
268 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
270 this.nextthink = time + 0.1;
274 void nade_napalm_ball(entity this)
279 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
282 proj.owner = this.owner;
283 proj.realowner = this.realowner;
284 proj.team = this.owner.team;
285 proj.bot_dodge = true;
286 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
287 set_movetype(proj, MOVETYPE_BOUNCE);
288 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
289 PROJECTILE_MAKETRIGGER(proj);
290 setmodel(proj, MDL_Null);
291 proj.scale = 1;//0.5;
292 setsize(proj, '-4 -4 -4', '4 4 4');
293 setorigin(proj, this.origin);
294 setthink(proj, napalm_ball_think);
295 proj.nextthink = time;
296 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
297 proj.effects = EF_LOWPRECISION | EF_FLAME;
299 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
300 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
301 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
302 proj.velocity = kick;
304 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
306 proj.angles = vectoangles(proj.velocity);
307 proj.flags = FL_PROJECTILE;
308 IL_PUSH(g_projectiles, proj);
309 IL_PUSH(g_bot_dodge, proj);
310 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
312 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
316 void napalm_fountain_think(entity this)
319 if(round_handler_IsActive())
320 if(!round_handler_IsRoundStarted())
326 if(time >= this.ltime)
332 vector midpoint = ((this.absmin + this.absmax) * 0.5);
333 if(pointcontents(midpoint) == CONTENT_WATER)
335 this.velocity = this.velocity * 0.5;
337 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
338 { this.velocity_z = 200; }
340 UpdateCSQCProjectile(this);
343 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
344 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
346 this.nextthink = time + 0.1;
347 if(time >= this.nade_special_time)
349 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
350 nade_napalm_ball(this);
354 void nade_napalm_boom(entity this)
356 for (int c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
357 nade_napalm_ball(this);
359 entity fountain = new(nade_napalm_fountain);
360 fountain.owner = this.owner;
361 fountain.realowner = this.realowner;
362 fountain.origin = this.origin;
363 fountain.flags = FL_PROJECTILE;
364 IL_PUSH(g_projectiles, fountain);
365 IL_PUSH(g_bot_dodge, fountain);
366 setorigin(fountain, fountain.origin);
367 setthink(fountain, napalm_fountain_think);
368 fountain.nextthink = time;
369 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
370 fountain.pushltime = fountain.ltime;
371 fountain.team = this.team;
372 set_movetype(fountain, MOVETYPE_TOSS);
373 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
374 fountain.bot_dodge = true;
375 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
376 fountain.nade_special_time = time;
377 setsize(fountain, '-16 -16 -16', '16 16 16');
378 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
381 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
383 frost_target.frozen_by = freezefield.realowner;
384 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
385 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
387 Drop_Special_Items(frost_target);
390 void nade_ice_think(entity this)
392 if(round_handler_IsActive())
393 if(!round_handler_IsRoundStarted())
399 if(time >= this.ltime)
401 if ( autocvar_g_nades_ice_explode )
403 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
404 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
405 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
407 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
408 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
409 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
410 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
417 this.nextthink = time+0.1;
422 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
424 randomw = random()*M_PI*2;
426 randomp.x = randomr*cos(randomw);
427 randomp.y = randomr*sin(randomw);
429 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
431 if(time >= this.nade_special_time)
433 this.nade_special_time = time+0.7;
435 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
436 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
440 float current_freeze_time = this.ltime - time - 0.1;
442 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,
444 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
445 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
446 if(!STAT(FROZEN, it))
447 nade_ice_freeze(this, it, current_freeze_time);
451 void nade_ice_boom(entity this)
453 entity fountain = new(nade_ice_fountain);
454 fountain.owner = this.owner;
455 fountain.realowner = this.realowner;
456 fountain.origin = this.origin;
457 setorigin(fountain, fountain.origin);
458 setthink(fountain, nade_ice_think);
459 fountain.nextthink = time;
460 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
461 fountain.pushltime = fountain.wait = fountain.ltime;
462 fountain.team = this.team;
463 set_movetype(fountain, MOVETYPE_TOSS);
464 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
465 fountain.bot_dodge = false;
466 setsize(fountain, '-16 -16 -16', '16 16 16');
467 fountain.nade_special_time = time+0.3;
468 fountain.angles = this.angles;
470 if ( autocvar_g_nades_ice_explode )
472 setmodel(fountain, MDL_PROJECTILE_GRENADE);
473 entity timer = new(nade_timer);
474 setmodel(timer, MDL_NADE_TIMER);
475 setattachment(timer, fountain, "");
476 timer.colormap = this.colormap;
477 timer.glowmod = this.glowmod;
478 setthink(timer, nade_timer_think);
479 timer.nextthink = time;
480 timer.wait = fountain.ltime;
481 timer.owner = fountain;
485 setmodel(fountain, MDL_Null);
488 void nade_translocate_boom(entity this)
490 if(this.realowner.vehicle)
493 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
494 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
495 locout = trace_endpos;
497 makevectors(this.realowner.angles);
499 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
501 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
504 void nade_spawn_boom(entity this)
506 entity player = this.realowner;
507 entity spawnloc = new(nade_spawn_loc);
508 setorigin(spawnloc, this.origin);
509 setsize(spawnloc, player.mins, player.maxs);
510 set_movetype(spawnloc, MOVETYPE_NONE);
511 spawnloc.solid = SOLID_NOT;
512 spawnloc.drawonlytoclient = player;
513 spawnloc.effects = EF_STARDUST;
514 spawnloc.cnt = autocvar_g_nades_spawn_count;
516 if(player.nade_spawnloc)
517 delete(player.nade_spawnloc);
519 player.nade_spawnloc = spawnloc;
522 void nades_orb_think(entity this)
524 if(time >= this.ltime)
530 this.nextthink = time;
532 if(time >= this.nade_special_time)
534 this.nade_special_time = time+0.25;
535 this.nade_show_particles = 1;
538 this.nade_show_particles = 0;
541 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
543 // NOTE: this function merely places an orb
544 // you must add a custom touch function to the returned entity if desired
545 // also set .colormod if you wish to have it colorized
546 entity orb = new(nades_spawn_orb);
548 orb.realowner = realown;
551 orb.orb_lifetime = orb_ltime; // required for timers
552 orb.ltime = time + orb.orb_lifetime;
553 orb.bot_dodge = false;
554 orb.team = realown.team;
555 orb.solid = SOLID_TRIGGER;
557 setmodel(orb, MDL_NADE_ORB);
559 orb.orb_radius = orb_rad; // required for fading
560 vector size = '1 1 1' * orb.orb_radius / 2;
561 setsize(orb, -size, size);
563 Net_LinkEntity(orb, true, 0, orb_send);
566 setthink(orb, nades_orb_think);
567 orb.nextthink = time;
572 void nade_entrap_touch(entity this, entity toucher)
574 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
576 if (!isPushable(toucher))
579 float pushdeltatime = time - toucher.lastpushtime;
580 if (pushdeltatime > 0.15) pushdeltatime = 0;
581 toucher.lastpushtime = time;
582 if(!pushdeltatime) return;
584 // div0: ticrate independent, 1 = identity (not 20)
585 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
588 UpdateCSQCProjectile(toucher);
592 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
594 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
595 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
597 float tint_alpha = 0.75;
598 if(SAME_TEAM(toucher, this.realowner))
600 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
604 void nade_entrap_boom(entity this)
606 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
608 settouch(orb, nade_entrap_touch);
609 orb.colormod = NADE_TYPE_ENTRAP.m_color;
612 void nade_heal_touch(entity this, entity toucher)
616 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
617 if(!IS_DEAD(toucher))
618 if(!STAT(FROZEN, toucher))
620 health_factor = autocvar_g_nades_heal_rate*frametime/2;
621 if ( toucher != this.realowner )
623 if ( SAME_TEAM(toucher,this) )
624 health_factor *= autocvar_g_nades_heal_friend;
626 health_factor *= autocvar_g_nades_heal_foe;
628 if ( health_factor > 0 )
630 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
631 float hp = GetResource(toucher, RES_HEALTH);
634 if (this.nade_show_particles)
636 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
638 GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
641 else if ( health_factor < 0 )
643 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
648 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
650 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
651 STAT(HEALING_ORB, show_red) = time+0.1;
652 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
656 void nade_heal_boom(entity this)
658 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
660 settouch(orb, nade_heal_touch);
661 orb.colormod = '1 0 0';
664 void nade_monster_boom(entity this)
667 e.noalign = true; // don't drop to floor
668 e = spawnmonster(e, this.pokenade_type, MON_Null, this.realowner, this.realowner, this.origin, false, false, 1);
670 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
671 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
672 e.monster_skill = MONSTER_SKILL_INSANE;
675 void nade_veil_touch(entity this, entity toucher)
677 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
679 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
681 float tint_alpha = 0.75;
682 if(SAME_TEAM(toucher, this.realowner))
685 if(!STAT(VEIL_ORB, show_tint))
687 toucher.nade_veil_prevalpha = toucher.alpha;
691 STAT(VEIL_ORB, show_tint) = time + 0.1;
692 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
696 void nade_veil_boom(entity this)
698 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
700 settouch(orb, nade_veil_touch);
701 orb.colormod = NADE_TYPE_VEIL.m_color;
704 void nade_boom(entity this)
707 bool nade_blast = true;
709 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
711 case NADE_TYPE_NAPALM:
712 nade_blast = autocvar_g_nades_napalm_blast;
713 expef = EFFECT_EXPLOSION_MEDIUM;
717 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
719 case NADE_TYPE_TRANSLOCATE:
722 case NADE_TYPE_MONSTER:
723 case NADE_TYPE_SPAWN:
725 switch(this.realowner.team)
727 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
728 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
729 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
730 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
731 default: expef = EFFECT_SPAWN_NEUTRAL; break;
736 expef = EFFECT_SPAWN_RED;
739 case NADE_TYPE_ENTRAP:
741 expef = EFFECT_SPAWN_YELLOW;
746 expef = EFFECT_SPAWN_NEUTRAL;
750 case NADE_TYPE_NORMAL:
751 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
756 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
758 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
759 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
761 this.event_damage = func_null; // prevent somehow calling damage in the next call
765 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
766 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
767 Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
771 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
773 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
774 case NADE_TYPE_ICE: nade_ice_boom(this); break;
775 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
776 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
777 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
778 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
779 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
780 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
783 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
791 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
792 void nade_pickup(entity this, entity thenade)
794 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
796 // set refire so player can't even
797 this.nade_refire = time + autocvar_g_nades_nade_refire;
798 STAT(NADE_TIMER, this) = 0;
801 this.nade.nade_time_primed = thenade.nade_time_primed;
804 bool CanThrowNade(entity this);
805 void nade_touch(entity this, entity toucher)
808 UpdateCSQCProjectile(this);
810 if(toucher == this.realowner)
811 return; // no this impacts
813 if(autocvar_g_nades_pickup)
814 if(time >= this.spawnshieldtime)
815 if(!toucher.nade && GetResource(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
816 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
817 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
819 nade_pickup(toucher, this);
820 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
824 /*float is_weapclip = 0;
825 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
826 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
827 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
829 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
831 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
839 PROJECTILE_TOUCH(this, toucher);
841 //setsize(this, '-2 -2 -2', '2 2 2');
842 //UpdateCSQCProjectile(this);
843 if(GetResource(this, RES_HEALTH) == this.max_health)
845 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
849 this.enemy = toucher;
853 void nade_beep(entity this)
855 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
856 setthink(this, nade_boom);
857 this.nextthink = max(this.wait, time);
860 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
862 if(ITEM_DAMAGE_NEEDKILL(deathtype))
864 this.takedamage = DAMAGE_NO;
869 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
872 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
873 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
878 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
880 force *= 0.5; // too much
883 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
886 damage = this.max_health * 0.55;
888 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
889 damage = this.max_health * 0.1;
890 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_SHOTGUN)) // WEAPONTODO
892 if(!(deathtype & HITTYPE_SECONDARY))
893 damage = this.max_health * 1.15;
897 entity death_weapon = DEATH_WEAPONOF(deathtype);
898 if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
900 damage = this.max_health * 0.1;
904 this.velocity += force;
905 UpdateCSQCProjectile(this);
907 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
910 float hp = GetResource(this, RES_HEALTH);
911 if(hp == this.max_health)
913 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
914 this.nextthink = max(time + this.nade_lifetime, time);
915 setthink(this, nade_beep);
919 SetResource(this, RES_HEALTH, hp);
922 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
923 this.realowner = attacker;
926 W_PrepareExplosionByDamage(this, attacker, nade_boom);
928 nade_burn_spawn(this);
931 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
936 entity _nade = e.nade;
943 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
945 makevectors(e.v_angle);
947 // NOTE: always throw from first weapon entity?
948 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
950 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
951 + (v_right * autocvar_g_nades_throw_offset.y)
952 + (v_up * autocvar_g_nades_throw_offset.z);
954 setorigin(_nade, w_shotorg + offset);
955 //setmodel(_nade, MDL_PROJECTILE_NADE);
956 //setattachment(_nade, NULL, "");
957 PROJECTILE_MAKETRIGGER(_nade);
958 if(STAT(NADES_SMALL, e))
959 setsize(_nade, '-8 -8 -8', '8 8 8');
961 setsize(_nade, '-16 -16 -16', '16 16 16');
962 set_movetype(_nade, MOVETYPE_BOUNCE);
964 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
965 if (trace_startsolid)
966 setorigin(_nade, e.origin);
968 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
969 _nade.velocity = '0 0 100';
970 else if(autocvar_g_nades_nade_newton_style == 1)
971 _nade.velocity = e.velocity + _velocity;
972 else if(autocvar_g_nades_nade_newton_style == 2)
973 _nade.velocity = _velocity;
975 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
980 settouch(_nade, nade_touch);
981 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
982 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
983 _nade.max_health = GetResource(_nade, RES_HEALTH);
984 _nade.takedamage = DAMAGE_AIM;
985 _nade.event_damage = nade_damage;
986 setcefc(_nade, func_null);
987 _nade.exteriormodeltoclient = NULL;
988 _nade.traileffectnum = 0;
989 _nade.teleportable = true;
990 _nade.pushable = true;
992 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
993 _nade.damagedbycontents = true;
994 IL_PUSH(g_damagedbycontents, _nade);
995 _nade.angles = vectoangles(_nade.velocity);
996 _nade.flags = FL_PROJECTILE;
997 IL_PUSH(g_projectiles, _nade);
998 IL_PUSH(g_bot_dodge, _nade);
999 _nade.projectiledeathtype = DEATH_NADE.m_id;
1000 _nade.toss_time = time;
1001 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1003 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1004 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1006 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1012 setthink(_nade, nade_boom);
1013 _nade.nextthink = _time;
1016 e.nade_refire = time + autocvar_g_nades_nade_refire;
1017 STAT(NADE_TIMER, e) = 0;
1020 void nades_GiveBonus(entity player, float score)
1022 if (autocvar_g_nades)
1023 if (autocvar_g_nades_bonus)
1024 if (IS_REAL_CLIENT(player))
1025 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1026 if (!STAT(FROZEN, player))
1027 if (!IS_DEAD(player))
1029 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1030 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1032 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1034 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1035 play2(player, SND(NADE_BONUS));
1036 STAT(NADE_BONUS, player)++;
1037 STAT(NADE_BONUS_SCORE, player) -= 1;
1042 /** Remove all bonus nades from a player */
1043 void nades_RemoveBonus(entity player)
1045 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1048 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1050 entity player = M_ARGV(0, entity);
1052 nades_RemoveBonus(player);
1055 bool nade_customize(entity this, entity client)
1057 //if(IS_SPEC(client)) { return false; }
1058 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1060 // somewhat hide the model, but keep the glow
1062 if(this.traileffectnum)
1063 this.traileffectnum = 0;
1068 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1069 if(!this.traileffectnum)
1071 entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
1072 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[false], this.team).eent_eff_name);
1080 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1082 entity n = new(nade), fn = new(fake_nade);
1084 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1085 n.pokenade_type = pntype;
1087 if(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1088 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1090 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1092 setmodel(n, MDL_PROJECTILE_NADE);
1093 //setattachment(n, player, "bip01 l hand");
1094 n.exteriormodeltoclient = player;
1095 setcefc(n, nade_customize);
1096 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1097 n.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1098 n.realowner = nowner;
1099 n.colormap = player.colormap;
1100 n.glowmod = player.glowmod;
1101 n.wait = time + max(0, ntime);
1102 n.nade_time_primed = time;
1103 setthink(n, nade_beep);
1104 n.nextthink = max(n.wait - 3, time);
1105 n.projectiledeathtype = DEATH_NADE.m_id;
1106 n.weaponentity_fld = weaponentity;
1107 n.nade_lifetime = ntime;
1108 n.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1110 setmodel(fn, MDL_NADE_VIEW);
1111 //setattachment(fn, player.(weaponentity), "");
1112 fn.viewmodelforclient = player;
1113 fn.realowner = fn.owner = player;
1114 fn.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1115 fn.colormap = player.colormap;
1116 fn.glowmod = player.glowmod;
1117 setthink(fn, SUB_Remove);
1118 fn.nextthink = n.wait;
1119 fn.weaponentity_fld = weaponentity;
1120 fn.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1123 player.fake_nade = fn;
1126 void nade_prime(entity this)
1128 if(autocvar_g_nades_bonus_only && !STAT(NADE_BONUS, this))
1129 return; // only allow bonus nades
1131 // TODO: handle old nade if it exists?
1137 delete(this.fake_nade);
1138 this.fake_nade = NULL;
1141 string pntype = this.pokenade_type;
1143 if(StatusEffects_active(STATUSEFFECT_Strength, this) && autocvar_g_nades_bonus_onstrength)
1144 ntype = STAT(NADE_BONUS_TYPE, this);
1145 else if (STAT(NADE_BONUS, this) >= 1)
1147 ntype = STAT(NADE_BONUS_TYPE, this);
1148 pntype = this.pokenade_type;
1149 STAT(NADE_BONUS, this) -= 1;
1153 ntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1154 pntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1157 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1160 bool CanThrowNade(entity this)
1162 return !(this.vehicle || !autocvar_g_nades || IS_DEAD(this) || !IS_PLAYER(this) || weaponLocked(this));
1165 .bool nade_altbutton;
1167 void nades_CheckThrow(entity this)
1169 if(!CanThrowNade(this))
1172 entity held_nade = this.nade;
1175 this.nade_altbutton = true;
1176 if(time > this.nade_refire)
1179 this.nade_refire = time + autocvar_g_nades_nade_refire;
1184 this.nade_altbutton = false;
1185 if (time >= held_nade.nade_time_primed + 1) {
1186 makevectors(this.v_angle);
1187 float _force = time - held_nade.nade_time_primed;
1188 _force /= autocvar_g_nades_nade_lifetime;
1189 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1190 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1191 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1192 toss_nade(this, true, dir * _force, 0);
1197 void nades_Clear(entity player)
1200 delete(player.nade);
1201 if(player.fake_nade)
1202 delete(player.fake_nade);
1204 player.nade = player.fake_nade = NULL;
1205 STAT(NADE_TIMER, player) = 0;
1208 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1210 entity player = M_ARGV(0, entity);
1213 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1216 CLASS(NadeOffhand, OffhandWeapon)
1217 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1219 entity held_nade = player.nade;
1221 if (!CanThrowNade(player)) return;
1222 if (!(time > player.nade_refire)) return;
1226 held_nade = player.nade;
1228 } else if (time >= held_nade.nade_time_primed + 1) {
1230 makevectors(player.v_angle);
1231 float _force = time - held_nade.nade_time_primed;
1232 _force /= autocvar_g_nades_nade_lifetime;
1233 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1234 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1235 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1236 toss_nade(player, false, dir * _force, 0);
1240 ENDCLASS(NadeOffhand)
1241 NadeOffhand OFFHAND_NADE;
1242 REGISTER_MUTATOR(nades, autocvar_g_nades)
1246 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);
1261 #ifdef IN_REVIVING_RANGE
1262 #undef IN_REVIVING_RANGE
1265 // returns true if player is reviving it
1266 #define IN_REVIVING_RANGE(player, it, revive_extra_size) \
1267 (it != player && !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))))
1277 OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1279 entity held_nade = player.nade;
1282 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1283 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1284 makevectors(player.angles);
1285 held_nade.velocity = player.velocity;
1286 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1287 held_nade.angles_y = player.angles.y;
1289 if (time + 0.1 >= held_nade.wait)
1291 toss_nade(player, false, '0 0 0', time + 0.05);
1292 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_THROW);
1296 if(IS_PLAYER(player))
1298 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1301 float key_count = 0;
1302 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1305 if(GameRules_scoring_is_vip(player))
1306 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1308 time_score = autocvar_g_nades_bonus_score_time;
1311 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1313 if(autocvar_g_nades_bonus_client_select)
1315 STAT(NADE_BONUS_TYPE, player) = CS_CVAR(player).cvar_cl_nade_type;
1316 player.pokenade_type = CS_CVAR(player).cvar_cl_pokenade_type;
1320 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1321 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1324 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1326 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1327 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1331 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1334 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1336 STAT(VEIL_ORB, player) = 0;
1338 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1340 player.alpha = player.nade_veil_prevalpha;
1344 if (!(frametime && IS_PLAYER(player)))
1347 entity revivers_last = NULL;
1348 entity revivers_first = NULL;
1350 bool player_is_reviving = false;
1352 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1353 FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), {
1354 // check if player is reviving anyone
1355 if (STAT(FROZEN, it) == FROZEN_TEMP_DYING)
1357 if ((STAT(FROZEN, player) == FROZEN_TEMP_DYING))
1359 if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
1361 player_is_reviving = true;
1365 if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING))
1366 continue; // both player and it are NOT frozen
1368 revivers_last.chain = it;
1370 if (!revivers_first)
1371 revivers_first = it;
1375 revivers_last.chain = NULL;
1377 if (!n) // no teammate nearby
1379 // freezetag already resets revive progress
1380 if (!g_freezetag && !STAT(FROZEN, player) && !player_is_reviving)
1381 STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
1383 else if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1385 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1386 // undo what PlayerPreThink did
1387 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * player.revive_speed, 1);
1388 SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1390 if(STAT(REVIVE_PROGRESS, player) >= 1)
1392 Unfreeze(player, false);
1394 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
1395 Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1398 for(entity it = revivers_first; it; it = it.chain)
1399 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1403 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1405 entity player = M_ARGV(0, entity);
1406 // these automatically reset, no need to worry
1408 if(STAT(ENTRAP_ORB, player) > time)
1409 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1412 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1414 entity mon = M_ARGV(0, entity);
1416 if (STAT(ENTRAP_ORB, mon) > time)
1418 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1419 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1422 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1424 mon.alpha = mon.nade_veil_prevalpha;
1425 STAT(VEIL_ORB, mon) = 0;
1429 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1431 entity player = M_ARGV(0, entity);
1433 if(autocvar_g_nades_spawn)
1434 player.nade_refire = time + autocvar_g_spawnshieldtime;
1436 player.nade_refire = time + autocvar_g_nades_nade_refire;
1438 if(autocvar_g_nades_bonus_client_select)
1439 STAT(NADE_BONUS_TYPE, player) = CS_CVAR(player).cvar_cl_nade_type;
1441 STAT(NADE_TIMER, player) = 0;
1443 if (!player.offhand) player.offhand = OFFHAND_NADE;
1445 if(player.nade_spawnloc)
1447 setorigin(player, player.nade_spawnloc.origin);
1448 player.nade_spawnloc.cnt -= 1;
1450 if(player.nade_spawnloc.cnt <= 0)
1452 delete(player.nade_spawnloc);
1453 player.nade_spawnloc = NULL;
1458 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1460 entity frag_attacker = M_ARGV(1, entity);
1461 entity frag_target = M_ARGV(2, entity);
1463 if(frag_target.nade)
1464 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1465 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1467 if(IS_PLAYER(frag_attacker))
1469 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)
1470 : autocvar_g_nades_bonus_score_minor);
1471 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1472 nades_RemoveBonus(frag_attacker);
1473 else if(GameRules_scoring_is_vip(frag_target))
1474 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1475 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1477 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1478 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1479 switch(CS(frag_attacker).killcount)
1482 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1487 nades_GiveBonus(frag_attacker, killcount_bonus);
1490 nades_RemoveBonus(frag_target);
1493 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1495 entity frag_inflictor = M_ARGV(0, entity);
1496 entity frag_attacker = M_ARGV(1, entity);
1497 entity frag_target = M_ARGV(2, entity);
1498 float frag_deathtype = M_ARGV(3, float);
1500 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1501 if(time - frag_inflictor.toss_time <= 0.1)
1503 Unfreeze(frag_target, false);
1504 SetResource(frag_target, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
1505 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1506 M_ARGV(4, float) = 0;
1507 M_ARGV(6, vector) = '0 0 0';
1508 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1509 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1513 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1515 entity frag_target = M_ARGV(0, entity);
1516 entity frag_attacker = M_ARGV(1, entity);
1518 if(IS_PLAYER(frag_attacker))
1519 if(DIFF_TEAM(frag_attacker, frag_target))
1520 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1521 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1524 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1526 entity frag_target = M_ARGV(0, entity);
1528 if(frag_target.nade)
1529 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1532 void nades_RemovePlayer(entity this)
1535 nades_RemoveBonus(this);
1538 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1539 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1540 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1542 FOREACH_CLIENT(IS_PLAYER(it),
1544 nades_RemovePlayer(it);
1548 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1550 entity spectatee = M_ARGV(0, entity);
1551 entity client = M_ARGV(1, entity);
1553 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1554 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1555 client.pokenade_type = spectatee.pokenade_type;
1556 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1557 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1558 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1559 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1560 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1561 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1562 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1563 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1566 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1568 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1571 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1573 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' (dropweapon) to use them\n");