]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/nades/nades.qc
Purge self from the damage/death mutator hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / nades.qc
index 459d95020308e36159cc271b45c2d20572d744eb..999bd4ada0f08b695f675a089ec3a8769344f3be 100644 (file)
@@ -2,6 +2,13 @@
 
 #ifdef IMPLEMENTATION
 
+#ifdef SVQC
+bool autocvar_g_nades_nade_small;
+float autocvar_g_nades_spread = 0.04;
+#endif
+
+REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
+
 #ifndef MENUQC
 entity Nade_TrailEffect(int proj, int nade_team)
 {
@@ -31,50 +38,62 @@ entity Nade_TrailEffect(int proj, int nade_team)
 REGISTER_MUTATOR(cl_nades, true);
 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
 {
-       if (getstatf(STAT_HEALING_ORB) <= time) return false;
-       MUTATOR_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
-       MUTATOR_ARGV(0, float) = getstatf(STAT_HEALING_ORB_ALPHA);
+       if (STAT(HEALING_ORB) <= time) return false;
+       M_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
+       M_ARGV(1, float) = STAT(HEALING_ORB_ALPHA);
        return true;
 }
 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
 {
-       if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN)
+       entity proj = M_ARGV(0, entity);
+
+       if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
        {
-               self.modelindex = 0;
-               self.traileffect = EFFECT_FIREBALL.m_id;
+               proj.modelindex = 0;
+               proj.traileffect = EFFECT_FIREBALL.m_id;
                return true;
        }
-       if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null)
+       if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
        {
-               setmodel(self, MDL_PROJECTILE_NADE);
-               entity trail = Nade_TrailEffect(self.cnt, self.team);
-               if (trail.eent_eff_name) self.traileffect = trail.m_id;
+               setmodel(proj, MDL_PROJECTILE_NADE);
+               entity trail = Nade_TrailEffect(proj.cnt, proj.team);
+               if (trail.eent_eff_name) proj.traileffect = trail.m_id;
                return true;
        }
 }
 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
 {
-       if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN)
+       entity proj = M_ARGV(0, entity);
+
+       if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
        {
-               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
-               self.mins = '-16 -16 -16';
-               self.maxs = '16 16 16';
+               loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
+               proj.mins = '-16 -16 -16';
+               proj.maxs = '16 16 16';
        }
 
-       entity nade_type = Nade_FromProjectile(self.cnt);
+       entity nade_type = Nade_FromProjectile(proj.cnt);
        if (nade_type == NADE_TYPE_Null) return;
-       self.mins = '-16 -16 -16';
-       self.maxs = '16 16 16';
-       self.colormod = nade_type.m_color;
-       self.move_movetype = MOVETYPE_BOUNCE;
-       self.move_touch = func_null;
-       self.scale = 1.5;
-       self.avelocity = randomvec() * 720;
+       if(STAT(NADES_SMALL, NULL))
+       {
+               proj.mins = '-8 -8 -8';
+               proj.maxs = '8 8 8';
+       }
+       else
+       {
+               proj.mins = '-16 -16 -16';
+               proj.maxs = '16 16 16';
+       }
+       proj.colormod = nade_type.m_color;
+       proj.move_movetype = MOVETYPE_BOUNCE;
+       settouch(proj, func_null);
+       proj.scale = 1.5;
+       proj.avelocity = randomvec() * 720;
 
        if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
-               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+               proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
        else
-               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+               proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
 }
 bool Projectile_isnade(int p)
 {
@@ -82,9 +101,9 @@ bool Projectile_isnade(int p)
 }
 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
 {
-       float bonusNades    = getstatf(STAT_NADE_BONUS);
-       float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
-       float bonusType     = getstati(STAT_NADE_BONUS_TYPE);
+       float bonusNades    = STAT(NADE_BONUS);
+       float bonusProgress = STAT(NADE_BONUS_SCORE);
+       float bonusType     = STAT(NADE_BONUS_TYPE);
        Nade def = Nades_from(bonusType);
        vector nadeColor    = def.m_color;
        string nadeIcon     = def.m_icon;
@@ -119,36 +138,23 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
 
 #ifdef SVQC
 
-#include "../../../gamemodes/all.qh"
-#include "../../../monsters/spawn.qh"
-#include "../../../monsters/sv_monsters.qh"
-#include "../../../../server/g_subs.qh"
+#include <common/gamemodes/all.qh>
+#include <common/monsters/spawn.qh>
+#include <common/monsters/sv_monsters.qh>
+#include <server/g_subs.qh>
 
-REGISTER_MUTATOR(nades, cvar("g_nades"))
-{
-       MUTATOR_ONADD
-       {
-               addstat(STAT_NADE_TIMER, AS_FLOAT, nade_timer);
-               addstat(STAT_NADE_BONUS, AS_FLOAT, bonus_nades);
-               addstat(STAT_NADE_BONUS_TYPE, AS_INT, nade_type);
-               addstat(STAT_NADE_BONUS_SCORE, AS_FLOAT, bonus_nade_score);
-               addstat(STAT_HEALING_ORB, AS_FLOAT, stat_healing_orb);
-               addstat(STAT_HEALING_ORB_ALPHA, AS_FLOAT, stat_healing_orb_alpha);
-       }
-
-       return false;
-}
+REGISTER_MUTATOR(nades, cvar("g_nades"));
 
 .float nade_time_primed;
 
 .entity nade_spawnloc;
 
-void nade_timer_think()
-{SELFPARAM();
-       self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
-       self.nextthink = time;
-       if(!self.owner || wasfreed(self.owner))
-               remove(self);
+void nade_timer_think(entity this)
+{
+       this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
+       this.nextthink = time;
+       if(!this.owner || wasfreed(this.owner))
+               remove(this);
 }
 
 void nade_burn_spawn(entity _nade)
@@ -163,7 +169,7 @@ void nade_spawn(entity _nade)
        setattachment(timer, _nade, "");
        timer.colormap = _nade.colormap;
        timer.glowmod = _nade.glowmod;
-       timer.think = nade_timer_think;
+       setthink(timer, nade_timer_think);
        timer.nextthink = time;
        timer.wait = _nade.wait;
        timer.owner = _nade;
@@ -174,8 +180,8 @@ void nade_spawn(entity _nade)
        CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
 }
 
-void napalm_damage(float dist, float damage, float edgedamage, float burntime)
-{SELFPARAM();
+void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
+{
        entity e;
        float d;
        vector p;
@@ -184,17 +190,17 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime)
                return;
 
        RandomSelection_Init();
-       for(e = WarpZone_FindRadius(self.origin, dist, true); e; e = e.chain)
+       for(e = WarpZone_FindRadius(this.origin, dist, true); e; e = e.chain)
                if(e.takedamage == DAMAGE_AIM)
-               if(self.realowner != e || autocvar_g_nades_napalm_selfdamage)
-               if(!IS_PLAYER(e) || !self.realowner || DIFF_TEAM(e, self))
-               if(!e.frozen)
+               if(this.realowner != e || autocvar_g_nades_napalm_selfdamage)
+               if(!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
+               if(!STAT(FROZEN, e))
                {
                        p = e.origin;
                        p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
                        p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
                        p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
-                       d = vlen(WarpZone_UnTransformOrigin(e, self.origin) - p);
+                       d = vlen(WarpZone_UnTransformOrigin(e, this.origin) - p);
                        if(d < dist)
                        {
                                e.fireball_impactvec = p;
@@ -203,59 +209,59 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime)
                }
        if(RandomSelection_chosen_ent)
        {
-               d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, self.origin) - RandomSelection_chosen_ent.fireball_impactvec);
+               d = vlen(WarpZone_UnTransformOrigin(RandomSelection_chosen_ent, this.origin) - RandomSelection_chosen_ent.fireball_impactvec);
                d = damage + (edgedamage - damage) * (d / dist);
-               Fire_AddDamage(RandomSelection_chosen_ent, self.realowner, d * burntime, burntime, self.projectiledeathtype | HITTYPE_BOUNCE);
-               //trailparticles(self, particleeffectnum(EFFECT_FIREBALL_LASER), self.origin, RandomSelection_chosen_ent.fireball_impactvec);
-               Send_Effect(EFFECT_FIREBALL_LASER, self.origin, RandomSelection_chosen_ent.fireball_impactvec - self.origin, 1);
+               Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, d * burntime, burntime, this.projectiledeathtype | HITTYPE_BOUNCE);
+               //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
+               Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
        }
 }
 
 
-void napalm_ball_think()
-{SELFPARAM();
+void napalm_ball_think(entity this)
+{
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       if(time > self.pushltime)
+       if(time > this.pushltime)
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       vector midpoint = ((self.absmin + self.absmax) * 0.5);
+       vector midpoint = ((this.absmin + this.absmax) * 0.5);
        if(pointcontents(midpoint) == CONTENT_WATER)
        {
-               self.velocity = self.velocity * 0.5;
+               this.velocity = this.velocity * 0.5;
 
                if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
-                       { self.velocity_z = 200; }
+                       { this.velocity_z = 200; }
        }
 
-       self.angles = vectoangles(self.velocity);
+       this.angles = vectoangles(this.velocity);
 
-       napalm_damage(autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
+       napalm_damage(this, autocvar_g_nades_napalm_ball_radius,autocvar_g_nades_napalm_ball_damage,
                                  autocvar_g_nades_napalm_ball_damage,autocvar_g_nades_napalm_burntime);
 
-       self.nextthink = time + 0.1;
+       this.nextthink = time + 0.1;
 }
 
 
-void nade_napalm_ball()
-{SELFPARAM();
+void nade_napalm_ball(entity this)
+{
        entity proj;
        vector kick;
 
-       spamsound(self, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
+       spamsound(this, CH_SHOTS, SND(FIREBALL_FIRE), VOL_BASE, ATTEN_NORM);
 
        proj = new(grenade);
-       proj.owner = self.owner;
-       proj.realowner = self.realowner;
-       proj.team = self.owner.team;
+       proj.owner = this.owner;
+       proj.realowner = this.realowner;
+       proj.team = this.owner.team;
        proj.bot_dodge = true;
        proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
        proj.movetype = MOVETYPE_BOUNCE;
@@ -264,8 +270,8 @@ void nade_napalm_ball()
        setmodel(proj, MDL_Null);
        proj.scale = 1;//0.5;
        setsize(proj, '-4 -4 -4', '4 4 4');
-       setorigin(proj, self.origin);
-       proj.think = napalm_ball_think;
+       setorigin(proj, this.origin);
+       setthink(proj, napalm_ball_think);
        proj.nextthink = time;
        proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
        proj.effects = EF_LOWPRECISION | EF_FLAME;
@@ -285,50 +291,50 @@ void nade_napalm_ball()
 }
 
 
-void napalm_fountain_think()
-{SELFPARAM();
+void napalm_fountain_think(entity this)
+{
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       if(time >= self.ltime)
+       if(time >= this.ltime)
        {
-               remove(self);
+               remove(this);
                return;
        }
 
-       vector midpoint = ((self.absmin + self.absmax) * 0.5);
+       vector midpoint = ((this.absmin + this.absmax) * 0.5);
        if(pointcontents(midpoint) == CONTENT_WATER)
        {
-               self.velocity = self.velocity * 0.5;
+               this.velocity = this.velocity * 0.5;
 
                if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
-                       { self.velocity_z = 200; }
+                       { this.velocity_z = 200; }
 
-               UpdateCSQCProjectile(self);
+               UpdateCSQCProjectile(this);
        }
 
-       napalm_damage(autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
+       napalm_damage(this, autocvar_g_nades_napalm_fountain_radius, autocvar_g_nades_napalm_fountain_damage,
                autocvar_g_nades_napalm_fountain_edgedamage, autocvar_g_nades_napalm_burntime);
 
-       self.nextthink = time + 0.1;
-       if(time >= self.nade_special_time)
+       this.nextthink = time + 0.1;
+       if(time >= this.nade_special_time)
        {
-               self.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
-               nade_napalm_ball();
+               this.nade_special_time = time + autocvar_g_nades_napalm_fountain_delay;
+               nade_napalm_ball(this);
        }
 }
 
-void nade_napalm_boom()
-{SELFPARAM();
+void nade_napalm_boom(entity this)
+{
        entity fountain;
        int c;
        for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
-               nade_napalm_ball();
+               nade_napalm_ball(this);
 
 
        fountain = spawn();
@@ -336,7 +342,7 @@ void nade_napalm_boom()
        fountain.realowner = self.realowner;
        fountain.origin = self.origin;
        setorigin(fountain, fountain.origin);
-       fountain.think = napalm_fountain_think;
+       setthink(fountain, napalm_fountain_think);
        fountain.nextthink = time;
        fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime;
        fountain.pushltime = fountain.ltime;
@@ -359,8 +365,8 @@ void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
        Drop_Special_Items(frost_target);
 }
 
-void nade_ice_think()
-{SELFPARAM();
+void nade_ice_think(entity this)
+{
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
@@ -416,33 +422,33 @@ void nade_ice_think()
        for(e = findradius(self.origin, autocvar_g_nades_nade_radius); e; e = e.chain)
        if(e != self)
        if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, self.realowner) || e == self.realowner))
-       if(e.takedamage && e.deadflag == DEAD_NO)
+       if(e.takedamage && !IS_DEAD(e))
        if(e.health > 0)
        if(!e.revival_time || ((time - e.revival_time) >= 1.5))
-       if(!e.frozen)
+       if(!STAT(FROZEN, e))
        if(current_freeze_time > 0)
                nade_ice_freeze(self, e, current_freeze_time);
 }
 
-void nade_ice_boom()
-{SELFPARAM();
+void nade_ice_boom(entity this)
+{
        entity fountain;
        fountain = spawn();
-       fountain.owner = self.owner;
-       fountain.realowner = self.realowner;
-       fountain.origin = self.origin;
+       fountain.owner = this.owner;
+       fountain.realowner = this.realowner;
+       fountain.origin = this.origin;
        setorigin(fountain, fountain.origin);
-       fountain.think = nade_ice_think;
+       setthink(fountain, nade_ice_think);
        fountain.nextthink = time;
        fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
        fountain.pushltime = fountain.wait = fountain.ltime;
-       fountain.team = self.team;
+       fountain.team = this.team;
        fountain.movetype = MOVETYPE_TOSS;
        fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
        fountain.bot_dodge = false;
        setsize(fountain, '-16 -16 -16', '16 16 16');
        fountain.nade_special_time = time+0.3;
-       fountain.angles = self.angles;
+       fountain.angles = this.angles;
 
        if ( autocvar_g_nades_ice_explode )
        {
@@ -450,9 +456,9 @@ void nade_ice_boom()
                entity timer = new(nade_timer);
                setmodel(timer, MDL_NADE_TIMER);
                setattachment(timer, fountain, "");
-               timer.colormap = self.colormap;
-               timer.glowmod = self.glowmod;
-               timer.think = nade_timer_think;
+               timer.colormap = this.colormap;
+               timer.glowmod = this.glowmod;
+               setthink(timer, nade_timer_think);
                timer.nextthink = time;
                timer.wait = fountain.ltime;
                timer.owner = fountain;
@@ -462,44 +468,44 @@ void nade_ice_boom()
                setmodel(fountain, MDL_Null);
 }
 
-void nade_translocate_boom()
-{SELFPARAM();
-       if(self.realowner.vehicle)
+void nade_translocate_boom(entity this)
+{
+       if(this.realowner.vehicle)
                return;
 
-       vector locout = self.origin + '0 0 1' * (1 - self.realowner.mins.z - 24);
-       tracebox(locout, self.realowner.mins, self.realowner.maxs, locout, MOVE_NOMONSTERS, self.realowner);
+       vector locout = this.origin + '0 0 1' * (1 - this.realowner.mins.z - 24);
+       tracebox(locout, this.realowner.mins, this.realowner.maxs, locout, MOVE_NOMONSTERS, this.realowner);
        locout = trace_endpos;
 
-       makevectors(self.realowner.angles);
+       makevectors(this.realowner.angles);
 
-       MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
+       MUTATOR_CALLHOOK(PortalTeleport, this.realowner);
 
-       TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+       TeleportPlayer(this, this.realowner, locout, this.realowner.angles, v_forward * vlen(this.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
 }
 
-void nade_spawn_boom()
-{SELFPARAM();
+void nade_spawn_boom(entity this)
+{
        entity spawnloc = spawn();
-       setorigin(spawnloc, self.origin);
-       setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
+       setorigin(spawnloc, this.origin);
+       setsize(spawnloc, this.realowner.mins, this.realowner.maxs);
        spawnloc.movetype = MOVETYPE_NONE;
        spawnloc.solid = SOLID_NOT;
-       spawnloc.drawonlytoclient = self.realowner;
+       spawnloc.drawonlytoclient = this.realowner;
        spawnloc.effects = EF_STARDUST;
        spawnloc.cnt = autocvar_g_nades_spawn_count;
 
-       if(self.realowner.nade_spawnloc)
+       if(this.realowner.nade_spawnloc)
        {
-               remove(self.realowner.nade_spawnloc);
-               self.realowner.nade_spawnloc = world;
+               remove(this.realowner.nade_spawnloc);
+               this.realowner.nade_spawnloc = world;
        }
 
-       self.realowner.nade_spawnloc = spawnloc;
+       this.realowner.nade_spawnloc = spawnloc;
 }
 
-void nade_heal_think()
-{SELFPARAM();
+void nade_heal_think(entity this)
+{
        if(time >= self.ltime)
        {
                remove(self);
@@ -517,13 +523,13 @@ void nade_heal_think()
                self.nade_show_particles = 0;
 }
 
-void nade_heal_touch()
-{SELFPARAM();
+void nade_heal_touch(entity this)
+{
        float maxhealth;
        float health_factor;
        if(IS_PLAYER(other) || IS_MONSTER(other))
-       if(other.deadflag == DEAD_NO)
-       if(!other.frozen)
+       if(!IS_DEAD(other))
+       if(!STAT(FROZEN, other))
        {
                health_factor = autocvar_g_nades_heal_rate*frametime/2;
                if ( other != self.realowner )
@@ -559,19 +565,19 @@ void nade_heal_touch()
        }
 }
 
-void nade_heal_boom()
-{SELFPARAM();
+void nade_heal_boom(entity this)
+{
        entity healer;
        healer = spawn();
-       healer.owner = self.owner;
-       healer.realowner = self.realowner;
-       setorigin(healer, self.origin);
+       healer.owner = this.owner;
+       healer.realowner = this.realowner;
+       setorigin(healer, this.origin);
        healer.healer_lifetime = autocvar_g_nades_heal_time; // save the cvar
        healer.ltime = time + healer.healer_lifetime;
-       healer.team = self.realowner.team;
+       healer.team = this.realowner.team;
        healer.bot_dodge = false;
        healer.solid = SOLID_TRIGGER;
-       healer.touch = nade_heal_touch;
+       settouch(healer, nade_heal_touch);
 
        setmodel(healer, MDL_NADE_HEAL);
        healer.healer_radius = autocvar_g_nades_nade_radius;
@@ -580,26 +586,26 @@ void nade_heal_boom()
 
        Net_LinkEntity(healer, true, 0, healer_send);
 
-       healer.think = nade_heal_think;
+       setthink(healer, nade_heal_think);
        healer.nextthink = time;
        healer.SendFlags |= 1;
 }
 
-void nade_monster_boom()
-{SELFPARAM();
-       entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
+void nade_monster_boom(entity this)
+{
+       entity e = spawnmonster(this.pokenade_type, 0, this.realowner, this.realowner, this.origin, false, false, 1);
 
        if(autocvar_g_nades_pokenade_monster_lifetime > 0)
                e.monster_lifetime = time + autocvar_g_nades_pokenade_monster_lifetime;
        e.monster_skill = MONSTER_SKILL_INSANE;
 }
 
-void nade_boom()
-{SELFPARAM();
+void nade_boom(entity this)
+{
        entity expef = NULL;
        bool nade_blast = true;
 
-       switch ( Nades_from(self.nade_type) )
+       switch ( Nades_from(this.nade_type) )
        {
                case NADE_TYPE_NAPALM:
                        nade_blast = autocvar_g_nades_napalm_blast;
@@ -615,7 +621,7 @@ void nade_boom()
                case NADE_TYPE_MONSTER:
                case NADE_TYPE_SPAWN:
                        nade_blast = false;
-                       switch(self.realowner.team)
+                       switch(this.realowner.team)
                        {
                                case NUM_TEAM_1: expef = EFFECT_SPAWN_RED; break;
                                case NUM_TEAM_2: expef = EFFECT_SPAWN_BLUE; break;
@@ -631,46 +637,79 @@ void nade_boom()
 
                default:
                case NADE_TYPE_NORMAL:
-                       expef = EFFECT_NADE_EXPLODE(self.realowner.team);
+                       expef = EFFECT_NADE_EXPLODE(this.realowner.team);
                        break;
        }
 
        if(expef)
-               Send_Effect(expef, findbetterlocation(self.origin, 8), '0 0 0', 1);
+               Send_Effect(expef, findbetterlocation(this.origin, 8), '0 0 0', 1);
 
-       sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
-       sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
+       sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
 
-       self.event_damage = func_null; // prevent somehow calling damage in the next call
+       this.event_damage = func_null; // prevent somehow calling damage in the next call
 
        if(nade_blast)
        {
-               RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
-                                autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy);
-               Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self);
+               RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage,
+                                autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy);
+               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);
        }
 
-       if(self.takedamage)
-       switch ( Nades_from(self.nade_type) )
+       if(this.takedamage)
+       switch ( Nades_from(this.nade_type) )
        {
-               case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
-               case NADE_TYPE_ICE: nade_ice_boom(); break;
-               case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(); break;
-               case NADE_TYPE_SPAWN: nade_spawn_boom(); break;
-               case NADE_TYPE_HEAL: nade_heal_boom(); break;
-               case NADE_TYPE_MONSTER: nade_monster_boom(); break;
+               case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
+               case NADE_TYPE_ICE: nade_ice_boom(this); break;
+               case NADE_TYPE_TRANSLOCATE: nade_translocate_boom(this); break;
+               case NADE_TYPE_SPAWN: nade_spawn_boom(this); break;
+               case NADE_TYPE_HEAL: nade_heal_boom(this); break;
+               case NADE_TYPE_MONSTER: nade_monster_boom(this); break;
        }
 
-       entity head;
-       for(head = world; (head = find(head, classname, "grapplinghook")); )
-       if(head.aiment == self)
-               RemoveGrapplingHook(head.realowner);
+       FOREACH_ENTITY_ENT(aiment, this,
+       {
+               if(it.classname == "grapplinghook")
+                       RemoveGrapplingHook(it.realowner);
+       });
 
-       remove(self);
+       remove(this);
 }
 
-void nade_touch()
-{SELFPARAM();
+void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
+void nade_pickup(entity this, entity thenade)
+{
+       spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, thenade.nade_type, thenade.pokenade_type);
+
+       // set refire so player can't even
+       this.nade_refire = time + autocvar_g_nades_nade_refire;
+       this.nade_timer = 0;
+
+       if(this.nade)
+               this.nade.nade_time_primed = thenade.nade_time_primed;
+}
+
+bool CanThrowNade(entity this);
+void nade_touch(entity this)
+{
+       if(other)
+               UpdateCSQCProjectile(self);
+
+       if(other == self.realowner)
+               return; // no self impacts
+
+       if(autocvar_g_nades_pickup)
+       if(time >= self.spawnshieldtime)
+       if(!other.nade && self.health == self.max_health) // no boosted shot pickups, thank you very much
+       if(!other.frozen)
+       if(CanThrowNade(other)) // prevent some obvious things, like dead players
+       if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here
+       {
+               nade_pickup(other, self);
+               sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+               remove(self);
+               return;
+       }
        /*float is_weapclip = 0;
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
        if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
@@ -678,15 +717,16 @@ void nade_touch()
                is_weapclip = 1;*/
        if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip)
        {
-               entity head;
-               for(head = world; (head = find(head, classname, "grapplinghook")); )
-               if(head.aiment == self)
-                       RemoveGrapplingHook(head.realowner);
+               FOREACH_ENTITY_ENT(aiment, self,
+               {
+                       if(it.classname == "grapplinghook")
+                               RemoveGrapplingHook(it.realowner);
+               });
                remove(self);
                return;
        }
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        //setsize(self, '-2 -2 -2', '2 2 2');
        //UpdateCSQCProjectile(self);
@@ -697,26 +737,26 @@ void nade_touch()
        }
 
        self.enemy = other;
-       nade_boom();
+       nade_boom(self);
 }
 
-void nade_beep()
-{SELFPARAM();
-       sound(self, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
-       self.think = nade_boom;
-       self.nextthink = max(self.wait, time);
+void nade_beep(entity this)
+{
+       sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+       setthink(this, nade_boom);
+       this.nextthink = max(this.wait, time);
 }
 
-void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+void nade_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
-               self.takedamage = DAMAGE_NO;
-               nade_boom();
+               this.takedamage = DAMAGE_NO;
+               WITHSELF(this, nade_boom(this));
                return;
        }
 
-       if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id)
+       if(this.nade_type == NADE_TYPE_TRANSLOCATE.m_id || this.nade_type == NADE_TYPE_SPAWN.m_id)
                return;
 
        if (MUTATOR_CALLHOOK(Nade_Damage, DEATH_WEAPONOF(deathtype), force, damage)) {}
@@ -733,46 +773,46 @@ void nade_damage(entity inflictor, entity attacker, float damage, int deathtype,
        else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
        {
                force *= 6;
-               damage = self.max_health * 0.55;
+               damage = this.max_health * 0.55;
        }
        else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
-               damage = self.max_health * 0.1;
+               damage = this.max_health * 0.1;
        else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
        {
                if(deathtype & HITTYPE_SECONDARY)
                {
-                       damage = self.max_health * 0.1;
+                       damage = this.max_health * 0.1;
                        force *= 10;
                }
                else
-                       damage = self.max_health * 1.15;
+                       damage = this.max_health * 1.15;
        }
 
-       self.velocity += force;
-       UpdateCSQCProjectile(self);
+       this.velocity += force;
+       UpdateCSQCProjectile(this);
 
-       if(damage <= 0 || ((self.flags & FL_ONGROUND) && IS_PLAYER(attacker)))
+       if(damage <= 0 || ((IS_ONGROUND(this)) && IS_PLAYER(attacker)))
                return;
 
-       if(self.health == self.max_health)
+       if(this.health == this.max_health)
        {
-               sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
-               self.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
-               self.think = nade_beep;
+               sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+               this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time);
+               setthink(this, nade_beep);
        }
 
-       self.health -= damage;
+       this.health -= damage;
 
-       if ( self.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
-               self.realowner = attacker;
+       if ( this.nade_type != NADE_TYPE_HEAL.m_id || IS_PLAYER(attacker) )
+               this.realowner = attacker;
 
-       if(self.health <= 0)
-               W_PrepareExplosionByDamage(attacker, nade_boom);
+       if(this.health <= 0)
+               W_PrepareExplosionByDamage(this, attacker, nade_boom);
        else
-               nade_burn_spawn(self);
+               nade_burn_spawn(this);
 }
 
-void toss_nade(entity e, vector _velocity, float _time)
+void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
 {SELFPARAM();
        if(e.nade == world)
                return;
@@ -785,9 +825,9 @@ void toss_nade(entity e, vector _velocity, float _time)
 
        makevectors(e.v_angle);
 
-       W_SetupShot(e, false, false, "", CH_WEAPON_A, 0);
+       W_SetupShot(e, false, false, SND_Null, CH_WEAPON_A, 0);
 
-       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_NADES);
+       Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
 
        vector offset = (v_forward * autocvar_g_nades_throw_offset.x)
                                  + (v_right * autocvar_g_nades_throw_offset.y)
@@ -799,14 +839,17 @@ void toss_nade(entity e, vector _velocity, float _time)
        //setmodel(_nade, MDL_PROJECTILE_NADE);
        //setattachment(_nade, world, "");
        PROJECTILE_MAKETRIGGER(_nade);
-       setsize(_nade, '-16 -16 -16', '16 16 16');
+       if(STAT(NADES_SMALL, e))
+               setsize(_nade, '-8 -8 -8', '8 8 8');
+       else
+               setsize(_nade, '-16 -16 -16', '16 16 16');
        _nade.movetype = MOVETYPE_BOUNCE;
 
        tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
        if (trace_startsolid)
                setorigin(_nade, e.origin);
 
-       if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && self.BUTTON_CROUCH)
+       if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(self))
                _nade.velocity = '0 0 100';
        else if(autocvar_g_nades_nade_newton_style == 1)
                _nade.velocity = e.velocity + _velocity;
@@ -815,12 +858,16 @@ void toss_nade(entity e, vector _velocity, float _time)
        else
                _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true);
 
-       _nade.touch = nade_touch;
+       if(set_owner)
+               _nade.realowner = e;
+
+       settouch(_nade, nade_touch);
+       _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
        _nade.health = autocvar_g_nades_nade_health;
        _nade.max_health = _nade.health;
        _nade.takedamage = DAMAGE_AIM;
        _nade.event_damage = nade_damage;
-       _nade.customizeentityforclient = func_null;
+       setcefc(_nade, func_null);
        _nade.exteriormodeltoclient = world;
        _nade.traileffectnum = 0;
        _nade.teleportable = true;
@@ -843,7 +890,7 @@ void toss_nade(entity e, vector _velocity, float _time)
 
        if(_time)
        {
-               _nade.think = nade_boom;
+               setthink(_nade, nade_boom);
                _nade.nextthink = _time;
        }
 
@@ -857,8 +904,8 @@ void nades_GiveBonus(entity player, float score)
        if (autocvar_g_nades_bonus)
        if (IS_REAL_CLIENT(player))
        if (IS_PLAYER(player) && player.bonus_nades < autocvar_g_nades_bonus_max)
-       if (player.frozen == 0)
-       if (player.deadflag == DEAD_NO)
+       if (STAT(FROZEN, player) == 0)
+       if (!IS_DEAD(player))
        {
                if ( player.bonus_nade_score < 1 )
                        player.bonus_nade_score += score/autocvar_g_nades_bonus_score_max;
@@ -881,13 +928,15 @@ void nades_RemoveBonus(entity player)
 
 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
 {
-       nades_RemoveBonus(self);
+    entity player = M_ARGV(0, entity);
+
+       nades_RemoveBonus(player);
 }
 
-float nade_customize()
-{SELFPARAM();
+float nade_customize(entity this)
+{
        //if(IS_SPEC(other)) { return false; }
-       if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
+       if(other == self.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient))
        {
                // somewhat hide the model, but keep the glow
                //self.effects = 0;
@@ -906,6 +955,42 @@ float nade_customize()
        return true;
 }
 
+void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
+{
+       entity n = new(nade), fn = new(fake_nade);
+
+       n.nade_type = bound(1, ntype, Nades_COUNT);
+       n.pokenade_type = pntype;
+
+       setmodel(n, MDL_PROJECTILE_NADE);
+       //setattachment(n, player, "bip01 l hand");
+       n.exteriormodeltoclient = player;
+       setcefc(n, nade_customize);
+       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], player.team).eent_eff_name);
+       n.colormod = Nades_from(n.nade_type).m_color;
+       n.realowner = nowner;
+       n.colormap = player.colormap;
+       n.glowmod = player.glowmod;
+       n.wait = time + max(0, ntime);
+       n.nade_time_primed = time;
+       setthink(n, nade_beep);
+       n.nextthink = max(n.wait - 3, time);
+       n.projectiledeathtype = DEATH_NADE.m_id;
+
+       setmodel(fn, MDL_NADE_VIEW);
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+       setattachment(fn, player.(weaponentity), "");
+       fn.realowner = fn.owner = player;
+       fn.colormod = Nades_from(n.nade_type).m_color;
+       fn.colormap = player.colormap;
+       fn.glowmod = player.glowmod;
+       setthink(fn, SUB_Remove);
+       fn.nextthink = n.wait;
+
+       player.nade = n;
+       player.fake_nade = fn;
+}
+
 void nade_prime()
 {SELFPARAM();
        if(autocvar_g_nades_bonus_only)
@@ -918,71 +1003,44 @@ void nade_prime()
        if(self.fake_nade)
                remove(self.fake_nade);
 
-       entity n = new(nade), fn = new(fake_nade);
+       int ntype;
+       string pntype = self.pokenade_type;
 
        if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
-               n.nade_type = self.nade_type;
+               ntype = self.nade_type;
        else if (self.bonus_nades >= 1)
        {
-               n.nade_type = self.nade_type;
-               n.pokenade_type = self.pokenade_type;
+               ntype = self.nade_type;
+               pntype = self.pokenade_type;
                self.bonus_nades -= 1;
        }
        else
        {
-               n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
-               n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
+               ntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
+               pntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
        }
 
-       n.nade_type = bound(1, n.nade_type, Nades_COUNT);
-
-       setmodel(n, MDL_PROJECTILE_NADE);
-       //setattachment(n, self, "bip01 l hand");
-       n.exteriormodeltoclient = self;
-       n.customizeentityforclient = nade_customize;
-       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], self.team).eent_eff_name);
-       n.colormod = Nades_from(n.nade_type).m_color;
-       n.realowner = self;
-       n.colormap = self.colormap;
-       n.glowmod = self.glowmod;
-       n.wait = time + autocvar_g_nades_nade_lifetime;
-       n.nade_time_primed = time;
-       n.think = nade_beep;
-       n.nextthink = max(n.wait - 3, time);
-       n.projectiledeathtype = DEATH_NADE.m_id;
-
-       setmodel(fn, MDL_NADE_VIEW);
-       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-       setattachment(fn, self.(weaponentity), "");
-       fn.realowner = fn.owner = self;
-       fn.colormod = Nades_from(n.nade_type).m_color;
-       fn.colormap = self.colormap;
-       fn.glowmod = self.glowmod;
-       fn.think = SUB_Remove_self;
-       fn.nextthink = n.wait;
-
-       self.nade = n;
-       self.fake_nade = fn;
+       spawn_held_nade(self, self, autocvar_g_nades_nade_lifetime, ntype, pntype);
 }
 
-float CanThrowNade()
-{SELFPARAM();
-       if(self.vehicle)
+bool CanThrowNade(entity this)
+{
+       if(this.vehicle)
                return false;
 
        if(gameover)
                return false;
 
-       if(self.deadflag != DEAD_NO)
+       if(IS_DEAD(this))
                return false;
 
        if (!autocvar_g_nades)
                return false; // allow turning them off mid match
 
-       if(forbidWeaponUse(self))
+       if(forbidWeaponUse(this))
                return false;
 
-       if (!IS_PLAYER(self))
+       if (!IS_PLAYER(this))
                return false;
 
        return true;
@@ -992,7 +1050,7 @@ float CanThrowNade()
 
 void nades_CheckThrow()
 {SELFPARAM();
-       if(!CanThrowNade())
+       if(!CanThrowNade(self))
                return;
 
        entity held_nade = self.nade;
@@ -1014,7 +1072,9 @@ void nades_CheckThrow()
                        float _force = time - held_nade.nade_time_primed;
                        _force /= autocvar_g_nades_nade_lifetime;
                        _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
-                       toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
+                       vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05);
+                       dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
+                       toss_nade(self, true, dir * _force, 0);
                }
        }
 }
@@ -1033,7 +1093,7 @@ void nades_Clear(entity player)
 MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
 {
        if(vh_player.nade)
-               toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
+               toss_nade(vh_player, true, '0 0 100', max(vh_player.nade.wait, time + 0.05));
 
        return false;
 }
@@ -1052,10 +1112,10 @@ CLASS(NadeOffhand, OffhandWeapon)
                        held_nade.angles_y = player.angles.y;
 
                        if (time + 0.1 >= held_nade.wait)
-                               toss_nade(player, '0 0 0', time + 0.05);
+                               toss_nade(player, false, '0 0 0', time + 0.05);
                }
 
-        if (!CanThrowNade()) return;
+        if (!CanThrowNade(player)) return;
         if (!(time > player.nade_refire)) return;
                if (key_pressed) {
                        if (!held_nade) {
@@ -1068,7 +1128,9 @@ CLASS(NadeOffhand, OffhandWeapon)
                                float _force = time - held_nade.nade_time_primed;
                                _force /= autocvar_g_nades_nade_lifetime;
                                _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
-                               toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
+                               vector dir = (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1);
+                               dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style);
+                               toss_nade(player, false, dir * _force, 0);
                        }
                }
     }
@@ -1077,6 +1139,7 @@ NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOff
 
 MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST)
 {
+    SELFPARAM();
        if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
                nades_CheckThrow();
                return true;
@@ -1137,23 +1200,22 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
        {
                vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size;
                n = 0;
-               FOR_EACH_PLAYER(other) if(self != other)
-               {
-                       if(other.deadflag == DEAD_NO)
-                       if(other.frozen == 0)
-                       if(SAME_TEAM(other, self))
-                       if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax))
+               FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+                       if(!IS_DEAD(it))
+                       if(STAT(FROZEN, it) == 0)
+                       if(SAME_TEAM(it, self))
+                       if(boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, it.absmin, it.absmax))
                        {
                                if(!o)
-                                       o = other;
-                               if(self.frozen == 1)
-                                       other.reviving = true;
+                                       o = it;
+                               if(STAT(FROZEN, self) == 1)
+                                       it.reviving = true;
                                ++n;
                        }
-               }
+               ));
        }
 
-       if(n && self.frozen == 3) // OK, there is at least one teammate reviving us
+       if(n && STAT(FROZEN, self) == 3) // OK, there is at least one teammate reviving us
        {
                self.revive_progress = bound(0, self.revive_progress + frametime * max(1/60, autocvar_g_freezetag_revive_speed), 1);
                self.health = max(1, self.revive_progress * start_health);
@@ -1166,39 +1228,40 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
                        Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
                }
 
-               FOR_EACH_PLAYER(other) if(other.reviving)
-               {
+               FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA(
                        other.revive_progress = self.revive_progress;
                        other.reviving = false;
-               }
+               ));
        }
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
-{SELFPARAM();
+{
+       entity player = M_ARGV(0, entity);
+
        if(autocvar_g_nades_spawn)
-               self.nade_refire = time + autocvar_g_spawnshieldtime;
+               player.nade_refire = time + autocvar_g_spawnshieldtime;
        else
-               self.nade_refire  = time + autocvar_g_nades_nade_refire;
+               player.nade_refire  = time + autocvar_g_nades_nade_refire;
 
        if(autocvar_g_nades_bonus_client_select)
-               self.nade_type = self.cvar_cl_nade_type;
+               player.nade_type = player.cvar_cl_nade_type;
 
-       self.nade_timer = 0;
+       player.nade_timer = 0;
 
-       if (!self.offhand) self.offhand = OFFHAND_NADE;
+       if (!player.offhand) player.offhand = OFFHAND_NADE;
 
-       if(self.nade_spawnloc)
+       if(player.nade_spawnloc)
        {
-               setorigin(self, self.nade_spawnloc.origin);
-               self.nade_spawnloc.cnt -= 1;
+               setorigin(player, player.nade_spawnloc.origin);
+               player.nade_spawnloc.cnt -= 1;
 
-               if(self.nade_spawnloc.cnt <= 0)
+               if(player.nade_spawnloc.cnt <= 0)
                {
-                       remove(self.nade_spawnloc);
-                       self.nade_spawnloc = world;
+                       remove(player.nade_spawnloc);
+                       player.nade_spawnloc = world;
                }
        }
 
@@ -1207,9 +1270,12 @@ MUTATOR_HOOKFUNCTION(nades, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+
        if(frag_target.nade)
-       if(!frag_target.frozen || !autocvar_g_freezetag_revive_nade)
-               toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
+       if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
+               toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
 
        float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
 
@@ -1235,13 +1301,16 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
        }
 
        nades_RemoveBonus(frag_target);
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
 {
-       if(frag_target.frozen)
+       entity frag_inflictor = M_ARGV(0, entity);
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+
+       if(STAT(FROZEN, frag_target))
        if(autocvar_g_freezetag_revive_nade)
        if(frag_attacker == frag_target)
        if(frag_deathtype == DEATH_NADE.m_id)
@@ -1250,8 +1319,8 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
                Unfreeze(frag_target);
                frag_target.health = autocvar_g_freezetag_revive_nade_health;
                Send_Effect(EFFECT_ICEORGLASS, frag_target.origin, '0 0 0', 3);
-               frag_damage = 0;
-               frag_force = '0 0 0';
+               M_ARGV(4, float) = 0;
+               M_ARGV(6, vector) = '0 0 0';
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
                Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
        }
@@ -1260,10 +1329,13 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
 }
 
 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
-{SELFPARAM();
+{
+       entity frag_target = M_ARGV(0, entity);
+       entity frag_attacker = M_ARGV(1, entity);
+
        if(IS_PLAYER(frag_attacker))
-       if(DIFF_TEAM(frag_attacker, self))
-       if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
+       if(DIFF_TEAM(frag_attacker, frag_target))
+       if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
                nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor);
 
        return false;
@@ -1271,8 +1343,10 @@ MUTATOR_HOOKFUNCTION(nades, MonsterDies)
 
 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
 {
+       entity frag_target = M_ARGV(0, entity);
+       
        if(frag_target.nade)
-               toss_nade(frag_target, '0 0 0', time + 0.05);
+               toss_nade(frag_target, true, '0 0 0', time + 0.05);
 
        return false;
 }
@@ -1300,13 +1374,8 @@ MUTATOR_HOOKFUNCTION(nades, SpectateCopy)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(nades, GetCvars)
-{
-       GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_nade_type, "cl_nade_type");
-       GetCvars_handleString(get_cvars_s, get_cvars_f, cvar_cl_pokenade_type, "cl_pokenade_type");
-
-       return false;
-}
+REPLICATE(cvar_cl_nade_type, int, "cl_nade_type");
+REPLICATE(cvar_cl_pokenade_type, string, "cl_pokenade_type");
 
 MUTATOR_HOOKFUNCTION(nades, BuildMutatorsString)
 {