]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/sv_vehicles.qc
Clean out some more self uses from vehicle code
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qc
index dc57e259f9b9cf78268ec4448c2bd6c1d45af253..7e5bc93eb87abfdf7bff47b8404dd652cee62338 100644 (file)
@@ -196,20 +196,20 @@ vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_
 }
 
 // projectile handling
-void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
        // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
-       if(inflictor.owner == self.owner)
+       if(inflictor.owner == this.owner)
                return;
 
-       self.health -= damage;
-       self.velocity += force;
-       if(self.health < 1)
+       this.health -= damage;
+       this.velocity += force;
+       if(this.health < 1)
        {
-               self.takedamage = DAMAGE_NO;
-               self.event_damage = func_null;
-               self.think = self.use;
-               self.nextthink = time;
+               this.takedamage = DAMAGE_NO;
+               this.event_damage = func_null;
+               this.think = this.use;
+               this.nextthink = time;
        }
 }
 
@@ -232,12 +232,13 @@ void vehicles_projectile_explode()
        remove (self);
 }
 
-entity vehicles_projectile(string _mzlfx, string _mzlsound,
+entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
                                                   vector _org, vector _vel,
                                                   float _dmg, float _radi, float _force,  float _size,
                                                   int _deahtype, float _projtype, float _health,
                                                   bool _cull, bool _clianim, entity _owner)
-{SELFPARAM();
+{
+    TC(Sound, _mzlsound);
        entity proj;
 
        proj = spawn();
@@ -257,7 +258,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
        proj.velocity            = _vel;
        proj.touch                      = vehicles_projectile_explode;
        proj.use                          = vehicles_projectile_explode;
-       proj.owner                      = self;
+       proj.owner                      = this;
        proj.realowner          = _owner;
        proj.think                      = SUB_Remove_self;
        proj.nextthink          = time + 30;
@@ -271,8 +272,8 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
        else
                proj.flags                 = FL_PROJECTILE | FL_NOTARGET;
 
-       if(_mzlsound)
-               _sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
+       if(_mzlsound != SND_Null)
+               sound (this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
 
        if(_mzlfx)
                Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
@@ -337,7 +338,7 @@ bool vehicle_addplayerslot( entity _owner,
                                                                entity _slot,
                                                                int _hud,
                                                                string _hud_model,
-                                                               bool() _framefunc,
+                                                               bool(entity) _framefunc,
                                                                void(bool) _exitfunc, float() _enterfunc)
 {
        if(!(_owner.vehicle_flags & VHF_MULTISLOT))
@@ -577,18 +578,18 @@ void vehicle_use()
        }
 }
 
-void vehicles_regen(float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
-{SELFPARAM();
-       if(self.(regen_field) < field_max)
+void vehicles_regen(entity this, float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
+{
+       if(this.(regen_field) < field_max)
        if(timer + rpause < time)
        {
                if(_healthscale)
-                       regen = regen * (self.vehicle_health / self.max_health);
+                       regen = regen * (this.vehicle_health / this.max_health);
 
-               self.(regen_field) = min(self.(regen_field) + regen * delta_time, field_max);
+               this.(regen_field) = min(this.(regen_field) + regen * delta_time, field_max);
 
-               if(self.owner)
-                       self.owner.(regen_field) = (self.(regen_field) / field_max) * 100;
+               if(this.owner)
+                       this.owner.(regen_field) = (this.(regen_field) / field_max) * 100;
        }
 }
 
@@ -615,8 +616,8 @@ void vehicles_painframe(entity this)
        if(this.pain_frame < time)
        {
                float _ftmp = myhealth / 50;
-               this.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
-               pointparticles(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
+               this.pain_frame = time + max(0.1, 0.1 + (random() * 0.5 * _ftmp));
+               Send_Effect(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
 
                if(this.vehicle_flags & VHF_DMGSHAKE)
                        this.velocity += randomvec() * 30;
@@ -634,9 +635,9 @@ void vehicles_frame(entity this, entity actor)
        vehicles_painframe(this);
 }
 
-void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
-       self.dmg_time = time;
+void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+       this.dmg_time = time;
 
        // WEAPONTODO
        if(DEATH_ISWEAPON(deathtype, WEP_VORTEX))
@@ -657,74 +658,74 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, int deatht
        if(DEATH_WEAPONOF(deathtype) != WEP_Null)
                damage *= autocvar_g_vehicles_weapon_damagerate;
 
-       self.enemy = attacker;
+       this.enemy = attacker;
 
-       self.pain_finished = time;
+       this.pain_finished = time;
 
-       if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
+       if((this.vehicle_flags & VHF_HASSHIELD) && (this.vehicle_shield > 0))
        {
-               if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
+               if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == world)
                {
-                       self.vehicle_shieldent = spawn();
-                       self.vehicle_shieldent.effects = EF_LOWPRECISION;
-
-                       setmodel(self.vehicle_shieldent, MDL_VEH_SHIELD);
-                       setattachment(self.vehicle_shieldent, self, "");
-                       setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
-                       self.vehicle_shieldent.scale       = 256 / vlen(self.maxs - self.mins);
-                       self.vehicle_shieldent.think       = shieldhit_think;
+                       this.vehicle_shieldent = spawn();
+                       this.vehicle_shieldent.effects = EF_LOWPRECISION;
+
+                       setmodel(this.vehicle_shieldent, MDL_VEH_SHIELD);
+                       setattachment(this.vehicle_shieldent, this, "");
+                       setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
+                       this.vehicle_shieldent.scale       = 256 / vlen(this.maxs - this.mins);
+                       this.vehicle_shieldent.think       = shieldhit_think;
                }
 
-               self.vehicle_shieldent.colormod = '1 1 1';
-               self.vehicle_shieldent.alpha = 0.45;
-               self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
-               self.vehicle_shieldent.nextthink = time;
-               self.vehicle_shieldent.effects &= ~EF_NODRAW;
+               this.vehicle_shieldent.colormod = '1 1 1';
+               this.vehicle_shieldent.alpha = 0.45;
+               this.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (this.origin + this.vehicle_shieldent.origin))) - this.angles;
+               this.vehicle_shieldent.nextthink = time;
+               this.vehicle_shieldent.effects &= ~EF_NODRAW;
 
-               self.vehicle_shield -= damage;
+               this.vehicle_shield -= damage;
 
-               if(self.vehicle_shield < 0)
+               if(this.vehicle_shield < 0)
                {
-                       self.vehicle_health -= fabs(self.vehicle_shield);
-                       self.vehicle_shieldent.colormod = '2 0 0';
-                       self.vehicle_shield = 0;
-                       self.vehicle_shieldent.alpha = 0.75;
+                       this.vehicle_health -= fabs(this.vehicle_shield);
+                       this.vehicle_shieldent.colormod = '2 0 0';
+                       this.vehicle_shield = 0;
+                       this.vehicle_shieldent.alpha = 0.75;
 
                        if(sound_allowed(MSG_BROADCAST, attacker))
-                               spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);   // FIXME: PLACEHOLDER
+                               spamsound (this, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);   // FIXME: PLACEHOLDER
                }
                else
                        if(sound_allowed(MSG_BROADCAST, attacker))
-                               spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
+                               spamsound (this, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
 
        }
        else
        {
-               self.vehicle_health -= damage;
+               this.vehicle_health -= damage;
 
                if(sound_allowed(MSG_BROADCAST, attacker))
-                       spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
+                       spamsound (this, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
        }
 
-       if(self.damageforcescale < 1 && self.damageforcescale > 0)
-               self.velocity += force * self.damageforcescale;
+       if(this.damageforcescale < 1 && this.damageforcescale > 0)
+               this.velocity += force * this.damageforcescale;
        else
-               self.velocity += force;
+               this.velocity += force;
 
-       if(self.vehicle_health <= 0)
+       if(this.vehicle_health <= 0)
        {
-               if(self.owner)
-                       if(self.vehicle_flags & VHF_DEATHEJECT)
-                               vehicles_exit(VHEF_EJECT);
+               if(this.owner)
+                       if(this.vehicle_flags & VHF_DEATHEJECT)
+                               WITH(entity, self, this, vehicles_exit(VHEF_EJECT));
                        else
-                               vehicles_exit(VHEF_RELEASE);
+                               WITH(entity, self, this, vehicles_exit(VHEF_RELEASE));
 
 
-               antilag_clear(self);
+               antilag_clear(this, this);
 
-               Vehicle info = Vehicles_from(self.vehicleid);
-               info.vr_death(info, self);
-               vehicles_setreturn(self);
+               Vehicle info = Vehicles_from(this.vehicleid);
+               info.vr_death(info, this);
+               vehicles_setreturn(this);
        }
 }
 
@@ -884,8 +885,8 @@ void vehicles_exit(bool eject)
        if(!teamplay)
                _vehicle.team = 0;
 
-       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES);
-       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
+       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES);
+       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
 
        WaypointSprite_Kill(_vehicle.wps_intruder);
 
@@ -922,7 +923,7 @@ void vehicles_touch()
                if((self.origin_z + self.maxs_z) > (other.origin_z))
                if(vehicles_crushable(other))
                {
-                       if(vlen(self.velocity) >= 30)
+                       if(vdist(self.velocity, >=, 30))
                                Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
 
                        return; // Dont do selfdamage when hitting "soft targets".
@@ -1007,7 +1008,7 @@ void vehicles_enter(entity pl, entity veh)
        if(DIFF_TEAM(pl, veh))
        if(autocvar_g_vehicles_steal)
        {
-               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), LAMBDA(Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL)));
+               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
 
                Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
 
@@ -1107,7 +1108,7 @@ void vehicles_enter(entity pl, entity veh)
        info.vr_enter(info, veh);
        setself(this);
 
-       antilag_clear(pl);
+       antilag_clear(pl, CS(pl));
 }
 
 void vehicles_think()
@@ -1164,7 +1165,7 @@ void vehicles_spawn()
        if(self.vehicle_controller)
                self.team = self.vehicle_controller.team;
 
-       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, LAMBDA(RemoveGrapplingHook(it)));
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it));
 
        vehicles_reset_colors();