]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
Remove SELFPARAM() from .think and .touch
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / onslaught.qc
index 93afb72077500dca1fc5c9903a263ee458a2f2a9..0870ed6bfa323b0811b504b9d7db39330c9fd19a 100644 (file)
@@ -13,7 +13,7 @@ REGISTER_MUTATOR(ons, false)
                ons_Initialize();
 
                ActivateTeamplay();
-               SetLimits(autocvar_g_onslaught_point_limit, -1, -1, -1);
+               SetLimits(autocvar_g_onslaught_point_limit, autocvar_leadlimit_override, autocvar_timelimit_override, -1);
                have_team_spawns = -1; // request team spawns
        }
 
@@ -172,8 +172,8 @@ bool ons_CaptureShield_Customize()
        return true;
 }
 
-void ons_CaptureShield_Touch()
-{SELFPARAM();
+void ons_CaptureShield_Touch(entity this)
+{
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
        if(!IS_PLAYER(other)) { return; }
        if(SAME_TEAM(other, self)) { return; }
@@ -208,7 +208,7 @@ void ons_CaptureShield_Spawn(entity generator, bool is_generator)
        shield.team = generator.team;
        shield.colormap = generator.colormap;
        shield.reset = ons_CaptureShield_Reset;
-       shield.touch = ons_CaptureShield_Touch;
+       settouch(shield, ons_CaptureShield_Touch);
        shield.customizeentityforclient = ons_CaptureShield_Customize;
        shield.effects = EF_ADDITIVE;
        shield.movetype = MOVETYPE_NOCLIP;
@@ -395,36 +395,36 @@ bool ons_Link_Send(entity this, entity to, int sendflags)
        return true;
 }
 
-void ons_Link_CheckUpdate()
-{SELFPARAM();
+void ons_Link_CheckUpdate(entity this)
+{
        // TODO check if the two sides have moved (currently they won't move anyway)
        float cc = 0, cc1 = 0, cc2 = 0;
 
-       if(self.goalentity.islinked || self.goalentity.iscaptured) { cc1 = (self.goalentity.team - 1) * 0x01; }
-       if(self.enemy.islinked || self.enemy.iscaptured) { cc2 = (self.enemy.team - 1) * 0x10; }
+       if(this.goalentity.islinked || this.goalentity.iscaptured) { cc1 = (this.goalentity.team - 1) * 0x01; }
+       if(this.enemy.islinked || this.enemy.iscaptured) { cc2 = (this.enemy.team - 1) * 0x10; }
 
        cc = cc1 + cc2;
 
-       if(cc != self.clientcolors)
+       if(cc != this.clientcolors)
        {
-               self.clientcolors = cc;
-               self.SendFlags |= 4;
+               this.clientcolors = cc;
+               this.SendFlags |= 4;
        }
 
-       self.nextthink = time;
+       this.nextthink = time;
 }
 
-void ons_DelayedLinkSetup()
-{SELFPARAM();
-       self.goalentity = find(world, targetname, self.target);
-       self.enemy = find(world, targetname, self.target2);
-       if(!self.goalentity) { objerror("can not find target\n"); }
-       if(!self.enemy) { objerror("can not find target2\n"); }
+void ons_DelayedLinkSetup(entity this)
+{
+       this.goalentity = find(world, targetname, this.target);
+       this.enemy = find(world, targetname, this.target2);
+       if(!this.goalentity) { objerror("can not find target\n"); }
+       if(!this.enemy) { objerror("can not find target2\n"); }
 
-       LOG_DEBUG(strcat(etos(self.goalentity), " linked with ", etos(self.enemy), "\n"));
-       self.SendFlags |= 3;
-       self.think = ons_Link_CheckUpdate;
-       self.nextthink = time;
+       LOG_DEBUG(strcat(etos(this.goalentity), " linked with ", etos(this.enemy), "\n"));
+       this.SendFlags |= 3;
+       setthink(this, ons_Link_CheckUpdate);
+       this.nextthink = time;
 }
 
 
@@ -546,10 +546,7 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               setself(this.owner);
-               activator = this;
-               WITH(entity, self, this, SUB_UseTargets());
-               setself(this);
+               SUB_UseTargets(this.owner, this, NULL);
 
                this.owner.waslinked = this.owner.islinked;
                if(this.owner.model != "models/onslaught/controlpoint_pad.md3")
@@ -562,9 +559,9 @@ void ons_ControlPoint_Icon_Damage(entity this, entity inflictor, entity attacker
        this.SendFlags |= CPSF_STATUS;
 }
 
-void ons_ControlPoint_Icon_Think()
-{SELFPARAM();
-       self.nextthink = time + ONS_CP_THINKRATE;
+void ons_ControlPoint_Icon_Think(entity this)
+{
+       this.nextthink = time + ONS_CP_THINKRATE;
 
        if(autocvar_g_onslaught_cp_proxydecap)
        {
@@ -572,9 +569,9 @@ void ons_ControlPoint_Icon_Think()
                int _friendly_count = 0;
 
                FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), {
-                       if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
+                       if(vdist(it.origin - this.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
                        {
-                               if(SAME_TEAM(it, self))
+                               if(SAME_TEAM(it, this))
                                        ++_friendly_count;
                                else
                                        ++_enemy_count;
@@ -584,113 +581,107 @@ void ons_ControlPoint_Icon_Think()
                _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
                _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * ONS_CP_THINKRATE);
 
-               self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
-               self.SendFlags |= CPSF_STATUS;
-               if(self.health <= 0)
+               this.health = bound(0, this.health + (_friendly_count - _enemy_count), this.max_health);
+               this.SendFlags |= CPSF_STATUS;
+               if(this.health <= 0)
                {
-                       ons_ControlPoint_Icon_Damage(self, self, self, 1, 0, self.origin, '0 0 0');
+                       ons_ControlPoint_Icon_Damage(this, this, this, 1, 0, this.origin, '0 0 0');
                        return;
                }
        }
 
-       if (time > self.pain_finished + 5)
+       if (time > this.pain_finished + 5)
        {
-               if(self.health < self.max_health)
+               if(this.health < this.max_health)
                {
-                       self.health = self.health + self.count;
-                       if (self.health >= self.max_health)
-                               self.health = self.max_health;
-                       WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+                       this.health = this.health + this.count;
+                       if (this.health >= this.max_health)
+                               this.health = this.max_health;
+                       WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
                }
        }
 
-       if(self.owner.islinked != self.owner.waslinked)
+       if(this.owner.islinked != this.owner.waslinked)
        {
                // unteam the spawnpoint if needed
-               int t = self.owner.team;
-               if(!self.owner.islinked)
-                       self.owner.team = 0;
+               int t = this.owner.team;
+               if(!this.owner.islinked)
+                       this.owner.team = 0;
 
-               setself(self.owner);
-               activator = self;
-               SUB_UseTargets ();
-               setself(this);
+               SUB_UseTargets(this.owner, this, NULL);
 
-               self.owner.team = t;
+               this.owner.team = t;
 
-               self.owner.waslinked = self.owner.islinked;
+               this.owner.waslinked = this.owner.islinked;
        }
 
        // damaged fx
-       if(random() < 0.6 - self.health / self.max_health)
+       if(random() < 0.6 - this.health / this.max_health)
        {
-               Send_Effect(EFFECT_ELECTRIC_SPARKS, self.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
+               Send_Effect(EFFECT_ELECTRIC_SPARKS, this.origin + randompos('-10 -10 -20', '10 10 20'), '0 0 0', 1);
 
                if(random() > 0.8)
-                       sound(self, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_PAIN, SND_ONS_SPARK1, VOL_BASE, ATTEN_NORM);
                else if (random() > 0.5)
-                       sound(self, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
+                       sound(this, CH_PAIN, SND_ONS_SPARK2, VOL_BASE, ATTEN_NORM);
        }
 }
 
-void ons_ControlPoint_Icon_BuildThink()
-{SELFPARAM();
+void ons_ControlPoint_Icon_BuildThink(entity this)
+{
        int a;
 
-       self.nextthink = time + ONS_CP_THINKRATE;
+       this.nextthink = time + ONS_CP_THINKRATE;
 
        // only do this if there is power
-       a = ons_ControlPoint_CanBeLinked(self.owner, self.owner.team);
+       a = ons_ControlPoint_CanBeLinked(this.owner, this.owner.team);
        if(!a)
                return;
 
-       self.health = self.health + self.count;
+       this.health = this.health + this.count;
 
-       self.SendFlags |= CPSF_STATUS;
+       this.SendFlags |= CPSF_STATUS;
 
-       if (self.health >= self.max_health)
+       if (this.health >= this.max_health)
        {
-               self.health = self.max_health;
-               self.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
-               self.think = ons_ControlPoint_Icon_Think;
-               sound(self, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
-               self.owner.iscaptured = true;
-               self.solid = SOLID_BBOX;
+               this.health = this.max_health;
+               this.count = autocvar_g_onslaught_cp_regen * ONS_CP_THINKRATE; // slow repair rate from now on
+               setthink(this, ons_ControlPoint_Icon_Think);
+               sound(this, CH_TRIGGER, SND_ONS_CONTROLPOINT_BUILT, VOL_BASE, ATTEN_NORM);
+               this.owner.iscaptured = true;
+               this.solid = SOLID_BBOX;
 
-               Send_Effect(EFFECT_CAP(self.owner.team), self.owner.origin, '0 0 0', 1);
+               Send_Effect(EFFECT_CAP(this.owner.team), this.owner.origin, '0 0 0', 1);
 
-               WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
-               WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+               WaypointSprite_UpdateMaxHealth(this.owner.sprite, this.max_health);
+               WaypointSprite_UpdateHealth(this.owner.sprite, this.health);
 
-               if(IS_PLAYER(self.owner.ons_toucher))
+               if(IS_PLAYER(this.owner.ons_toucher))
                {
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message);
-                       Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(self.owner.ons_toucher.team, CENTER_ONS_CAPTURE), self.owner.message);
-                       Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message);
-                       PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1);
-                       PlayerTeamScore_AddScore(self.owner.ons_toucher, 10);
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
+                       Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
+                       Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
+                       PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
+                       PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
                }
 
-               self.owner.ons_toucher = world;
+               this.owner.ons_toucher = world;
 
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               setself(self.owner);
-               activator = self;
-               SUB_UseTargets ();
-               setself(this);
+               SUB_UseTargets(this.owner, this, NULL);
 
-               self.SendFlags |= CPSF_SETUP;
+               this.SendFlags |= CPSF_SETUP;
        }
-       if(self.owner.model != MDL_ONS_CP_PAD2.model_str())
-               setmodel_fixsize(self.owner, MDL_ONS_CP_PAD2);
+       if(this.owner.model != MDL_ONS_CP_PAD2.model_str())
+               setmodel_fixsize(this.owner, MDL_ONS_CP_PAD2);
 
-       if(random() < 0.9 - self.health / self.max_health)
-               Send_Effect(EFFECT_RAGE, self.origin + 10 * randomvec(), '0 0 -1', 1);
+       if(random() < 0.9 - this.health / this.max_health)
+               Send_Effect(EFFECT_RAGE, this.origin + 10 * randomvec(), '0 0 -1', 1);
 }
 
-void onslaught_controlpoint_icon_link(entity e, void() spawnproc);
+void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc);
 
 void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
 {
@@ -785,8 +776,8 @@ void ons_ControlPoint_UpdateSprite(entity e)
        }
 }
 
-void ons_ControlPoint_Touch()
-{SELFPARAM();
+void ons_ControlPoint_Touch(entity this)
+{
        entity toucher = other;
        int attackable;
 
@@ -822,8 +813,8 @@ void ons_ControlPoint_Touch()
        onslaught_updatelinks();
 }
 
-void ons_ControlPoint_Think()
-{SELFPARAM();
+void ons_ControlPoint_Think(entity this)
+{
        self.nextthink = time + ONS_CP_THINKRATE;
        CSQCMODEL_AUTOUPDATE(self);
 }
@@ -839,7 +830,7 @@ void ons_ControlPoint_Reset(entity this)
        this.iscaptured = false;
        this.islinked = false;
        this.isshielded = true;
-       this.think = ons_ControlPoint_Think;
+       setthink(this, ons_ControlPoint_Think);
        this.ons_toucher = world;
        this.nextthink = time + ONS_CP_THINKRATE;
        setmodel_fixsize(this, MDL_ONS_CP_PAD1);
@@ -849,27 +840,23 @@ void ons_ControlPoint_Reset(entity this)
 
        onslaught_updatelinks();
 
-       activator = this;
-       SUB_UseTargets(); // to reset the structures, playerspawns etc.
+       SUB_UseTargets(this, this, NULL); // to reset the structures, playerspawns etc.
 
        CSQCMODEL_AUTOUPDATE(this);
 }
 
-void ons_DelayedControlPoint_Setup()
-{SELFPARAM();
+void ons_DelayedControlPoint_Setup(entity this)
+{
        onslaught_updatelinks();
 
        // captureshield setup
-       ons_CaptureShield_Spawn(self, false);
+       ons_CaptureShield_Spawn(this, false);
 
-       CSQCMODEL_AUTOINIT(self);
+       CSQCMODEL_AUTOINIT(this);
 }
 
 void ons_ControlPoint_Setup(entity cp)
-{SELFPARAM();
-       // declarations
-       setself(cp); // for later usage with droptofloor()
-
+{
        // main setup
        cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
        ons_worldcplist = cp;
@@ -878,8 +865,8 @@ void ons_ControlPoint_Setup(entity cp)
        cp.team = 0;
        cp.solid = SOLID_BBOX;
        cp.movetype = MOVETYPE_NONE;
-       cp.touch = ons_ControlPoint_Touch;
-       cp.think = ons_ControlPoint_Think;
+       settouch(cp, ons_ControlPoint_Touch);
+       setthink(cp, ons_ControlPoint_Think);
        cp.nextthink = time + ONS_CP_THINKRATE;
        cp.reset = ons_ControlPoint_Reset;
        cp.colormap = 1024;
@@ -902,14 +889,13 @@ void ons_ControlPoint_Setup(entity cp)
        {
                setorigin(cp, cp.origin + '0 0 20');
                cp.noalign = false;
-               setself(cp);
-               droptofloor();
+               WITHSELF(cp, droptofloor());
                cp.movetype = MOVETYPE_TOSS;
        }
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_SpawnFixed(WP_Null, cp.origin + CPGEN_WAYPOINT_OFFSET, cp, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(cp.sprite, cp.team, SPRITERULE_TEAMPLAY);
 
        InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
 }
@@ -1004,7 +990,7 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d
                this.takedamage = DAMAGE_NO; // can't be hurt anymore
                this.event_damage = func_null; // won't do anything if hurt
                this.count = 0; // reset counter
-               this.think = func_null;
+               setthink(this, func_null);
                this.nextthink = 0;
                //this.think(); // do the first explosion now
 
@@ -1035,22 +1021,22 @@ void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float d
        this.SendFlags |= GSF_STATUS;
 }
 
-void ons_GeneratorThink()
-{SELFPARAM();
-       self.nextthink = time + GEN_THINKRATE;
+void ons_GeneratorThink(entity this)
+{
+       this.nextthink = time + GEN_THINKRATE;
        if (!gameover)
        {
-               if(!self.isshielded && self.wait < time)
+               if(!this.isshielded && this.wait < time)
                {
-                       self.wait = time + 5;
+                       this.wait = time + 5;
                        FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
-                               if(SAME_TEAM(it, self))
+                               if(SAME_TEAM(it, this))
                                {
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
                                        soundto(MSG_ONE, it, CHAN_AUTO, SND(KH_ALARM), VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
                                }
                                else
-                                       Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(self.team, CENTER_ONS_NOTSHIELDED));
+                                       Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(this.team, CENTER_ONS_NOTSHIELDED));
                        });
                }
        }
@@ -1066,7 +1052,7 @@ void ons_GeneratorReset(entity this)
        this.islinked = true;
        this.isshielded = true;
        this.event_damage = ons_GeneratorDamage;
-       this.think = ons_GeneratorThink;
+       setthink(this, ons_GeneratorThink);
        this.nextthink = time + GEN_THINKRATE;
 
        Net_LinkEntity(this, false, 0, generator_send);
@@ -1081,8 +1067,8 @@ void ons_GeneratorReset(entity this)
        onslaught_updatelinks();
 }
 
-void ons_DelayedGeneratorSetup()
-{SELFPARAM();
+void ons_DelayedGeneratorSetup(entity this)
+{
        // bot waypoints
        waypoint_spawnforitem_force(self, self.origin);
        self.nearestwaypointtimeout = 0; // activate waypointing again
@@ -1097,8 +1083,8 @@ void ons_DelayedGeneratorSetup()
 }
 
 
-void onslaught_generator_touch()
-{SELFPARAM();
+void onslaught_generator_touch(entity this)
+{
        if ( IS_PLAYER(other) )
        if ( SAME_TEAM(self,other) )
        if ( self.iscaptured )
@@ -1108,10 +1094,9 @@ void onslaught_generator_touch()
 }
 
 void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
-{SELFPARAM();
+{
        // declarations
        int teamnumber = gen.team;
-       setself(gen); // for later usage with droptofloor()
 
        // main setup
        gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
@@ -1127,12 +1112,12 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.bot_attack = true;
        gen.event_damage = ons_GeneratorDamage;
        gen.reset = ons_GeneratorReset;
-       gen.think = ons_GeneratorThink;
+       setthink(gen, ons_GeneratorThink);
        gen.nextthink = time + GEN_THINKRATE;
        gen.iscaptured = true;
        gen.islinked = true;
        gen.isshielded = true;
-       gen.touch = onslaught_generator_touch;
+       settouch(gen, onslaught_generator_touch);
 
        // appearence
        // model handled by CSQC
@@ -1141,14 +1126,13 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.colormap = 1024 + (teamnumber - 1) * 17;
 
        // generator placement
-       setself(gen);
-       droptofloor();
+       WITHSELF(gen, droptofloor());
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
-       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(gen.sprite, gen.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_UpdateMaxHealth(gen.sprite, gen.max_health);
+       WaypointSprite_UpdateHealth(gen.sprite, gen.health);
 
        InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
 }
@@ -1771,11 +1755,11 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
 // ==============
 
 MUTATOR_HOOKFUNCTION(ons, reset_map_global)
-{SELFPARAM();
+{
        FOREACH_CLIENT(IS_PLAYER(it), {
                it.ons_roundlost = false;
                it.ons_deathloc = '0 0 0';
-               WITH(entity, self, it, PutClientInServer());
+               WITHSELF(it, PutClientInServer());
        });
        return false;
 }
@@ -1951,25 +1935,24 @@ MUTATOR_HOOKFUNCTION(ons, MonsterMove)
        return false;
 }
 
-void ons_MonsterSpawn_Delayed()
-{SELFPARAM();
-       entity e, own = self.owner;
+void ons_MonsterSpawn_Delayed(entity this)
+{
+       entity own = self.owner;
 
-       if(!own) { remove(self); return; }
+       if(!own) { remove(this); return; }
 
        if(own.targetname)
        {
-               e = find(world, target, own.targetname);
+               entity e = find(world, target, own.targetname);
                if(e != world)
                {
                        own.team = e.team;
 
-                       activator = e;
-                       own.use();
+                       own.use(own, e, NULL);
                }
        }
 
-       remove(self);
+       remove(this);
 }
 
 MUTATOR_HOOKFUNCTION(ons, MonsterSpawn)
@@ -1981,22 +1964,21 @@ MUTATOR_HOOKFUNCTION(ons, MonsterSpawn)
        return false;
 }
 
-void ons_TurretSpawn_Delayed()
-{SELFPARAM();
-       entity e, own = self.owner;
+void ons_TurretSpawn_Delayed(entity this)
+{
+       entity own = self.owner;
 
        if(!own) { remove(self); return; }
 
        if(own.targetname)
        {
-               e = find(world, target, own.targetname);
+               entity e = find(world, target, own.targetname);
                if(e != world)
                {
                        own.team = e.team;
                        own.active = ACTIVE_NOT;
 
-                       activator = e;
-                       own.use();
+                       own.use(own, e, NULL);
                }
        }
 
@@ -2174,7 +2156,7 @@ MUTATOR_HOOKFUNCTION(ons, TurretThink)
        }
 
        if(self.team != self.tur_head.team)
-               turret_respawn();
+               turret_respawn(self);
 
        return false;
 }
@@ -2195,16 +2177,16 @@ keys:
  */
 spawnfunc(onslaught_link)
 {
-       if(!g_onslaught) { remove(self); return; }
+       if(!g_onslaught) { remove(this); return; }
 
-       if (self.target == "" || self.target2 == "")
+       if (this.target == "" || this.target2 == "")
                objerror("target and target2 must be set\n");
 
-       self.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
-       ons_worldlinklist = self;
+       this.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
+       ons_worldlinklist = this;
 
-       InitializeEntity(self, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
-       Net_LinkEntity(self, false, 0, ons_Link_Send);
+       InitializeEntity(this, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
+       Net_LinkEntity(this, false, 0, ons_Link_Send);
 }
 
 /*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
@@ -2220,9 +2202,9 @@ keys:
 
 spawnfunc(onslaught_controlpoint)
 {
-       if(!g_onslaught) { remove(self); return; }
+       if(!g_onslaught) { remove(this); return; }
 
-       ons_ControlPoint_Setup(self);
+       ons_ControlPoint_Setup(this);
 }
 
 /*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
@@ -2236,10 +2218,10 @@ keys:
  */
 spawnfunc(onslaught_generator)
 {
-       if(!g_onslaught) { remove(self); return; }
-       if(!self.team) { objerror("team must be set"); }
+       if(!g_onslaught) { remove(this); return; }
+       if(!this.team) { objerror("team must be set"); }
 
-       ons_GeneratorSetup(self);
+       ons_GeneratorSetup(this);
 }
 
 // scoreboard setup
@@ -2253,7 +2235,7 @@ void ons_ScoreRules()
        ScoreRules_basics_end();
 }
 
-void ons_DelayedInit() // Do this check with a delay so we can wait for teams to be set up
+void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up
 {
        ons_ScoreRules();