]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/sv_turrets.qc
Remove SELFPARAM() from .think and .touch
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / sv_turrets.qc
index 1502be25114f1ddfb5bf90192c796d9f37d2febb..66b3f3dbb61d864a744a620845d809db1b32e0dc 100644 (file)
@@ -164,15 +164,15 @@ float turret_targetscore_generic(entity _turret, entity _target)
 }
 
 // Generic damage handling
-void turret_hide()
-{SELFPARAM();
+void turret_hide(entity this)
+{
        self.effects   |= EF_NODRAW;
        self.nextthink = time + self.respawntime - 0.2;
-       self.think       = turret_respawn;
+       setthink(self, turret_respawn);
 }
 
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
        self.deadflag             = DEAD_DEAD;
        self.tur_head.deadflag = self.deadflag;
 
@@ -201,7 +201,7 @@ void turret_die()
                // Setup respawn
                self.SendFlags    |= TNSF_STATUS;
                self.nextthink   = time + 0.2;
-               self.think               = turret_hide;
+               setthink(self, turret_hide);
 
                tur.tr_death(tur, self);
        }
@@ -245,15 +245,15 @@ void turret_damage(entity this, entity inflictor, entity attacker, float damage,
                this.tur_head.event_damage = func_null;
                this.takedamage                  = DAMAGE_NO;
                this.nextthink = time;
-               this.think = turret_die;
+               setthink(this, turret_die);
        }
 
        this.SendFlags  |= TNSF_STATUS;
 }
 
-void() turret_think;
-void turret_respawn()
-{SELFPARAM();
+void turret_think(entity this);
+void turret_respawn(entity this)
+{
        // Make sure all parts belong to the same team since
        // this function doubles as "teamchange" function.
        self.tur_head.team      = self.team;
@@ -272,7 +272,7 @@ void turret_respawn()
        self.ammo                                       = self.ammo_max;
 
        self.nextthink = time + self.ticrate;
-       self.think       = turret_think;
+       setthink(self, turret_think);
 
        self.SendFlags = TNSF_FULL_UPDATE;
 
@@ -427,8 +427,8 @@ void load_unit_settings(entity ent, bool is_reload)
        }
 }
 
-void turret_projectile_explode()
-{SELFPARAM();
+void turret_projectile_explode(entity this)
+{
 
        self.takedamage = DAMAGE_NO;
        self.event_damage = func_null;
@@ -443,10 +443,10 @@ void turret_projectile_explode()
        remove(self);
 }
 
-void turret_projectile_touch()
+void turret_projectile_touch(entity this)
 {
        PROJECTILE_TOUCH;
-       turret_projectile_explode();
+       turret_projectile_explode(this);
 }
 
 void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
@@ -455,7 +455,7 @@ void turret_projectile_damage(entity this, entity inflictor, entity attacker, fl
        this.health     -= damage;
        //this.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
        if(this.health <= 0)
-               WITHSELF(this, W_PrepareExplosionByDamage(this.owner, turret_projectile_explode));
+               W_PrepareExplosionByDamage(this, this.owner, turret_projectile_explode);
 }
 
 entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
@@ -471,8 +471,8 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
        proj.realowner    = self;
        proj.bot_dodge    = true;
        proj.bot_dodgerating = self.shot_dmg;
-       proj.think                = turret_projectile_explode;
-       proj.touch                = turret_projectile_touch;
+       setthink(proj, turret_projectile_explode);
+       settouch(proj, turret_projectile_touch);
        proj.nextthink    = time + 9;
        proj.movetype           = MOVETYPE_FLYMISSILE;
        proj.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
@@ -499,39 +499,33 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
 ** and updated aim<->predict impact distance.
 **/
 void turret_do_updates(entity t_turret)
-{SELFPARAM();
-       vector enemy_pos;
-
-       setself(t_turret);
+{
+       vector enemy_pos = real_origin(t_turret.enemy);
 
-       enemy_pos = real_origin(self.enemy);
+       WITHSELF(t_turret, turret_tag_fire_update());
 
-       turret_tag_fire_update();
+       t_turret.tur_shotdir_updated = v_forward;
+       t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos);
+       t_turret.tur_dist_aimpos = vlen(t_turret.tur_shotorg - t_turret.tur_aimpos);
 
-       self.tur_shotdir_updated = v_forward;
-       self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos);
-       self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos);
-
-       /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy))
+       /*if((t_turret.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (t_turret.enemy))
        {
-               oldpos = self.enemy.origin;
-               setorigin(self.enemy, self.tur_aimpos);
-               tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-               setorigin(self.enemy, oldpos);
+               oldpos = t_turret.enemy.origin;
+               setorigin(t_turret.enemy, t_turret.tur_aimpos);
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1', '1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
+               setorigin(t_turret.enemy, oldpos);
 
-               if(trace_ent == self.enemy)
-                       self.tur_dist_impact_to_aimpos = 0;
+               if(trace_ent == t_turret.enemy)
+                       t_turret.tur_dist_impact_to_aimpos = 0;
                else
-                       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos);
+                       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos);
        }
        else*/
-               tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-
-       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
-       self.tur_impactent                       = trace_ent;
-       self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1','1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
 
-       setself(this);
+       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos) - (vlen(t_turret.enemy.maxs - t_turret.enemy.mins) * 0.5);
+       t_turret.tur_impactent                   = trace_ent;
+       t_turret.tur_impacttime                 = vlen(t_turret.tur_shotorg - trace_endpos) / t_turret.shot_speed;
 }
 
 /**
@@ -1017,8 +1011,8 @@ void turret_fire()
 #endif
 }
 
-void turret_think()
-{SELFPARAM();
+void turret_think(entity this)
+{
        self.nextthink = time + self.ticrate;
 
        MUTATOR_CALLHOOK(TurretThink, self);
@@ -1179,30 +1173,29 @@ void turret_think()
        When .used a turret switch team to activator.team.
        If activator is world, the turret go inactive.
 */
-void turret_use()
-{SELFPARAM();
-       LOG_TRACE("Turret ",self.netname, " used by ", activator.classname, "\n");
+void turret_use(entity this, entity actor, entity trigger)
+{
+       LOG_TRACE("Turret ",this.netname, " used by ", actor.classname, "\n");
 
-       self.team = activator.team;
+       this.team = actor.team;
 
-       if(self.team == 0)
-               self.active = ACTIVE_NOT;
+       if(this.team == 0)
+               this.active = ACTIVE_NOT;
        else
-               self.active = ACTIVE_ACTIVE;
+               this.active = ACTIVE_ACTIVE;
 
 }
 
 void turret_link()
 {SELFPARAM();
        Net_LinkEntity(self, true, 0, turret_send);
-       self.think       = turret_think;
+       setthink(self, turret_think);
        self.nextthink = time;
        self.tur_head.effects = EF_NODRAW;
 }
 
-void turrets_manager_think()
+void turrets_manager_think(entity this)
 {
-       SELFPARAM();
        this.nextthink = time + 1;
 
        if (autocvar_g_turrets_reloadcvars == 1)
@@ -1262,7 +1255,7 @@ float turret_initialize(Turret tur)
        if(!e)
        {
                e = new(turret_manager);
-               e.think = turrets_manager_think;
+               setthink(e, turrets_manager_think);
                e.nextthink = time + 2;
        }
 
@@ -1386,7 +1379,7 @@ float turret_initialize(Turret tur)
 #endif
 
        turret_link();
-       turret_respawn();
+       turret_respawn(self);
        turret_tag_fire_update();
 
        tur.tr_setup(tur, self);