]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/vehicle/raptor.qc
Merge branch 'master' into Mario/entcs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / raptor.qc
index 649977603b043d53095b7dd91a41f8872886653c..a03c936bd787f6d8e075857ed38b3efc8c5841f3 100644 (file)
-#ifndef VEHICLE_RAPTOR
-#define VEHICLE_RAPTOR
 #include "raptor.qh"
 
-#include "raptor_weapons.qc"
-
-CLASS(Raptor, Vehicle)
-/* spawnflags */ ATTRIB(Raptor, spawnflags, int, VHF_DMGSHAKE | VHF_DMGROLL);
-/* mins       */ ATTRIB(Raptor, mins, vector, '-80 -80 0');
-/* maxs       */ ATTRIB(Raptor, maxs, vector, '80 80 70');
-/* view offset*/ ATTRIB(Raptor, view_ofs, vector, '0 0 160');
-/* view dist  */ ATTRIB(Raptor, height, float, 200);
-/* model         */ ATTRIB(Raptor, mdl, string, "models/vehicles/raptor.dpm");
-/* model         */ ATTRIB(Raptor, model, string, "models/vehicles/raptor.dpm");
-/* head_model */ ATTRIB(Raptor, head_model, string, "");
-/* hud_model  */ ATTRIB(Raptor, hud_model, string, "models/vehicles/raptor_cockpit.dpm");
-/* tags       */ ATTRIB(Raptor, tag_head, string, "");
-/* tags       */ ATTRIB(Raptor, tag_hud, string, "tag_hud");
-/* tags       */ ATTRIB(Raptor, tag_view, string, "tag_camera");
-/* netname    */ ATTRIB(Raptor, netname, string, "raptor");
-/* fullname   */ ATTRIB(Raptor, vehicle_name, string, _("Raptor"));
-/* icon       */ ATTRIB(Raptor, m_icon, string, "vehicle_raptor");
-ENDCLASS(Raptor)
-REGISTER_VEHICLE(RAPTOR, NEW(Raptor));
-
-#endif
-
 #ifdef IMPLEMENTATION
 
-#include "raptor_weapons.qc"
-
 #ifdef SVQC
 
-bool autocvar_g_vehicle_raptor;
+bool autocvar_g_vehicle_raptor = true;
+
+float autocvar_g_vehicle_raptor_respawntime = 40;
+float autocvar_g_vehicle_raptor_takeofftime = 1.5;
 
-float autocvar_g_vehicle_raptor_respawntime;
-float autocvar_g_vehicle_raptor_takeofftime;
+// 0: go where player aims, +forward etc relative to aim angles
+// 1: ignore aim for up/down movement. +forward always moved forward, +jump always moves up
+int autocvar_g_vehicle_raptor_movestyle = 1;
+float autocvar_g_vehicle_raptor_turnspeed = 200;
+float autocvar_g_vehicle_raptor_pitchspeed = 50;
+float autocvar_g_vehicle_raptor_pitchlimit = 45;
 
-float autocvar_g_vehicle_raptor_movestyle;
-float autocvar_g_vehicle_raptor_turnspeed;
-float autocvar_g_vehicle_raptor_pitchspeed;
-float autocvar_g_vehicle_raptor_pitchlimit;
+float autocvar_g_vehicle_raptor_speed_forward = 1700;
+float autocvar_g_vehicle_raptor_speed_strafe = 900;
+float autocvar_g_vehicle_raptor_speed_up = 1700;
+float autocvar_g_vehicle_raptor_speed_down = 1700;
+float autocvar_g_vehicle_raptor_friction = 2;
 
-float autocvar_g_vehicle_raptor_speed_forward;
-float autocvar_g_vehicle_raptor_speed_strafe;
-float autocvar_g_vehicle_raptor_speed_up;
-float autocvar_g_vehicle_raptor_speed_down;
-float autocvar_g_vehicle_raptor_friction;
+bool autocvar_g_vehicle_raptor_swim = false;
 
-float autocvar_g_vehicle_raptor_cannon_turnspeed;
-float autocvar_g_vehicle_raptor_cannon_turnlimit;
-float autocvar_g_vehicle_raptor_cannon_pitchlimit_up;
-float autocvar_g_vehicle_raptor_cannon_pitchlimit_down;
+float autocvar_g_vehicle_raptor_cannon_turnspeed = 120;
+float autocvar_g_vehicle_raptor_cannon_turnlimit = 20;
+float autocvar_g_vehicle_raptor_cannon_pitchlimit_up = 12;
+float autocvar_g_vehicle_raptor_cannon_pitchlimit_down = 32;
 
-float autocvar_g_vehicle_raptor_cannon_locktarget;
-float autocvar_g_vehicle_raptor_cannon_locking_time;
-float autocvar_g_vehicle_raptor_cannon_locking_releasetime;
-float autocvar_g_vehicle_raptor_cannon_locked_time;
-float autocvar_g_vehicle_raptor_cannon_predicttarget;
+float autocvar_g_vehicle_raptor_cannon_locktarget = 0;
+float autocvar_g_vehicle_raptor_cannon_locking_time = 0.2;
+float autocvar_g_vehicle_raptor_cannon_locking_releasetime = 0.45;
+float autocvar_g_vehicle_raptor_cannon_locked_time = 1;
+float autocvar_g_vehicle_raptor_cannon_predicttarget = 1;
 
-float autocvar_g_vehicle_raptor_energy;
-float autocvar_g_vehicle_raptor_energy_regen;
-float autocvar_g_vehicle_raptor_energy_regen_pause;
+float autocvar_g_vehicle_raptor_energy = 100;
+float autocvar_g_vehicle_raptor_energy_regen = 25;
+float autocvar_g_vehicle_raptor_energy_regen_pause = 0.25;
 
-float autocvar_g_vehicle_raptor_health;
-float autocvar_g_vehicle_raptor_health_regen;
-float autocvar_g_vehicle_raptor_health_regen_pause;
+float autocvar_g_vehicle_raptor_health = 150;
+float autocvar_g_vehicle_raptor_health_regen = 0;
+float autocvar_g_vehicle_raptor_health_regen_pause = 0;
 
-float autocvar_g_vehicle_raptor_shield;
-float autocvar_g_vehicle_raptor_shield_regen;
-float autocvar_g_vehicle_raptor_shield_regen_pause;
+float autocvar_g_vehicle_raptor_shield = 75;
+float autocvar_g_vehicle_raptor_shield_regen = 25;
+float autocvar_g_vehicle_raptor_shield_regen_pause = 1.5;
 
-float autocvar_g_vehicle_raptor_bouncefactor;
-float autocvar_g_vehicle_raptor_bouncestop;
-vector autocvar_g_vehicle_raptor_bouncepain;
+float autocvar_g_vehicle_raptor_bouncefactor = 0.2;
+float autocvar_g_vehicle_raptor_bouncestop = 0;
+vector autocvar_g_vehicle_raptor_bouncepain = '1 4 1000';
 
 .entity bomb1;
 .entity bomb2;
 
-float raptor_altitude(float amax)
-{SELFPARAM();
-       tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * amax), MOVE_WORLDONLY, self);
-       return vlen(self.origin - trace_endpos);
-}
-
-void raptor_land()
-{SELFPARAM();
+void raptor_land(entity this)
+{
        float hgt;
 
-       hgt = raptor_altitude(512);
-       self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
-       self.angles_x *= 0.95;
-       self.angles_z *= 0.95;
+       hgt = vehicle_altitude(this, 512);
+       this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * PHYS_INPUT_FRAMETIME);
+       this.angles_x *= 0.95;
+       this.angles_z *= 0.95;
 
-       if(hgt < 128)
-       if(hgt > 0)
-               self.frame = (hgt / 128) * 25;
+       if(hgt < 128 && hgt > 0)
+               this.frame = (hgt / 128) * 25;
 
-       self.bomb1.gun1.avelocity_y = 90 + ((self.frame / 25) * 2000);
-       self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
+       this.bomb1.gun1.avelocity_y = 90 + ((this.frame / 25) * 2000);
+       this.bomb1.gun2.avelocity_y = -this.bomb1.gun1.avelocity_y;
 
        if(hgt < 16)
        {
-               self.movetype = MOVETYPE_TOSS;
-               self.think      = vehicles_think;
-               self.frame      = 0;
+               set_movetype(this, MOVETYPE_TOSS);
+               setthink(this, vehicles_think);
+               this.frame      = 0;
        }
 
-       self.nextthink  = time;
+       this.nextthink  = time;
 
-       CSQCMODEL_AUTOUPDATE(self);
+       CSQCMODEL_AUTOUPDATE(this);
 }
 
-void raptor_exit(float eject)
-{SELFPARAM();
-       vector spot;
-       self.tur_head.exteriormodeltoclient = world;
+void raptor_exit(entity this, int eject)
+{
+       this.tur_head.exteriormodeltoclient = NULL;
 
-       if(!IS_DEAD(self))
+       if(!IS_DEAD(this))
        {
-               self.think        = raptor_land;
-               self.nextthink  = time;
+               setthink(this, raptor_land);
+               this.nextthink = time;
        }
 
-       if(!self.owner)
+       if(!this.owner)
                return;
 
-       makevectors(self.angles);
+       makevectors(this.angles);
+       vector spot;
        if(eject)
        {
-               spot = self.origin + v_forward * 100 + '0 0 64';
-               spot = vehicles_findgoodexit(spot);
-               setorigin(self.owner , spot);
-               self.owner.velocity = (v_up + v_forward * 0.25) * 750;
-               self.owner.oldvelocity = self.owner.velocity;
+               spot = this.origin + v_forward * 100 + '0 0 64';
+               spot = vehicles_findgoodexit(this, spot);
+               setorigin(this.owner , spot);
+               this.owner.velocity = (v_up + v_forward * 0.25) * 750;
+               this.owner.oldvelocity = this.owner.velocity;
        }
        else
        {
-               if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
+               if(vdist(this.velocity, >, 2 * autocvar_sv_maxairspeed))
                {
-                       self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
-                       self.owner.velocity_z += 200;
-                       spot = self.origin + v_forward * 32 + '0 0 64';
-                       spot = vehicles_findgoodexit(spot);
+                       this.owner.velocity = normalize(this.velocity) * autocvar_sv_maxairspeed * 2;
+                       this.owner.velocity_z += 200;
+                       spot = this.origin + v_forward * 32 + '0 0 64';
+                       spot = vehicles_findgoodexit(this, spot);
                }
                else
                {
-                       self.owner.velocity = self.velocity * 0.5;
-                       self.owner.velocity_z += 10;
-                       spot = self.origin - v_forward * 200 + '0 0 64';
-                       spot = vehicles_findgoodexit(spot);
+                       this.owner.velocity = this.velocity * 0.5;
+                       this.owner.velocity_z += 10;
+                       spot = this.origin - v_forward * 200 + '0 0 64';
+                       spot = vehicles_findgoodexit(this, spot);
                }
-               self.owner.oldvelocity = self.owner.velocity;
-               setorigin(self.owner , spot);
+               this.owner.oldvelocity = this.owner.velocity;
+               setorigin(this.owner , spot);
        }
 
-       antilag_clear(self.owner);
-       self.owner = world;
+       antilag_clear(this.owner, CS(this.owner));
+       this.owner = NULL;
 }
 
-float raptor_frame()
-{SELFPARAM();
-       entity player, raptor;
-       float ftmp = 0;
-       vector df;
+bool raptor_frame(entity this, float dt)
+{
+       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);
 
        /*
-       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 = 0;
        }
        /*
-       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);
-               player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
-               return 1;
+               PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
+               return;
        }
-       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(player.BUTTON_JUMP)
+                       if(PHYS_INPUT_BUTTON_JUMP(this))
                        {
-                               player.BUTTON_CROUCH = true;
-                               player.BUTTON_JUMP = 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;
@@ -231,106 +195,106 @@ 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);
+       float 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(player.BUTTON_CROUCH)
+       if(PHYS_INPUT_BUTTON_CROUCH(this))
                df -=   v_up * autocvar_g_vehicle_raptor_speed_down;
-       else if (player.BUTTON_JUMP)
+       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 * dt;
+       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 = NULL;
 
                if(trace_ent)
-               if(trace_ent.movetype)
+               if(trace_ent.move_movetype)
                if(trace_ent.takedamage)
                if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
                {
                        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.move_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;
@@ -342,263 +306,260 @@ float raptor_frame()
        else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1)
        {
 
-               vehicles_locktarget(self, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
-                                                        (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
+               vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * dt,
+                                                        (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * dt,
                                                         autocvar_g_vehicle_raptor_cannon_locked_time);
 
-               if(self.lock_target != world)
+               if(vehic.lock_target != NULL)
                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(player.BUTTON_ATCK)
-       if (wep1.wr_checkammo1(wep1))
+       if(!forbidWeaponUse(this))
+       if(PHYS_INPUT_BUTTON_ATCK(this))
+       if (wep1.wr_checkammo1(wep1, vehic))
        {
            .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, dt, 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, dt, 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, dt, 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(player.BUTTON_ATCK2)
+               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(player.BUTTON_ATCK2)
+               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);
-               float _incomming = 0;
-               while(_missile)
+               bool incoming = false;
+               IL_EACH(g_projectiles, it.enemy == vehic,
                {
-                       if(_missile.flags & FL_PROJECTILE)
-                       if(MISSILE_IS_TRACKING(_missile))
-                       if(vlen(self.origin - _missile.origin) < 2 * autocvar_g_vehicle_raptor_flare_range)
-                               ++_incomming;
+                       if(MISSILE_IS_TRACKING(it))
+                       if(vdist(vehic.origin - it.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
+                       {
+                               incoming = true;
+                               break;
+                       }
+               });
 
-                       _missile = _missile.chain;
+               if(incoming)
+               {
+                       msg_entity = this;
+                       soundto(MSG_ONE, vehic, CH_PAIN_SINGLE, SND(VEH_MISSILE_ALARM), VOL_BASE, ATTEN_NONE);
                }
 
-               if(_incomming)
-                       sound(self, 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);
 
-       player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
-
-       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, float dt)
+{
+       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;
-               player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
+               vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / PHYS_INPUT_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, dt, 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, dt, 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, dt, 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);
 
-       player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
-       setself(player);
-       return 1;
+       PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
 }
 
-void raptor_blowup()
-{SELFPARAM();
-       self.deadflag   = DEAD_DEAD;
-       self.vehicle_exit(VHEF_NORMAL);
-       RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH.m_id, world);
-
-       self.alpha                = -1;
-       self.movetype      = MOVETYPE_NONE;
-       self.effects            = EF_NODRAW;
-       self.colormod      = '0 0 0';
-       self.avelocity    = '0 0 0';
-       self.velocity      = '0 0 0';
-
-       setorigin(self, self.pos1);
-       self.touch = func_null;
-       self.nextthink = 0;
+void raptor_blowup(entity this, entity toucher)
+{
+       this.deadflag   = DEAD_DEAD;
+       this.vehicle_exit(this, VHEF_NORMAL);
+       RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_RAPT_DEATH.m_id, NULL);
+
+       this.alpha                = -1;
+       set_movetype(this, MOVETYPE_NONE);
+       this.effects            = EF_NODRAW;
+       this.colormod      = '0 0 0';
+       this.avelocity    = '0 0 0';
+       this.velocity      = '0 0 0';
+
+       setorigin(this, this.pos1);
+       settouch(this, func_null);
+       this.nextthink = 0;
 }
 
-void raptor_diethink()
-{SELFPARAM();
-       if(time >= self.wait)
-               self.think = raptor_blowup;
+void raptor_diethink(entity this)
+{
+       if(time >= this.wait)
+       {
+               raptor_blowup(this, NULL);
+               return;
+       }
 
        if(random() < 0.05)
        {
-               sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
-               Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
+               sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+               Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
        }
-       self.nextthink = time;
+       this.nextthink = time;
 
-       CSQCMODEL_AUTOUPDATE(self);
+       CSQCMODEL_AUTOUPDATE(this);
 }
 
 // If we dont do this ever now and then, the raptors rotors
 // stop working, presumably due to angle overflow. cute.
-void raptor_rotor_anglefix()
-{SELFPARAM();
-       self.gun1.angles_y = anglemods(self.gun1.angles_y);
-       self.gun2.angles_y = anglemods(self.gun2.angles_y);
-       self.nextthink = time + 15;
+void raptor_rotor_anglefix(entity this)
+{
+       this.gun1.angles_y = anglemods(this.gun1.angles_y);
+       this.gun2.angles_y = anglemods(this.gun2.angles_y);
+       this.nextthink = time + 15;
 }
 
-float raptor_impulse(float _imp)
-{SELFPARAM();
+bool raptor_impulse(entity this, int _imp)
+{
        switch(_imp)
        {
                case IMP_weapon_group_1.impulse:
-                       self.vehicle.vehicle_weapon2mode = RSM_BOMB;
-                       CSQCVehicleSetup(self, 0);
+                       this.vehicle.vehicle_weapon2mode = RSM_BOMB;
+                       CSQCVehicleSetup(this, 0);
                        return true;
                case IMP_weapon_group_2.impulse:
-                       self.vehicle.vehicle_weapon2mode = RSM_FLARE;
-                       CSQCVehicleSetup(self, 0);
+                       this.vehicle.vehicle_weapon2mode = RSM_FLARE;
+                       CSQCVehicleSetup(this, 0);
                        return true;
 
                case IMP_weapon_next_byid.impulse:
                case IMP_weapon_next_bypriority.impulse:
                case IMP_weapon_next_bygroup.impulse:
-                       self.vehicle.vehicle_weapon2mode += 1;
-                       if(self.vehicle.vehicle_weapon2mode > RSM_LAST)
-                               self.vehicle.vehicle_weapon2mode = RSM_FIRST;
+                       this.vehicle.vehicle_weapon2mode += 1;
+                       if(this.vehicle.vehicle_weapon2mode > RSM_LAST)
+                               this.vehicle.vehicle_weapon2mode = RSM_FIRST;
 
-                       CSQCVehicleSetup(self, 0);
+                       CSQCVehicleSetup(this, 0);
                        return true;
                case IMP_weapon_last.impulse:
                case IMP_weapon_prev_byid.impulse:
                case IMP_weapon_prev_bypriority.impulse:
                case IMP_weapon_prev_bygroup.impulse:
-                       self.vehicle.vehicle_weapon2mode -= 1;
-                       if(self.vehicle.vehicle_weapon2mode < RSM_FIRST)
-                               self.vehicle.vehicle_weapon2mode = RSM_LAST;
+                       this.vehicle.vehicle_weapon2mode -= 1;
+                       if(this.vehicle.vehicle_weapon2mode < RSM_FIRST)
+                               this.vehicle.vehicle_weapon2mode = RSM_LAST;
 
-                       CSQCVehicleSetup(self, 0);
+                       CSQCVehicleSetup(this, 0);
                        return true;
 
                /*
@@ -613,247 +574,253 @@ float raptor_impulse(float _imp)
 
 spawnfunc(vehicle_raptor)
 {
-       if(!autocvar_g_vehicle_raptor) { remove(self); return; }
-       if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
+       if(!autocvar_g_vehicle_raptor) { delete(this); return; }
+       if(!vehicle_initialize(this, VEH_RAPTOR, false)) { delete(this); return; }
 }
 
-               METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance))
-               {
-                       if(autocvar_g_vehicle_raptor_bouncepain)
-                               vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
-               }
-               METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
-               {
-                       self.vehicle_weapon2mode = RSM_BOMB;
-                       self.owner.PlayerPhysplug = raptor_takeoff;
-                       self.movetype      = MOVETYPE_BOUNCEMISSILE;
-                       self.solid                = SOLID_SLIDEBOX;
-                       self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_raptor_health) * 100;
-                       self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
-                       self.velocity_z = 1; // Nudge upwards to takeoff sequense can work.
-                       self.tur_head.exteriormodeltoclient = self.owner;
-
-                       self.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
-                       self.lip   = time;
-
-                       if(self.owner.flagcarried)
-                          setorigin(self.owner.flagcarried, '-20 0 96');
-
-                       CSQCVehicleSetup(self.owner, 0);
-               }
-               METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
-               {
-                       self.health                             = 0;
-                       self.event_damage               = func_null;
-                       self.solid                              = SOLID_CORPSE;
-                       self.takedamage                 = DAMAGE_NO;
-                       self.deadflag                   = DEAD_DYING;
-                       self.movetype                   = MOVETYPE_BOUNCE;
-                       self.think                              = raptor_diethink;
-                       self.nextthink                  = time;
-                       self.wait                               = time + 5 + (random() * 5);
-
-                       Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation (self.origin, 16), '0 0 0', 1);
-
-                       self.velocity_z += 600;
-
-                       self.avelocity = '0 0.5 1' * (random() * 400);
-                       self.avelocity -= '0 0.5 1' * (random() * 400);
-
-                       self.colormod = '-0.5 -0.5 -0.5';
-                       self.touch = raptor_blowup;
-               }
-               METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
-               {
-                       if(!self.gun1)
-                       {
-                               entity spinner;
-                               vector ofs;
-
-                               //FIXME: Camera is in a bad place in HUD model.
-                               //setorigin(self.vehicle_viewport, '25 0 5');
-
-                               self.vehicles_impulse   = raptor_impulse;
-
-                               self.frame = 0;
-
-                               self.bomb1 = new(raptor_bomb);
-                               self.bomb2 = new(raptor_bomb);
-                               self.gun1  = new(raptor_gun);
-                               self.gun2  = new(raptor_gun);
-
-                               setmodel(self.bomb1, MDL_VEH_RAPTOR_CB_FOLDED);
-                               setmodel(self.bomb2, MDL_VEH_RAPTOR_CB_FOLDED);
-                               setmodel(self.gun1, MDL_VEH_RAPTOR_GUN);
-                               setmodel(self.gun2, MDL_VEH_RAPTOR_GUN);
-                               setmodel(self.tur_head, MDL_VEH_RAPTOR_TAIL);
-
-                               setattachment(self.bomb1, self, "bombmount_left");
-                               setattachment(self.bomb2, self, "bombmount_right");
-                               setattachment(self.tur_head, self,"root");
-
-                               // FIXMODEL Guns mounts to angled bones
-                               self.bomb1.angles = self.angles;
-                               self.angles = '0 0 0';
-                               // This messes up gun-aim, so work arround it.
-                               //setattachment(self.gun1, self, "gunmount_left");
-                               ofs = gettaginfo(self, gettagindex(self, "gunmount_left"));
-                               ofs -= self.origin;
-                               setattachment(self.gun1, self, "");
-                               setorigin(self.gun1, ofs);
-
-                               //setattachment(self.gun2, self, "gunmount_right");
-                               ofs = gettaginfo(self, gettagindex(self, "gunmount_right"));
-                               ofs -= self.origin;
-                               setattachment(self.gun2, self, "");
-                               setorigin(self.gun2, ofs);
-
-                               self.angles = self.bomb1.angles;
-                               self.bomb1.angles = '0 0 0';
-
-                               spinner = new(raptor_spinner);
-                               spinner.owner = self;
-                               setmodel(spinner, MDL_VEH_RAPTOR_PROP);
-                               setattachment(spinner, self, "engine_left");
-                               spinner.movetype = MOVETYPE_NOCLIP;
-                               spinner.avelocity = '0 90 0';
-                               self.bomb1.gun1 = spinner;
-
-                               spinner = new(raptor_spinner);
-                               spinner.owner = self;
-                               setmodel(spinner, MDL_VEH_RAPTOR_PROP);
-                               setattachment(spinner, self, "engine_right");
-                               spinner.movetype = MOVETYPE_NOCLIP;
-                               spinner.avelocity = '0 -90 0';
-                               self.bomb1.gun2 = spinner;
-
-                               // Sigh.
-                               self.bomb1.think = raptor_rotor_anglefix;
-                               self.bomb1.nextthink = time;
-
-                               self.mass                          = 1 ;
-                       }
+METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance))
+{
+    if(autocvar_g_vehicle_raptor_bouncepain)
+        vehicles_impact(instance, autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
+}
+METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
+{
+    instance.vehicle_weapon2mode = RSM_BOMB;
+    instance.owner.PlayerPhysplug = raptor_takeoff;
+    set_movetype(instance, MOVETYPE_BOUNCEMISSILE);
+    instance.solid               = SOLID_SLIDEBOX;
+    instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_raptor_health) * 100;
+    instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
+    instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work
+    instance.tur_head.exteriormodeltoclient = instance.owner;
+
+    instance.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
+    instance.lip   = time;
+
+    if(instance.owner.flagcarried)
+       setorigin(instance.owner.flagcarried, '-20 0 96');
+
+    CSQCVehicleSetup(instance.owner, 0);
+}
+METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
+{
+    instance.health                            = 0;
+    instance.event_damage              = func_null;
+    instance.solid                             = SOLID_CORPSE;
+    instance.takedamage                        = DAMAGE_NO;
+    instance.deadflag                  = DEAD_DYING;
+    set_movetype(instance, MOVETYPE_BOUNCE);
+    setthink(instance, raptor_diethink);
+    instance.nextthink                 = time;
+    instance.wait                              = time + 5 + (random() * 5);
 
-                       self.frame                = 0;
-                       self.vehicle_health = autocvar_g_vehicle_raptor_health;
-                       self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
-                       self.movetype      = MOVETYPE_TOSS;
-                       self.solid                = SOLID_SLIDEBOX;
-                       self.vehicle_energy = 1;
+    Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation (instance.origin, 16), '0 0 0', 1);
 
-                       self.PlayerPhysplug = raptor_frame;
+    instance.velocity_z += 600;
 
-                       self.bomb1.gun1.avelocity_y = 90;
-                       self.bomb1.gun2.avelocity_y = -90;
+    instance.avelocity = '0 0.5 1' * (random() * 400);
+    instance.avelocity -= '0 0.5 1' * (random() * 400);
 
-                       self.delay = time;
+    instance.colormod = '-0.5 -0.5 -0.5';
+    settouch(instance, raptor_blowup);
+}
+METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
+{
+    if(!instance.gun1)
+    {
+        entity spinner;
+        vector ofs;
+
+        //FIXME: Camera is in a bad place in HUD model.
+        //setorigin(instance.vehicle_viewport, '25 0 5');
+
+        instance.vehicles_impulse = raptor_impulse;
+
+        instance.frame = 0;
+
+        instance.bomb1 = new(raptor_bomb);
+        instance.bomb2 = new(raptor_bomb);
+        instance.gun1  = new(raptor_gun);
+        instance.gun2  = new(raptor_gun);
+
+        setmodel(instance.bomb1, MDL_VEH_RAPTOR_CB_FOLDED);
+        setmodel(instance.bomb2, MDL_VEH_RAPTOR_CB_FOLDED);
+        setmodel(instance.gun1, MDL_VEH_RAPTOR_GUN);
+        setmodel(instance.gun2, MDL_VEH_RAPTOR_GUN);
+        setmodel(instance.tur_head, MDL_VEH_RAPTOR_TAIL);
+
+        setattachment(instance.bomb1, instance, "bombmount_left");
+        setattachment(instance.bomb2, instance, "bombmount_right");
+        setattachment(instance.tur_head, instance,"root");
+
+        // FIXMODEL Guns mounts to angled bones
+        instance.bomb1.angles = instance.angles;
+        instance.angles = '0 0 0';
+        // This messes up gun-aim, so work arround it.
+        //setattachment(instance.gun1, instance, "gunmount_left");
+        ofs = gettaginfo(instance, gettagindex(instance, "gunmount_left"));
+        ofs -= instance.origin;
+        setattachment(instance.gun1, instance, "");
+        setorigin(instance.gun1, ofs);
+
+        //setattachment(instance.gun2, instance, "gunmount_right");
+        ofs = gettaginfo(instance, gettagindex(instance, "gunmount_right"));
+        ofs -= instance.origin;
+        setattachment(instance.gun2, instance, "");
+        setorigin(instance.gun2, ofs);
+
+        instance.angles = instance.bomb1.angles;
+        instance.bomb1.angles = '0 0 0';
+
+        spinner = new(raptor_spinner);
+        spinner.owner = instance;
+        setmodel(spinner, MDL_VEH_RAPTOR_PROP);
+        setattachment(spinner, instance, "engine_left");
+        set_movetype(spinner, MOVETYPE_NOCLIP);
+        spinner.avelocity = '0 90 0';
+        instance.bomb1.gun1 = spinner;
+
+        spinner = new(raptor_spinner);
+        spinner.owner = instance;
+        setmodel(spinner, MDL_VEH_RAPTOR_PROP);
+        setattachment(spinner, instance, "engine_right");
+        set_movetype(spinner, MOVETYPE_NOCLIP);
+        spinner.avelocity = '0 -90 0';
+        instance.bomb1.gun2 = spinner;
+
+        // Sigh.
+        setthink(instance.bomb1, raptor_rotor_anglefix);
+        instance.bomb1.nextthink = time;
+
+        instance.mass                     = 1 ;
+    }
+
+    instance.frame               = 0;
+    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
+    set_movetype(instance, MOVETYPE_TOSS);
+    instance.solid               = SOLID_SLIDEBOX;
+    instance.vehicle_energy = 1;
+
+    if(!autocvar_g_vehicle_raptor_swim)
+       instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
+
+    instance.PlayerPhysplug = raptor_frame;
+
+    instance.bomb1.gun1.avelocity_y = 90;
+    instance.bomb1.gun2.avelocity_y = -90;
+
+    instance.delay = time;
+
+    instance.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
+    instance.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
+    instance.damageforcescale = 0.25;
+    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
+}
+METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
+{
+    if(autocvar_g_vehicle_raptor_shield)
+        instance.vehicle_flags |= VHF_HASSHIELD;
 
-                       self.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
-                       self.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
-                       self.damageforcescale = 0.25;
-                       self.vehicle_health = autocvar_g_vehicle_raptor_health;
-                       self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
-               }
-               METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
-               {
-                       if(autocvar_g_vehicle_raptor_shield)
-                               self.vehicle_flags |= VHF_HASSHIELD;
+    if(autocvar_g_vehicle_raptor_shield_regen)
+        instance.vehicle_flags |= VHF_SHIELDREGEN;
 
-                       if(autocvar_g_vehicle_raptor_shield_regen)
-                               self.vehicle_flags |= VHF_SHIELDREGEN;
+    if(autocvar_g_vehicle_raptor_health_regen)
+        instance.vehicle_flags |= VHF_HEALTHREGEN;
 
-                       if(autocvar_g_vehicle_raptor_health_regen)
-                               self.vehicle_flags |= VHF_HEALTHREGEN;
+    if(autocvar_g_vehicle_raptor_energy_regen)
+        instance.vehicle_flags |= VHF_ENERGYREGEN;
 
-                       if(autocvar_g_vehicle_raptor_energy_regen)
-                               self.vehicle_flags |= VHF_ENERGYREGEN;
+    instance.vehicle_exit = raptor_exit;
+    instance.respawntime = autocvar_g_vehicle_raptor_respawntime;
+    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
+    instance.max_health = instance.vehicle_health;
 
-                       self.vehicle_exit = raptor_exit;
-                       self.respawntime = autocvar_g_vehicle_raptor_respawntime;
-                       self.vehicle_health = autocvar_g_vehicle_raptor_health;
-                       self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
-                       self.max_health = self.vehicle_health;
-               }
+    if(!autocvar_g_vehicle_raptor_swim)
+       instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
+}
 
 #endif
 #ifdef CSQC
 
-               METHOD(Raptor, vr_hud, void(Raptor thisveh))
-               {
-                       Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2",
-                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
-                                                        "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
-               }
-               METHOD(Raptor, vr_crosshair, void(Raptor thisveh))
-               {
-                       string crosshair;
-
-                       switch(weapon2mode)
-                       {
-                               case RSM_FLARE: crosshair = vCROSS_RAIN;  break;
-                               case RSM_BOMB:  crosshair = vCROSS_BURST; break;
-                               default:        crosshair = vCROSS_BURST;
-                       }
-
-                       vector tmpSize = '0 0 0';
-                       if(weapon2mode != RSM_FLARE)
-                       {
-                               vector where;
-
-                               if(!dropmark)
-                               {
-                                       dropmark = spawn();
-                                       dropmark.owner = self;
-                                       dropmark.gravity = 1;
-                               }
-
-                               float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
-                               if(reload2 == 1)
-                               {
-                                       setorigin(dropmark, pmove_org);
-                                       dropmark.velocity = pmove_vel;
-                                       tracetoss(dropmark, self);
-
-                                       where = project_3d_to_2d(trace_endpos);
-
-                                       setorigin(dropmark, trace_endpos);
-                                       tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
-
-                                       if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
-                                       {
-                                               where.x -= tmpSize.x * 0.5;
-                                               where.y -= tmpSize.y * 0.5;
-                                               where.z = 0;
-                                               drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
-                                               drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
-                                       }
-                                       dropmark.cnt = time + 5;
-                               }
-                               else
-                               {
-                                       if(dropmark.cnt > time)
-                                       {
-                                               where = project_3d_to_2d(dropmark.origin);
-                                               tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
-
-                                               if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
-                                               {
-                                                       where.x -= tmpSize.x * 0.5;
-                                                       where.y -= tmpSize.y * 0.5;
-                                                       where.z = 0;
-                                                       drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
-                                                       drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
-                                               }
-                                       }
-                               }
-                       }
-
-                       Vehicles_drawCrosshair(crosshair);
-               }
-               METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
-               {
-                       AuxiliaryXhair[1].axh_image = vCROSS_LOCK;
-               }
+METHOD(Raptor, vr_hud, void(Raptor thisveh))
+{
+    Vehicles_drawHUD(VEH_RAPTOR.m_icon, "vehicle_raptor_weapon1", "vehicle_raptor_weapon2",
+                     "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
+                     "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
+}
+METHOD(Raptor, vr_crosshair, void(Raptor thisveh, entity player))
+{
+    string crosshair;
+
+    switch(weapon2mode)
+    {
+        case RSM_FLARE: crosshair = vCROSS_RAIN;  break;
+        case RSM_BOMB:  crosshair = vCROSS_BURST; break;
+        default:        crosshair = vCROSS_BURST;
+    }
+
+    vector tmpSize = '0 0 0';
+    if(weapon2mode != RSM_FLARE && !spectatee_status)
+    {
+        vector where;
+
+        if(!dropmark)
+        {
+            dropmark = spawn();
+            dropmark.owner = player;
+            dropmark.gravity = 1;
+        }
+
+        float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
+        if(reload2 == 1)
+        {
+            setorigin(dropmark, pmove_org);
+            dropmark.velocity = pmove_vel;
+            tracetoss(dropmark, player);
+
+            where = project_3d_to_2d(trace_endpos);
+
+            setorigin(dropmark, trace_endpos);
+            tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
+
+            if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
+            {
+                where.x -= tmpSize.x * 0.5;
+                where.y -= tmpSize.y * 0.5;
+                where.z = 0;
+                drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
+                drawpic(where, vCROSS_DROP, tmpSize, '0 1 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
+            }
+            dropmark.cnt = time + 5;
+        }
+        else
+        {
+            if(dropmark.cnt > time)
+            {
+                where = project_3d_to_2d(dropmark.origin);
+                tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
+
+                if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
+                {
+                    where.x -= tmpSize.x * 0.5;
+                    where.y -= tmpSize.y * 0.5;
+                    where.z = 0;
+                    drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.9, DRAWFLAG_ADDITIVE);
+                    drawpic(where, vCROSS_DROP, tmpSize, '1 0 0', autocvar_crosshair_alpha * 0.6, DRAWFLAG_NORMAL); // Ensure visibility against bright bg
+                }
+            }
+        }
+    }
+
+    Vehicles_drawCrosshair(crosshair);
+}
+METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
+{
+    AuxiliaryXhair[1].axh_image = vCROSS_LOCK;
+}
 
 #endif
 #endif