]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/cl_turrets.qc
Clean up some of the turret code's self uses
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / cl_turrets.qc
index 079d6b3f0dbc445577c8b95b1834f81d0e0d353e..63b30bc355cf021a411571a0e84a45d38b464ed3 100644 (file)
@@ -6,22 +6,23 @@ void turret_remove(entity this)
 }
 
 .vector glowmod;
-void turret_changeteam()
-{SELFPARAM();
-       self.glowmod = Team_ColorRGB(self.team - 1) * 2;
-       self.teamradar_color = Team_ColorRGB(self.team - 1);
+void turret_changeteam(entity this)
+{
+       this.glowmod = Team_ColorRGB(this.team - 1) * 2;
+       this.teamradar_color = Team_ColorRGB(this.team - 1);
 
-       if(self.team)
-               self.colormap = 1024 + (self.team - 1) * 17;
+       if(this.team)
+               this.colormap = 1024 + (this.team - 1) * 17;
 
-       self.tur_head.colormap = self.colormap;
-       self.tur_head.glowmod = self.glowmod;
+       this.tur_head.colormap = this.colormap;
+       this.tur_head.glowmod = this.glowmod;
 
 }
 
-void turret_head_draw()
-{SELFPARAM();
-       self.drawmask = MASK_NORMAL;
+// unused?
+void turret_head_draw(entity this)
+{
+       this.drawmask = MASK_NORMAL;
 }
 
 void turret_draw(entity this)
@@ -201,47 +202,47 @@ void turret_draw2d(entity this)
                        );
 }
 
-void turret_construct()
-{SELFPARAM();
-       entity tur = get_turretinfo(self.m_id);
+void turret_construct(entity this)
+{
+       entity tur = get_turretinfo(this.m_id);
 
-       if(self.tur_head == world)
-               self.tur_head = spawn();
+       if(this.tur_head == world)
+               this.tur_head = spawn();
 
-       self.netname = tur.turret_name;
+       this.netname = tur.turret_name;
 
-       setorigin(self, self.origin);
-       _setmodel(self, tur.model);
-       _setmodel(self.tur_head, tur.head_model);
-       setsize(self, tur.mins, tur.maxs);
-       setsize(self.tur_head, '0 0 0', '0 0 0');
+       setorigin(this, this.origin);
+       _setmodel(this, tur.model);
+       _setmodel(this.tur_head, tur.head_model);
+       setsize(this, tur.mins, tur.maxs);
+       setsize(this.tur_head, '0 0 0', '0 0 0');
 
-       if(self.m_id == TUR_EWHEEL.m_id)
-               setattachment(self.tur_head, self, "");
+       if(this.m_id == TUR_EWHEEL.m_id)
+               setattachment(this.tur_head, this, "");
        else
-               setattachment(self.tur_head, self, "tag_head");
-
-       self.tur_head.classname                 = "turret_head";
-       self.tur_head.owner                             = self;
-       self.tur_head.move_movetype             = MOVETYPE_NOCLIP;
-       self.move_movetype                              = MOVETYPE_NOCLIP;
-       self.tur_head.angles                    = self.angles;
-       self.health                                             = 255;
-       self.solid                                              = SOLID_BBOX;
-       self.tur_head.solid                             = SOLID_NOT;
-       self.movetype                                   = MOVETYPE_NOCLIP;
-       self.tur_head.movetype                  = MOVETYPE_NOCLIP;
-       self.draw                                               = turret_draw;
-       self.entremove                                  = turret_remove;
-       self.drawmask                                   = MASK_NORMAL;
-       self.tur_head.drawmask                  = MASK_NORMAL;
-       self.anim_start_time                    = 0;
-       self.draw2d = turret_draw2d;
-       self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
-       self.teamradar_color = '1 0 0';
-       self.alpha = 1;
-
-       tur.tr_setup(tur, self);
+               setattachment(this.tur_head, this, "tag_head");
+
+       this.tur_head.classname                 = "turret_head";
+       this.tur_head.owner                             = this;
+       this.tur_head.move_movetype             = MOVETYPE_NOCLIP;
+       this.move_movetype                              = MOVETYPE_NOCLIP;
+       this.tur_head.angles                    = this.angles;
+       this.health                                             = 255;
+       this.solid                                              = SOLID_BBOX;
+       this.tur_head.solid                             = SOLID_NOT;
+       this.movetype                                   = MOVETYPE_NOCLIP;
+       this.tur_head.movetype                  = MOVETYPE_NOCLIP;
+       this.draw                                               = turret_draw;
+       this.entremove                                  = turret_remove;
+       this.drawmask                                   = MASK_NORMAL;
+       this.tur_head.drawmask                  = MASK_NORMAL;
+       this.anim_start_time                    = 0;
+       this.draw2d = turret_draw2d;
+       this.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
+       this.teamradar_color = '1 0 0';
+       this.alpha = 1;
+
+       tur.tr_setup(tur, this);
 }
 
 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
@@ -313,8 +314,8 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
        return gib;
 }
 
-void turret_die()
-{SELFPARAM();
+void turret_die(entity this)
+{
        sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
        pointparticles(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
        if (!autocvar_cl_nogibs)
@@ -359,85 +360,85 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
 
        if(sf & TNSF_SETUP)
        {
-               self.m_id = ReadByte();
+               this.m_id = ReadByte();
 
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-               setorigin(self, self.origin);
+               this.origin_x = ReadCoord();
+               this.origin_y = ReadCoord();
+               this.origin_z = ReadCoord();
+               setorigin(this, this.origin);
 
-               self.angles_x = ReadAngle();
-               self.angles_y = ReadAngle();
+               this.angles_x = ReadAngle();
+               this.angles_y = ReadAngle();
 
-               turret_construct();
-               self.colormap = 1024;
-               self.glowmod = '0 1 1';
-               self.tur_head.colormap = self.colormap;
-               self.tur_head.glowmod = self.glowmod;
+               turret_construct(this);
+               this.colormap = 1024;
+               this.glowmod = '0 1 1';
+               this.tur_head.colormap = this.colormap;
+               this.tur_head.glowmod = this.glowmod;
        }
 
        if(sf & TNSF_ANG)
        {
-               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-                       self.tur_head = spawn();
+               if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       this.tur_head = spawn();
 
-               self.tur_head.move_angles_x = ReadShort();
-               self.tur_head.move_angles_y = ReadShort();
-               //self.tur_head.angles = self.angles + self.tur_head.move_angles;
-               self.tur_head.angles = self.tur_head.move_angles;
+               this.tur_head.move_angles_x = ReadShort();
+               this.tur_head.move_angles_y = ReadShort();
+               //this.tur_head.angles = this.angles + this.tur_head.move_angles;
+               this.tur_head.angles = this.tur_head.move_angles;
        }
 
        if(sf & TNSF_AVEL)
        {
-               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-                       self.tur_head = spawn();
+               if(this.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       this.tur_head = spawn();
 
-               self.tur_head.move_avelocity_x = ReadShort();
-               self.tur_head.move_avelocity_y = ReadShort();
+               this.tur_head.move_avelocity_x = ReadShort();
+               this.tur_head.move_avelocity_y = ReadShort();
        }
 
        if(sf & TNSF_MOVE)
        {
-               self.origin_x = ReadShort();
-               self.origin_y = ReadShort();
-               self.origin_z = ReadShort();
-               setorigin(self, self.origin);
+               this.origin_x = ReadShort();
+               this.origin_y = ReadShort();
+               this.origin_z = ReadShort();
+               setorigin(this, this.origin);
 
-               self.velocity_x = ReadShort();
-               self.velocity_y = ReadShort();
-               self.velocity_z = ReadShort();
+               this.velocity_x = ReadShort();
+               this.velocity_y = ReadShort();
+               this.velocity_z = ReadShort();
 
-               self.move_angles_y = ReadShort();
+               this.move_angles_y = ReadShort();
 
-               self.move_time   = time;
-               self.move_velocity = self.velocity;
-               self.move_origin   = self.origin;
+               this.move_time   = time;
+               this.move_velocity = this.velocity;
+               this.move_origin   = this.origin;
        }
 
        if(sf & TNSF_ANIM)
        {
-               self.frame1time = ReadCoord();
-               self.frame        = ReadByte();
+               this.frame1time = ReadCoord();
+               this.frame        = ReadByte();
        }
 
        if(sf & TNSF_STATUS)
        {
                float _tmp;
                _tmp = ReadByte();
-               if(_tmp != self.team)
+               if(_tmp != this.team)
                {
-                       self.team = _tmp;
-                       turret_changeteam();
+                       this.team = _tmp;
+                       turret_changeteam(this);
                }
 
                _tmp = ReadByte();
-               if(_tmp == 0 && self.health != 0)
-                       turret_die();
-               else if(self.health && self.health != _tmp)
-                       self.helpme = servertime + 10;
+               if(_tmp == 0 && this.health != 0)
+                       turret_die(this);
+               else if(this.health && this.health != _tmp)
+                       this.helpme = servertime + 10;
 
-               self.health = _tmp;
+               this.health = _tmp;
        }
-       //self.enemy.health = self.health / 255;
+       //this.enemy.health = this.health / 255;
        return true;
 }