]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/sv_turrets.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / sv_turrets.qc
index 1ca91e0a8b30623abea2670624e79ea0afde91dd..1502be25114f1ddfb5bf90192c796d9f37d2febb 100644 (file)
@@ -207,17 +207,17 @@ void turret_die()
        }
 }
 
-void turret_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{SELFPARAM();
+void turret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
+{
        // Enough already!
-       if(self.deadflag == DEAD_DEAD)
+       if(this.deadflag == DEAD_DEAD)
                return;
 
        // Inactive turrets take no damage. (hm..)
-       if(!self.active)
+       if(!this.active)
                return;
 
-       if(SAME_TEAM(self, attacker))
+       if(SAME_TEAM(this, attacker))
        {
                if(autocvar_g_friendlyfire)
                        damage = damage * autocvar_g_friendlyfire;
@@ -225,30 +225,30 @@ void turret_damage (entity inflictor, entity attacker, float damage, int deathty
                        return;
        }
 
-       self.health -= damage;
+       this.health -= damage;
 
        // thorw head slightly off aim when hit?
-       if (self.damage_flags & TFL_DMG_HEADSHAKE)
+       if (this.damage_flags & TFL_DMG_HEADSHAKE)
        {
-               self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
-               self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
+               this.tur_head.angles_x = this.tur_head.angles_x + (-0.5 + random()) * damage;
+               this.tur_head.angles_y = this.tur_head.angles_y + (-0.5 + random()) * damage;
 
-               self.SendFlags  |= TNSF_ANG;
+               this.SendFlags  |= TNSF_ANG;
        }
 
-       if (self.turret_flags & TUR_FLAG_MOVE)
-               self.velocity = self.velocity + vforce;
+       if (this.turret_flags & TUR_FLAG_MOVE)
+               this.velocity = this.velocity + vforce;
 
-       if (self.health <= 0)
+       if (this.health <= 0)
        {
-               self.event_damage                 = func_null;
-               self.tur_head.event_damage = func_null;
-               self.takedamage                  = DAMAGE_NO;
-               self.nextthink = time;
-               self.think = turret_die;
+               this.event_damage                 = func_null;
+               this.tur_head.event_damage = func_null;
+               this.takedamage                  = DAMAGE_NO;
+               this.nextthink = time;
+               this.think = turret_die;
        }
 
-       self.SendFlags  |= TNSF_STATUS;
+       this.SendFlags  |= TNSF_STATUS;
 }
 
 void() turret_think;
@@ -449,20 +449,21 @@ void turret_projectile_touch()
        turret_projectile_explode();
 }
 
-void turret_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{SELFPARAM();
-       self.velocity  += vforce;
-       self.health     -= damage;
-       //self.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
-       if(self.health <= 0)
-               W_PrepareExplosionByDamage(self.owner, turret_projectile_explode);
+void turret_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
+{
+       this.velocity  += vforce;
+       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));
 }
 
-entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
+entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
 {SELFPARAM();
+    TC(Sound, _snd);
        entity proj;
 
-       _sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
+       sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
        proj                             = spawn ();
        setorigin(proj, self.tur_shotorg);
        setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size);
@@ -816,7 +817,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
 
                traceline(e_turret.origin + '0 0 16', v_tmp, 0, e_turret);
 
-               if (e_turret.aim_firetolerance_dist < vlen(v_tmp - trace_endpos))
+               if(vdist(v_tmp - trace_endpos, >, e_turret.aim_firetolerance_dist))
                        return -19;
        }
 
@@ -994,7 +995,7 @@ void turret_fire()
                return;
 
        Turret info = get_turretinfo(self.m_id);
-       info.tr_attack(info);
+       info.tr_attack(info, self);
 
        self.attack_finished_single[0] = time + self.shot_refire;
        self.ammo -= self.shot_dmg;
@@ -1108,7 +1109,7 @@ void turret_think()
                                        turret_fire();
 
                                Turret tur = get_turretinfo(self.m_id);
-                               tur.tr_think(tur);
+                               tur.tr_think(tur, self);
 
                                return;
                        }
@@ -1147,7 +1148,7 @@ void turret_think()
                                turret_track();
 
                        Turret tur = get_turretinfo(self.m_id);
-                       tur.tr_think(tur);
+                       tur.tr_think(tur, self);
 
                        // And bail.
                        return;
@@ -1171,7 +1172,7 @@ void turret_think()
        }
 
        Turret tur = get_turretinfo(self.m_id);
-       tur.tr_think(tur);
+       tur.tr_think(tur, self);
 }
 
 /*
@@ -1206,11 +1207,11 @@ void turrets_manager_think()
 
        if (autocvar_g_turrets_reloadcvars == 1)
        {
-               FOREACH_ENTITY(IS_TURRET(it), LAMBDA(
+               FOREACH_ENTITY(IS_TURRET(it), {
                        load_unit_settings(it, true);
                        Turret tur = get_turretinfo(it.m_id);
-                       tur.tr_think(tur);
-               ));
+                       tur.tr_think(tur, it);
+               });
                cvar_set("g_turrets_reloadcvars", "0");
        }
 }
@@ -1376,7 +1377,7 @@ float turret_initialize(Turret tur)
 
 #ifdef TURRET_DEBUG
        self.tur_debug_start = self.nextthink;
-       while (vlen(self.tur_debug_rvec) < 2)
+       while(vdist(self.tur_debug_rvec, <, 2))
                self.tur_debug_rvec = randomvec() * 4;
 
        self.tur_debug_rvec_x = fabs(self.tur_debug_rvec_x);