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)
15 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
16 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
18 entity Nade_TrailEffect(int proj, int nade_team)
22 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
23 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
26 FOREACH(Nades, true, {
27 for (int j = 0; j < 2; j++)
29 if (it.m_projectile[j] == proj)
31 string trail = it.m_trail[j].eent_eff_name;
32 if (trail) return it.m_trail[j];
43 REGISTER_MUTATOR(cl_nades, true);
44 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
46 entity proj = M_ARGV(0, entity);
48 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
51 proj.traileffect = EFFECT_FIREBALL.m_id;
54 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
56 setmodel(proj, MDL_PROJECTILE_NADE);
57 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
58 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
62 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
64 entity proj = M_ARGV(0, entity);
66 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
68 loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
69 proj.mins = '-16 -16 -16';
70 proj.maxs = '16 16 16';
73 entity nade_type = Nade_FromProjectile(proj.cnt);
74 if (nade_type == NADE_TYPE_Null) return;
77 proj.mins = '-8 -8 -8';
82 proj.mins = '-16 -16 -16';
83 proj.maxs = '16 16 16';
85 proj.colormod = nade_type.m_color;
86 set_movetype(proj, MOVETYPE_BOUNCE);
87 settouch(proj, func_null);
89 proj.avelocity = randomvec() * 720;
90 proj.alphamod = nade_type.m_alpha;
92 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
93 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
95 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
98 MUTATOR_HOOKFUNCTION(cl_nades, BuildGameplayTipsString)
100 if (mut_is_active(MUT_NADES))
102 string key = getcommandkey(_("drop weapon / throw nade"), "dropweapon");
103 M_ARGV(0, string) = strcat(M_ARGV(0, string),
104 "\n", sprintf(_("^3nades^8 are enabled, press ^3%s^8 to use them"), key), "\n");
108 bool Projectile_isnade(int p)
110 return Nade_FromProjectile(p) != NADE_TYPE_Null;
112 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
114 float bonusNades = STAT(NADE_BONUS);
115 float bonusProgress = STAT(NADE_BONUS_SCORE);
116 float bonusType = STAT(NADE_BONUS_TYPE);
117 Nade def = REGISTRY_GET(Nades, bonusType);
118 vector nadeColor = def.m_color;
119 string nadeIcon = def.m_icon;
121 vector iconPos, textPos;
123 if(autocvar_hud_panel_ammo_iconalign)
125 iconPos = myPos + eX * 2 * mySize.y;
131 textPos = myPos + eX * mySize.y;
134 if(bonusNades > 0 || bonusProgress > 0)
136 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
138 if(autocvar_hud_panel_ammo_text)
139 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
142 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
144 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
151 #include <common/gamemodes/_mod.qh>
152 #include <common/monsters/sv_spawn.qh>
153 #include <common/monsters/sv_monsters.qh>
155 .float nade_time_primed;
156 .float nade_lifetime;
158 .entity nade_spawnloc;
161 void nade_timer_think(entity this)
163 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
164 this.nextthink = time;
165 if(!this.owner || wasfreed(this.owner))
169 void nade_burn_spawn(entity _nade)
171 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
174 void nade_spawn(entity _nade)
176 entity timer = new(nade_timer);
177 setmodel(timer, MDL_NADE_TIMER);
178 setattachment(timer, _nade, "");
179 timer.colormap = _nade.colormap;
180 timer.glowmod = _nade.glowmod;
181 setthink(timer, nade_timer_think);
182 timer.nextthink = time;
183 timer.wait = _nade.wait;
187 _nade.effects |= EF_LOWPRECISION;
189 CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
192 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
201 RandomSelection_Init();
202 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
203 if(e.takedamage == DAMAGE_AIM)
204 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
205 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
209 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
210 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
211 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
212 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
215 e.fireball_impactvec = p;
216 RandomSelection_AddEnt(e, 1 / (1 + d), !StatusEffects_active(STATUSEFFECT_Burning, e));
219 if(RandomSelection_chosen_ent)
221 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
222 d = damage + (edgedamage - damage) * (d / dist);
223 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
224 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
225 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
230 void napalm_ball_think(entity this)
232 if(round_handler_IsActive())
233 if(!round_handler_IsRoundStarted())
239 if(time > this.pushltime)
245 vector midpoint = ((this.absmin + this.absmax) * 0.5);
246 if(pointcontents(midpoint) == CONTENT_WATER)
248 this.velocity = this.velocity * 0.5;
250 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
251 { this.velocity_z = 200; }
254 this.angles = vectoangles(this.velocity);
256 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
257 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
259 this.nextthink = time + 0.1;
263 void nade_napalm_ball(entity this)
268 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
271 proj.owner = this.owner;
272 proj.realowner = this.realowner;
273 proj.team = this.owner.team;
274 proj.bot_dodge = true;
275 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
276 set_movetype(proj, MOVETYPE_BOUNCE);
277 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
278 PROJECTILE_MAKETRIGGER(proj);
279 setmodel(proj, MDL_Null);
280 proj.scale = 1;//0.5;
281 setsize(proj, '-4 -4 -4', '4 4 4');
282 setorigin(proj, this.origin);
283 setthink(proj, napalm_ball_think);
284 proj.nextthink = time;
285 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
286 proj.effects = EF_LOWPRECISION | EF_FLAME;
288 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
289 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
290 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
291 proj.velocity = kick;
293 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
295 proj.angles = vectoangles(proj.velocity);
296 proj.flags = FL_PROJECTILE;
297 IL_PUSH(g_projectiles, proj);
298 IL_PUSH(g_bot_dodge, proj);
299 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
301 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
305 void napalm_fountain_think(entity this)
308 if(round_handler_IsActive())
309 if(!round_handler_IsRoundStarted())
315 if(time >= this.ltime)
321 vector midpoint = ((this.absmin + this.absmax) * 0.5);
322 if(pointcontents(midpoint) == CONTENT_WATER)
324 this.velocity = this.velocity * 0.5;
326 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
327 { this.velocity_z = 200; }
329 UpdateCSQCProjectile(this);
332 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
333 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
335 this.nextthink = time + 0.1;
336 if(time >= this.nade_special_time)
338 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
339 nade_napalm_ball(this);
343 void nade_napalm_boom(entity this)
345 for (int c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
346 nade_napalm_ball(this);
348 entity fountain = new(nade_napalm_fountain);
349 fountain.owner = this.owner;
350 fountain.realowner = this.realowner;
351 fountain.origin = this.origin;
352 fountain.flags = FL_PROJECTILE;
353 IL_PUSH(g_projectiles, fountain);
354 IL_PUSH(g_bot_dodge, fountain);
355 setorigin(fountain, fountain.origin);
356 setthink(fountain, napalm_fountain_think);
357 fountain.nextthink = time;
358 fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
359 fountain.pushltime = fountain.ltime;
360 fountain.team = this.team;
361 set_movetype(fountain, MOVETYPE_TOSS);
362 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
363 fountain.bot_dodge = true;
364 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
365 fountain.nade_special_time = time;
366 setsize(fountain, '-16 -16 -16', '16 16 16');
367 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
370 void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
372 frost_target.frozen_by = freezefield.realowner;
373 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
374 Freeze(frost_target, 1 / freezetime, FROZEN_TEMP_DYING, false);
376 Drop_Special_Items(frost_target);
379 void nade_ice_think(entity this)
381 if(round_handler_IsActive())
382 if(!round_handler_IsRoundStarted())
388 if(time >= this.ltime)
390 if ( autocvar_g_nades_ice_explode )
392 entity expef = EFFECT_NADE_EXPLODE(this.realowner.team);
393 Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1);
394 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
396 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
397 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
398 Damage_DamageInfo(this.origin, false, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
399 autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this);
406 this.nextthink = time+0.1;
411 randomr = exp(-5*randomr*randomr)*autocvar_g_nades_nade_radius;
413 randomw = random()*M_PI*2;
415 randomp.x = randomr*cos(randomw);
416 randomp.y = randomr*sin(randomw);
418 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
420 if(time >= this.nade_special_time)
422 this.nade_special_time = time+0.7;
424 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
425 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
429 float current_freeze_time = this.ltime - time - 0.1;
431 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,
433 if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
434 if(!it.revival_time || ((time - it.revival_time) >= 1.5))
435 if(!STAT(FROZEN, it))
436 nade_ice_freeze(this, it, current_freeze_time);
440 void nade_ice_boom(entity this)
442 entity fountain = new(nade_ice_fountain);
443 fountain.owner = this.owner;
444 fountain.realowner = this.realowner;
445 fountain.origin = this.origin;
446 setorigin(fountain, fountain.origin);
447 setthink(fountain, nade_ice_think);
448 fountain.nextthink = time;
449 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
450 fountain.pushltime = fountain.wait = fountain.ltime;
451 fountain.team = this.team;
452 set_movetype(fountain, MOVETYPE_TOSS);
453 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
454 fountain.bot_dodge = false;
455 setsize(fountain, '-16 -16 -16', '16 16 16');
456 fountain.nade_special_time = time+0.3;
457 fountain.angles = this.angles;
459 if ( autocvar_g_nades_ice_explode )
461 setmodel(fountain, MDL_PROJECTILE_GRENADE);
462 entity timer = new(nade_timer);
463 setmodel(timer, MDL_NADE_TIMER);
464 setattachment(timer, fountain, "");
465 timer.colormap = this.colormap;
466 timer.glowmod = this.glowmod;
467 setthink(timer, nade_timer_think);
468 timer.nextthink = time;
469 timer.wait = fountain.ltime;
470 timer.owner = fountain;
474 setmodel(fountain, MDL_Null);
477 void nade_translocate_boom(entity this)
479 if(this.realowner.vehicle)
482 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
483 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
484 locout = trace_endpos;
486 makevectors(this.realowner.angles);
488 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
490 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
493 void nade_spawn_boom(entity this)
495 entity player = this.realowner;
496 entity spawnloc = new(nade_spawn_loc);
497 setorigin(spawnloc, this.origin);
498 setsize(spawnloc, player.mins, player.maxs);
499 set_movetype(spawnloc, MOVETYPE_NONE);
500 spawnloc.solid = SOLID_NOT;
501 spawnloc.drawonlytoclient = player;
502 spawnloc.effects = EF_STARDUST;
503 spawnloc.cnt = autocvar_g_nades_spawn_count;
505 if(player.nade_spawnloc)
506 delete(player.nade_spawnloc);
508 player.nade_spawnloc = spawnloc;
511 void nades_orb_think(entity this)
513 if(time >= this.ltime)
519 this.nextthink = time;
521 if(time >= this.nade_special_time)
523 this.nade_special_time = time+0.25;
524 this.nade_show_particles = 1;
527 this.nade_show_particles = 0;
530 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
532 // NOTE: this function merely places an orb
533 // you must add a custom touch function to the returned entity if desired
534 // also set .colormod if you wish to have it colorized
535 entity orb = new(nades_spawn_orb);
537 orb.realowner = realown;
540 orb.orb_lifetime = orb_ltime; // required for timers
541 orb.ltime = time + orb.orb_lifetime;
542 orb.bot_dodge = false;
543 orb.team = realown.team;
544 orb.solid = SOLID_TRIGGER;
546 setmodel(orb, MDL_NADE_ORB);
548 orb.orb_radius = orb_rad; // required for fading
549 vector size = '1 1 1' * orb.orb_radius / 2;
550 setsize(orb, -size, size);
552 Net_LinkEntity(orb, true, 0, orb_send);
555 setthink(orb, nades_orb_think);
556 orb.nextthink = time;
561 void nade_entrap_touch(entity this, entity toucher)
563 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
565 if (!isPushable(toucher))
568 float pushdeltatime = time - toucher.lastpushtime;
569 if (pushdeltatime > 0.15) pushdeltatime = 0;
570 toucher.lastpushtime = time;
571 if(!pushdeltatime) return;
573 // div0: ticrate independent, 1 = identity (not 20)
574 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
577 UpdateCSQCProjectile(toucher);
581 if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) )
583 entity show_tint = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher;
584 show_tint.nade_entrap_time = time + 0.1;
588 void nade_entrap_boom(entity this)
590 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
592 settouch(orb, nade_entrap_touch);
593 orb.colormod = NADE_TYPE_ENTRAP.m_color;
596 void nade_heal_touch(entity this, entity toucher)
600 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
601 if(!IS_DEAD(toucher))
602 if(!STAT(FROZEN, toucher))
604 health_factor = autocvar_g_nades_heal_rate*frametime/2;
605 if ( toucher != this.realowner )
607 if ( SAME_TEAM(toucher,this) )
608 health_factor *= autocvar_g_nades_heal_friend;
610 health_factor *= autocvar_g_nades_heal_foe;
612 if ( health_factor > 0 )
614 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
615 float hp = GetResource(toucher, RES_HEALTH);
618 if (this.nade_show_particles)
620 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
622 GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
625 else if ( health_factor < 0 )
627 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
633 void nade_heal_boom(entity this)
635 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
637 settouch(orb, nade_heal_touch);
638 orb.colormod = '1 0 0';
641 void nade_monster_boom(entity this)
643 if(!autocvar_g_monsters)
646 e.noalign = true; // don't drop to floor
647 e = spawnmonster(e, this.pokenade_type, MON_Null, this.realowner, this.realowner, this.origin, false, false, 1);
649 return; // monster failed to be spawned
651 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
652 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
653 e.monster_skill = MONSTER_SKILL_INSANE;
656 void nade_veil_touch(entity this, entity toucher)
658 if ( IS_REAL_CLIENT(toucher) || (IS_VEHICLE(toucher) && toucher.owner) )
660 entity show_tint = (IS_VEHICLE(toucher) && toucher.owner) ? toucher.owner : toucher;
662 float tint_alpha = 0.75;
663 if(SAME_TEAM(toucher, this.realowner))
666 if(!show_tint.nade_veil_time)
668 toucher.nade_veil_prevalpha = toucher.alpha;
672 show_tint.nade_veil_time = time + 0.1;
676 void nade_veil_boom(entity this)
678 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
680 settouch(orb, nade_veil_touch);
681 orb.colormod = NADE_TYPE_VEIL.m_color;
684 void nade_boom(entity this)
687 bool nade_blast = true;
689 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
691 case NADE_TYPE_NAPALM:
692 nade_blast = autocvar_g_nades_napalm_blast;
693 expef = EFFECT_EXPLOSION_MEDIUM;
697 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
699 case NADE_TYPE_TRANSLOCATE:
702 case NADE_TYPE_MONSTER:
703 if(!autocvar_g_monsters)
705 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
706 break; // fall back to a standard nade explosion
708 case NADE_TYPE_SPAWN:
710 switch(this.realowner.team)
712 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
713 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
714 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
715 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
716 default: expef = EFFECT_SPAWN_NEUTRAL; break;
721 expef = EFFECT_SPAWN_RED;
724 case NADE_TYPE_ENTRAP:
726 expef = EFFECT_SPAWN_YELLOW;
731 expef = EFFECT_SPAWN_NEUTRAL;
735 case NADE_TYPE_NORMAL:
736 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
741 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
743 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
744 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
746 this.event_damage = func_null; // prevent somehow calling damage in the next call
750 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
751 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
752 Damage_DamageInfo(this.origin, false, 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);
756 switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
758 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
759 case NADE_TYPE_ICE: nade_ice_boom(this); break;
760 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
761 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
762 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
763 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
764 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
765 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
768 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
776 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
777 void nade_pickup(entity this, entity thenade)
779 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
781 // set refire so player can't even
782 this.nade_refire = time + autocvar_g_nades_nade_refire;
783 STAT(NADE_TIMER, this) = 0;
786 this.nade.nade_time_primed = thenade.nade_time_primed;
789 bool CanThrowNade(entity this);
790 void nade_touch(entity this, entity toucher)
793 UpdateCSQCProjectile(this);
795 if(toucher == this.realowner)
796 return; // no this impacts
798 if(autocvar_g_nades_pickup)
799 if(time >= this.spawnshieldtime)
800 if(!toucher.nade && GetResource(this, RES_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
801 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
802 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
804 nade_pickup(toucher, this);
805 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
809 /*float is_weapclip = 0;
810 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
811 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
812 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
814 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
816 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
824 PROJECTILE_TOUCH(this, toucher);
826 //setsize(this, '-2 -2 -2', '2 2 2');
827 //UpdateCSQCProjectile(this);
828 if(GetResource(this, RES_HEALTH) == this.max_health)
830 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
834 this.enemy = toucher;
838 void nade_beep(entity this)
840 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
841 setthink(this, nade_boom);
842 this.nextthink = max(this.wait, time);
845 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
847 if(ITEM_DAMAGE_NEEDKILL(deathtype))
849 this.takedamage = DAMAGE_NO;
854 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
857 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
858 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
863 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
865 force *= 0.5; // too much
868 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_NEX))
871 damage = this.max_health * 0.55;
873 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_MACHINEGUN))
874 damage = this.max_health * 0.1;
875 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN) || DEATH_ISWEAPON(deathtype, WEP_OVERKILL_SHOTGUN)) // WEAPONTODO
877 if(!(deathtype & HITTYPE_SECONDARY))
878 damage = this.max_health * 1.15;
882 entity death_weapon = DEATH_WEAPONOF(deathtype);
883 if(((deathtype & HITTYPE_SECONDARY) ? (death_weapon.spawnflags & WEP_TYPE_MELEE_SEC) : (death_weapon.spawnflags & WEP_TYPE_MELEE_PRI)))
885 damage = this.max_health * 0.1;
889 this.velocity += force;
890 UpdateCSQCProjectile(this);
892 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
895 float hp = GetResource(this, RES_HEALTH);
896 if(hp == this.max_health)
898 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
899 this.nextthink = max(time + this.nade_lifetime, time);
900 setthink(this, nade_beep);
904 SetResource(this, RES_HEALTH, hp);
907 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
908 this.realowner = attacker;
911 W_PrepareExplosionByDamage(this, attacker, nade_boom);
913 nade_burn_spawn(this);
916 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
921 entity _nade = e.nade;
928 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
930 makevectors(e.v_angle);
932 // NOTE: always throw from first weapon entity?
933 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
935 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
936 + (v_right * autocvar_g_nades_throw_offset.y)
937 + (v_up * autocvar_g_nades_throw_offset.z);
939 setorigin(_nade, w_shotorg + offset);
940 //setmodel(_nade, MDL_PROJECTILE_NADE);
941 //setattachment(_nade, NULL, "");
942 PROJECTILE_MAKETRIGGER(_nade);
943 if(STAT(NADES_SMALL, e))
944 setsize(_nade, '-8 -8 -8', '8 8 8');
946 setsize(_nade, '-16 -16 -16', '16 16 16');
947 set_movetype(_nade, MOVETYPE_BOUNCE);
949 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
950 if (trace_startsolid)
951 setorigin(_nade, e.origin);
953 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
954 _nade.velocity = '0 0 100';
955 else if(autocvar_g_nades_nade_newton_style == 1)
956 _nade.velocity = e.velocity + _velocity;
957 else if(autocvar_g_nades_nade_newton_style == 2)
958 _nade.velocity = _velocity;
960 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
965 settouch(_nade, nade_touch);
966 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
967 SetResource(_nade, RES_HEALTH, autocvar_g_nades_nade_health);
968 _nade.max_health = GetResource(_nade, RES_HEALTH);
969 _nade.takedamage = DAMAGE_AIM;
970 _nade.event_damage = nade_damage;
971 setcefc(_nade, func_null);
972 _nade.exteriormodeltoclient = NULL;
973 _nade.traileffectnum = 0;
974 _nade.teleportable = true;
975 _nade.pushable = true;
977 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
978 _nade.damagedbycontents = true;
979 IL_PUSH(g_damagedbycontents, _nade);
980 _nade.angles = vectoangles(_nade.velocity);
981 _nade.flags = FL_PROJECTILE;
982 IL_PUSH(g_projectiles, _nade);
983 IL_PUSH(g_bot_dodge, _nade);
984 _nade.projectiledeathtype = DEATH_NADE.m_id;
985 _nade.toss_time = time;
986 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
988 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
989 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
991 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
997 setthink(_nade, nade_boom);
998 _nade.nextthink = _time;
1001 e.nade_refire = time + autocvar_g_nades_nade_refire;
1002 STAT(NADE_TIMER, e) = 0;
1005 void nades_GiveBonus(entity player, float score)
1007 if (autocvar_g_nades)
1008 if (autocvar_g_nades_bonus)
1009 if (IS_REAL_CLIENT(player))
1010 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1011 if (!STAT(FROZEN, player))
1012 if (!IS_DEAD(player))
1014 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1015 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1017 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1019 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1020 play2(player, SND(NADE_BONUS));
1021 STAT(NADE_BONUS, player)++;
1022 STAT(NADE_BONUS_SCORE, player) -= 1;
1027 /** Remove all bonus nades from a player */
1028 void nades_RemoveBonus(entity player)
1030 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1033 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1035 entity player = M_ARGV(0, entity);
1037 nades_RemoveBonus(player);
1040 bool nade_customize(entity this, entity client)
1042 //if(IS_SPEC(client)) { return false; }
1043 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1045 // somewhat hide the model, but keep the glow
1047 if(this.traileffectnum)
1048 this.traileffectnum = 0;
1053 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1054 if(!this.traileffectnum)
1056 entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
1057 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[false], this.team).eent_eff_name);
1065 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1067 entity n = new(nade), fn = new(fake_nade);
1069 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1070 n.pokenade_type = pntype;
1072 if(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1073 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1075 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1077 setmodel(n, MDL_PROJECTILE_NADE);
1078 //setattachment(n, player, "bip01 l hand");
1079 n.exteriormodeltoclient = player;
1080 setcefc(n, nade_customize);
1081 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1082 n.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1083 n.realowner = nowner;
1084 n.colormap = player.colormap;
1085 n.glowmod = player.glowmod;
1086 n.wait = time + max(0, ntime);
1087 n.nade_time_primed = time;
1088 setthink(n, nade_beep);
1089 n.nextthink = max(n.wait - 3, time);
1090 n.projectiledeathtype = DEATH_NADE.m_id;
1091 n.weaponentity_fld = weaponentity;
1092 n.nade_lifetime = ntime;
1093 n.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1095 setmodel(fn, MDL_NADE_VIEW);
1096 //setattachment(fn, player.(weaponentity), "");
1097 fn.viewmodelforclient = player;
1098 fn.realowner = fn.owner = player;
1099 fn.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
1100 fn.colormap = player.colormap;
1101 fn.glowmod = player.glowmod;
1102 setthink(fn, SUB_Remove);
1103 fn.nextthink = n.wait;
1104 fn.weaponentity_fld = weaponentity;
1105 fn.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
1108 player.fake_nade = fn;
1111 void nade_prime(entity this)
1113 if(autocvar_g_nades_bonus_only && !STAT(NADE_BONUS, this))
1114 return; // only allow bonus nades
1116 // TODO: handle old nade if it exists?
1122 delete(this.fake_nade);
1123 this.fake_nade = NULL;
1126 string pntype = this.pokenade_type;
1128 if(StatusEffects_active(STATUSEFFECT_Strength, this) && autocvar_g_nades_bonus_onstrength)
1129 ntype = STAT(NADE_BONUS_TYPE, this);
1130 else if (STAT(NADE_BONUS, this) >= 1)
1132 ntype = STAT(NADE_BONUS_TYPE, this);
1133 pntype = this.pokenade_type;
1134 STAT(NADE_BONUS, this) -= 1;
1138 ntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1139 pntype = ((autocvar_g_nades_client_select) ? CS_CVAR(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1142 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1145 bool CanThrowNade(entity this)
1147 return !(this.vehicle || !autocvar_g_nades || IS_DEAD(this) || !IS_PLAYER(this) || weaponLocked(this));
1150 .bool nade_altbutton;
1152 void nades_CheckThrow(entity this)
1154 if(!CanThrowNade(this))
1157 entity held_nade = this.nade;
1160 this.nade_altbutton = true;
1161 if(time > this.nade_refire)
1164 this.nade_refire = time + autocvar_g_nades_nade_refire;
1169 this.nade_altbutton = false;
1170 if (time >= held_nade.nade_time_primed + 1) {
1171 makevectors(this.v_angle);
1172 float _force = time - held_nade.nade_time_primed;
1173 _force /= autocvar_g_nades_nade_lifetime;
1174 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1175 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1176 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1177 toss_nade(this, true, dir * _force, 0);
1182 void nades_Clear(entity player)
1185 delete(player.nade);
1186 if(player.fake_nade)
1187 delete(player.fake_nade);
1189 player.nade = player.fake_nade = NULL;
1190 STAT(NADE_TIMER, player) = 0;
1193 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1195 entity player = M_ARGV(0, entity);
1198 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1201 CLASS(NadeOffhand, OffhandWeapon)
1202 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1204 entity held_nade = player.nade;
1206 if (!CanThrowNade(player)) return;
1207 if (!(time > player.nade_refire)) return;
1211 held_nade = player.nade;
1213 } else if (time >= held_nade.nade_time_primed + 1) {
1215 makevectors(player.v_angle);
1216 float _force = time - held_nade.nade_time_primed;
1217 _force /= autocvar_g_nades_nade_lifetime;
1218 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1219 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1220 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, autocvar_g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1221 toss_nade(player, false, dir * _force, 0);
1225 ENDCLASS(NadeOffhand)
1226 NadeOffhand OFFHAND_NADE;
1227 REGISTER_MUTATOR(nades, autocvar_g_nades)
1231 OFFHAND_NADE = NEW(NadeOffhand);
1236 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1238 entity player = M_ARGV(0, entity);
1240 if (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1241 nades_CheckThrow(player);
1246 #ifdef IN_REVIVING_RANGE
1247 #undef IN_REVIVING_RANGE
1250 // returns true if player is reviving it
1251 #define IN_REVIVING_RANGE(player, it, revive_extra_size) \
1252 (it != player && !IS_DEAD(it) && SAME_TEAM(it, player) \
1253 && boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1255 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1257 entity player = M_ARGV(0, entity);
1259 if (!IS_PLAYER(player)) { return; }
1261 if (player.nade && (player.offhand != OFFHAND_NADE || (STAT(WEAPONS, player) & WEPSET(HOOK))))
1262 OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1264 entity held_nade = player.nade;
1267 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1268 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1269 makevectors(player.angles);
1270 held_nade.velocity = player.velocity;
1271 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1272 held_nade.angles_y = player.angles.y;
1274 if (time + 0.1 >= held_nade.wait)
1276 toss_nade(player, false, '0 0 0', time + 0.05);
1277 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_THROW);
1281 if(IS_PLAYER(player))
1283 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1286 float key_count = 0;
1287 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1290 if(GameRules_scoring_is_vip(player))
1291 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1293 time_score = autocvar_g_nades_bonus_score_time;
1296 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1298 if(autocvar_g_nades_bonus_client_select)
1300 STAT(NADE_BONUS_TYPE, player) = CS_CVAR(player).cvar_cl_nade_type;
1301 player.pokenade_type = CS_CVAR(player).cvar_cl_pokenade_type;
1305 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1306 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1309 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1311 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1312 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1316 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1319 if(player.nade_veil_time && player.nade_veil_time <= time)
1321 player.nade_veil_time = 0;
1323 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1325 player.alpha = player.nade_veil_prevalpha;
1329 if (!(frametime && IS_PLAYER(player)))
1332 entity revivers_last = NULL;
1333 entity revivers_first = NULL;
1335 bool player_is_reviving = false;
1337 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1338 FOREACH_CLIENT(IS_PLAYER(it) && IN_REVIVING_RANGE(player, it, revive_extra_size), {
1339 // check if player is reviving anyone
1340 if (STAT(FROZEN, it) == FROZEN_TEMP_DYING)
1342 if ((STAT(FROZEN, player) == FROZEN_TEMP_DYING))
1344 if (!IN_REVIVING_RANGE(player, it, revive_extra_size))
1346 player_is_reviving = true;
1350 if (!(STAT(FROZEN, player) == FROZEN_TEMP_DYING))
1351 continue; // both player and it are NOT frozen
1353 revivers_last.chain = it;
1355 if (!revivers_first)
1356 revivers_first = it;
1360 revivers_last.chain = NULL;
1362 if (!n) // no teammate nearby
1364 // freezetag already resets revive progress
1365 if (!g_freezetag && !STAT(FROZEN, player) && !player_is_reviving)
1366 STAT(REVIVE_PROGRESS, player) = 0; // thawing nobody
1368 else if (n > 0 && STAT(FROZEN, player) == FROZEN_TEMP_DYING) // OK, there is at least one teammate reviving us
1370 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1371 // undo what PlayerPreThink did
1372 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * player.revive_speed, 1);
1373 SetResource(player, RES_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1375 if(STAT(REVIVE_PROGRESS, player) >= 1)
1377 Unfreeze(player, false);
1379 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, revivers_first.netname);
1380 Send_Notification(NOTIF_ONE, revivers_first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1383 for(entity it = revivers_first; it; it = it.chain)
1384 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1388 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1390 entity player = M_ARGV(0, entity);
1391 // these automatically reset, no need to worry
1393 if(player.nade_entrap_time > 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 (mon.nade_entrap_time > 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 (mon.nade_veil_time && mon.nade_veil_time <= time)
1409 mon.alpha = mon.nade_veil_prevalpha;
1410 mon.nade_veil_time = 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_CVAR(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);
1456 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1457 nades_RemoveBonus(frag_attacker);
1458 else if(GameRules_scoring_is_vip(frag_target))
1459 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1460 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1462 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1463 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1464 switch(CS(frag_attacker).killcount)
1467 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1472 nades_GiveBonus(frag_attacker, killcount_bonus);
1475 nades_RemoveBonus(frag_target);
1478 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1480 entity frag_inflictor = M_ARGV(0, entity);
1481 entity frag_attacker = M_ARGV(1, entity);
1482 entity frag_target = M_ARGV(2, entity);
1483 float frag_deathtype = M_ARGV(3, float);
1485 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1486 if(time - frag_inflictor.toss_time <= 0.1)
1488 Unfreeze(frag_target, false);
1489 SetResource(frag_target, RES_HEALTH, autocvar_g_freezetag_revive_nade_health);
1490 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1491 M_ARGV(4, float) = 0;
1492 M_ARGV(6, vector) = '0 0 0';
1493 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1494 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1498 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1500 entity frag_target = M_ARGV(0, entity);
1501 entity frag_attacker = M_ARGV(1, entity);
1503 if(IS_PLAYER(frag_attacker))
1504 if(DIFF_TEAM(frag_attacker, frag_target))
1505 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1506 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1509 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1511 entity frag_target = M_ARGV(0, entity);
1513 if(frag_target.nade)
1514 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1517 void nades_RemovePlayer(entity this)
1520 nades_RemoveBonus(this);
1523 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1524 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1525 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1527 FOREACH_CLIENT(IS_PLAYER(it),
1529 nades_RemovePlayer(it);
1533 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1535 entity spectatee = M_ARGV(0, entity);
1536 entity client = M_ARGV(1, entity);
1538 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1539 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1540 client.pokenade_type = spectatee.pokenade_type;
1541 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1542 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1545 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsPrettyString)
1547 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Nades");
1550 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1552 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");