]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/sv_vehicles.qc
Merge branch 'master' into Mario/hagar_notfixed
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qc
index 4a5d5439f4c6985f7e82e7acaaeee4fe150cbe31..35b6c677f957de6fbfe84ee53ad28a78ce4aa3e7 100644 (file)
@@ -1,5 +1,4 @@
 #include "sv_vehicles.qh"
-#include "../effects/effects.qh"
 
 #if 0
 bool vehicle_send(entity to, int sf)
@@ -38,20 +37,20 @@ bool vehicle_send(entity to, int sf)
 }
 #endif
 
-bool SendAuxiliaryXhair(entity to, int sf)
-{SELFPARAM();
+bool SendAuxiliaryXhair(entity this, entity to, int sf)
+{
 
-       WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
 
-       WriteByte(MSG_ENTITY, self.cnt);
+       WriteByte(MSG_ENTITY, this.cnt);
 
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       WriteCoord(MSG_ENTITY, this.origin_x);
+       WriteCoord(MSG_ENTITY, this.origin_y);
+       WriteCoord(MSG_ENTITY, this.origin_z);
 
-       WriteByte(MSG_ENTITY, rint(self.colormod_x * 255));
-       WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
-       WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
+       WriteByte(MSG_ENTITY, rint(this.colormod_x * 255));
+       WriteByte(MSG_ENTITY, rint(this.colormod_y * 255));
+       WriteByte(MSG_ENTITY, rint(this.colormod_z * 255));
 
        return true;
 }
@@ -88,41 +87,26 @@ void CSQCVehicleSetup(entity own, int vehicle_id)
 
        msg_entity = own;
 
-       WriteByte(MSG_ONE, SVC_TEMPENTITY);
-       WriteByte(MSG_ONE, TE_CSQC_VEHICLESETUP);
+       WriteHeader(MSG_ONE, TE_CSQC_VEHICLESETUP);
        WriteByte(MSG_ONE, vehicle_id);
 }
 
-vector targetdrone_getnewspot()
-{SELFPARAM();
-       vector spot;
-       int i;
-       for(i = 0; i < 100; ++i)
-       {
-               spot = self.origin + randomvec() * 1024;
-               tracebox(spot, self.mins, self.maxs, spot, MOVE_NORMAL, self);
-               if(trace_fraction == 1.0 && trace_startsolid == 0 && trace_allsolid == 0)
-                       return spot;
-       }
-       return self.origin;
-}
-
-void vehicles_locktarget(float incr, float decr, float _lock_time)
-{SELFPARAM();
-       if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
+void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
+{
+       if(this.lock_target && IS_DEAD(this.lock_target))
        {
-               self.lock_target        = world;
-               self.lock_strength  = 0;
-               self.lock_time    = 0;
+               this.lock_target        = world;
+               this.lock_strength  = 0;
+               this.lock_time    = 0;
        }
 
-       if(self.lock_time > time)
+       if(this.lock_time > time)
        {
-               if(self.lock_target)
-               if(self.lock_soundtime < time)
+               if(this.lock_target)
+               if(this.lock_soundtime < time)
                {
-                       self.lock_soundtime = time + 0.5;
-                       play2(self.owner, "vehicles/locked.wav");
+                       this.lock_soundtime = time + 0.5;
+                       play2(this.owner, "vehicles/locked.wav");
                }
 
                return;
@@ -130,10 +114,10 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
 
        if(trace_ent != world)
        {
-               if(SAME_TEAM(trace_ent, self))
+               if(SAME_TEAM(trace_ent, this))
                        trace_ent = world;
 
-               if(trace_ent.deadflag != DEAD_NO)
+               if(IS_DEAD(trace_ent))
                        trace_ent = world;
 
                if(!(IS_VEHICLE(trace_ent) || IS_TURRET(trace_ent)))
@@ -143,48 +127,48 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
                        trace_ent = world; // invisible
        }
 
-       if(self.lock_target == world && trace_ent != world)
-               self.lock_target = trace_ent;
+       if(this.lock_target == world && trace_ent != world)
+               this.lock_target = trace_ent;
 
-       if(self.lock_target && trace_ent == self.lock_target)
+       if(this.lock_target && trace_ent == this.lock_target)
        {
-               if(self.lock_strength != 1 && self.lock_strength + incr >= 1)
+               if(this.lock_strength != 1 && this.lock_strength + incr >= 1)
                {
-                       play2(self.owner, "vehicles/lock.wav");
-                       self.lock_soundtime = time + 0.8;
+                       play2(this.owner, "vehicles/lock.wav");
+                       this.lock_soundtime = time + 0.8;
                }
-               else if (self.lock_strength != 1 && self.lock_soundtime < time)
+               else if (this.lock_strength != 1 && this.lock_soundtime < time)
                {
-                       play2(self.owner, "vehicles/locking.wav");
-                       self.lock_soundtime = time + 0.3;
+                       play2(this.owner, "vehicles/locking.wav");
+                       this.lock_soundtime = time + 0.3;
                }
        }
 
        // Have a locking target
        // Trace hit current target
-       if(trace_ent == self.lock_target && trace_ent != world)
+       if(trace_ent == this.lock_target && trace_ent != world)
        {
-               self.lock_strength = min(self.lock_strength + incr, 1);
-               if(self.lock_strength == 1)
-                       self.lock_time = time + _lock_time;
+               this.lock_strength = min(this.lock_strength + incr, 1);
+               if(this.lock_strength == 1)
+                       this.lock_time = time + _lock_time;
        }
        else
        {
                if(trace_ent)
-                       self.lock_strength = max(self.lock_strength - decr * 2, 0);
+                       this.lock_strength = max(this.lock_strength - decr * 2, 0);
                else
-                       self.lock_strength = max(self.lock_strength - decr, 0);
+                       this.lock_strength = max(this.lock_strength - decr, 0);
 
-               if(self.lock_strength == 0)
-                       self.lock_target = world;
+               if(this.lock_strength == 0)
+                       this.lock_target = world;
        }
 }
 
-vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
-{SELFPARAM();
-       force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
+vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power)
+{
+       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
        v_forward  = normalize(v_forward) * -1;
-       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
+       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
 
        force_fromtag_power = (1 - trace_fraction) * max_power;
        force_fromtag_normpower = force_fromtag_power / max_power;
@@ -192,12 +176,11 @@ vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float
        return v_forward  * force_fromtag_power;
 }
 
-vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
-{SELFPARAM();
-
-       force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
+vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_length, float max_power)
+{
+       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
        v_forward  = normalize(v_forward) * -1;
-       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
+       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
 
        // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
        if(trace_fraction == 1.0)
@@ -213,20 +196,20 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
 }
 
 // projectile handling
-void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
        // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
-       if(inflictor.owner == self.owner)
+       if(inflictor.owner == this.owner)
                return;
 
-       self.health -= damage;
-       self.velocity += force;
-       if(self.health < 1)
+       this.health -= damage;
+       this.velocity += force;
+       if(this.health < 1)
        {
-               self.takedamage = DAMAGE_NO;
-               self.event_damage = func_null;
-               self.think = self.use;
-               self.nextthink = time;
+               this.takedamage = DAMAGE_NO;
+               this.event_damage = func_null;
+               this.think = this.use;
+               this.nextthink = time;
        }
 }
 
@@ -249,12 +232,13 @@ void vehicles_projectile_explode()
        remove (self);
 }
 
-entity vehicles_projectile(string _mzlfx, string _mzlsound,
+entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound,
                                                   vector _org, vector _vel,
                                                   float _dmg, float _radi, float _force,  float _size,
                                                   int _deahtype, float _projtype, float _health,
                                                   bool _cull, bool _clianim, entity _owner)
-{SELFPARAM();
+{
+    TC(Sound, _mzlsound);
        entity proj;
 
        proj = spawn();
@@ -274,9 +258,9 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
        proj.velocity            = _vel;
        proj.touch                      = vehicles_projectile_explode;
        proj.use                          = vehicles_projectile_explode;
-       proj.owner                      = self;
+       proj.owner                      = this;
        proj.realowner          = _owner;
-       proj.think                      = SUB_Remove;
+       proj.think                      = SUB_Remove_self;
        proj.nextthink          = time + 30;
 
        if(_health)
@@ -288,8 +272,8 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
        else
                proj.flags                 = FL_PROJECTILE | FL_NOTARGET;
 
-       if(_mzlsound)
-               _sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
+       if(_mzlsound != SND_Null)
+               sound (this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
 
        if(_mzlfx)
                Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
@@ -318,11 +302,12 @@ void vehicles_gib_think()
                self.nextthink = time + 0.1;
 }
 
-entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
-{SELFPARAM();
+entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
+{
        entity _gib = spawn();
        _setmodel(_gib, _template.model);
-       setorigin(_gib, gettaginfo(self, gettagindex(self, _tag)));
+       vector org = gettaginfo(this, gettagindex(this, _tag));
+       setorigin(_gib, org);
        _gib.velocity = _vel;
        _gib.movetype = MOVETYPE_TOSS;
        _gib.solid = SOLID_CORPSE;
@@ -352,9 +337,9 @@ entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, b
 bool vehicle_addplayerslot(    entity _owner,
                                                                entity _slot,
                                                                int _hud,
-                                                               string _hud_model,
-                                                               bool() _framefunc,
-                                                               void(bool) _exitfunc, float() _enterfunc)
+                                                               Model _hud_model,
+                                                               bool(entity) _framefunc,
+                                                               void(bool) _exitfunc, float(entity, entity) _enterfunc)
 {
        if(!(_owner.vehicle_flags & VHF_MULTISLOT))
                _owner.vehicle_flags |= VHF_MULTISLOT;
@@ -369,7 +354,7 @@ bool vehicle_addplayerslot( entity _owner,
        _slot.vehicle_hudmodel.viewmodelforclient = _slot;
        _slot.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
 
-       _setmodel(_slot.vehicle_hudmodel, _hud_model);
+       setmodel(_slot.vehicle_hudmodel, _hud_model);
        setmodel(_slot.vehicle_viewport, MDL_Null);
 
        setattachment(_slot.vehicle_hudmodel, _slot, "");
@@ -396,75 +381,63 @@ vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string
        return vtag;
 }
 
-void vehicles_reset_colors()
-{SELFPARAM();
-       entity e;
-       float _effects = 0, _colormap;
-       vector _glowmod, _colormod;
-
+void vehicles_reset_colors(entity this)
+{
+       int eff = 0, cmap;
+       const vector cmod = '0 0 0';
+       if(this.team && teamplay)
+               cmap = 1024 + (this.team - 1) * 17;
+       else
+               cmap = 1024;
        if(autocvar_g_nodepthtestplayers)
-               _effects |= EF_NODEPTHTEST;
-
+               eff |= EF_NODEPTHTEST;
        if(autocvar_g_fullbrightplayers)
-               _effects |= EF_FULLBRIGHT;
-
-       if(self.team)
-               _colormap = 1024 + (self.team - 1) * 17;
-       else
-               _colormap = 1024;
-
-       _glowmod  = '0 0 0';
-       _colormod = '0 0 0';
+               eff |= EF_FULLBRIGHT;
 
        // Find all ents attacked to main model and setup effects, colormod etc.
-       e = findchainentity(tag_entity, self);
-       while(e)
+       FOREACH_ENTITY_ENT(tag_entity, this,
        {
-               if(e != self.vehicle_shieldent)
+               if(it != this.vehicle_shieldent)
                {
-                       e.effects   = _effects; //  | EF_LOWPRECISION;
-                       e.colormod  = _colormod;
-                       e.colormap  = _colormap;
-                       e.alpha  = 1;
+                       it.effects = eff;
+                       it.colormod = cmod;
+                       it.colormap = cmap;
+                       it.alpha = 1;
                }
-               e = e.chain;
-       }
+       });
+
        // Also check head tags
-       e = findchainentity(tag_entity, self.tur_head);
-       while(e)
+       FOREACH_ENTITY_ENT(tag_entity, this.tur_head,
        {
-               if(e != self.vehicle_shieldent)
+               if(it != this.vehicle_shieldent)
                {
-                       e.effects   = _effects; //  | EF_LOWPRECISION;
-                       e.colormod  = _colormod;
-                       e.colormap  = _colormap;
-                       e.alpha  = 1;
+                       it.effects = eff;
+                       it.colormod = cmod;
+                       it.colormap = cmap;
+                       it.alpha = 1;
                }
-               e = e.chain;
-       }
+       });
 
-       self.vehicle_hudmodel.effects  = self.effects  = _effects; // | EF_LOWPRECISION;
-       self.vehicle_hudmodel.colormod = self.colormod = _colormod;
-       self.vehicle_hudmodel.colormap = self.colormap = _colormap;
-       self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
+       this.vehicle_hudmodel.effects  = this.effects  = eff; // | EF_LOWPRECISION;
+       this.vehicle_hudmodel.colormod = this.colormod = cmod;
+       this.vehicle_hudmodel.colormap = this.colormap = cmap;
+       this.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT);
 
-       self.alpha       = 1;
-       self.avelocity = '0 0 0';
-       self.velocity  = '0 0 0';
-       self.effects   = _effects;
+       this.alpha       = 1;
+       this.avelocity = '0 0 0';
+       this.velocity  = '0 0 0';
+       this.effects   = eff;
 }
 
 void vehicles_clearreturn(entity veh)
 {
-       entity ret;
        // Remove "return helper", if any.
-       ret = findchain(classname, "vehicle_return");
-       while(ret)
+       for (entity ret = findchain(classname, "vehicle_return"); ret; ret = ret.chain)
        {
                if(ret.wp00 == veh)
                {
                        ret.classname   = "";
-                       ret.think          = SUB_Remove;
+                       ret.think          = SUB_Remove_self;
                        ret.nextthink   = time + 0.1;
 
                        if(ret.waypointsprite_attached)
@@ -472,7 +445,6 @@ void vehicles_clearreturn(entity veh)
 
                        return;
                }
-               ret = ret.chain;
        }
 }
 
@@ -529,7 +501,7 @@ void vehicles_showwp()
                rgb = Team_ColorRGB(self.team);
        else
                rgb = '1 1 1';
-       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
        wp.colormod = rgb;
        if(self.waypointsprite_attached)
        {
@@ -549,13 +521,12 @@ void vehicles_setreturn(entity veh)
 
        vehicles_clearreturn(veh);
 
-       ret = spawn();
-       ret.classname   = "vehicle_return";
+       ret = new(vehicle_return);
        ret.wp00           = veh;
        ret.team                = veh.team;
        ret.think          = vehicles_showwp;
 
-       if(veh.deadflag != DEAD_NO)
+       if(IS_DEAD(veh))
        {
                ret.cnt          = time + veh.respawntime;
                ret.nextthink   = min(time + veh.respawntime, time + veh.respawntime - 5);
@@ -581,7 +552,7 @@ void vehicle_use()
        else
                self.active = ACTIVE_ACTIVE;
 
-       if(self.active == ACTIVE_ACTIVE && self.deadflag == DEAD_NO && !gameover)
+       if(self.active == ACTIVE_ACTIVE && !IS_DEAD(self) && !gameover)
        {
                LOG_TRACE("Respawning vehicle: ", self.netname, "\n");
                if(self.effects & EF_NODRAW)
@@ -592,23 +563,23 @@ void vehicle_use()
                else
                {
                        vehicles_setreturn(self);
-                       vehicles_reset_colors();
+                       vehicles_reset_colors(self);
                }
        }
 }
 
-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;
        }
 }
 
@@ -627,118 +598,124 @@ void shieldhit_think()
        }
 }
 
-void vehicles_painframe()
-{SELFPARAM();
-       if(self.owner.vehicle_health <= 50)
-       if(self.pain_frame < time)
+void vehicles_painframe(entity this)
+{
+       int myhealth = ((this.owner) ? this.owner.vehicle_health : ((this.vehicle_health / this.max_health) * 100));
+
+       if(myhealth <= 50)
+       if(this.pain_frame < time)
        {
-               float _ftmp;
-               _ftmp = self.owner.vehicle_health / 50;
-               self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
-               pointparticles(particleeffectnum(EFFECT_SMOKE_SMALL), (self.origin + (randomvec() * 80)), '0 0 0', 1);
+               float _ftmp = myhealth / 50;
+               this.pain_frame = time + max(0.1, 0.1 + (random() * 0.5 * _ftmp));
+               Send_Effect(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
 
-               if(self.vehicle_flags & VHF_DMGSHAKE)
-                       self.velocity += randomvec() * 30;
+               if(this.vehicle_flags & VHF_DMGSHAKE)
+                       this.velocity += randomvec() * 30;
 
-               if(self.vehicle_flags & VHF_DMGROLL)
-                       if(self.vehicle_flags & VHF_DMGHEADROLL)
-                               self.tur_head.angles += randomvec();
+               if(this.vehicle_flags & VHF_DMGROLL)
+                       if(this.vehicle_flags & VHF_DMGHEADROLL)
+                               this.tur_head.angles += randomvec();
                        else
-                               self.angles += randomvec();
-
+                               this.angles += randomvec();
        }
 }
 
-void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
-       self.dmg_time = time;
+void vehicles_frame(entity this, entity actor)
+{
+       vehicles_painframe(this);
+}
+
+void vehicles_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
+{
+       this.dmg_time = time;
 
        // WEAPONTODO
-       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX))
                damage *= autocvar_g_vehicles_vortex_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
                damage *= autocvar_g_vehicles_machinegun_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_RIFLE.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_RIFLE))
                damage *= autocvar_g_vehicles_rifle_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
                damage *= autocvar_g_vehicles_vaporizer_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_SEEKER.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_SEEKER))
                damage *= autocvar_g_vehicles_tag_damagerate;
 
-       if(DEATH_WEAPONOFWEAPONDEATH(deathtype))
+       if(DEATH_WEAPONOF(deathtype) != WEP_Null)
                damage *= autocvar_g_vehicles_weapon_damagerate;
 
-       self.enemy = attacker;
+       this.enemy = attacker;
 
-       self.pain_finished = time;
+       this.pain_finished = time;
 
-       if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
+       if((this.vehicle_flags & VHF_HASSHIELD) && (this.vehicle_shield > 0))
        {
-               if (wasfreed(self.vehicle_shieldent) || self.vehicle_shieldent == world)
+               if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == world)
                {
-                       self.vehicle_shieldent = spawn();
-                       self.vehicle_shieldent.effects = EF_LOWPRECISION;
-
-                       setmodel(self.vehicle_shieldent, MDL_VEH_SHIELD);
-                       setattachment(self.vehicle_shieldent, self, "");
-                       setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
-                       self.vehicle_shieldent.scale       = 256 / vlen(self.maxs - self.mins);
-                       self.vehicle_shieldent.think       = shieldhit_think;
+                       this.vehicle_shieldent = spawn();
+                       this.vehicle_shieldent.effects = EF_LOWPRECISION;
+
+                       setmodel(this.vehicle_shieldent, MDL_VEH_SHIELD);
+                       setattachment(this.vehicle_shieldent, this, "");
+                       setorigin(this.vehicle_shieldent, real_origin(this) - this.origin);
+                       this.vehicle_shieldent.scale       = 256 / vlen(this.maxs - this.mins);
+                       this.vehicle_shieldent.think       = shieldhit_think;
                }
 
-               self.vehicle_shieldent.colormod = '1 1 1';
-               self.vehicle_shieldent.alpha = 0.45;
-               self.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (self.origin + self.vehicle_shieldent.origin))) - self.angles;
-               self.vehicle_shieldent.nextthink = time;
-               self.vehicle_shieldent.effects &= ~EF_NODRAW;
+               this.vehicle_shieldent.colormod = '1 1 1';
+               this.vehicle_shieldent.alpha = 0.45;
+               this.vehicle_shieldent.angles = vectoangles(normalize(hitloc - (this.origin + this.vehicle_shieldent.origin))) - this.angles;
+               this.vehicle_shieldent.nextthink = time;
+               this.vehicle_shieldent.effects &= ~EF_NODRAW;
 
-               self.vehicle_shield -= damage;
+               this.vehicle_shield -= damage;
 
-               if(self.vehicle_shield < 0)
+               if(this.vehicle_shield < 0)
                {
-                       self.vehicle_health -= fabs(self.vehicle_shield);
-                       self.vehicle_shieldent.colormod = '2 0 0';
-                       self.vehicle_shield = 0;
-                       self.vehicle_shieldent.alpha = 0.75;
+                       this.vehicle_health -= fabs(this.vehicle_shield);
+                       this.vehicle_shieldent.colormod = '2 0 0';
+                       this.vehicle_shield = 0;
+                       this.vehicle_shieldent.alpha = 0.75;
 
                        if(sound_allowed(MSG_BROADCAST, attacker))
-                               spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);   // FIXME: PLACEHOLDER
+                               spamsound (this, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);   // FIXME: PLACEHOLDER
                }
                else
                        if(sound_allowed(MSG_BROADCAST, attacker))
-                               spamsound (self, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
+                               spamsound (this, CH_PAIN, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
 
        }
        else
        {
-               self.vehicle_health -= damage;
+               this.vehicle_health -= damage;
 
                if(sound_allowed(MSG_BROADCAST, attacker))
-                       spamsound (self, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
+                       spamsound (this, CH_PAIN, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);  // FIXME: PLACEHOLDER
        }
 
-       if(self.damageforcescale < 1 && self.damageforcescale > 0)
-               self.velocity += force * self.damageforcescale;
+       if(this.damageforcescale < 1 && this.damageforcescale > 0)
+               this.velocity += force * this.damageforcescale;
        else
-               self.velocity += force;
+               this.velocity += force;
 
-       if(self.vehicle_health <= 0)
+       if(this.vehicle_health <= 0)
        {
-               if(self.owner)
-                       if(self.vehicle_flags & VHF_DEATHEJECT)
-                               vehicles_exit(VHEF_EJECT);
+               if(this.owner)
+                       if(this.vehicle_flags & VHF_DEATHEJECT)
+                               WITHSELF(this, vehicles_exit(VHEF_EJECT));
                        else
-                               vehicles_exit(VHEF_RELEASE);
+                               WITHSELF(this, vehicles_exit(VHEF_RELEASE));
 
 
-               antilag_clear(self);
+               antilag_clear(this, this);
 
-               VEH_ACTION(self.vehicleid, VR_DEATH);
-               vehicles_setreturn(self);
+               Vehicle info = Vehicles_from(this.vehicleid);
+               info.vr_death(info, this);
+               vehicles_setreturn(this);
        }
 }
 
@@ -753,21 +730,21 @@ float vehicles_crushable(entity e)
        return false;
 }
 
-void vehicles_impact(float _minspeed, float _speedfac, float _maxpain)
-{SELFPARAM();
+void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
+{
        if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
                return;
 
-       if(self.play_time < time)
+       if(this.play_time < time)
        {
-               float wc = vlen(self.velocity - self.oldvelocity);
-               //dprint("oldvel: ", vtos(self.oldvelocity), "\n");
-               //dprint("vel: ", vtos(self.velocity), "\n");
+               float wc = vlen(this.velocity - this.oldvelocity);
+               //dprint("oldvel: ", vtos(this.oldvelocity), "\n");
+               //dprint("vel: ", vtos(this.velocity), "\n");
                if(_minspeed < wc)
                {
                        float take = min(_speedfac * wc, _maxpain);
-                       Damage (self, world, world, take, DEATH_FALL, self.origin, '0 0 0');
-                       self.play_time = time + 0.25;
+                       Damage (this, world, world, take, DEATH_FALL.m_id, this.origin, '0 0 0');
+                       this.play_time = time + 0.25;
 
                        //dprint("wc: ", ftos(wc), "\n");
                        //dprint("take: ", ftos(take), "\n");
@@ -781,7 +758,7 @@ vector vehicles_findgoodexit(vector prefer_spot)
        //vector exitspot;
        float mysize;
 
-       tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, self.owner);
+       tracebox(self.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, self.owner);
        if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
                return prefer_spot;
 
@@ -794,7 +771,7 @@ vector vehicles_findgoodexit(vector prefer_spot)
                v = randomvec();
                v_z = 0;
                v = v2 + normalize(v) * mysize;
-               tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, self.owner);
+               tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, self.owner);
                if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
                        return v;
        }
@@ -869,7 +846,7 @@ void vehicles_exit(bool eject)
                        WriteAngle(MSG_ONE, 0);
                }
 
-               setsize(_player, PL_MIN,PL_MAX);
+               setsize(_player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
 
                _player.takedamage              = DAMAGE_AIM;
                _player.solid                   = SOLID_SLIDEBOX;
@@ -879,10 +856,10 @@ void vehicles_exit(bool eject)
                _player.alpha                   = 1;
                _player.PlayerPhysplug  = func_null;
                _player.vehicle                 = world;
-               _player.view_ofs                = PL_VIEW_OFS;
+               _player.view_ofs                = STAT(PL_VIEW_OFS, NULL);
                _player.event_damage    = PlayerDamage;
                _player.hud                             = HUD_NORMAL;
-               _player.switchweapon    = _vehicle.switchweapon;
+               PS(_player).m_switchweapon = _vehicle.m_switchweapon;
                _player.last_vehiclecheck = time + 3;
                _player.vehicle_enter_delay = time + 2;
 
@@ -890,7 +867,7 @@ void vehicles_exit(bool eject)
        }
        _vehicle.flags |= FL_NOTARGET;
 
-       if(_vehicle.deadflag == DEAD_NO)
+       if(!IS_DEAD(_vehicle))
                _vehicle.avelocity = '0 0 0';
 
        _vehicle.tur_head.nodrawtoclient = world;
@@ -898,8 +875,8 @@ void vehicles_exit(bool eject)
        if(!teamplay)
                _vehicle.team = 0;
 
-       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES);
-       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER_CPID, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
+       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES);
+       Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle?
 
        WaypointSprite_Kill(_vehicle.wps_intruder);
 
@@ -914,7 +891,7 @@ void vehicles_exit(bool eject)
        _vehicle.vehicle_exit(eject);
 
        vehicles_setreturn(_vehicle);
-       vehicles_reset_colors();
+       vehicles_reset_colors(_vehicle);
        _vehicle.owner = world;
 
        CSQCMODEL_AUTOINIT(self);
@@ -936,14 +913,16 @@ void vehicles_touch()
                if((self.origin_z + self.maxs_z) > (other.origin_z))
                if(vehicles_crushable(other))
                {
-                       if(vlen(self.velocity) >= 30)
-                               Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
+                       if(vdist(self.velocity, >=, 30))
+                               Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
 
                        return; // Dont do selfdamage when hitting "soft targets".
                }
 
-               if(self.play_time < time)
-                       VEH_ACTION(self.vehicleid, VR_IMPACT);
+               if(self.play_time < time) {
+                       Vehicle info = Vehicles_from(self.vehicleid);
+                       info.vr_impact(info, self);
+               }
 
                return;
        }
@@ -954,22 +933,29 @@ void vehicles_touch()
        vehicles_enter(other, self);
 }
 
-bool vehicle_impulse(int imp)
-{SELFPARAM();
-       switch(imp)
+bool vehicle_impulse(entity this, int imp)
+{
+       entity v = this.vehicle;
+       if (!v) return false;
+       if (IS_DEAD(v)) return false;
+       bool(int) f = v.vehicles_impulse;
+       if (f && f(imp)) return true;
+       switch (imp)
        {
-               case 17:
+               case IMP_weapon_drop.impulse:
                {
                        stuffcmd(self, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n");
                        return true;
                }
        }
-
        return false;
 }
 
 void vehicles_enter(entity pl, entity veh)
-{SELFPARAM();
+{
+    SELFPARAM();
+       entity oldself = self;
+
    // Remove this when bots know how to use vehicles
        if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
                return;
@@ -977,8 +963,8 @@ void vehicles_enter(entity pl, entity veh)
        if((!IS_PLAYER(pl))
        || (veh.phase >= time)
        || (pl.vehicle_enter_delay >= time)
-       || (pl.frozen)
-       || (pl.deadflag != DEAD_NO)
+       || (STAT(FROZEN, pl))
+       || (IS_DEAD(pl))
        || (pl.vehicle)
        ) { return; }
 
@@ -986,28 +972,17 @@ void vehicles_enter(entity pl, entity veh)
        if(veh.vehicle_flags & VHF_MULTISLOT)
        if(veh.owner)
        {
-               setself(veh);
-               other = pl; // TODO: fix
-
                if(!veh.gunner1)
                if(time >= veh.gun1.phase)
                if(veh.gun1.vehicle_enter)
-               if(veh.gun1.vehicle_enter())
-               {
-                       setself(this);
+               if(veh.gun1.vehicle_enter(veh, pl))
                        return;
-               }
 
                if(!veh.gunner2)
                if(time >= veh.gun2.phase)
                if(veh.gun2.vehicle_enter)
-               if(veh.gun2.vehicle_enter())
-               {
-                       setself(this);
+               if(veh.gun2.vehicle_enter(veh, pl))
                        return;
-               }
-
-               setself(this);
        }
 
        if(teamplay)
@@ -1015,9 +990,7 @@ void vehicles_enter(entity pl, entity veh)
        if(DIFF_TEAM(pl, veh))
        if(autocvar_g_vehicles_steal)
        {
-               entity head;
-               FOR_EACH_PLAYER(head) if(SAME_TEAM(head, veh))
-                       Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_VEHICLE_STEAL);
+               FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, veh), Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_VEHICLE_STEAL));
 
                Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
 
@@ -1044,10 +1017,10 @@ void vehicles_enter(entity pl, entity veh)
 
        veh.vehicle_hudmodel.viewmodelforclient = pl;
 
-       tracebox(pl.origin, PL_MIN, PL_MAX, pl.origin, false, pl);
+       tracebox(pl.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pl.origin, false, pl);
        pl.crouch = false;
-       pl.view_ofs = PL_VIEW_OFS;
-       setsize (pl, PL_MIN, PL_MAX);
+       pl.view_ofs = STAT(PL_VIEW_OFS, NULL);
+       setsize (pl, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
 
        veh.event_damage        = vehicles_damage;
        veh.nextthink           = 0;
@@ -1062,7 +1035,7 @@ void vehicles_enter(entity pl, entity veh)
        veh.colormap            = pl.colormap;
        if(veh.tur_head)
                veh.tur_head.colormap = pl.colormap;
-       veh.switchweapon = pl.switchweapon;
+       veh.m_switchweapon = PS(pl).m_switchweapon;
        pl.hud = veh.vehicleid;
        pl.PlayerPhysplug = veh.PlayerPhysplug;
 
@@ -1076,8 +1049,8 @@ void vehicles_enter(entity pl, entity veh)
        //veh.exteriormodeltoclient = veh.owner;
        //veh.tur_head.exteriormodeltoclient = veh.owner;
 
-       pl.flags &= ~FL_ONGROUND;
-       veh.flags &= ~FL_ONGROUND;
+       UNSET_ONGROUND(pl);
+       UNSET_ONGROUND(veh);
 
        veh.team = pl.team;
        veh.flags -= FL_NOTARGET;
@@ -1113,10 +1086,11 @@ void vehicles_enter(entity pl, entity veh)
 
        setself(veh);
        CSQCModel_UnlinkEntity(veh);
-       VEH_ACTION(veh.vehicleid, VR_ENTER);
-       setself(this);
+       Vehicle info = Vehicles_from(veh.vehicleid);
+       info.vr_enter(info, veh);
+       setself(oldself);
 
-       antilag_clear(pl);
+       antilag_clear(pl, CS(pl));
 }
 
 void vehicles_think()
@@ -1126,7 +1100,10 @@ void vehicles_think()
        if(self.owner)
                self.owner.vehicle_weapon2mode = self.vehicle_weapon2mode;
 
-       VEH_ACTION(self.vehicleid, VR_THINK);
+       Vehicle info = Vehicles_from(self.vehicleid);
+       info.vr_think(info, self);
+
+       vehicles_painframe(self);
 
        CSQCMODEL_AUTOUPDATE(self);
 }
@@ -1170,129 +1147,128 @@ void vehicles_spawn()
        if(self.vehicle_controller)
                self.team = self.vehicle_controller.team;
 
-       entity head; // remove hooks (if any)
-       FOR_EACH_PLAYER(head)
-       if(head.hook.aiment == self)
-               RemoveGrapplingHook(head);
+       FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it));
 
-       vehicles_reset_colors();
+       vehicles_reset_colors(self);
 
-       VEH_ACTION(self.vehicleid, VR_SPAWN);
+       Vehicle info = Vehicles_from(self.vehicleid);
+       info.vr_spawn(info, self);
 
        CSQCMODEL_AUTOINIT(self);
 }
 
-bool vehicle_initialize(entity veh, bool nodrop)
-{SELFPARAM();
+bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
+{
        if(!autocvar_g_vehicles)
                return false;
 
-       if(!veh.vehicleid)
+       if(!info.vehicleid)
                return false;
 
-       if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); }
+       if(!this.tur_head)
+               info.vr_precache(info);
 
-       if(self.targetname && self.targetname != "")
+       if(this.targetname && this.targetname != "")
        {
-               self.vehicle_controller = find(world, target, self.targetname);
-               if(!self.vehicle_controller)
+               this.vehicle_controller = find(world, target, this.targetname);
+               if(!this.vehicle_controller)
                {
                        bprint("^1WARNING: ^7Vehicle with invalid .targetname\n");
-                       self.active = ACTIVE_ACTIVE;
+                       this.active = ACTIVE_ACTIVE;
                }
                else
                {
-                       self.team = self.vehicle_controller.team;
-                       self.use = vehicle_use;
+                       this.team = this.vehicle_controller.team;
+                       this.use = vehicle_use;
 
                        if(teamplay)
                        {
-                               if(self.vehicle_controller.team == 0)
-                                       self.active = ACTIVE_NOT;
+                               if(this.vehicle_controller.team == 0)
+                                       this.active = ACTIVE_NOT;
                                else
-                                       self.active = ACTIVE_ACTIVE;
+                                       this.active = ACTIVE_ACTIVE;
                        }
                }
        }
-       else { self.active = ACTIVE_ACTIVE; }
+       else { this.active = ACTIVE_ACTIVE; }
 
-       if(self.team && (!teamplay || !autocvar_g_vehicles_teams))
-               self.team = 0;
+       if(this.team && (!teamplay || !autocvar_g_vehicles_teams))
+               this.team = 0;
 
-       if(self.mdl == "" || !self.mdl)
-               _setmodel(self, veh.model);
+       if(this.mdl == "" || !this.mdl)
+               _setmodel(this, info.model);
        else
-               _setmodel(self, self.mdl);
-
-       self.vehicle_flags |= VHF_ISVEHICLE;
-
-       self.vehicle_viewport           = spawn();
-       self.vehicle_hudmodel           = spawn();
-       self.tur_head                           = spawn();
-       self.tur_head.owner                     = self;
-       self.takedamage                         = DAMAGE_NO;
-       self.bot_attack                         = true;
-       self.iscreature                         = true;
-       self.teleportable                       = false; // no teleporting for vehicles, too buggy
-       self.damagedbycontents          = true;
-       self.vehicleid                          = veh.vehicleid;
-       self.PlayerPhysplug                     = veh.PlayerPhysplug;
-       self.event_damage                       = func_null;
-       self.touch                                      = vehicles_touch;
-       self.think                                      = vehicles_spawn;
-       self.nextthink                          = time;
-       self.effects                            = EF_NODRAW;
-       self.dphitcontentsmask          = DPCONTENTS_BODY | DPCONTENTS_SOLID;
+               _setmodel(this, this.mdl);
+
+       this.vehicle_flags |= VHF_ISVEHICLE;
+
+       this.vehicle_viewport           = new(vehicle_viewport);
+       this.vehicle_hudmodel           = new(vehicle_hudmodel);
+       this.tur_head                           = new(tur_head);
+       this.tur_head.owner                     = this;
+       this.takedamage                         = DAMAGE_NO;
+       this.bot_attack                         = true;
+       this.iscreature                         = true;
+       this.teleportable                       = false; // no teleporting for vehicles, too buggy
+       this.damagedbycontents          = true;
+       this.vehicleid                          = info.vehicleid;
+       this.PlayerPhysplug                     = info.PlayerPhysplug;
+       this.event_damage                       = func_null;
+       this.touch                                      = vehicles_touch;
+       this.think                                      = vehicles_spawn;
+       this.nextthink                          = time;
+       this.effects                            = EF_NODRAW;
+       this.dphitcontentsmask          = DPCONTENTS_BODY | DPCONTENTS_SOLID;
 
        if(autocvar_g_playerclip_collisions)
-               self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
+               this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP;
 
        if(autocvar_g_nodepthtestplayers)
-               self.effects |= EF_NODEPTHTEST;
+               this.effects |= EF_NODEPTHTEST;
 
        if(autocvar_g_fullbrightplayers)
-               self.effects |= EF_FULLBRIGHT;
+               this.effects |= EF_FULLBRIGHT;
 
-       _setmodel(self.vehicle_hudmodel, veh.hud_model);
-       setmodel(self.vehicle_viewport, MDL_Null);
+       _setmodel(this.vehicle_hudmodel, info.hud_model);
+       setmodel(this.vehicle_viewport, MDL_Null);
 
-       if(veh.head_model != "")
+       if(info.head_model != "")
        {
-               _setmodel(self.tur_head, veh.head_model);
-               setattachment(self.tur_head, self, veh.tag_head);
-               setattachment(self.vehicle_hudmodel, self.tur_head, veh.tag_hud);
-               setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view);
+               _setmodel(this.tur_head, info.head_model);
+               setattachment(this.tur_head, this, info.tag_head);
+               setattachment(this.vehicle_hudmodel, this.tur_head, info.tag_hud);
+               setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
        }
        else
        {
-               setattachment(self.tur_head, self, "");
-               setattachment(self.vehicle_hudmodel, self, veh.tag_hud);
-               setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view);
+               setattachment(this.tur_head, this, "");
+               setattachment(this.vehicle_hudmodel, this, info.tag_hud);
+               setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view);
        }
 
-       setsize(self, veh.mins, veh.maxs);
+       setsize(this, info.mins, info.maxs);
 
        if(!nodrop)
        {
-               setorigin(self, self.origin);
-               tracebox(self.origin + '0 0 100', veh.mins, veh.maxs, self.origin - '0 0 10000', MOVE_WORLDONLY, self);
-               setorigin(self, trace_endpos);
+               setorigin(this, this.origin);
+               tracebox(this.origin + '0 0 100', info.mins, info.maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this);
+               setorigin(this, trace_endpos);
        }
 
-       self.pos1 = self.origin;
-       self.pos2 = self.angles;
-       self.tur_head.team = self.team;
+       this.pos1 = this.origin;
+       this.pos2 = this.angles;
+       this.tur_head.team = this.team;
 
-       VEH_ACTION(veh.vehicleid, VR_SETUP);
+       info.vr_setup(info, this);
 
-       if(self.active == ACTIVE_NOT)
-               self.nextthink = 0; // wait until activated
+       if(this.active == ACTIVE_NOT)
+               this.nextthink = 0; // wait until activated
        else if(autocvar_g_vehicles_delayspawn)
-               self.nextthink = time + self.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter);
+               this.nextthink = time + this.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter);
        else
-               self.nextthink = time + game_starttime;
+               this.nextthink = time + game_starttime;
 
-       if(MUTATOR_CALLHOOK(VehicleSpawn))
+       if(MUTATOR_CALLHOOK(VehicleSpawn, this))
                return false;
 
        return true;