]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/sv_turrets.qc
Remove oldself variables
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / sv_turrets.qc
index fa5318dc2d602917a982aa14bdbfbd348da84aca..92971878370ae1b205fd8c6a27ba61c1ab2a46d1 100644 (file)
@@ -3,7 +3,7 @@
 
 // Generic aiming
 vector turret_aim_generic()
-{
+{SELFPARAM();
 
        vector pre_pos, prep;
        float distance, impact_time = 0, i, mintime;
@@ -165,14 +165,14 @@ float turret_targetscore_generic(entity _turret, entity _target)
 
 // Generic damage handling
 void turret_hide()
-{
+{SELFPARAM();
        self.effects   |= EF_NODRAW;
        self.nextthink = time + self.respawntime - 0.2;
        self.think       = turret_respawn;
 }
 
 void turret_die()
-{
+{SELFPARAM();
        self.deadflag             = DEAD_DEAD;
        self.tur_head.deadflag = self.deadflag;
 
@@ -207,7 +207,7 @@ void turret_die()
 }
 
 void turret_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
        // Enough already!
        if(self.deadflag == DEAD_DEAD)
                return;
@@ -252,7 +252,7 @@ void turret_damage (entity inflictor, entity attacker, float damage, int deathty
 
 void() turret_think;
 void turret_respawn()
-{
+{SELFPARAM();
        // Make sure all parts belong to the same team since
        // this function doubles as "teamchange" function.
        self.tur_head.team      = self.team;
@@ -283,7 +283,7 @@ void turret_respawn()
 #define cvar_base "g_turrets_unit_"
 .float clientframe;
 void turrets_setframe(float _frame, float client_only)
-{
+{SELFPARAM();
        if((client_only ? self.clientframe : self.frame ) != _frame)
        {
                self.SendFlags |= TNSF_ANIM;
@@ -298,7 +298,7 @@ void turrets_setframe(float _frame, float client_only)
 }
 
 float turret_send(entity to, float sf)
-{
+{SELFPARAM();
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
        WriteByte(MSG_ENTITY, sf);
@@ -359,7 +359,7 @@ float turret_send(entity to, float sf)
 }
 
 void load_unit_settings(entity ent, string unitname, float is_reload)
-{
+{SELFPARAM();
        string sbase;
 
        if (ent == world)
@@ -423,7 +423,7 @@ void load_unit_settings(entity ent, string unitname, float is_reload)
 }
 
 void turret_projectile_explode()
-{
+{SELFPARAM();
 
        self.takedamage = DAMAGE_NO;
        self.event_damage = func_null;
@@ -445,7 +445,7 @@ void turret_projectile_touch()
 }
 
 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
@@ -454,7 +454,7 @@ void turret_projectile_damage(entity inflictor, entity attacker, float damage, i
 }
 
 entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
-{
+{SELFPARAM();
        entity proj;
 
        sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
@@ -493,12 +493,10 @@ entity turret_projectile(string _snd, float _size, float _health, float _death,
 ** and updated aim<->predict impact distance.
 **/
 void turret_do_updates(entity t_turret)
-{
+{SELFPARAM();
        vector enemy_pos;
-       entity oldself;
 
-       oldself = self;
-       self = t_turret;
+       setself(t_turret);
 
        enemy_pos = real_origin(self.enemy);
 
@@ -527,7 +525,7 @@ void turret_do_updates(entity t_turret)
        self.tur_impactent                       = trace_ent;
        self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
 
-       self = oldself;
+       setself(this);
 }
 
 /**
@@ -536,7 +534,7 @@ void turret_do_updates(entity t_turret)
 **/
 .float turret_framecounter;
 void turret_track()
-{
+{SELFPARAM();
        vector target_angle; // This is where we want to aim
        vector move_angle;   // This is where we can aim
        float f_tmp;
@@ -827,14 +825,14 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
        */
 
 #ifdef TURRET_DEBUG_TARGETSELECT
-       dprint("Target:",e_target.netname," is a valid target for ",e_turret.netname,"\n");
+       LOG_TRACE("Target:",e_target.netname," is a valid target for ",e_turret.netname,"\n");
 #endif
 
        return 1;
 }
 
 entity turret_select_target()
-{
+{SELFPARAM();
        entity e;               // target looper entity
        float  score;   // target looper entity score
        entity e_enemy;  // currently best scoreing target
@@ -901,7 +899,7 @@ entity turret_select_target()
 ** Preforms pre-fire checks based on the uints firecheck_flags
 **/
 float turret_firecheck()
-{
+{SELFPARAM();
        // This one just dont care =)
        if (self.firecheck_flags & TFL_FIRECHECK_NO)
                return 1;
@@ -974,11 +972,23 @@ float turret_firecheck()
        return 1;
 }
 
+bool turret_checkfire()
+{SELFPARAM();
+       bool ret = false; // dummy
+       if(MUTATOR_CALLHOOK(Turret_CheckFire, ret))
+               return ret_bool;
+
+       return self.turret_firecheckfunc();
+}
+
 void turret_fire()
-{
+{SELFPARAM();
        if (autocvar_g_turrets_nofire != 0)
                return;
 
+       if(MUTATOR_CALLHOOK(TurretFire, self))
+               return;
+
        TUR_ACTION(self.turretid, TR_ATTACK);
 
        self.attack_finished_single = time + self.shot_refire;
@@ -1002,7 +1012,7 @@ void turret_fire()
 }
 
 void turret_think()
-{
+{SELFPARAM();
        entity e;
 
        self.nextthink = time + self.ticrate;
@@ -1060,7 +1070,7 @@ void turret_think()
 
                                        turret_do_updates(self);
 
-                                       if (self.turret_firecheckfunc())
+                                       if (turret_checkfire())
                                                turret_fire();
                                }
                        }
@@ -1084,7 +1094,7 @@ void turret_think()
                turret_do_updates(self);
 
                // Fire?
-               if (self.turret_firecheckfunc())
+               if (turret_checkfire())
                        turret_fire();
        }
        else
@@ -1104,7 +1114,7 @@ void turret_think()
                                turret_do_updates(self);
 
                                // Fire!
-                               if (self.turret_firecheckfunc() != 0)
+                               if (turret_checkfire())
                                        turret_fire();
 
                                TUR_ACTION(self.turretid, TR_THINK);
@@ -1164,7 +1174,7 @@ void turret_think()
                turret_do_updates(self);
 
                // Fire?
-               if (self.turret_firecheckfunc())
+               if (turret_checkfire())
                        turret_fire();
        }
 
@@ -1176,8 +1186,8 @@ void turret_think()
        If activator is world, the turret go inactive.
 */
 void turret_use()
-{
-       dprint("Turret ",self.netname, " used by ", activator.classname, "\n");
+{SELFPARAM();
+       LOG_TRACE("Turret ",self.netname, " used by ", activator.classname, "\n");
 
        self.team = activator.team;
 
@@ -1189,7 +1199,7 @@ void turret_use()
 }
 
 void turret_link()
-{
+{SELFPARAM();
        Net_LinkEntity(self, true, 0, turret_send);
        self.think       = turret_think;
        self.nextthink = time;
@@ -1197,7 +1207,7 @@ void turret_link()
 }
 
 void turrets_manager_think()
-{
+{SELFPARAM();
        self.nextthink = time + 1;
 
        entity e;
@@ -1219,7 +1229,7 @@ void turrets_manager_think()
 }
 
 float turret_initialize(float tur_id)
-{
+{SELFPARAM();
        if(!autocvar_g_turrets)
                return false;
 
@@ -1361,7 +1371,7 @@ float turret_initialize(float tur_id)
                if (self.tur_defend == world)
                {
                        self.target = "";
-                       dprint("Turret has invalid defendpoint!\n");
+                       LOG_TRACE("Turret has invalid defendpoint!\n");
                }
        }