4 bool autocvar_g_nades_nade_small;
5 float autocvar_g_nades_spread = 0.04;
8 REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
11 entity Nade_TrailEffect(int proj, int nade_team)
15 case PROJECTILE_NADE: return EFFECT_NADE_TRAIL(nade_team);
16 case PROJECTILE_NADE_BURN: return EFFECT_NADE_TRAIL_BURN(nade_team);
19 FOREACH(Nades, true, {
20 for (int j = 0; j < 2; j++)
22 if (it.m_projectile[j] == proj)
24 string trail = it.m_trail[j].eent_eff_name;
25 if (trail) return it.m_trail[j];
36 REGISTER_MUTATOR(cl_nades, true);
37 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
39 // TODO: make a common orb state!
40 if (STAT(HEALING_ORB) > time)
42 M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
43 M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
46 if (STAT(ENTRAP_ORB) > time)
48 M_ARGV(0, vector) = NADE_TYPE_ENTRAP.m_color;
49 M_ARGV(1, float) = STAT(ENTRAP_ORB_ALPHA);
52 if (STAT(VEIL_ORB) > time)
54 M_ARGV(0, vector) = NADE_TYPE_VEIL.m_color;
55 M_ARGV(1, float) = STAT(VEIL_ORB_ALPHA);
60 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
62 entity proj = M_ARGV(0, entity);
64 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
67 proj.traileffect = EFFECT_FIREBALL.m_id;
70 if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
72 setmodel(proj, MDL_PROJECTILE_NADE);
73 entity trail = Nade_TrailEffect(proj.cnt, proj.team);
74 if (trail.eent_eff_name) proj.traileffect = trail.m_id;
78 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
80 entity proj = M_ARGV(0, entity);
82 if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
84 loopsound(proj, CH_SHOTS_SINGLE, SND_FIREBALL_FLY2, VOL_BASE, ATTEN_NORM);
85 proj.mins = '-16 -16 -16';
86 proj.maxs = '16 16 16';
89 entity nade_type = Nade_FromProjectile(proj.cnt);
90 if (nade_type == NADE_TYPE_Null) return;
93 proj.mins = '-8 -8 -8';
98 proj.mins = '-16 -16 -16';
99 proj.maxs = '16 16 16';
101 proj.colormod = nade_type.m_color;
102 set_movetype(proj, MOVETYPE_BOUNCE);
103 settouch(proj, func_null);
105 proj.avelocity = randomvec() * 720;
106 proj.alphamod = nade_type.m_alpha;
108 if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
109 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
111 proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
113 bool Projectile_isnade(int p)
115 return Nade_FromProjectile(p) != NADE_TYPE_Null;
117 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
119 float bonusNades = STAT(NADE_BONUS);
120 float bonusProgress = STAT(NADE_BONUS_SCORE);
121 float bonusType = STAT(NADE_BONUS_TYPE);
122 Nade def = Nades_from(bonusType);
123 vector nadeColor = def.m_color;
124 string nadeIcon = def.m_icon;
126 vector iconPos, textPos;
128 if(autocvar_hud_panel_ammo_iconalign)
130 iconPos = myPos + eX * 2 * mySize.y;
136 textPos = myPos + eX * mySize.y;
139 if(bonusNades > 0 || bonusProgress > 0)
141 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
143 if(autocvar_hud_panel_ammo_text)
144 drawstring_aspect(textPos, ftos(bonusNades), vec2((2/3) * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
147 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
149 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
156 #include <common/gamemodes/_mod.qh>
157 #include <common/monsters/sv_spawn.qh>
158 #include <common/monsters/sv_monsters.qh>
159 #include <server/g_subs.qh>
161 REGISTER_MUTATOR(nades, autocvar_g_nades);
163 .float nade_time_primed;
164 .float nade_lifetime;
166 .entity nade_spawnloc;
169 void nade_timer_think(entity this)
171 this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10);
172 this.nextthink = time;
173 if(!this.owner || wasfreed(this.owner))
177 void nade_burn_spawn(entity _nade)
179 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
182 void nade_spawn(entity _nade)
184 entity timer = new(nade_timer);
185 setmodel(timer, MDL_NADE_TIMER);
186 setattachment(timer, _nade, "");
187 timer.colormap = _nade.colormap;
188 timer.glowmod = _nade.glowmod;
189 setthink(timer, nade_timer_think);
190 timer.nextthink = time;
191 timer.wait = _nade.wait;
195 _nade.effects |= EF_LOWPRECISION;
197 CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
200 void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
209 RandomSelection_Init();
210 for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
211 if(e.takedamage == DAMAGE_AIM)
212 if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
213 if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
217 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
218 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
219 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
220 d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
223 e.fireball_impactvec = p;
224 RandomSelection_AddEnt(e, 1 / (1 + d), !Fire_IsBurning(e));
227 if(RandomSelection_chosen_ent)
229 d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
230 d = damage + (edgedamage - damage) * (d / dist);
231 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype);
232 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
233 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
238 void napalm_ball_think(entity this)
240 if(round_handler_IsActive())
241 if(!round_handler_IsRoundStarted())
247 if(time > this.pushltime)
253 vector midpoint = ((this.absmin + this.absmax) * 0.5);
254 if(pointcontents(midpoint) == CONTENT_WATER)
256 this.velocity = this.velocity * 0.5;
258 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
259 { this.velocity_z = 200; }
262 this.angles = vectoangles(this.velocity);
264 napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
265 autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
267 this.nextthink = time + 0.1;
271 void nade_napalm_ball(entity this)
276 spamsound(this, CH_SHOTS, SND_FIREBALL_FIRE, VOL_BASE, ATTEN_NORM);
279 proj.owner = this.owner;
280 proj.realowner = this.realowner;
281 proj.team = this.owner.team;
282 proj.bot_dodge = true;
283 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
284 set_movetype(proj, MOVETYPE_BOUNCE);
285 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
286 PROJECTILE_MAKETRIGGER(proj);
287 setmodel(proj, MDL_Null);
288 proj.scale = 1;//0.5;
289 setsize(proj, '-4 -4 -4', '4 4 4');
290 setorigin(proj, this.origin);
291 setthink(proj, napalm_ball_think);
292 proj.nextthink = time;
293 proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
294 proj.effects = EF_LOWPRECISION | EF_FLAME;
296 kick.x =(random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
297 kick.y = (random() - 0.5) * 2 * autocvar_g_nades_napalm_ball_spread;
298 kick.z = (random()/2+0.5) * autocvar_g_nades_napalm_ball_spread;
299 proj.velocity = kick;
301 proj.pushltime = time + autocvar_g_nades_napalm_ball_lifetime;
303 proj.angles = vectoangles(proj.velocity);
304 proj.flags = FL_PROJECTILE;
305 IL_PUSH(g_projectiles, proj);
306 IL_PUSH(g_bot_dodge, proj);
307 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
309 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
313 void napalm_fountain_think(entity this)
316 if(round_handler_IsActive())
317 if(!round_handler_IsRoundStarted())
323 if(time >= this.ltime)
329 vector midpoint = ((this.absmin + this.absmax) * 0.5);
330 if(pointcontents(midpoint) == CONTENT_WATER)
332 this.velocity = this.velocity * 0.5;
334 if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
335 { this.velocity_z = 200; }
337 UpdateCSQCProjectile(this);
340 napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
341 autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
343 this.nextthink = time + 0.1;
344 if(time >= this.nade_special_time)
346 this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
347 nade_napalm_ball(this);
351 void nade_napalm_boom(entity this)
355 for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
356 nade_napalm_ball(this);
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, 3, 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) && GetResourceAmount(it, RESOURCE_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)
455 fountain.owner = this.owner;
456 fountain.realowner = this.realowner;
457 fountain.origin = this.origin;
458 setorigin(fountain, fountain.origin);
459 setthink(fountain, nade_ice_think);
460 fountain.nextthink = time;
461 fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
462 fountain.pushltime = fountain.wait = fountain.ltime;
463 fountain.team = this.team;
464 set_movetype(fountain, MOVETYPE_TOSS);
465 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
466 fountain.bot_dodge = false;
467 setsize(fountain, '-16 -16 -16', '16 16 16');
468 fountain.nade_special_time = time+0.3;
469 fountain.angles = this.angles;
471 if ( autocvar_g_nades_ice_explode )
473 setmodel(fountain, MDL_PROJECTILE_GRENADE);
474 entity timer = new(nade_timer);
475 setmodel(timer, MDL_NADE_TIMER);
476 setattachment(timer, fountain, "");
477 timer.colormap = this.colormap;
478 timer.glowmod = this.glowmod;
479 setthink(timer, nade_timer_think);
480 timer.nextthink = time;
481 timer.wait = fountain.ltime;
482 timer.owner = fountain;
486 setmodel(fountain, MDL_Null);
489 void nade_translocate_boom(entity this)
491 if(this.realowner.vehicle)
494 vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
495 tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
496 locout = trace_endpos;
498 makevectors(this.realowner.angles);
500 MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
502 TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
505 void nade_spawn_boom(entity this)
507 entity spawnloc = spawn();
508 setorigin(spawnloc, this.origin);
509 setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
510 set_movetype(spawnloc, MOVETYPE_NONE);
511 spawnloc.solid = SOLID_NOT;
512 spawnloc.drawonlytoclient = this.realowner;
513 spawnloc.effects = EF_STARDUST;
514 spawnloc.cnt = autocvar_g_nades_spawn_count;
516 if(this.realowner.nade_spawnloc)
518 delete(this.realowner.nade_spawnloc);
519 this.realowner.nade_spawnloc = NULL;
522 this.realowner.nade_spawnloc = spawnloc;
525 void nades_orb_think(entity this)
527 if(time >= this.ltime)
533 this.nextthink = time;
535 if(time >= this.nade_special_time)
537 this.nade_special_time = time+0.25;
538 this.nade_show_particles = 1;
541 this.nade_show_particles = 0;
544 entity nades_spawn_orb(entity own, entity realown, vector org, float orb_ltime, float orb_rad)
546 // NOTE: this function merely places an orb
547 // you must add a custom touch function to the returned entity if desired
548 // also set .colormod if you wish to have it colorized
549 entity orb = spawn(); // Net_LinkEntity sets the classname (TODO)
551 orb.realowner = realown;
554 orb.orb_lifetime = orb_ltime; // required for timers
555 orb.ltime = time + orb.orb_lifetime;
556 orb.bot_dodge = false;
557 orb.team = realown.team;
558 orb.solid = SOLID_TRIGGER;
560 setmodel(orb, MDL_NADE_ORB);
562 orb.orb_radius = orb_rad; // required for fading
563 vector size = '1 1 1' * orb.orb_radius / 2;
564 setsize(orb, -size, size);
566 Net_LinkEntity(orb, true, 0, orb_send);
569 setthink(orb, nades_orb_think);
570 orb.nextthink = time;
575 void nade_entrap_touch(entity this, entity toucher)
577 if(DIFF_TEAM(toucher, this.realowner)) // TODO: what if realowner changes team or disconnects?
579 if (!isPushable(toucher))
582 float pushdeltatime = time - toucher.lastpushtime;
583 if (pushdeltatime > 0.15) pushdeltatime = 0;
584 toucher.lastpushtime = time;
585 if(!pushdeltatime) return;
587 // div0: ticrate independent, 1 = identity (not 20)
588 toucher.velocity = toucher.velocity * (autocvar_g_nades_entrap_strength ** pushdeltatime);
591 UpdateCSQCProjectile(toucher);
595 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
597 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
598 STAT(ENTRAP_ORB, show_tint) = time + 0.1;
600 float tint_alpha = 0.75;
601 if(SAME_TEAM(toucher, this.realowner))
603 STAT(ENTRAP_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
607 void nade_entrap_boom(entity this)
609 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_entrap_time, autocvar_g_nades_entrap_radius);
611 settouch(orb, nade_entrap_touch);
612 orb.colormod = NADE_TYPE_ENTRAP.m_color;
615 void nade_heal_touch(entity this, entity toucher)
619 if(IS_PLAYER(toucher) || IS_MONSTER(toucher))
620 if(!IS_DEAD(toucher))
621 if(!STAT(FROZEN, toucher))
623 health_factor = autocvar_g_nades_heal_rate*frametime/2;
624 if ( toucher != this.realowner )
626 if ( SAME_TEAM(toucher,this) )
627 health_factor *= autocvar_g_nades_heal_friend;
629 health_factor *= autocvar_g_nades_heal_foe;
631 if ( health_factor > 0 )
633 maxhealth = (IS_MONSTER(toucher)) ? toucher.max_health : g_pickup_healthmega_max;
634 float hp = GetResourceAmount(toucher, RESOURCE_HEALTH);
637 if (this.nade_show_particles)
639 Send_Effect(EFFECT_HEALING, toucher.origin, '0 0 0', 1);
641 GiveResourceWithLimit(toucher, RESOURCE_HEALTH, health_factor, maxhealth);
644 else if ( health_factor < 0 )
646 Damage(toucher,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,DMG_NOWEP,toucher.origin,'0 0 0');
651 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) )
653 entity show_red = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
654 STAT(HEALING_ORB, show_red) = time+0.1;
655 STAT(HEALING_ORB_ALPHA, show_red) = 0.75 * (this.ltime - time) / this.orb_lifetime;
659 void nade_heal_boom(entity this)
661 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_heal_time, autocvar_g_nades_nade_radius);
663 settouch(orb, nade_heal_touch);
664 orb.colormod = '1 0 0';
667 void nade_monster_boom(entity this)
669 entity e = spawnmonster(spawn(), this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
671 if(autocvar_g_nades_pokenade_monster_lifetime > 0)
672 e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
673 e.monster_skill = MONSTER_SKILL_INSANE;
676 void nade_veil_touch(entity this, entity toucher)
678 if ( IS_REAL_CLIENT(toucher) || IS_VEHICLE(toucher) || IS_MONSTER(toucher) )
680 entity show_tint = (IS_VEHICLE(toucher)) ? toucher.owner : toucher;
682 float tint_alpha = 0.75;
683 if(SAME_TEAM(toucher, this.realowner))
686 if(!STAT(VEIL_ORB, show_tint))
688 toucher.nade_veil_prevalpha = toucher.alpha;
692 STAT(VEIL_ORB, show_tint) = time + 0.1;
693 STAT(VEIL_ORB_ALPHA, show_tint) = tint_alpha * (this.ltime - time) / this.orb_lifetime;
697 void nade_veil_boom(entity this)
699 entity orb = nades_spawn_orb(this.owner, this.realowner, this.origin, autocvar_g_nades_veil_time, autocvar_g_nades_veil_radius);
701 settouch(orb, nade_veil_touch);
702 orb.colormod = NADE_TYPE_VEIL.m_color;
705 void nade_boom(entity this)
708 bool nade_blast = true;
710 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
712 case NADE_TYPE_NAPALM:
713 nade_blast = autocvar_g_nades_napalm_blast;
714 expef = EFFECT_EXPLOSION_MEDIUM;
718 expef = EFFECT_ELECTRO_COMBO; // hookbomb_explode electro_combo bigplasma_impact
720 case NADE_TYPE_TRANSLOCATE:
723 case NADE_TYPE_MONSTER:
724 case NADE_TYPE_SPAWN:
726 switch(this.realowner.team)
728 case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
729 case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
730 case NUM_TEAM_3: expef = EFFECT_SPAWN_YELLOW; break;
731 case NUM_TEAM_4: expef = EFFECT_SPAWN_PINK; break;
732 default: expef = EFFECT_SPAWN_NEUTRAL; break;
737 expef = EFFECT_SPAWN_RED;
740 case NADE_TYPE_ENTRAP:
742 expef = EFFECT_SPAWN_YELLOW;
747 expef = EFFECT_SPAWN_NEUTRAL;
751 case NADE_TYPE_NORMAL:
752 expef = EFFECT_NADE_EXPLODE(this.realowner.team);
757 Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
759 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
760 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
762 this.event_damage = func_null; // prevent somehow calling damage in the next call
766 RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
767 autocvar_g_nades_nade_radius, this, NULL, autocvar_g_nades_nade_force, this.projectiledeathtype, DMG_NOWEP, this.enemy);
768 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);
772 switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
774 case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
775 case NADE_TYPE_ICE: nade_ice_boom(this); break;
776 case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
777 case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
778 case NADE_TYPE_HEAL: nade_heal_boom(this); break;
779 case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
780 case NADE_TYPE_ENTRAP: nade_entrap_boom(this); break;
781 case NADE_TYPE_VEIL: nade_veil_boom(this); break;
784 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
792 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
793 void nade_pickup(entity this, entity thenade)
795 spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, STAT(NADE_BONUS_TYPE, thenade), thenade.pokenade_type);
797 // set refire so player can't even
798 this.nade_refire = time + autocvar_g_nades_nade_refire;
799 STAT(NADE_TIMER, this) = 0;
802 this.nade.nade_time_primed = thenade.nade_time_primed;
805 bool CanThrowNade(entity this);
806 void nade_touch(entity this, entity toucher)
809 UpdateCSQCProjectile(this);
811 if(toucher == this.realowner)
812 return; // no this impacts
814 if(autocvar_g_nades_pickup)
815 if(time >= this.spawnshieldtime)
816 if(!toucher.nade && GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health) // no boosted shot pickups, thank you very much
817 if(CanThrowNade(toucher)) // prevent some obvious things, like dead players
818 if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here
820 nade_pickup(toucher, this);
821 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
825 /*float is_weapclip = 0;
826 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
827 if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
828 if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
830 if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
832 IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this,
840 PROJECTILE_TOUCH(this, toucher);
842 //setsize(this, '-2 -2 -2', '2 2 2');
843 //UpdateCSQCProjectile(this);
844 if(GetResourceAmount(this, RESOURCE_HEALTH) == this.max_health)
846 spamsound(this, CH_SHOTS, SND_GRENADE_BOUNCE_RANDOM(), VOL_BASE, ATTEN_NORM);
850 this.enemy = toucher;
854 void nade_beep(entity this)
856 sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
857 setthink(this, nade_boom);
858 this.nextthink = max(this.wait, time);
861 void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
863 if(ITEM_DAMAGE_NEEDKILL(deathtype))
865 this.takedamage = DAMAGE_NO;
870 if(STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, this) == NADE_TYPE_SPAWN.m_id)
873 if (MUTATOR_CALLHOOK(Nade_Damage, this, DEATH_WEAPONOF(deathtype), force, damage)) {}
874 else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
879 else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
881 force *= 0.5; // too much
884 else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
887 damage = this.max_health * 0.55;
889 else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
890 damage = this.max_health * 0.1;
891 else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
893 if(deathtype & HITTYPE_SECONDARY)
895 damage = this.max_health * 0.1;
899 damage = this.max_health * 1.15;
902 this.velocity += force;
903 UpdateCSQCProjectile(this);
905 if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
908 float hp = GetResourceAmount(this, RESOURCE_HEALTH);
909 if(hp == this.max_health)
911 sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
912 this.nextthink = max(time + this.nade_lifetime, time);
913 setthink(this, nade_beep);
917 SetResourceAmount(this, RESOURCE_HEALTH, hp);
920 if ( STAT(NADE_BONUS_TYPE, this) != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
921 this.realowner = attacker;
924 W_PrepareExplosionByDamage(this, attacker, nade_boom);
926 nade_burn_spawn(this);
929 void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
934 entity _nade = e.nade;
940 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
942 makevectors(e.v_angle);
944 // NOTE: always throw from first weapon entity?
945 W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0, DEATH_NADE.m_id);
947 vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
948 + (v_right * autocvar_g_nades_throw_offset.y)
949 + (v_up * autocvar_g_nades_throw_offset.z);
951 setorigin(_nade, w_shotorg + offset);
952 //setmodel(_nade, MDL_PROJECTILE_NADE);
953 //setattachment(_nade, NULL, "");
954 PROJECTILE_MAKETRIGGER(_nade);
955 if(STAT(NADES_SMALL, e))
956 setsize(_nade, '-8 -8 -8', '8 8 8');
958 setsize(_nade, '-16 -16 -16', '16 16 16');
959 set_movetype(_nade, MOVETYPE_BOUNCE);
961 tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, MOVE_NOMONSTERS, _nade);
962 if (trace_startsolid)
963 setorigin(_nade, e.origin);
965 if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e))
966 _nade.velocity = '0 0 100';
967 else if(autocvar_g_nades_nade_newton_style == 1)
968 _nade.velocity = e.velocity + _velocity;
969 else if(autocvar_g_nades_nade_newton_style == 2)
970 _nade.velocity = _velocity;
972 _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true);
977 settouch(_nade, nade_touch);
978 _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
979 SetResourceAmount(_nade, RESOURCE_HEALTH, autocvar_g_nades_nade_health);
980 _nade.max_health = _nade.health;
981 _nade.takedamage = DAMAGE_AIM;
982 _nade.event_damage = nade_damage;
983 setcefc(_nade, func_null);
984 _nade.exteriormodeltoclient = NULL;
985 _nade.traileffectnum = 0;
986 _nade.teleportable = true;
987 _nade.pushable = true;
989 _nade.missile_flags = MIF_SPLASH | MIF_ARC;
990 _nade.damagedbycontents = true;
991 IL_PUSH(g_damagedbycontents, _nade);
992 _nade.angles = vectoangles(_nade.velocity);
993 _nade.flags = FL_PROJECTILE;
994 IL_PUSH(g_projectiles, _nade);
995 IL_PUSH(g_bot_dodge, _nade);
996 _nade.projectiledeathtype = DEATH_NADE.m_id;
997 _nade.toss_time = time;
998 _nade.solid = SOLID_CORPSE; //((STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
1000 if(STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_TRANSLOCATE.m_id || STAT(NADE_BONUS_TYPE, _nade) == NADE_TYPE_SPAWN.m_id)
1001 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
1003 _nade.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
1009 setthink(_nade, nade_boom);
1010 _nade.nextthink = _time;
1013 e.nade_refire = time + autocvar_g_nades_nade_refire;
1014 STAT(NADE_TIMER, e) = 0;
1017 void nades_GiveBonus(entity player, float score)
1019 if (autocvar_g_nades)
1020 if (autocvar_g_nades_bonus)
1021 if (IS_REAL_CLIENT(player))
1022 if (IS_PLAYER(player) && STAT(NADE_BONUS, player) < autocvar_g_nades_bonus_max)
1023 if (STAT(FROZEN, player) == 0)
1024 if (!IS_DEAD(player))
1026 if ( STAT(NADE_BONUS_SCORE, player) < 1 )
1027 STAT(NADE_BONUS_SCORE, player) += score/autocvar_g_nades_bonus_score_max;
1029 if ( STAT(NADE_BONUS_SCORE, player) >= 1 )
1031 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_NADE_BONUS);
1032 play2(player, SND(KH_ALARM));
1033 STAT(NADE_BONUS, player)++;
1034 STAT(NADE_BONUS_SCORE, player) -= 1;
1039 /** Remove all bonus nades from a player */
1040 void nades_RemoveBonus(entity player)
1042 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1045 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
1047 entity player = M_ARGV(0, entity);
1049 nades_RemoveBonus(player);
1052 bool nade_customize(entity this, entity client)
1054 //if(IS_SPEC(client)) { return false; }
1055 if(client == this.exteriormodeltoclient || (IS_SPEC(client) && client.enemy == this.exteriormodeltoclient))
1057 // somewhat hide the model, but keep the glow
1059 if(this.traileffectnum)
1060 this.traileffectnum = 0;
1065 //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
1066 if(!this.traileffectnum)
1067 this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
1074 void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
1076 entity n = new(nade), fn = new(fake_nade);
1078 STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
1079 n.pokenade_type = pntype;
1081 if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
1082 STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
1084 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
1086 setmodel(n, MDL_PROJECTILE_NADE);
1087 //setattachment(n, player, "bip01 l hand");
1088 n.exteriormodeltoclient = player;
1089 setcefc(n, nade_customize);
1090 n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
1091 n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1092 n.realowner = nowner;
1093 n.colormap = player.colormap;
1094 n.glowmod = player.glowmod;
1095 n.wait = time + max(0, ntime);
1096 n.nade_time_primed = time;
1097 setthink(n, nade_beep);
1098 n.nextthink = max(n.wait - 3, time);
1099 n.projectiledeathtype = DEATH_NADE.m_id;
1100 n.weaponentity_fld = weaponentity;
1101 n.nade_lifetime = ntime;
1102 n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1104 setmodel(fn, MDL_NADE_VIEW);
1105 setattachment(fn, player.(weaponentity), "");
1106 fn.realowner = fn.owner = player;
1107 fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
1108 fn.colormap = player.colormap;
1109 fn.glowmod = player.glowmod;
1110 setthink(fn, SUB_Remove);
1111 fn.nextthink = n.wait;
1112 fn.weaponentity_fld = weaponentity;
1113 fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
1116 player.fake_nade = fn;
1119 void nade_prime(entity this)
1121 if(autocvar_g_nades_bonus_only)
1122 if(!STAT(NADE_BONUS, this))
1123 return; // only allow bonus nades
1129 delete(this.fake_nade);
1132 string pntype = this.pokenade_type;
1134 if((this.items & ITEM_Strength.m_itemid) && autocvar_g_nades_bonus_onstrength)
1135 ntype = STAT(NADE_BONUS_TYPE, this);
1136 else if (STAT(NADE_BONUS, this) >= 1)
1138 ntype = STAT(NADE_BONUS_TYPE, this);
1139 pntype = this.pokenade_type;
1140 STAT(NADE_BONUS, this) -= 1;
1144 ntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_nade_type : autocvar_g_nades_nade_type);
1145 pntype = ((autocvar_g_nades_client_select) ? CS(this).cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
1148 spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype);
1151 bool CanThrowNade(entity this)
1159 if (!autocvar_g_nades)
1160 return false; // allow turning them off mid match
1162 if(forbidWeaponUse(this))
1165 if (!IS_PLAYER(this))
1171 .bool nade_altbutton;
1173 void nades_CheckThrow(entity this)
1175 if(!CanThrowNade(this))
1178 entity held_nade = this.nade;
1181 this.nade_altbutton = true;
1182 if(time > this.nade_refire)
1184 Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW);
1186 this.nade_refire = time + autocvar_g_nades_nade_refire;
1191 this.nade_altbutton = false;
1192 if (time >= held_nade.nade_time_primed + 1) {
1193 makevectors(this.v_angle);
1194 float _force = time - held_nade.nade_time_primed;
1195 _force /= autocvar_g_nades_nade_lifetime;
1196 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1197 vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
1198 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1199 toss_nade(this, true, dir * _force, 0);
1204 void nades_Clear(entity player)
1207 delete(player.nade);
1208 if(player.fake_nade)
1209 delete(player.fake_nade);
1211 player.nade = player.fake_nade = NULL;
1212 STAT(NADE_TIMER, player) = 0;
1215 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
1217 entity player = M_ARGV(0, entity);
1220 toss_nade(player, true, '0 0 100', max(player.nade.wait, time + 0.05));
1223 CLASS(NadeOffhand, OffhandWeapon)
1224 METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
1226 entity held_nade = player.nade;
1228 if (!CanThrowNade(player)) return;
1229 if (!(time > player.nade_refire)) return;
1233 held_nade = player.nade;
1235 } else if (time >= held_nade.nade_time_primed + 1) {
1237 makevectors(player.v_angle);
1238 float _force = time - held_nade.nade_time_primed;
1239 _force /= autocvar_g_nades_nade_lifetime;
1240 _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
1241 vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
1242 dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
1243 toss_nade(player, false, dir * _force, 0);
1247 ENDCLASS(NadeOffhand)
1248 NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOffhand); }
1250 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
1252 entity player = M_ARGV(0, entity);
1254 if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
1255 nades_CheckThrow(player);
1260 MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
1262 entity player = M_ARGV(0, entity);
1264 if (!IS_PLAYER(player)) { return; }
1266 if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
1268 entity held_nade = player.nade;
1271 STAT(NADE_TIMER, player) = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1);
1272 // LOG_TRACEF("%d %d", STAT(NADE_TIMER, player), time - held_nade.nade_time_primed);
1273 makevectors(player.angles);
1274 held_nade.velocity = player.velocity;
1275 setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
1276 held_nade.angles_y = player.angles.y;
1278 if (time + 0.1 >= held_nade.wait)
1279 toss_nade(player, false, '0 0 0', time + 0.05);
1282 if(IS_PLAYER(player))
1284 if ( autocvar_g_nades_bonus && autocvar_g_nades )
1287 float key_count = 0;
1288 FOR_EACH_KH_KEY(key) if(key.owner == player) { ++key_count; }
1291 if(GameRules_scoring_is_vip(player))
1292 time_score = autocvar_g_nades_bonus_score_time_flagcarrier;
1294 time_score = autocvar_g_nades_bonus_score_time;
1297 time_score = autocvar_g_nades_bonus_score_time_flagcarrier * key_count; // multiply by the number of keys the player is holding
1299 if(autocvar_g_nades_bonus_client_select)
1301 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1302 player.pokenade_type = CS(player).cvar_cl_pokenade_type;
1306 STAT(NADE_BONUS_TYPE, player) = autocvar_g_nades_bonus_type;
1307 player.pokenade_type = autocvar_g_nades_pokenade_monster_type;
1310 STAT(NADE_BONUS_TYPE, player) = bound(1, STAT(NADE_BONUS_TYPE, player), Nades_COUNT);
1312 if(STAT(NADE_BONUS_SCORE, player) >= 0 && autocvar_g_nades_bonus_score_max)
1313 nades_GiveBonus(player, time_score / autocvar_g_nades_bonus_score_max);
1317 STAT(NADE_BONUS, player) = STAT(NADE_BONUS_SCORE, player) = 0;
1320 if(STAT(VEIL_ORB, player) && STAT(VEIL_ORB, player) <= time)
1322 STAT(VEIL_ORB, player) = 0;
1324 player.vehicle.alpha = player.vehicle.nade_veil_prevalpha;
1326 player.alpha = player.nade_veil_prevalpha;
1332 if(player.freezetag_frozen_timeout > 0 && time >= player.freezetag_frozen_timeout)
1334 else if(STAT(FROZEN, player) == 3)
1336 vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
1338 FOREACH_CLIENT(IS_PLAYER(it) && it != player, {
1339 if(!IS_DEAD(it) && STAT(FROZEN, it) == 0 && SAME_TEAM(it, player))
1340 if(boxesoverlap(player.absmin - revive_extra_size, player.absmax + revive_extra_size, it.absmin, it.absmax))
1350 if(n > 0 && STAT(FROZEN, player) == 3) // OK, there is at least one teammate reviving us
1352 STAT(REVIVE_PROGRESS, player) = bound(0, STAT(REVIVE_PROGRESS, player) + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
1353 SetResourceAmount(player, RESOURCE_HEALTH, max(1, STAT(REVIVE_PROGRESS, player) * start_health));
1355 if(STAT(REVIVE_PROGRESS, player) >= 1)
1359 Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
1360 Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
1363 FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
1364 STAT(REVIVE_PROGRESS, it) = STAT(REVIVE_PROGRESS, player);
1365 it.reviving = false;
1370 MUTATOR_HOOKFUNCTION(nades, PlayerPhysics_UpdateStats)
1372 entity player = M_ARGV(0, entity);
1373 // these automatically reset, no need to worry
1375 if(STAT(ENTRAP_ORB, player) > time)
1376 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_nades_entrap_speed;
1379 MUTATOR_HOOKFUNCTION(nades, MonsterMove)
1381 entity mon = M_ARGV(0, entity);
1383 if (STAT(ENTRAP_ORB, mon) > time)
1385 M_ARGV(1, float) *= autocvar_g_nades_entrap_speed; // run speed
1386 M_ARGV(2, float) *= autocvar_g_nades_entrap_speed; // walk speed
1389 if (STAT(VEIL_ORB, mon) && STAT(VEIL_ORB, mon) <= time)
1391 mon.alpha = mon.nade_veil_prevalpha;
1392 STAT(VEIL_ORB, mon) = 0;
1396 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
1398 entity player = M_ARGV(0, entity);
1400 if(autocvar_g_nades_spawn)
1401 player.nade_refire = time + autocvar_g_spawnshieldtime;
1403 player.nade_refire = time + autocvar_g_nades_nade_refire;
1405 if(autocvar_g_nades_bonus_client_select)
1406 STAT(NADE_BONUS_TYPE, player) = CS(player).cvar_cl_nade_type;
1408 STAT(NADE_TIMER, player) = 0;
1410 if (!player.offhand) player.offhand = OFFHAND_NADE;
1412 if(player.nade_spawnloc)
1414 setorigin(player, player.nade_spawnloc.origin);
1415 player.nade_spawnloc.cnt -= 1;
1417 if(player.nade_spawnloc.cnt <= 0)
1419 delete(player.nade_spawnloc);
1420 player.nade_spawnloc = NULL;
1425 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
1427 entity frag_attacker = M_ARGV(1, entity);
1428 entity frag_target = M_ARGV(2, entity);
1430 if(frag_target.nade)
1431 if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
1432 toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
1434 if(IS_PLAYER(frag_attacker))
1436 float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
1438 if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target)
1439 nades_RemoveBonus(frag_attacker);
1440 else if(GameRules_scoring_is_vip(frag_target))
1441 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium);
1442 else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1)
1444 #define SPREE_ITEM(counta,countb,center,normal,gentle) \
1445 case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; }
1446 switch(CS(frag_attacker).killcount)
1449 default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break;
1454 nades_GiveBonus(frag_attacker, killcount_bonus);
1457 nades_RemoveBonus(frag_target);
1460 MUTATOR_HOOKFUNCTION(nades, Damage_Calculate)
1462 entity frag_inflictor = M_ARGV(0, entity);
1463 entity frag_attacker = M_ARGV(1, entity);
1464 entity frag_target = M_ARGV(2, entity);
1465 float frag_deathtype = M_ARGV(3, float);
1467 if(autocvar_g_freezetag_revive_nade && STAT(FROZEN, frag_target) && frag_attacker == frag_target && frag_deathtype == DEATH_NADE.m_id)
1468 if(time - frag_inflictor.toss_time <= 0.1)
1470 Unfreeze(frag_target);
1471 SetResourceAmount(frag_target, RESOURCE_HEALTH, autocvar_g_freezetag_revive_nade_health);
1472 Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
1473 M_ARGV(4, float) = 0;
1474 M_ARGV(6, vector) = '0 0 0';
1475 Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
1476 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
1480 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
1482 entity frag_target = M_ARGV(0, entity);
1483 entity frag_attacker = M_ARGV(1, entity);
1485 if(IS_PLAYER(frag_attacker))
1486 if(DIFF_TEAM(frag_attacker, frag_target))
1487 if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
1488 nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
1491 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
1493 entity frag_target = M_ARGV(0, entity);
1495 if(frag_target.nade)
1496 toss_nade(frag_target, true, '0 0 0', time + 0.05);
1499 void nades_RemovePlayer(entity this)
1502 nades_RemoveBonus(this);
1505 MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1506 MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); }
1507 MUTATOR_HOOKFUNCTION(nades, reset_map_global)
1509 FOREACH_CLIENT(IS_PLAYER(it),
1511 nades_RemovePlayer(it);
1515 MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
1517 entity spectatee = M_ARGV(0, entity);
1518 entity client = M_ARGV(1, entity);
1520 STAT(NADE_TIMER, client) = STAT(NADE_TIMER, spectatee);
1521 STAT(NADE_BONUS_TYPE, client) = STAT(NADE_BONUS_TYPE, spectatee);
1522 client.pokenade_type = spectatee.pokenade_type;
1523 STAT(NADE_BONUS, client) = STAT(NADE_BONUS, spectatee);
1524 STAT(NADE_BONUS_SCORE, client) = STAT(NADE_BONUS_SCORE, spectatee);
1525 STAT(HEALING_ORB, client) = STAT(HEALING_ORB, spectatee);
1526 STAT(HEALING_ORB_ALPHA, client) = STAT(HEALING_ORB_ALPHA, spectatee);
1527 STAT(ENTRAP_ORB, client) = STAT(ENTRAP_ORB, spectatee);
1528 STAT(ENTRAP_ORB_ALPHA, client) = STAT(ENTRAP_ORB_ALPHA, spectatee);
1529 STAT(VEIL_ORB, client) = STAT(VEIL_ORB, spectatee);
1530 STAT(VEIL_ORB_ALPHA, client) = STAT(VEIL_ORB_ALPHA, spectatee);
1533 REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
1534 REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
1536 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
1538 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":Nades");
1541 MUTATOR_HOOKFUNCTION(nades, BuildGameplayTipsString)
1543 M_ARGV(0, string) = strcat(M_ARGV(0, string), "\n\n^3nades^8 are enabled, press 'g' to use them\n");