]> 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 96f346164f03c2eb946ed61e57dcec1c4e35957a..999bd4ada0f08b695f675a089ec3a8769344f3be 100644 (file)
@@ -39,59 +39,61 @@ REGISTER_MUTATOR(cl_nades, true);
 MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
 {
        if (STAT(HEALING_ORB) <= time) return false;
-       MUTATOR_ARGV(0, vector) = NADE_TYPE_HEAL.m_color;
-       MUTATOR_ARGV(0, float) = STAT(HEALING_ORB_ALPHA);
+       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)
 {
-    SELFPARAM();
-       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)
 {
-    SELFPARAM();
-       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;
        if(STAT(NADES_SMALL, NULL))
        {
-               self.mins = '-8 -8 -8';
-               self.maxs = '8 8 8';
+               proj.mins = '-8 -8 -8';
+               proj.maxs = '8 8 8';
        }
        else
        {
-               self.mins = '-16 -16 -16';
-               self.maxs = '16 16 16';
+               proj.mins = '-16 -16 -16';
+               proj.maxs = '16 16 16';
        }
-       self.colormod = nade_type.m_color;
-       self.move_movetype = MOVETYPE_BOUNCE;
-       settouch(self, func_null);
-       self.scale = 1.5;
-       self.avelocity = randomvec() * 720;
+       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)
 {
@@ -147,8 +149,8 @@ REGISTER_MUTATOR(nades, cvar("g_nades"));
 
 .entity nade_spawnloc;
 
-void nade_timer_think()
-{SELFPARAM();
+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))
@@ -167,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;
@@ -216,8 +218,8 @@ void napalm_damage(entity this, float dist, float damage, float edgedamage, floa
 }
 
 
-void napalm_ball_think()
-{SELFPARAM();
+void napalm_ball_think(entity this)
+{
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
@@ -269,7 +271,7 @@ void nade_napalm_ball(entity this)
        proj.scale = 1;//0.5;
        setsize(proj, '-4 -4 -4', '4 4 4');
        setorigin(proj, this.origin);
-       proj.think = napalm_ball_think;
+       setthink(proj, napalm_ball_think);
        proj.nextthink = time;
        proj.damageforcescale = autocvar_g_nades_napalm_ball_damageforcescale;
        proj.effects = EF_LOWPRECISION | EF_FLAME;
@@ -289,8 +291,8 @@ void nade_napalm_ball(entity this)
 }
 
 
-void napalm_fountain_think()
-{SELFPARAM();
+void napalm_fountain_think(entity this)
+{
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
@@ -340,7 +342,7 @@ void nade_napalm_boom(entity this)
        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;
@@ -363,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())
@@ -436,7 +438,7 @@ void nade_ice_boom(entity this)
        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;
@@ -456,7 +458,7 @@ void nade_ice_boom(entity this)
                setattachment(timer, fountain, "");
                timer.colormap = this.colormap;
                timer.glowmod = this.glowmod;
-               timer.think = nade_timer_think;
+               setthink(timer, nade_timer_think);
                timer.nextthink = time;
                timer.wait = fountain.ltime;
                timer.owner = fountain;
@@ -502,8 +504,8 @@ void nade_spawn_boom(entity this)
        this.realowner.nade_spawnloc = spawnloc;
 }
 
-void nade_heal_think()
-{SELFPARAM();
+void nade_heal_think(entity this)
+{
        if(time >= self.ltime)
        {
                remove(self);
@@ -521,8 +523,8 @@ 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))
@@ -584,7 +586,7 @@ void nade_heal_boom(entity this)
 
        Net_LinkEntity(healer, true, 0, healer_send);
 
-       healer.think = nade_heal_think;
+       setthink(healer, nade_heal_think);
        healer.nextthink = time;
        healer.SendFlags |= 1;
 }
@@ -598,8 +600,8 @@ void nade_monster_boom(entity this)
        e.monster_skill = MONSTER_SKILL_INSANE;
 }
 
-void nade_boom()
-{SELFPARAM();
+void nade_boom(entity this)
+{
        entity expef = NULL;
        bool nade_blast = true;
 
@@ -688,8 +690,8 @@ void nade_pickup(entity this, entity thenade)
 }
 
 bool CanThrowNade(entity this);
-void nade_touch()
-{SELFPARAM();
+void nade_touch(entity this)
+{
        if(other)
                UpdateCSQCProjectile(self);
 
@@ -724,7 +726,7 @@ void nade_touch()
                return;
        }
 
-       PROJECTILE_TOUCH;
+       PROJECTILE_TOUCH(this);
 
        //setsize(self, '-2 -2 -2', '2 2 2');
        //UpdateCSQCProjectile(self);
@@ -735,13 +737,13 @@ void nade_touch()
        }
 
        self.enemy = other;
-       nade_boom();
+       nade_boom(self);
 }
 
-void nade_beep()
-{SELFPARAM();
+void nade_beep(entity this)
+{
        sound(this, CH_SHOTS_SINGLE, SND_NADE_BEEP, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
-       this.think = nade_boom;
+       setthink(this, nade_boom);
        this.nextthink = max(this.wait, time);
 }
 
@@ -750,7 +752,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
                this.takedamage = DAMAGE_NO;
-               WITHSELF(this, nade_boom());
+               WITHSELF(this, nade_boom(this));
                return;
        }
 
@@ -796,7 +798,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i
        {
                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);
-               this.think = nade_beep;
+               setthink(this, nade_beep);
        }
 
        this.health -= damage;
@@ -865,7 +867,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
        _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;
@@ -888,7 +890,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
 
        if(_time)
        {
-               _nade.think = nade_boom;
+               setthink(_nade, nade_boom);
                _nade.nextthink = _time;
        }
 
@@ -926,12 +928,13 @@ void nades_RemoveBonus(entity player)
 
 MUTATOR_HOOKFUNCTION(nades, PutClientInServer)
 {
-    SELFPARAM();
-       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.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient))
        {
@@ -962,7 +965,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        setmodel(n, MDL_PROJECTILE_NADE);
        //setattachment(n, player, "bip01 l hand");
        n.exteriormodeltoclient = player;
-       n.customizeentityforclient = nade_customize;
+       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;
@@ -970,7 +973,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        n.glowmod = player.glowmod;
        n.wait = time + max(0, ntime);
        n.nade_time_primed = time;
-       n.think = nade_beep;
+       setthink(n, nade_beep);
        n.nextthink = max(n.wait - 3, time);
        n.projectiledeathtype = DEATH_NADE.m_id;
 
@@ -981,7 +984,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin
        fn.colormod = Nades_from(n.nade_type).m_color;
        fn.colormap = player.colormap;
        fn.glowmod = player.glowmod;
-       fn.think = SUB_Remove_self;
+       setthink(fn, SUB_Remove);
        fn.nextthink = n.wait;
 
        player.nade = n;
@@ -1235,28 +1238,30 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 }
 
 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;
                }
        }
 
@@ -1265,6 +1270,9 @@ 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(!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));
@@ -1293,12 +1301,15 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
        }
 
        nades_RemoveBonus(frag_target);
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
 {
+       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)
@@ -1308,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);
        }
@@ -1319,6 +1330,9 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
 
 MUTATOR_HOOKFUNCTION(nades, MonsterDies)
 {
+       entity frag_target = M_ARGV(0, entity);
+       entity frag_attacker = M_ARGV(1, entity);
+
        if(IS_PLAYER(frag_attacker))
        if(DIFF_TEAM(frag_attacker, frag_target))
        if(!(frag_target.spawnflags & MONSTERFLAG_SPAWNED))
@@ -1329,6 +1343,8 @@ MUTATOR_HOOKFUNCTION(nades, MonsterDies)
 
 MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
 {
+       entity frag_target = M_ARGV(0, entity);
+       
        if(frag_target.nade)
                toss_nade(frag_target, true, '0 0 0', time + 0.05);