Clean up vehicle physics plugin a bit
authorMario <mario@smbclan.net>
Wed, 23 Mar 2016 17:56:11 +0000 (03:56 +1000)
committerMario <mario@smbclan.net>
Wed, 23 Mar 2016 17:56:38 +0000 (03:56 +1000)
13 files changed:
qcsrc/common/physics/player.qc
qcsrc/common/physics/player.qh
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh
qcsrc/common/vehicles/vehicle.qh
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/racer_weapon.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc

index c9942a6..8476869 100644 (file)
@@ -1325,7 +1325,7 @@ void PM_Main(entity this)
        Physics_UpdateStats(this, maxspeed_mod);
 
        if (this.PlayerPhysplug)
-               if (this.PlayerPhysplug())
+               if (this.PlayerPhysplug(this))
                        return;
 #elif defined(CSQC)
        if(autocvar_slowmo != STAT(MOVEVARS_TIMESCALE))
index 252b157..339d617 100644 (file)
@@ -23,7 +23,7 @@
 .vector v_angle_old;
 .string lastclassname;
 
-.float() PlayerPhysplug;
+.float(entity) PlayerPhysplug;
 float AdjustAirAccelQW(float accelqw, float factor);
 
 bool IsFlying(entity a);
index bbc1285..7e5bc93 100644 (file)
@@ -232,12 +232,12 @@ void vehicles_projectile_explode()
        remove (self);
 }
 
-entity vehicles_projectile(string _mzlfx, Sound _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;
 
@@ -258,7 +258,7 @@ entity vehicles_projectile(string _mzlfx, Sound _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;
@@ -273,7 +273,7 @@ entity vehicles_projectile(string _mzlfx, Sound _mzlsound,
                proj.flags                 = FL_PROJECTILE | FL_NOTARGET;
 
        if(_mzlsound != SND_Null)
-               sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
+               sound (this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
 
        if(_mzlfx)
                Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
@@ -338,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))
@@ -578,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;
        }
 }
 
index e9a4d3f..06b9178 100644 (file)
@@ -93,8 +93,8 @@ vector force_fromtag_origin;
 float vehicles_exit_running;
 
 // macros
-#define VEHICLE_UPDATE_PLAYER(ply,fld,vhname) \
-       ply.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
+#define VEHICLE_UPDATE_PLAYER(ply,vehi,fld,vhname) \
+       ply.vehicle_##fld = (vehi.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
 
 .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly
 
index 723a985..c49218d 100644 (file)
@@ -24,7 +24,7 @@ CLASS(Vehicle, Object)
     /** cockpit model tag */
     ATTRIB(Vehicle, tag_view, string, string_null)
     /** player physics mod */
-    ATTRIB(Vehicle, PlayerPhysplug, int(), func_null)
+    ATTRIB(Vehicle, PlayerPhysplug, bool(entity), func_null)
     /**  */
     ATTRIB(Vehicle, spawnflags, int, 0)
     /** vehicle hitbox size */
index d795d2a..115a83b 100644 (file)
@@ -96,19 +96,18 @@ vector autocvar_g_vehicle_bumblebee_bouncepain = '1 100 200';
 
 bool autocvar_g_vehicle_bumblebee = true;
 
-float bumblebee_gunner_frame()
-{SELFPARAM();
-       entity vehic    = self.vehicle.owner;
-       entity gun      = self.vehicle;
-       entity gunner   = self;
-       setself(vehic);
+bool bumblebee_gunner_frame(entity this)
+{
+       entity vehic = this.vehicle.owner;
+       entity gun = this.vehicle;
+       return = true;
 
        // this isn't technically a vehicle (yet), let's not do frame functions on it (yet)
        //vehicles_frame(gun, player);
 
        vehic.solid = SOLID_NOT;
-       //setorigin(gunner, vehic.origin);
-       gunner.velocity = vehic.velocity;
+       //setorigin(this, vehic.origin);
+       this.velocity = vehic.velocity;
 
        float _in, _out;
        vehic.angles_x *= -1;
@@ -118,16 +117,16 @@ float bumblebee_gunner_frame()
        {
                _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
                _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
-               setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
+               setorigin(this, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
        }
        else
        {
                _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
                _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
-               setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
+               setorigin(this, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
        }
 
-       crosshair_trace(gunner);
+       crosshair_trace(this);
        vector _ct = trace_endpos;
        vector ad;
 
@@ -141,7 +140,7 @@ float bumblebee_gunner_frame()
                                if(trace_ent.takedamage)
                                        if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
                                        {
-                                               if(DIFF_TEAM(trace_ent, gunner))
+                                               if(DIFF_TEAM(trace_ent, this))
                                                {
                                                        gun.enemy = trace_ent;
                                                        gun.lock_time = time + 5;
@@ -160,13 +159,13 @@ float bumblebee_gunner_frame()
 
 
                ad = vf;
-               distance = vlen(ad - gunner.origin);
+               distance = vlen(ad - this.origin);
                impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
                ad = vf + _vel * impact_time;
                trace_endpos = ad;
 
 
-               UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
+               UpdateAuxiliaryXhair(this, ad, '1 0 1', 1);
                vehicle_aimturret(vehic, trace_endpos, gun, "fire",
                                                  autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
                                                  _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
@@ -177,36 +176,33 @@ float bumblebee_gunner_frame()
                                                  autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
                                                  _out * -1,  _in,  autocvar_g_vehicle_bumblebee_cannon_turnspeed);
 
-       if(!forbidWeaponUse(gunner))
-       if(PHYS_INPUT_BUTTON_ATCK(gunner))
+       if(!forbidWeaponUse(this))
+       if(PHYS_INPUT_BUTTON_ATCK(this))
                if(time > gun.attack_finished_single[0])
                        if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
                        {
                                gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
-                               bumblebee_fire_cannon(gun, "fire", gunner);
+                               bumblebee_fire_cannon(vehic, gun, "fire", this);
                                gun.delay = time;
                                gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire;
                        }
 
-       VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, bumblebee);
 
        if(vehic.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee);
 
        ad = gettaginfo(gun, gettagindex(gun, "fire"));
        traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
 
-       UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
+       UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' *(1 - this.vehicle_reload1)), 0);
 
        if(vehic.owner)
-               UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
+               UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' *(1 - this.vehicle_reload1)), ((this == vehic.gunner1) ? 1 : 2));
 
        vehic.solid = SOLID_BBOX;
-       PHYS_INPUT_BUTTON_ATCK(gunner) = PHYS_INPUT_BUTTON_ATCK2(gunner) = PHYS_INPUT_BUTTON_CROUCH(gunner) = false;
-       gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
-
-       setself(gunner);
-       return 1;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
+       this.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 }
 
 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
@@ -394,61 +390,53 @@ void bumblebee_touch()
        vehicles_touch();
 }
 
-void bumblebee_regen()
-{SELFPARAM();
-       if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
-               self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
-                                                                          self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
+void bumblebee_regen(entity this)
+{
+       if(this.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
+               this.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
+                                                                          this.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
 
-       if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
-               self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
-                                                                          self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
+       if(this.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
+               this.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
+                                                                          this.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
 
-       if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(self.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, true);
+       if(this.vehicle_flags  & VHF_SHIELDREGEN)
+               vehicles_regen(this, this.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, true);
 
-       if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(self.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, false);
+       if(this.vehicle_flags  & VHF_HEALTHREGEN)
+               vehicles_regen(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, false);
 
-       if(self.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(self.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, false);
+       if(this.vehicle_flags  & VHF_ENERGYREGEN)
+               vehicles_regen(this, this.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, false);
 
 }
 
-float bumblebee_pilot_frame()
-{SELFPARAM();
-       entity pilot, vehic;
-       vector newvel;
+bool bumblebee_pilot_frame(entity this)
+{
+       entity vehic = this.vehicle;
+       return = true;
 
        if(intermission_running)
        {
-               self.vehicle.velocity = '0 0 0';
-               self.vehicle.avelocity = '0 0 0';
-               return 1;
+               vehic.velocity = '0 0 0';
+               vehic.avelocity = '0 0 0';
+               return;
        }
 
-       pilot = self;
-       vehic = self.vehicle;
-       setself(vehic);
-
-       vehicles_frame(vehic, pilot);
+       vehicles_frame(vehic, this);
 
        if(IS_DEAD(vehic))
        {
-               setself(pilot);
-               PHYS_INPUT_BUTTON_ATCK(pilot) = PHYS_INPUT_BUTTON_ATCK2(pilot) = false;
-               return 1;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
+               return;
        }
 
-       bumblebee_regen();
-
-       crosshair_trace(pilot);
+       bumblebee_regen(vehic);
 
-       vector vang;
-       float ftmp;
+       crosshair_trace(this);
 
-       vang = vehic.angles;
-       newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
+       vector vang = vehic.angles;
+       vector newvel = vectoangles(normalize(trace_endpos - vehic.origin + '0 0 32'));
        vang.x *= -1;
        newvel.x *= -1;
        if(newvel.x > 180)  newvel.x -= 360;
@@ -456,16 +444,16 @@ float bumblebee_pilot_frame()
        if(newvel.y > 180)  newvel.y -= 360;
        if(newvel.y < -180) newvel.y += 360;
 
-       ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
+       float ftmp = shortangle_f(this.v_angle.y - vang.y, vang.y);
        if(ftmp > 180)  ftmp -= 360;
        if(ftmp < -180) ftmp += 360;
        vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
 
        // Pitch
        ftmp = 0;
-       if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
+       if(this.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
                ftmp = 4;
-       else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
+       else if(this.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
                ftmp = -8;
 
        newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
@@ -479,19 +467,19 @@ float bumblebee_pilot_frame()
        makevectors('0 1 0' * vehic.angles.y);
        newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
 
-       if(pilot.movement.x != 0)
+       if(this.movement.x != 0)
        {
-               if(pilot.movement.x > 0)
+               if(this.movement.x > 0)
                        newvel += v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
-               else if(pilot.movement.x < 0)
+               else if(this.movement.x < 0)
                        newvel -= v_forward  * autocvar_g_vehicle_bumblebee_speed_forward;
        }
 
-       if(pilot.movement.y != 0)
+       if(this.movement.y != 0)
        {
-               if(pilot.movement.y < 0)
+               if(this.movement.y < 0)
                        newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
-               else if(pilot.movement.y > 0)
+               else if(this.movement.y > 0)
                        newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
                ftmp = newvel * v_right;
                ftmp *= frametime * 0.1;
@@ -504,13 +492,13 @@ float bumblebee_pilot_frame()
                        vehic.angles_z = 0;
        }
 
-       if(PHYS_INPUT_BUTTON_CROUCH(pilot))
+       if(PHYS_INPUT_BUTTON_CROUCH(this))
                newvel -=   v_up * autocvar_g_vehicle_bumblebee_speed_down;
-       else if(PHYS_INPUT_BUTTON_JUMP(pilot))
+       else if(PHYS_INPUT_BUTTON_JUMP(this))
                newvel +=  v_up * autocvar_g_vehicle_bumblebee_speed_up;
 
        vehic.velocity  += newvel * frametime;
-       pilot.velocity = pilot.movement  = vehic.velocity;
+       this.velocity = this.movement  = vehic.velocity;
 
 
        if(autocvar_g_vehicle_bumblebee_healgun_locktime)
@@ -525,7 +513,7 @@ float bumblebee_pilot_frame()
                {
                        if(teamplay)
                        {
-                               if(trace_ent.team == pilot.team)
+                               if(trace_ent.team == this.team)
                                {
                                        vehic.tur_head.enemy = trace_ent;
                                        vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
@@ -541,18 +529,18 @@ float bumblebee_pilot_frame()
                if(vehic.tur_head.enemy)
                {
                        trace_endpos = real_origin(vehic.tur_head.enemy);
-                       UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
+                       UpdateAuxiliaryXhair(this, trace_endpos, '0 0.75 0', 0);
                }
        }
 
-       vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
+       vang = vehicle_aimturret(vehic, trace_endpos, vehic.gun3, "fire",
                                          autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1,  autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
                                          autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1,  autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides,  autocvar_g_vehicle_bumblebee_raygun_turnspeed);
 
-       if(!forbidWeaponUse(pilot))
-       if((PHYS_INPUT_BUTTON_ATCK(pilot) || PHYS_INPUT_BUTTON_ATCK2(pilot)) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
+       if(!forbidWeaponUse(this))
+       if((PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
        {
-               vehic.gun3.enemy.realowner = pilot;
+               vehic.gun3.enemy.realowner = this;
                vehic.gun3.enemy.effects &= ~EF_NODRAW;
 
                vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
@@ -564,13 +552,13 @@ float bumblebee_pilot_frame()
                {
                        if(autocvar_g_vehicle_bumblebee_raygun)
                        {
-                               Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
+                               Damage(trace_ent, vehic, this, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
                                vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
                        }
                        else
                        {
                                if(!IS_DEAD(trace_ent))
-                                       if((teamplay && trace_ent.team == pilot.team) || !teamplay)
+                                       if((teamplay && trace_ent.team == this.team) || !teamplay)
                                        {
 
                                                if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
@@ -619,24 +607,21 @@ float bumblebee_pilot_frame()
        }
        */
 
-       VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
-       VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, bumblebee);
+       VEHICLE_UPDATE_PLAYER(this, vehic, energy, bumblebee);
 
-       pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
-       pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
+       this.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
+       this.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 
        if(vehic.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee);
 
        vehic.angles_x *= -1;
        makevectors(vehic.angles);
        vehic.angles_x *= -1;
-       setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
-
-       PHYS_INPUT_BUTTON_ATCK(pilot) = PHYS_INPUT_BUTTON_ATCK2(pilot) = PHYS_INPUT_BUTTON_CROUCH(pilot) = false;
-       setself(pilot);
+       setorigin(this, vehic.origin + v_up * 48 + v_forward * 160);
 
-       return 1;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
 void bumblebee_land()
index 14f4fbf..f6ae848 100644 (file)
@@ -21,10 +21,10 @@ float autocvar_g_vehicle_bumblebee_cannon_force = -35;
 
 bool bumble_raygun_send(entity this, entity to, int sf);
 
-void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
+void bumblebee_fire_cannon(entity this, entity _gun, string _tagname, entity _owner)
 {
     vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
-    vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND_VEH_BUMBLEBEE_FIRE,
+    vehicles_projectile(this, EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND_VEH_BUMBLEBEE_FIRE,
                         v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
                         autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force,  0,
                         DEATH_VH_BUMB_GUN.m_id, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
index ce5e004..7ec82cc 100644 (file)
@@ -170,240 +170,230 @@ void racer_fire_rocket_aim(entity player, string tagname, entity trg)
        racer_fire_rocket(player, v, v_forward, trg);
 }
 
-float racer_frame()
-{SELFPARAM();
-       entity player, racer;
-       vector df;
-       float ftmp;
+bool racer_frame(entity this)
+{
+       entity vehic = this.vehicle;
+       return = true;
 
        if(intermission_running)
        {
-               self.vehicle.velocity = '0 0 0';
-               self.vehicle.avelocity = '0 0 0';
-               return 1;
+               vehic.velocity = '0 0 0';
+               vehic.avelocity = '0 0 0';
+               return;
        }
 
-       player  = self;
-       racer   = self.vehicle;
-       setself(racer);
-
-       vehicles_frame(racer, player);
+       vehicles_frame(vehic, this);
 
-       if(pointcontents(racer.origin) != CONTENT_WATER)
-               racer.air_finished = time + autocvar_g_vehicle_racer_water_time;
+       if(pointcontents(vehic.origin) != CONTENT_WATER)
+               vehic.air_finished = time + autocvar_g_vehicle_racer_water_time;
 
-       if(IS_DEAD(racer))
+       if(IS_DEAD(vehic))
        {
-               setself(player);
-               PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
-               return 1;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
+               return;
        }
 
-       racer_align4point(self, PHYS_INPUT_TIMELENGTH);
+       racer_align4point(vehic, PHYS_INPUT_TIMELENGTH);
 
-       PHYS_INPUT_BUTTON_ZOOM(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
+       PHYS_INPUT_BUTTON_ZOOM(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 
-       crosshair_trace(player);
+       crosshair_trace(this);
 
-       racer.angles_x *= -1;
+       vehic.angles_x *= -1;
 
        // Yaw
-       ftmp = autocvar_g_vehicle_racer_turnspeed * PHYS_INPUT_TIMELENGTH;
-       ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - racer.angles_y, racer.angles_y), ftmp);
-       racer.angles_y = anglemods(racer.angles_y + ftmp);
+       float ftmp = autocvar_g_vehicle_racer_turnspeed * PHYS_INPUT_TIMELENGTH;
+       ftmp = bound(-ftmp, shortangle_f(this.v_angle_y - vehic.angles_y, vehic.angles_y), ftmp);
+       vehic.angles_y = anglemods(vehic.angles_y + ftmp);
 
        // Roll
-       racer.angles_z += -ftmp * autocvar_g_vehicle_racer_turnroll * PHYS_INPUT_TIMELENGTH;
+       vehic.angles_z += -ftmp * autocvar_g_vehicle_racer_turnroll * PHYS_INPUT_TIMELENGTH;
 
        // Pitch
        ftmp = autocvar_g_vehicle_racer_pitchspeed  * PHYS_INPUT_TIMELENGTH;
-       ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - racer.angles_x, racer.angles_x), ftmp);
-       racer.angles_x = bound(-autocvar_g_vehicle_racer_pitchlimit, anglemods(racer.angles_x + ftmp), autocvar_g_vehicle_racer_pitchlimit);
+       ftmp = bound(-ftmp, shortangle_f(this.v_angle_x - vehic.angles_x, vehic.angles_x), ftmp);
+       vehic.angles_x = bound(-autocvar_g_vehicle_racer_pitchlimit, anglemods(vehic.angles_x + ftmp), autocvar_g_vehicle_racer_pitchlimit);
 
-       makevectors(racer.angles);
-       racer.angles_x *= -1;
+       makevectors(vehic.angles);
+       vehic.angles_x *= -1;
 
-       //ftmp = racer.velocity_z;
-       df = racer.velocity * -autocvar_g_vehicle_racer_friction;
-       //racer.velocity_z = ftmp;
+       //ftmp = vehic.velocity_z;
+       vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction;
+       //vehic.velocity_z = ftmp;
 
-       int cont = pointcontents(racer.origin);
-       if(player.movement)
+       int cont = pointcontents(vehic.origin);
+       if(this.movement)
        {
                if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
                {
-                       if(player.movement_x) { df += v_forward * ((player.movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
-                       if(player.movement_y) { df += v_right * ((player.movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
+                       if(this.movement_x) { df += v_forward * ((this.movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
+                       if(this.movement_y) { df += v_right * ((this.movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
                }
                else
                {
-                       if(player.movement_x) { df += v_forward * ((player.movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
-                       if(player.movement_y) { df += v_right * ((player.movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
+                       if(this.movement_x) { df += v_forward * ((this.movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
+                       if(this.movement_y) { df += v_right * ((this.movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
                }
 
 #ifdef SVQC
-               if(self.sound_nexttime < time || self.sounds != 1)
+               if(vehic.sound_nexttime < time || vehic.sounds != 1)
                {
-                       self.sounds = 1;
-                       self.sound_nexttime = time + 10.922667; //soundlength("vehicles/racer_move.wav");
-                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_RACER_MOVE, VOL_VEHICLEENGINE, ATTEN_NORM);
+                       vehic.sounds = 1;
+                       vehic.sound_nexttime = time + 10.922667; //soundlength("vehicles/racer_move.wav");
+                       sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RACER_MOVE, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
 #endif
        }
 #ifdef SVQC
        else
        {
-               if(self.sound_nexttime < time || self.sounds != 0)
+               if(vehic.sound_nexttime < time || vehic.sounds != 0)
                {
-                       self.sounds = 0;
-                       self.sound_nexttime = time + 11.888604; //soundlength("vehicles/racer_idle.wav");
-                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_RACER_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
+                       vehic.sounds = 0;
+                       vehic.sound_nexttime = time + 11.888604; //soundlength("vehicles/racer_idle.wav");
+                       sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RACER_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
        }
 #endif
 
        // Afterburn
-       if (PHYS_INPUT_BUTTON_JUMP(player) && racer.vehicle_energy >= (autocvar_g_vehicle_racer_afterburn_cost * PHYS_INPUT_TIMELENGTH))
+       if (PHYS_INPUT_BUTTON_JUMP(this) && vehic.vehicle_energy >= (autocvar_g_vehicle_racer_afterburn_cost * PHYS_INPUT_TIMELENGTH))
        {
 #ifdef SVQC
-               if(time - racer.wait > 0.2)
-                       pointparticles(EFFECT_RACER_BOOSTER, self.origin - v_forward * 32, v_forward  * vlen(self.velocity), 1);
+               if(time - vehic.wait > 0.2)
+                       pointparticles(EFFECT_RACER_BOOSTER, vehic.origin - v_forward * 32, v_forward  * vlen(vehic.velocity), 1);
 #endif
 
-               racer.wait = time;
+               vehic.wait = time;
 
                if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
                {
-                       racer.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * PHYS_INPUT_TIMELENGTH;
+                       vehic.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * PHYS_INPUT_TIMELENGTH;
                        df += (v_forward * autocvar_g_vehicle_racer_waterburn_speed);
                }
                else
                {
-                       racer.vehicle_energy -= autocvar_g_vehicle_racer_afterburn_cost * PHYS_INPUT_TIMELENGTH;
+                       vehic.vehicle_energy -= autocvar_g_vehicle_racer_afterburn_cost * PHYS_INPUT_TIMELENGTH;
                        df += (v_forward * autocvar_g_vehicle_racer_speed_afterburn);
                }
 
 #ifdef SVQC
-               if(racer.invincible_finished < time)
+               if(vehic.invincible_finished < time)
                {
-                       traceline(racer.origin, racer.origin - '0 0 256', MOVE_NORMAL, self);
+                       traceline(vehic.origin, vehic.origin - '0 0 256', MOVE_NORMAL, vehic);
                        if(trace_fraction != 1.0)
                                pointparticles(EFFECT_SMOKE_SMALL, trace_endpos, '0 0 0', 1);
 
-                       racer.invincible_finished = time + 0.1 + (random() * 0.1);
+                       vehic.invincible_finished = time + 0.1 + (random() * 0.1);
                }
 
-               if(racer.strength_finished < time)
+               if(vehic.strength_finished < time)
                {
-                       racer.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
-                       sound (racer.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RACER_BOOST, VOL_VEHICLEENGINE, ATTEN_NORM);
+                       vehic.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
+                       sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RACER_BOOST, VOL_VEHICLEENGINE, ATTEN_NORM);
                }
 #endif
        }
        else
        {
-               racer.strength_finished = 0;
-               sound (racer.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
+               vehic.strength_finished = 0;
+               sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
        }
 
        if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
-               racer.racer_watertime = time;
+               vehic.racer_watertime = time;
 
        float dforce = autocvar_g_vehicle_racer_downforce;
-       if(time - racer.racer_watertime <= 3)
+       if(time - vehic.racer_watertime <= 3)
                dforce = autocvar_g_vehicle_racer_water_downforce;
 
-       df -= v_up * (vlen(racer.velocity) * dforce);
-       player.movement = racer.velocity += df * PHYS_INPUT_TIMELENGTH;
+       df -= v_up * (vlen(vehic.velocity) * dforce);
+       this.movement = vehic.velocity += df * PHYS_INPUT_TIMELENGTH;
 
 #ifdef SVQC
        Weapon wep1 = WEP_RACER;
-       if (!forbidWeaponUse(player))
-       if (PHYS_INPUT_BUTTON_ATCK(player))
+       if (!forbidWeaponUse(this))
+       if (PHYS_INPUT_BUTTON_ATCK(this))
        if (wep1.wr_checkammo1(wep1))
        {
-               string tagname = (racer.cnt)
-                   ? (racer.cnt = 0, "tag_fire1")
-                   : (racer.cnt = 1, "tag_fire2");
-               vector org = gettaginfo(self, gettagindex(self, tagname));
+               string tagname = (vehic.cnt)
+                   ? (vehic.cnt = 0, "tag_fire1")
+                   : (vehic.cnt = 1, "tag_fire2");
+               vector org = gettaginfo(vehic, gettagindex(vehic, tagname));
                w_shotorg = org;
                w_shotdir = v_forward;
                // Fix z-aim (for chase mode)
-               crosshair_trace(player);
+               crosshair_trace(this);
                w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
                .entity weaponentity = weaponentities[0];
-               wep1.wr_think(wep1, self, weaponentity, 1);
+               wep1.wr_think(wep1, vehic, weaponentity, 1);
        }
 
        if(autocvar_g_vehicle_racer_rocket_locktarget)
        {
-               vehicles_locktarget(self, (1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime,
+               vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime,
                                                 (1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * frametime,
                                                 autocvar_g_vehicle_racer_rocket_locked_time);
 
-               if(self.lock_target)
+               if(vehic.lock_target)
                {
-                       if(racer.lock_strength == 1)
-                               UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '1 0 0', 0);
-                       else if(self.lock_strength > 0.5)
-                               UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '0 1 0', 0);
-                       else if(self.lock_strength < 0.5)
-                               UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '0 0 1', 0);
+                       if(vehic.lock_strength == 1)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '1 0 0', 0);
+                       else if(vehic.lock_strength > 0.5)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 1 0', 0);
+                       else if(vehic.lock_strength < 0.5)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 0 1', 0);
                }
        }
 
-       if(!forbidWeaponUse(player))
-       if(time > racer.delay)
-       if(PHYS_INPUT_BUTTON_ATCK2(player))
+       if(!forbidWeaponUse(this))
+       if(time > vehic.delay)
+       if(PHYS_INPUT_BUTTON_ATCK2(this))
        {
-               racer.misc_bulletcounter += 1;
-               racer.delay = time + 0.3;
+               vehic.misc_bulletcounter += 1;
+               vehic.delay = time + 0.3;
 
-               if(racer.misc_bulletcounter == 1)
+               if(vehic.misc_bulletcounter == 1)
                {
-                       racer_fire_rocket_aim(player, "tag_rocket_r", (racer.lock_strength == 1 && racer.lock_target) ? racer.lock_target : world);
-                       player.vehicle_ammo2 = 50;
+                       racer_fire_rocket_aim(this, "tag_rocket_r", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target : world);
+                       this.vehicle_ammo2 = 50;
                }
-               else if(racer.misc_bulletcounter == 2)
+               else if(vehic.misc_bulletcounter == 2)
                {
-                       racer_fire_rocket_aim(player, "tag_rocket_l", (racer.lock_strength == 1 && racer.lock_target) ? racer.lock_target : world);
-                       racer.lock_strength  = 0;
-                       racer.lock_target       = world;
-                       racer.misc_bulletcounter = 0;
-                       racer.delay = time + autocvar_g_vehicle_racer_rocket_refire;
-                       racer.lip = time;
-                       player.vehicle_ammo2 = 0;
+                       racer_fire_rocket_aim(this, "tag_rocket_l", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target : world);
+                       vehic.lock_strength  = 0;
+                       vehic.lock_target       = world;
+                       vehic.misc_bulletcounter = 0;
+                       vehic.delay = time + autocvar_g_vehicle_racer_rocket_refire;
+                       vehic.lip = time;
+                       this.vehicle_ammo2 = 0;
                }
        }
-       else if(racer.misc_bulletcounter == 0)
-               player.vehicle_ammo2 = 100;
-
-       player.vehicle_reload2 = bound(0, 100 * ((time - racer.lip) / (racer.delay - racer.lip)), 100);
+       else if(vehic.misc_bulletcounter == 0)
+               this.vehicle_ammo2 = 100;
 
-       if(racer.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(racer.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, frametime, true);
+       this.vehicle_reload2 = bound(0, 100 * ((time - vehic.lip) / (vehic.delay - vehic.lip)), 100);
 
-       if(racer.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(racer.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, frametime, true);
 
-       if(racer.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(racer.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, frametime, false);
 
+       if(vehic.vehicle_flags  & VHF_ENERGYREGEN)
+               vehicles_regen(vehic, vehic.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, frametime, false);
 
-       VEHICLE_UPDATE_PLAYER(player, health, racer);
-       VEHICLE_UPDATE_PLAYER(player, energy, racer);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, racer);
+       VEHICLE_UPDATE_PLAYER(this, vehic, energy, racer);
 
-       if(racer.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(player, shield, racer);
+       if(vehic.vehicle_flags & VHF_HASSHIELD)
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, racer);
 
-       PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
 #endif
 
-       setorigin(player,racer.origin + '0 0 32');
-       player.velocity = racer.velocity;
-
-       setself(player);
-       return 1;
+       setorigin(this, vehic.origin + '0 0 32');
+       this.velocity = vehic.velocity;
 }
 
 void racer_think()
index 85938ce..9d8a830 100644 (file)
@@ -56,7 +56,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone
         if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0);
         vector org = w_shotorg;
         vector dir = w_shotdir;
-        entity bolt = vehicles_projectile(EFFECT_RACER_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE,
+        entity bolt = vehicles_projectile(veh, EFFECT_RACER_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE,
                                org, normalize(v_forward + randomvec() * autocvar_g_vehicle_racer_cannon_spread) * autocvar_g_vehicle_racer_cannon_speed,
                                autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force,  0,
                                DEATH_VH_WAKI_GUN.m_id, PROJECTILE_WAKICANNON, 0, true, true, player);
@@ -85,7 +85,7 @@ void racer_rocket_groundhugger();
 
 void racer_fire_rocket(entity player, vector org, vector dir, entity trg)
 {
-    entity rocket = vehicles_projectile(EFFECT_RACER_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
+    entity rocket = vehicles_projectile(player.vehicle, EFFECT_RACER_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
                            org, dir * autocvar_g_vehicle_racer_rocket_speed,
                            autocvar_g_vehicle_racer_rocket_damage, autocvar_g_vehicle_racer_rocket_radius, autocvar_g_vehicle_racer_rocket_force, 3,
                            DEATH_VH_WAKI_ROCKET.m_id, PROJECTILE_WAKIROCKET, 20, false, false, player);
index a90fee3..beb0e74 100644 (file)
@@ -160,72 +160,67 @@ void raptor_exit(float eject)
        self.owner = world;
 }
 
-float raptor_frame()
-{SELFPARAM();
-       entity player, raptor;
-       float ftmp = 0;
-       vector df;
+bool raptor_frame(entity this)
+{
+       entity vehic = this.vehicle;
+       return = true;
 
        if(intermission_running)
        {
-               self.vehicle.velocity = '0 0 0';
-               self.vehicle.avelocity = '0 0 0';
-               return 1;
+               vehic.velocity = '0 0 0';
+               vehic.avelocity = '0 0 0';
+               return;
        }
 
-       player = self;
-       raptor = self.vehicle;
-       setself(raptor);
-
-       vehicles_frame(raptor, player);
+       vehicles_frame(vehic, this);
 
+       float ftmp = 0;
        /*
-       ftmp = vlen(self.velocity);
+       ftmp = vlen(vehic.velocity);
        if(ftmp > autocvar_g_vehicle_raptor_speed_forward)
                ftmp = 1;
        else
                ftmp = ftmp / autocvar_g_vehicle_raptor_speed_forward;
        */
 
-       if(self.sound_nexttime < time)
+       if(vehic.sound_nexttime < time)
        {
-               self.sound_nexttime = time + 7.955812;
-               //sound (self.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_FLY, 1 - ftmp,   ATTEN_NORM );
-               sound (self, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, 1, ATTEN_NORM);
-               self.wait = ftmp;
+               vehic.sound_nexttime = time + 7.955812;
+               //sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_FLY, 1 - ftmp,   ATTEN_NORM );
+               sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, 1, ATTEN_NORM);
+               vehic.wait = ftmp;
        }
        /*
-       else if(fabs(ftmp - self.wait) > 0.2)
+       else if(fabs(ftmp - vehic.wait) > 0.2)
        {
-               sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, 1 - ftmp,   ATTEN_NORM );
-               sound (self, CH_TRIGGER_SINGLE, SND_Null, ftmp, ATTEN_NORM);
-               self.wait = ftmp;
+               sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, 1 - ftmp,   ATTEN_NORM );
+               sound (vehic, CH_TRIGGER_SINGLE, SND_Null, ftmp, ATTEN_NORM);
+               vehic.wait = ftmp;
        }
        */
 
-       if(IS_DEAD(raptor))
+       if(IS_DEAD(vehic))
        {
-               setself(player);
-               PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
                return 1;
        }
-       crosshair_trace(player);
+       crosshair_trace(this);
 
-       //if(time - self.lastteleporttime < 1)
+       //if(time - vehic.lastteleporttime < 1)
        //{
-               if(raptor.angles_z > 50 || raptor.angles_z < -50)
+               if(vehic.angles_z > 50 || vehic.angles_z < -50)
                {
-                       if(PHYS_INPUT_BUTTON_JUMP(player))
+                       if(PHYS_INPUT_BUTTON_JUMP(this))
                        {
-                               PHYS_INPUT_BUTTON_CROUCH(player) = true;
-                               PHYS_INPUT_BUTTON_JUMP(player) = false;
+                               PHYS_INPUT_BUTTON_CROUCH(this) = true;
+                               PHYS_INPUT_BUTTON_JUMP(this) = false;
                        }
                }
        //}
 
        vector vang;
-       vang = raptor.angles;
-       df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
+       vang = vehic.angles;
+       vector df = vectoangles(normalize(trace_endpos - vehic.origin + '0 0 32'));
        vang_x *= -1;
        df_x *= -1;
        if(df_x > 180)  df_x -= 360;
@@ -233,71 +228,71 @@ float raptor_frame()
        if(df_y > 180)  df_y -= 360;
        if(df_y < -180) df_y += 360;
 
-       ftmp = shortangle_f(player.v_angle_y - vang_y, vang_y);
+       ftmp = shortangle_f(this.v_angle_y - vang_y, vang_y);
        if(ftmp > 180)  ftmp -= 360; if(ftmp < -180) ftmp += 360;
-       raptor.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + raptor.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
+       vehic.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + vehic.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
 
        // Pitch
        ftmp = 0;
-       if(player.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
-       else if(player.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
+       if(this.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
+       else if(this.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
 
        df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit);
        ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit);
-       raptor.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + raptor.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
+       vehic.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + vehic.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
 
-       raptor.angles_x = anglemods(raptor.angles_x);
-       raptor.angles_y = anglemods(raptor.angles_y);
-       raptor.angles_z = anglemods(raptor.angles_z);
+       vehic.angles_x = anglemods(vehic.angles_x);
+       vehic.angles_y = anglemods(vehic.angles_y);
+       vehic.angles_z = anglemods(vehic.angles_z);
 
        if(autocvar_g_vehicle_raptor_movestyle == 1)
-               makevectors('0 1 0' * raptor.angles_y);
+               makevectors('0 1 0' * vehic.angles_y);
        else
-               makevectors(player.v_angle);
+               makevectors(this.v_angle);
 
-       df = raptor.velocity * -autocvar_g_vehicle_raptor_friction;
+       df = vehic.velocity * -autocvar_g_vehicle_raptor_friction;
 
-       if(player.movement_x != 0)
+       if(this.movement_x != 0)
        {
-               if(player.movement_x > 0)
+               if(this.movement_x > 0)
                        df += v_forward  * autocvar_g_vehicle_raptor_speed_forward;
-               else if(player.movement_x < 0)
+               else if(this.movement_x < 0)
                        df -= v_forward  * autocvar_g_vehicle_raptor_speed_forward;
        }
 
-       if(player.movement_y != 0)
+       if(this.movement_y != 0)
        {
-               if(player.movement_y < 0)
+               if(this.movement_y < 0)
                        df -= v_right * autocvar_g_vehicle_raptor_speed_strafe;
-               else if(player.movement_y > 0)
+               else if(this.movement_y > 0)
                        df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
 
-               raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
+               vehic.angles_z = bound(-30,vehic.angles_z + (this.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
        }
        else
        {
-               raptor.angles_z *= 0.95;
-               if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
-                       raptor.angles_z = 0;
+               vehic.angles_z *= 0.95;
+               if(vehic.angles_z >= -1 && vehic.angles_z <= -1)
+                       vehic.angles_z = 0;
        }
 
-       if(PHYS_INPUT_BUTTON_CROUCH(player))
+       if(PHYS_INPUT_BUTTON_CROUCH(this))
                df -=   v_up * autocvar_g_vehicle_raptor_speed_down;
-       else if (PHYS_INPUT_BUTTON_JUMP(player))
+       else if (PHYS_INPUT_BUTTON_JUMP(this))
                df +=  v_up * autocvar_g_vehicle_raptor_speed_up;
 
-       raptor.velocity  += df * frametime;
-       player.velocity = player.movement  = raptor.velocity;
-       setorigin(player, raptor.origin + '0 0 32');
+       vehic.velocity  += df * frametime;
+       this.velocity = this.movement  = vehic.velocity;
+       setorigin(this, vehic.origin + '0 0 32');
 
-       player.vehicle_weapon2mode = raptor.vehicle_weapon2mode;
+       this.vehicle_weapon2mode = vehic.vehicle_weapon2mode;
 
        vector vf, ad;
        // Target lock & predict
        if(autocvar_g_vehicle_raptor_cannon_locktarget == 2)
        {
-               if(raptor.gun1.lock_time < time || IS_DEAD(raptor.gun1.enemy) || STAT(FROZEN, raptor.gun1.enemy))
-                       raptor.gun1.enemy = world;
+               if(vehic.gun1.lock_time < time || IS_DEAD(vehic.gun1.enemy) || STAT(FROZEN, vehic.gun1.enemy))
+                       vehic.gun1.enemy = world;
 
                if(trace_ent)
                if(trace_ent.movetype)
@@ -306,33 +301,33 @@ float raptor_frame()
                {
                        if(teamplay)
                        {
-                               if(trace_ent.team != player.team)
+                               if(trace_ent.team != this.team)
                                {
-                                       raptor.gun1.enemy = trace_ent;
-                                       raptor.gun1.lock_time = time + 5;
+                                       vehic.gun1.enemy = trace_ent;
+                                       vehic.gun1.lock_time = time + 5;
                                }
                        }
                        else
                        {
-                               raptor.gun1.enemy = trace_ent;
-                               raptor.gun1.lock_time = time + 0.5;
+                               vehic.gun1.enemy = trace_ent;
+                               vehic.gun1.lock_time = time + 0.5;
                        }
                }
 
-               if(raptor.gun1.enemy)
+               if(vehic.gun1.enemy)
                {
                        float distance, impact_time;
 
-                       vf = real_origin(raptor.gun1.enemy);
-                       UpdateAuxiliaryXhair(player, vf, '1 0 0', 1);
-                       vector _vel = raptor.gun1.enemy.velocity;
-                       if(raptor.gun1.enemy.movetype == MOVETYPE_WALK)
+                       vf = real_origin(vehic.gun1.enemy);
+                       UpdateAuxiliaryXhair(this, vf, '1 0 0', 1);
+                       vector _vel = vehic.gun1.enemy.velocity;
+                       if(vehic.gun1.enemy.movetype == MOVETYPE_WALK)
                                _vel_z *= 0.1;
 
                        if(autocvar_g_vehicle_raptor_cannon_predicttarget)
                        {
                                ad = vf;
-                               distance = vlen(ad - player.origin);
+                               distance = vlen(ad - this.origin);
                                impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
                                ad = vf + _vel * impact_time;
                                trace_endpos = ad;
@@ -344,188 +339,180 @@ float raptor_frame()
        else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1)
        {
 
-               vehicles_locktarget(self, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
+               vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
                                                         (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
                                                         autocvar_g_vehicle_raptor_cannon_locked_time);
 
-               if(self.lock_target != world)
+               if(vehic.lock_target != world)
                if(autocvar_g_vehicle_raptor_cannon_predicttarget)
-               if(self.lock_strength == 1)
+               if(vehic.lock_strength == 1)
                {
                        float i, distance, impact_time;
 
-                       vf = real_origin(raptor.lock_target);
+                       vf = real_origin(vehic.lock_target);
                        ad = vf;
                        for(i = 0; i < 4; ++i)
                        {
-                               distance = vlen(ad - raptor.origin);
+                               distance = vlen(ad - vehic.origin);
                                impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
-                               ad = vf + raptor.lock_target.velocity * impact_time;
+                               ad = vf + vehic.lock_target.velocity * impact_time;
                        }
                        trace_endpos = ad;
                }
 
-               if(self.lock_target)
+               if(vehic.lock_target)
                {
-                       if(raptor.lock_strength == 1)
-                               UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '1 0 0', 1);
-                       else if(self.lock_strength > 0.5)
-                               UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 1 0', 1);
-                       else if(self.lock_strength < 0.5)
-                               UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 0 1', 1);
+                       if(vehic.lock_strength == 1)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '1 0 0', 1);
+                       else if(vehic.lock_strength > 0.5)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 1 0', 1);
+                       else if(vehic.lock_strength < 0.5)
+                               UpdateAuxiliaryXhair(this, real_origin(vehic.lock_target), '0 0 1', 1);
                }
        }
 
 
-       vehicle_aimturret(raptor, trace_endpos, raptor.gun1, "fire1",
+       vehicle_aimturret(vehic, trace_endpos, vehic.gun1, "fire1",
                                                  autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
                                                  autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
 
-       vehicle_aimturret(raptor, trace_endpos, raptor.gun2, "fire1",
+       vehicle_aimturret(vehic, trace_endpos, vehic.gun2, "fire1",
                                                  autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
                                                  autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
 
        /*
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor);
-       UpdateAuxiliaryXhair(player, trace_endpos, '0 1 0', 0);
+       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
        */
 
        Weapon wep1 = WEP_RAPTOR;
-       if(!forbidWeaponUse(player))
-       if(PHYS_INPUT_BUTTON_ATCK(player))
+       if(!forbidWeaponUse(this))
+       if(PHYS_INPUT_BUTTON_ATCK(this))
        if (wep1.wr_checkammo1(wep1))
        {
            .entity weaponentity = weaponentities[0];
-               wep1.wr_think(wep1, self, weaponentity, 1);
+               wep1.wr_think(wep1, vehic, weaponentity, 1);
        }
 
-       if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
+       if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
 
-       if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
 
-       if(self.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_ENERGYREGEN)
+               vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
 
        Weapon wep2a = WEP_RAPTOR_BOMB;
-       if(!forbidWeaponUse(player))
-       if(raptor.vehicle_weapon2mode == RSM_BOMB)
+       if(!forbidWeaponUse(this))
+       if(vehic.vehicle_weapon2mode == RSM_BOMB)
        {
-               if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
-               if(PHYS_INPUT_BUTTON_ATCK2(player))
+               if(time > vehic.lip + autocvar_g_vehicle_raptor_bombs_refire)
+               if(PHYS_INPUT_BUTTON_ATCK2(this))
                {
                    .entity weaponentity = weaponentities[1];
-                       wep2a.wr_think(wep2a, self, weaponentity, 2);
-                       raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
-                       raptor.lip   = time;
+                       wep2a.wr_think(wep2a, vehic, weaponentity, 2);
+                       vehic.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
+                       vehic.lip   = time;
                }
        }
        else
        {
                Weapon wep2b = WEP_RAPTOR_FLARE;
-               if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
-               if(PHYS_INPUT_BUTTON_ATCK2(player))
+               if(time > vehic.lip + autocvar_g_vehicle_raptor_flare_refire)
+               if(PHYS_INPUT_BUTTON_ATCK2(this))
                {
                    .entity weaponentity = weaponentities[1];
-                       wep2b.wr_think(wep2b, self, weaponentity, 2);
-                       raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
-                       raptor.lip   = time;
+                       wep2b.wr_think(wep2b, vehic, weaponentity, 2);
+                       vehic.delay = time + autocvar_g_vehicle_raptor_flare_refire;
+                       vehic.lip   = time;
                }
        }
 
-       raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
-       player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
-       player.vehicle_ammo2 = (player.vehicle_reload2 == 100) ? 100 : 0;
+       vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
+       this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
+       this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
 
-       if(self.bomb1.cnt < time)
+       if(vehic.bomb1.cnt < time)
        {
-               entity _missile = findchainentity(enemy, raptor);
+               entity _missile = findchainentity(enemy, vehic);
                float _incomming = 0;
                while(_missile)
                {
                        if(_missile.flags & FL_PROJECTILE)
                        if(MISSILE_IS_TRACKING(_missile))
-                       if(vdist(self.origin - _missile.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
+                       if(vdist(vehic.origin - _missile.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
                                ++_incomming;
 
                        _missile = _missile.chain;
                }
 
                if(_incomming)
-                       sound(self, CH_PAIN_SINGLE, SND_VEH_MISSILE_ALARM, VOL_BASE, ATTEN_NONE);
+                       sound(vehic, CH_PAIN_SINGLE, SND_VEH_MISSILE_ALARM, VOL_BASE, ATTEN_NONE);
 
-               self.bomb1.cnt = time + 1;
+               vehic.bomb1.cnt = time + 1;
        }
 
 
-       VEHICLE_UPDATE_PLAYER(player, health, raptor);
-       VEHICLE_UPDATE_PLAYER(player, energy, raptor);
-       if(self.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(player, shield, raptor);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor);
+       VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
+       if(vehic.vehicle_flags & VHF_HASSHIELD)
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
 
-       PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
-
-       setself(player);
-       return 1;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
-float raptor_takeoff()
-{SELFPARAM();
-       entity player, raptor;
-
-       player = self;
-       raptor = self.vehicle;
-       setself(raptor);
+bool raptor_takeoff(entity this)
+{
+       entity vehic = this.vehicle;
+       return = true;
 
-       self.nextthink = time;
-       CSQCMODEL_AUTOUPDATE(self);
-       self.nextthink = 0; // will this work?
+       vehic.nextthink = time;
+       CSQCMODEL_AUTOUPDATE(vehic);
+       vehic.nextthink = 0; // will this work?
 
-       if(self.sound_nexttime < time)
+       if(vehic.sound_nexttime < time)
        {
-               self.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
-               sound (self, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, VOL_VEHICLEENGINE, ATTEN_NORM);
+               vehic.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
+               sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_RAPTOR_SPEED, VOL_VEHICLEENGINE, ATTEN_NORM);
        }
 
        // Takeoff sequense
-       if(raptor.frame < 25)
+       if(vehic.frame < 25)
        {
-               raptor.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / sys_frametime);
-               raptor.velocity_z = min(raptor.velocity_z * 1.5, 256);
-               self.bomb1.gun1.avelocity_y = 90 + ((raptor.frame / 25) * 25000);
-               self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
-               PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
+               vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / sys_frametime);
+               vehic.velocity_z = min(vehic.velocity_z * 1.5, 256);
+               vehic.bomb1.gun1.avelocity_y = 90 + ((vehic.frame / 25) * 25000);
+               vehic.bomb1.gun2.avelocity_y = -vehic.bomb1.gun1.avelocity_y;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 
-               setorigin(player, raptor.origin + '0 0 32');
+               setorigin(this, vehic.origin + '0 0 32');
        }
        else
-               player.PlayerPhysplug = raptor_frame;
+               this.PlayerPhysplug = raptor_frame;
 
-       if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
+       if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true);
 
-       if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false);
 
-       if(self.vehicle_flags  & VHF_ENERGYREGEN)
-               vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_ENERGYREGEN)
+               vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false);
 
 
-       raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
-       player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
-       player.vehicle_ammo2 = (player.vehicle_reload2 == 100) ? 100 : 0;
+       vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip);
+       this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
+       this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
 
-       VEHICLE_UPDATE_PLAYER(player, health, raptor);
-       VEHICLE_UPDATE_PLAYER(player, energy, raptor);
-       if(self.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(player, shield, raptor);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor);
+       VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
+       if(vehic.vehicle_flags & VHF_HASSHIELD)
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
 
-       PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
-       setself(player);
-       return 1;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
 void raptor_blowup()
index 0f8b5af..eda7d02 100644 (file)
@@ -70,7 +70,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon
             veh.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
             actor.cnt = time;
         }
-        vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE,
+        vehicles_projectile(veh, EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE,
                                org, normalize(dir + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
                                autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force,  0,
                                DEATH_VH_RAPT_CANNON.m_id, PROJECTILE_RAPTORCANNON, 0, true, true, player);
index 253531f..fa2f6f9 100644 (file)
@@ -70,202 +70,196 @@ float autocvar_g_vehicle_spiderbot_shield_regen_pause = 0.35;
 vector autocvar_g_vehicle_spiderbot_bouncepain = '0 0 0';
 
 .float jump_delay;
-float spiderbot_frame()
-{SELFPARAM();
-       vector ad, vf;
-       entity player, spider;
-       float ftmp;
+bool spiderbot_frame(entity this)
+{
+       entity vehic = this.vehicle;
+       return = true;
 
        if(intermission_running)
        {
                self.vehicle.velocity = '0 0 0';
                self.vehicle.avelocity = '0 0 0';
-               return 1;
+               return;
        }
 
-       player = self;
-       spider = self.vehicle;
-
-       vehicles_frame(spider, player);
-
-       setself(spider);
+       vehicles_frame(vehic, this);
 
-       PHYS_INPUT_BUTTON_ZOOM(player) = false;
-       PHYS_INPUT_BUTTON_CROUCH(player) = false;
-       PS(player).m_switchweapon = WEP_Null;
-       player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
+       PHYS_INPUT_BUTTON_ZOOM(this) = false;
+       PHYS_INPUT_BUTTON_CROUCH(this) = false;
+       PS(this).m_switchweapon = WEP_Null;
+       this.vehicle_weapon2mode = vehic.vehicle_weapon2mode;
 
 
 #if 1 // 0 to enable per-gun impact aux crosshairs
        // Avarage gun impact point's -> aux cross
-       ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
-       vf = v_forward;
-       ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
+       vector ad = gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint01"));
+       vector vf = v_forward;
+       ad += gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint02"));
        vf += v_forward;
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
-       UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
+       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
 #else
-       ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
-       UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
-       vf = ad;
-       ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
-       UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
+       vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
+       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
+       vector vf = ad;
+       ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "barrels"));
+       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 1);
        ad = 0.5 * (ad + vf);
 #endif
 
-       crosshair_trace(player);
+       crosshair_trace(this);
        ad = vectoangles(normalize(trace_endpos - ad));
-       ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
+       ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(vehic.angles), AnglesTransform_FromAngles(ad))) - vehic.tur_head.angles;
        ad = AnglesTransform_Normalize(ad, true);
-       //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
+       //UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload2) + ('0 1 0' * (1 - this.vehicle_reload2)), 2);
 
        // Rotate head
-       ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
+       float ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
        ad_y = bound(-ftmp, ad_y, ftmp);
-       spider.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, spider.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
+       vehic.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, vehic.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
 
        // Pitch head
        ad_x = bound(ftmp * -1, ad_x, ftmp);
-       spider.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, spider.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
+       vehic.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, vehic.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
 
 
-       //fixedmakevectors(spider.angles);
-       makevectors(spider.angles + '-2 0 0' * spider.angles_x);
+       //fixedmakevectors(vehic.angles);
+       makevectors(vehic.angles + '-2 0 0' * vehic.angles_x);
 
-       movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
+       WITH(entity, self, vehic, movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit));
 
-       if(IS_ONGROUND(spider))
-               spider.jump_delay = time; // reset now so movement can begin
+       if(IS_ONGROUND(vehic))
+               vehic.jump_delay = time; // reset now so movement can begin
 
-       //if(IS_ONGROUND(spider))
+       //if(IS_ONGROUND(vehic))
        {
-               if(IS_ONGROUND(spider))
-               if(spider.frame == 4 && self.tur_head.wait != 0)
+               if(IS_ONGROUND(vehic))
+               if(vehic.frame == 4 && vehic.tur_head.wait != 0)
                {
-                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
-                       spider.frame = 5;
+                       sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
+                       vehic.frame = 5;
                }
 
-               if (!PHYS_INPUT_BUTTON_JUMP(player))
-                       PHYS_INPUT_BUTTON_JUMP(spider) = false;
+               if (!PHYS_INPUT_BUTTON_JUMP(this))
+                       PHYS_INPUT_BUTTON_JUMP(vehic) = false;
 
-               if((IS_ONGROUND(spider)) && PHYS_INPUT_BUTTON_JUMP(player) && !PHYS_INPUT_BUTTON_JUMP(spider) && self.tur_head.wait < time)
+               if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !PHYS_INPUT_BUTTON_JUMP(vehic) && vehic.tur_head.wait < time)
                {
-                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
+                       sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
                        //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
-                       self.delay = 0;
+                       vehic.delay = 0;
 
-                       self.tur_head.wait = time + 2;
-                       spider.jump_delay = time + 2;
-                       PHYS_INPUT_BUTTON_JUMP(spider) = true; // set spider's jump
-                       //PHYS_INPUT_BUTTON_JUMP(player) = false;
+                       vehic.tur_head.wait = time + 2;
+                       vehic.jump_delay = time + 2;
+                       PHYS_INPUT_BUTTON_JUMP(vehic) = true; // set spider's jump
+                       //PHYS_INPUT_BUTTON_JUMP(this) = false;
 
                        vector movefix = '0 0 0';
-                       if(player.movement_x > 0) movefix_x = 1;
-                       if(player.movement_x < 0) movefix_x = -1;
-                       if(player.movement_y > 0) movefix_y = 1;
-                       if(player.movement_y < 0) movefix_y = -1;
+                       if(this.movement_x > 0) movefix_x = 1;
+                       if(this.movement_x < 0) movefix_x = -1;
+                       if(this.movement_y > 0) movefix_y = 1;
+                       if(this.movement_y < 0) movefix_y = -1;
 
                        vector rt = movefix_y * v_right;
                        vector sd = movefix_x * v_forward;
                        if(movefix_y == 0 && movefix_x == 0)
                                sd = v_forward; // always do forward
 
-                       UNSET_ONGROUND(spider);
+                       UNSET_ONGROUND(vehic);
 
-                       spider.velocity = sd * 700 + rt * 600 + v_up * 600;
-                       spider.frame = 4;
+                       vehic.velocity = sd * 700 + rt * 600 + v_up * 600;
+                       vehic.frame = 4;
                }
-               else if(time >= spider.jump_delay)
+               else if(time >= vehic.jump_delay)
                {
-                       if(!player.movement)
+                       if(!this.movement)
                        {
-                               if(IS_ONGROUND(spider))
+                               if(IS_ONGROUND(vehic))
                                {
-                                       if(self.sound_nexttime < time || self.delay != 3)
+                                       if(vehic.sound_nexttime < time || vehic.delay != 3)
                                        {
-                                               self.delay = 3;
-                                               self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
+                                               vehic.delay = 3;
+                                               vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
                                                //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
-                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                        }
-                                       movelib_brake_simple(self, autocvar_g_vehicle_spiderbot_speed_stop);
-                                       spider.frame = 5;
+                                       movelib_brake_simple(vehic, autocvar_g_vehicle_spiderbot_speed_stop);
+                                       vehic.frame = 5;
                                }
                        }
                        else
                        {
                                // Turn Body
-                               if(player.movement_x == 0 && player.movement_y != 0)
+                               if(this.movement_x == 0 && this.movement_y != 0)
                                        ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
                                else
                                        ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
 
-                               ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
-                               spider.angles_y = anglemods(spider.angles_y + ftmp);
-                               spider.tur_head.angles_y -= ftmp;
+                               ftmp = bound(-ftmp, vehic.tur_head.angles_y, ftmp);
+                               vehic.angles_y = anglemods(vehic.angles_y + ftmp);
+                               vehic.tur_head.angles_y -= ftmp;
 
-                               if(player.movement_x != 0)
+                               if(this.movement_x != 0)
                                {
-                                       if(player.movement_x > 0)
+                                       if(this.movement_x > 0)
                                        {
-                                               player.movement_x = 1;
-                                               if(IS_ONGROUND(spider))
-                                                       spider.frame = 0;
+                                               this.movement_x = 1;
+                                               if(IS_ONGROUND(vehic))
+                                                       vehic.frame = 0;
                                        }
-                                       else if(player.movement_x < 0)
+                                       else if(this.movement_x < 0)
                                        {
-                                               player.movement_x = -1;
-                                               if(IS_ONGROUND(spider))
-                                                       spider.frame = 1;
+                                               this.movement_x = -1;
+                                               if(IS_ONGROUND(vehic))
+                                                       vehic.frame = 1;
                                        }
-                                       player.movement_y = 0;
-                                       float oldvelz = spider.velocity_z;
-                                       movelib_move_simple(self, normalize(v_forward * player.movement_x),((PHYS_INPUT_BUTTON_JUMP(player)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
-                                       spider.velocity_z = oldvelz;
+                                       this.movement_y = 0;
+                                       float oldvelz = vehic.velocity_z;
+                                       movelib_move_simple(vehic, normalize(v_forward * this.movement_x),((PHYS_INPUT_BUTTON_JUMP(this)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
+                                       vehic.velocity_z = oldvelz;
                                        float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
-                                       if(spider.velocity_z <= 20) // not while jumping
-                                               spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
-                                       if(IS_ONGROUND(spider))
-                                       if(self.sound_nexttime < time || self.delay != 1)
+                                       if(vehic.velocity_z <= 20) // not while jumping
+                                               vehic.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
+                                       if(IS_ONGROUND(vehic))
+                                       if(vehic.sound_nexttime < time || vehic.delay != 1)
                                        {
-                                               self.delay = 1;
-                                               self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               vehic.delay = 1;
+                                               vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
+                                               sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
                                        }
                                }
-                               else if(player.movement_y != 0)
+                               else if(this.movement_y != 0)
                                {
-                                       if(player.movement_y < 0)
+                                       if(this.movement_y < 0)
                                        {
-                                               player.movement_y = -1;
-                                               if(IS_ONGROUND(spider))
-                                                       spider.frame = 2;
+                                               this.movement_y = -1;
+                                               if(IS_ONGROUND(vehic))
+                                                       vehic.frame = 2;
                                        }
-                                       else if(player.movement_y > 0)
+                                       else if(this.movement_y > 0)
                                        {
-                                               player.movement_y = 1;
-                                               if(IS_ONGROUND(spider))
-                                                       spider.frame = 3;
+                                               this.movement_y = 1;
+                                               if(IS_ONGROUND(vehic))
+                                                       vehic.frame = 3;
                                        }
 
-                                       float oldvelz = spider.velocity_z;
-                                       movelib_move_simple(self, normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
-                                       spider.velocity_z = oldvelz;
+                                       float oldvelz = vehic.velocity_z;
+                                       movelib_move_simple(vehic, normalize(v_right * this.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
+                                       vehic.velocity_z = oldvelz;
                                        float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
-                                       if(spider.velocity_z <= 20) // not while jumping
-                                               spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
-                                       if(IS_ONGROUND(spider))
-                                       if(self.sound_nexttime < time || self.delay != 2)
+                                       if(vehic.velocity_z <= 20) // not while jumping
+                                               vehic.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
+                                       if(IS_ONGROUND(vehic))
+                                       if(vehic.sound_nexttime < time || vehic.delay != 2)
                                        {
-                                               self.delay = 2;
-                                               self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               vehic.delay = 2;
+                                               vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
+                                               sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
                                        }
                                }
@@ -273,81 +267,74 @@ float spiderbot_frame()
                }
        }
 
-       self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
-       self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
+       vehic.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
+       vehic.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
 
-       if(!forbidWeaponUse(player))
-       if(PHYS_INPUT_BUTTON_ATCK(player))
+       if(!forbidWeaponUse(this))
+       if(PHYS_INPUT_BUTTON_ATCK(this))
        {
-               spider.cnt = time;
-               if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single[0] <= time)
+               vehic.cnt = time;
+               if(vehic.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && vehic.tur_head.attack_finished_single[0] <= time)
                {
                        entity gun;
                        vector v;
-                       spider.misc_bulletcounter += 1;
+                       vehic.misc_bulletcounter += 1;
 
-                       setself(player);
-
-                       gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
+                       gun = (vehic.misc_bulletcounter % 2) ? vehic.gun1 : vehic.gun2;
 
                        v = gettaginfo(gun, gettagindex(gun, "barrels"));
                        v_forward = normalize(v_forward);
                        v += v_forward * 50;
 
-                       fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
-                                autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, 0);
+                       WITH(entity, self, this, fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
+                               autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, 0));
 
                        sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
                        //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
-                       pointparticles(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
-
-                       setself(spider);
-
-                       spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
-                       spider.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
-                       player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
-                       spider.gun1.angles_z += 45;
-                       spider.gun2.angles_z -= 45;
-                       if(spider.gun1.angles_z >= 360)
+                       Send_Effect(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
+
+                       vehic.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
+                       vehic.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
+                       this.vehicle_ammo1 = (vehic.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
+                       vehic.gun1.angles_z += 45;
+                       vehic.gun2.angles_z -= 45;
+                       if(vehic.gun1.angles_z >= 360)
                        {
-                               spider.gun1.angles_z = 0;
-                               spider.gun2.angles_z = 0;
+                               vehic.gun1.angles_z = 0;
+                               vehic.gun2.angles_z = 0;
                        }
                }
        }
        else
-               vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
+               vehicles_regen(vehic, vehic.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
                                                                                   autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
                                                                                   autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, false);
 
 
-       spiderbot_rocket_do();
+       WITH(entity, self, vehic, spiderbot_rocket_do());
 
-       if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, true);
+       if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, true);
 
-       if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, false);
+       if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
+               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, false);
 
-       PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
-       //player.vehicle_ammo2 = spider.tur_head.frame;
-       player.vehicle_ammo2 = (9 - spider.tur_head.frame) / 8 * 100; // Percentage, like ammo1
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
+       //this.vehicle_ammo2 = vehic.tur_head.frame;
+       this.vehicle_ammo2 = (9 - vehic.tur_head.frame) / 8 * 100; // Percentage, like ammo1
 
-       if(spider.gun2.cnt <= time)
-               player.vehicle_reload2 = 100;
+       if(vehic.gun2.cnt <= time)
+               this.vehicle_reload2 = 100;
        else
-               player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single[0]) * 100;
-
-       setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
-       player.velocity = spider.velocity;
+               this.vehicle_reload2 = 100 - ((vehic.gun2.cnt - time) / vehic.attack_finished_single[0]) * 100;
 
-       VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
+       setorigin(this, vehic.origin + '0 0 1' * vehic.maxs_z);
+       this.velocity = vehic.velocity;
 
-       if(self.vehicle_flags & VHF_HASSHIELD)
-               VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
+       VEHICLE_UPDATE_PLAYER(this, vehic, health, spiderbot);
 
-       setself(player);
-       return 1;
+       if(vehic.vehicle_flags & VHF_HASSHIELD)
+               VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot);
 }
 
 void spiderbot_exit(float eject)
index 2f08ef7..38817b1 100644 (file)
@@ -218,7 +218,7 @@ void spiderbot_rocket_do()
     switch(self.vehicle_weapon2mode)
     {
         case SBRM_VOLLY:
-            rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
+            rocket = vehicles_projectile(self, EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
                                    v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                    DEATH_VH_SPID_ROCKET.m_id, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
@@ -232,7 +232,7 @@ void spiderbot_rocket_do()
                 self.wait = -10;
             break;
         case SBRM_GUIDE:
-            rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
+            rocket = vehicles_projectile(self, EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
                                    v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                    DEATH_VH_SPID_ROCKET.m_id, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, false, self.owner);
@@ -244,7 +244,7 @@ void spiderbot_rocket_do()
 
         break;
         case SBRM_ARTILLERY:
-            rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
+            rocket = vehicles_projectile(self, EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, SND_ROCKET_FIRE,
                                    v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                    DEATH_VH_SPID_ROCKET.m_id, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);