]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/unit/spiderbot.qc
Merge branch 'master' into TimePath/global_self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / spiderbot.qc
index b3aa75ecd2af45430e3b58bdadc393824701262e..7060b781530f921da1fc60881a9a8e5bb2f61204 100644 (file)
@@ -1,7 +1,10 @@
-#ifdef REGISTER_VEHICLE
-REGISTER_VEHICLE(
+#ifndef VEHICLE_SPIDERBOT
+#define VEHICLE_SPIDERBOT
+#ifndef MENUQC
+int v_spiderbot(int);
+#endif
+REGISTER_VEHICLE_SIMPLE(
 /* VEH_##id   */ SPIDERBOT,
-/* function   */ v_spiderbot,
 /* spawnflags */ VHF_DMGSHAKE,
 /* mins,maxs  */ '-75 -75 10', '75 75 125',
 /* model         */ "models/vehicles/spiderbot.dpm",
@@ -10,8 +13,15 @@ REGISTER_VEHICLE(
 /* tags                  */ "tag_head", "tag_hud", "",
 /* netname       */ "spiderbot",
 /* fullname   */ _("Spiderbot")
-);
-#else
+) {
+    this.m_icon = "vehicle_spider";
+#ifndef MENUQC
+    this.vehicle_func = v_spiderbot;
+#endif
+}
+#endif
+
+#ifdef IMPLEMENTATION
 
 const int SBRM_FIRST = 1;
 const int SBRM_VOLLY = 1;
@@ -27,6 +37,7 @@ float autocvar_g_vehicle_spiderbot_respawntime;
 float autocvar_g_vehicle_spiderbot_speed_stop;
 float autocvar_g_vehicle_spiderbot_speed_strafe;
 float autocvar_g_vehicle_spiderbot_speed_walk;
+float autocvar_g_vehicle_spiderbot_speed_run = 700;
 float autocvar_g_vehicle_spiderbot_turnspeed;
 float autocvar_g_vehicle_spiderbot_turnspeed_strafe;
 float autocvar_g_vehicle_spiderbot_movement_inertia;
@@ -75,13 +86,13 @@ float autocvar_g_vehicle_spiderbot_rocket_lifetime;
 vector autocvar_g_vehicle_spiderbot_bouncepain;
 
 void spiderbot_rocket_artillery()
-{
+{SELFPARAM();
        self.nextthink = time;
        UpdateCSQCProjectile(self);
 }
 
 void spiderbot_rocket_unguided()
-{
+{SELFPARAM();
        vector newdir, olddir;
 
        self.nextthink  = time;
@@ -97,7 +108,7 @@ void spiderbot_rocket_unguided()
 }
 
 void spiderbot_rocket_guided()
-{
+{SELFPARAM();
        vector newdir, olddir;
 
        self.nextthink  = time;
@@ -117,7 +128,7 @@ void spiderbot_rocket_guided()
 }
 
 void spiderbot_guide_release()
-{
+{SELFPARAM();
        entity rkt;
        rkt = findchainentity(realowner, self.owner);
        if(!rkt)
@@ -210,7 +221,7 @@ vector spiberbot_calcartillery(vector org, vector tgt, float ht)
 }
 
 void spiderbot_rocket_do()
-{
+{SELFPARAM();
        vector v;
        entity rocket = world;
 
@@ -249,7 +260,7 @@ void spiderbot_rocket_do()
        if(self.wait != -10)
        if(!self.owner.BUTTON_ATCK2)
                return;
-               
+
        if(forbidWeaponUse(self.owner))
                return;
 
@@ -258,10 +269,10 @@ void spiderbot_rocket_do()
        switch(self.vehicle_weapon2mode)
        {
                case SBRM_VOLLY:
-                       rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
                                                                   v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
-                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
+                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
                        crosshair_trace(self.owner);
                        float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
                        _dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
@@ -272,10 +283,10 @@ void spiderbot_rocket_do()
                                self.wait = -10;
                        break;
                case SBRM_GUIDE:
-                       rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
-                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, FALSE, self.owner);
+                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, false, self.owner);
                        crosshair_trace(self.owner);
                        rocket.pos1        = trace_endpos;
                        rocket.nextthink  = time;
@@ -284,10 +295,10 @@ void spiderbot_rocket_do()
 
                break;
                case SBRM_ARTILLERY:
-                       rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
+                       rocket = vehicles_projectile(EFFECT_SPIDERBOT_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
-                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
+                                                                  DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
 
                        crosshair_trace(self.owner);
 
@@ -320,8 +331,9 @@ void spiderbot_rocket_do()
        self.gun2.cnt = time + self.attack_finished_single;
 }
 
+.float jump_delay;
 float spiderbot_frame()
-{
+{SELFPARAM();
        vector ad, vf;
        entity player, spider;
        float ftmp;
@@ -335,7 +347,7 @@ float spiderbot_frame()
 
        player = self;
        spider = self.vehicle;
-       self   = spider;
+       setself(spider);
 
        vehicles_painframe();
 
@@ -369,7 +381,7 @@ float spiderbot_frame()
        crosshair_trace(player);
        ad = vectoangles(normalize(trace_endpos - ad));
        ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
-       ad = AnglesTransform_Normalize(ad, TRUE);
+       ad = AnglesTransform_Normalize(ad, true);
        //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
 
        // Rotate head
@@ -388,37 +400,63 @@ float spiderbot_frame()
        movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
 
        if(spider.flags & FL_ONGROUND)
+               spider.jump_delay = time; // reset now so movement can begin
+
+       //if(spider.flags & FL_ONGROUND)
        {
+               if(spider.flags & FL_ONGROUND)
                if(spider.frame == 4 && self.tur_head.wait != 0)
                {
                        sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
                        spider.frame = 5;
                }
 
-               if(player.BUTTON_JUMP && self.tur_head.wait < time)
+               if(!player.BUTTON_JUMP)
+                       spider.BUTTON_JUMP = 0;
+
+               if((spider.flags & FL_ONGROUND) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
                {
                        sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
                        //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
                        self.delay = 0;
 
                        self.tur_head.wait = time + 2;
-                       player.BUTTON_JUMP = 0;
-                       spider.velocity   = v_forward * 700 + v_up * 600;
+                       spider.jump_delay = time + 2;
+                       spider.BUTTON_JUMP = 1; // set spider's jump
+                       //player.BUTTON_JUMP = 0;
+
+                       vector movefix = '0 0 0';
+                       if(player.movement_x > 0) movefix_x = 1;
+                       if(player.movement_x < 0) movefix_x = -1;
+                       if(player.movement_y > 0) movefix_y = 1;
+                       if(player.movement_y < 0) movefix_y = -1;
+
+                       vector rt = movefix_y * v_right;
+                       vector sd = movefix_x * v_forward;
+                       if(movefix_y == 0 && movefix_x == 0)
+                               sd = v_forward; // always do forward
+
+                       spider.flags &= ~FL_ONGROUND;
+
+                       spider.velocity = sd * 700 + rt * 600 + v_up * 600;
                        spider.frame = 4;
                }
-               else
+               else if(time >= spider.jump_delay)
                {
                        if(vlen(player.movement) == 0)
                        {
-                               if(self.sound_nexttime < time || self.delay != 3)
+                               if(spider.flags & FL_ONGROUND)
                                {
-                                       self.delay = 3;
-                                       self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
-                                       //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
-                                       sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                       if(self.sound_nexttime < time || self.delay != 3)
+                                       {
+                                               self.delay = 3;
+                                               self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
+                                               //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
+                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                       }
+                                       movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
+                                       spider.frame = 5;
                                }
-                               movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
-                               spider.frame = 5;
                        }
                        else
                        {
@@ -437,16 +475,23 @@ float spiderbot_frame()
                                        if(player.movement_x > 0)
                                        {
                                                player.movement_x = 1;
-                                               spider.frame = 0;
+                                               if(spider.flags & FL_ONGROUND)
+                                                       spider.frame = 0;
                                        }
                                        else if(player.movement_x < 0)
                                        {
                                                player.movement_x = -1;
-                                               spider.frame = 1;
+                                               if(spider.flags & FL_ONGROUND)
+                                                       spider.frame = 1;
                                        }
                                        player.movement_y = 0;
-                                       movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
-
+                                       float oldvelz = spider.velocity_z;
+                                       movelib_move_simple(normalize(v_forward * player.movement_x),((player.BUTTON_JUMP) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
+                                       spider.velocity_z = oldvelz;
+                                       float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
+                                       if(spider.velocity_z <= 20) // not while jumping
+                                               spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
+                                       if(spider.flags & FL_ONGROUND)
                                        if(self.sound_nexttime < time || self.delay != 1)
                                        {
                                                self.delay = 1;
@@ -460,14 +505,23 @@ float spiderbot_frame()
                                        if(player.movement_y < 0)
                                        {
                                                player.movement_y = -1;
-                                               spider.frame = 2;
+                                               if(spider.flags & FL_ONGROUND)
+                                                       spider.frame = 2;
                                        }
                                        else if(player.movement_y > 0)
                                        {
                                                player.movement_y = 1;
-                                               spider.frame = 3;
+                                               if(spider.flags & FL_ONGROUND)
+                                                       spider.frame = 3;
                                        }
+
+                                       float oldvelz = spider.velocity_z;
                                        movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
+                                       spider.velocity_z = oldvelz;
+                                       float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
+                                       if(spider.velocity_z <= 20) // not while jumping
+                                               spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
+                                       if(spider.flags & FL_ONGROUND)
                                        if(self.sound_nexttime < time || self.delay != 2)
                                        {
                                                self.delay = 2;
@@ -493,7 +547,7 @@ float spiderbot_frame()
                        vector v;
                        spider.misc_bulletcounter += 1;
 
-                       self = player;
+                       setself(player);
 
                        gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
 
@@ -504,11 +558,11 @@ float spiderbot_frame()
                        fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
 
-                       sound (gun, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
-                       //trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
-                       pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
+                       sound (gun, CH_WEAPON_A, W_Sound("uzi_fire"), VOL_BASE, ATTEN_NORM);
+                       //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
+                       pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH), v, v_forward * 2500, 1);
 
-                       self = spider;
+                       setself(spider);
 
                        spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
                        spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
@@ -525,19 +579,20 @@ float spiderbot_frame()
        else
                vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
                                                                                   autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
-                                                                                  autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, FALSE);
+                                                                                  autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, false);
 
 
        spiderbot_rocket_do();
 
        if(self.vehicle_flags  & VHF_SHIELDREGEN)
-               vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, TRUE);
+               vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, true);
 
        if(self.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, FALSE);
+               vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, false);
 
        player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
-       player.vehicle_ammo2 = spider.tur_head.frame;
+       //player.vehicle_ammo2 = spider.tur_head.frame;
+       player.vehicle_ammo2 = (9 - spider.tur_head.frame) / 8 * 100; // Percentage, like ammo1
 
        if(spider.gun2.cnt <= time)
                player.vehicle_reload2 = 100;
@@ -552,12 +607,12 @@ float spiderbot_frame()
        if(self.vehicle_flags & VHF_HASSHIELD)
                VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
 
-       self = player;
+       setself(player);
        return 1;
 }
 
 void spiderbot_exit(float eject)
-{
+{SELFPARAM();
        entity e;
        vector spot;
 
@@ -614,7 +669,7 @@ void spiderbot_exit(float eject)
 }
 
 void spiderbot_headfade()
-{
+{SELFPARAM();
        self.think = spiderbot_headfade;
        self.nextthink = self.fade_time;
        self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
@@ -623,21 +678,21 @@ void spiderbot_headfade()
        {
                if(self.alpha > 0.1)
                {
-                       sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-                       pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
+                       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                       Send_Effect(EFFECT_EXPLOSION_BIG, self.origin + '0 0 100', '0 0 0', 1);
                }
                remove(self);
        }
 }
 
 void spiderbot_blowup()
-{
+{SELFPARAM();
        if(self.cnt > time)
        {
                if(random() < 0.1)
                {
-                       sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-                       pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
+                       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+                       Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
                }
                self.nextthink = time + 0.1;
                return;
@@ -703,10 +758,27 @@ void spiderbot_blowup()
        self.vehicle_hudmodel.viewmodelforclient = self;
 }
 
-float spiderbot_impulse(float _imp)
-{
+bool spiderbot_impulse(int _imp)
+{SELFPARAM();
        switch(_imp)
        {
+               case 1:
+               case 230:
+                       self.vehicle.vehicle_weapon2mode = SBRM_VOLLY;
+                       CSQCVehicleSetup(self, 0);
+                       return true;
+               case 2:
+               case 231:
+                       self.vehicle.vehicle_weapon2mode = SBRM_GUIDE;
+                       CSQCVehicleSetup(self, 0);
+                       return true;
+               case 3:
+               case 232:
+               case 251:
+                       self.vehicle.vehicle_weapon2mode = SBRM_ARTILLERY;
+                       CSQCVehicleSetup(self, 0);
+                       return true;
+
                case 10:
                case 15:
                case 18:
@@ -716,7 +788,8 @@ float spiderbot_impulse(float _imp)
 
                        //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
                        CSQCVehicleSetup(self, 0);
-                       return TRUE;
+                       return true;
+               case 11:
                case 12:
                case 16:
                case 19:
@@ -726,7 +799,7 @@ float spiderbot_impulse(float _imp)
 
                        //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
                        CSQCVehicleSetup(self, 0);
-                       return TRUE;
+                       return true;
 
                /*
                case 17: // toss gun, could be used to exit?
@@ -735,25 +808,25 @@ float spiderbot_impulse(float _imp)
                        break;
                */
        }
-       return FALSE;
+       return false;
 }
 
 void spawnfunc_vehicle_spiderbot()
-{
+{SELFPARAM();
        if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
-       if(!vehicle_initialize(VEH_SPIDERBOT, FALSE)) { remove(self); return; }
+       if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
 }
 
 float v_spiderbot(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case VR_IMPACT:
                {
                        if(autocvar_g_vehicle_spiderbot_bouncepain)
                                vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
-               
-                       return TRUE;
+
+                       return true;
                }
                case VR_ENTER:
                {
@@ -768,15 +841,15 @@ float v_spiderbot(float req)
                                setattachment(self.owner.flagcarried, self.tur_head, "");
                                setorigin(self.owner.flagcarried, '-20 0 120');
                        }
-               
-                       return TRUE;
+
+                       return true;
                }
                case VR_THINK:
                {
                        if(self.flags & FL_ONGROUND)
                                movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
-                       
-                       return TRUE;
+
+                       return true;
                }
                case VR_DEATH:
                {
@@ -793,10 +866,10 @@ float v_spiderbot(float req)
                        self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
                        self.frame                              = 10;
                        self.movetype                   = MOVETYPE_TOSS;
-                       
+
                        CSQCModel_UnlinkEntity(); // networking the death scene would be a nightmare
 
-                       return TRUE;
+                       return true;
                }
                case VR_SPAWN:
                {
@@ -826,10 +899,10 @@ float v_spiderbot(float req)
                        self.damageforcescale = 0.03;
                        self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
                        self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
-                       
+
                        self.PlayerPhysplug = spiderbot_frame;
 
-                       return TRUE;
+                       return true;
                }
                case VR_SETUP:
                {
@@ -846,9 +919,9 @@ float v_spiderbot(float req)
                        self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
                        self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
                        self.max_health = self.vehicle_health;
-                       self.pushable = TRUE; // spiderbot can use jumppads
+                       self.pushable = true; // spiderbot can use jumppads
 
-                       return TRUE;
+                       return true;
                }
                case VR_PRECACHE:
                {
@@ -859,8 +932,8 @@ float v_spiderbot(float req)
                        precache_model ("models/vehicles/spiderbot_cockpit.dpm");
                        precache_model ( "models/uziflash.md3");
 
-                       precache_sound ("weapons/uzi_fire.wav" );
-                       precache_sound ("weapons/rocket_impact.wav");
+                       precache_sound (W_Sound("uzi_fire") );
+                       precache_sound (W_Sound("rocket_impact"));
 
                        precache_sound ("vehicles/spiderbot_die.wav");
                        precache_sound ("vehicles/spiderbot_idle.wav");
@@ -868,11 +941,11 @@ float v_spiderbot(float req)
                        precache_sound ("vehicles/spiderbot_strafe.wav");
                        precache_sound ("vehicles/spiderbot_walk.wav");
                        precache_sound ("vehicles/spiderbot_land.wav");
-                       return TRUE;
+                       return true;
                }
        }
 
-       return TRUE;
+       return true;
 }
 
 #endif // SVQC
@@ -880,200 +953,42 @@ float v_spiderbot(float req)
 float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
 float autocvar_cl_vehicle_spiderbot_cross_size = 1;
 
-#define spider_ico  "gfx/vehicles/sbot.tga"
-#define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
-#define spider_mgun "gfx/vehicles/sbot_mguns.tga"
-string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
-
 float v_spiderbot(float req)
 {
        switch(req)
        {
                case VR_HUD:
                {
-                       if(autocvar_r_letterbox)
-                               return TRUE;
-
-                       vector picsize, hudloc = '0 0 0', pic2size, picloc;
-                       float i;
+                       string crosshair;
 
-                       // Fetch health & ammo stats
-                       HUD_GETVEHICLESTATS
-
-                       picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
-                       hudloc_y = vid_conheight - picsize_y;
-                       hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
-
-                       drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
-
-                       ammo1   *= 0.01;
-                       shield  *= 0.01;
-                       vh_health  *= 0.01;
-                       reload2 *= 0.01;
-
-                       pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
-                       picloc = picsize * 0.5 - pic2size * 0.5;
-                       if(vh_health < 0.25)
-                               drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
-                       else
-                               drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
-                       drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
-                       drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
-                       drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
-
-               // Health bar
-                       picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
-                       picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
-                       drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
-                       drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
-                       drawresetcliparea();
-               // ..  and icon
-                       picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
-                       picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
-                       if(vh_health < 0.25)
+                       switch(weapon2mode)
                        {
-                               if(alarm1time < time)
-                               {
-                                       alarm1time = time + 2;
-                                       vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
-                               }
-                               drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
-                       }
-                       else
-                       {
-                               drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-                               if(alarm1time)
-                               {
-                                       vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
-                                       alarm1time = 0;
-                               }
-                       }
-               // Shield bar
-                       picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
-                       picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
-                       drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
-                       drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-                       drawresetcliparea();
-               // ..  and icon
-                       picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
-                       picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
-                       if(shield < 0.25)
-                       {
-                               if(alarm2time < time)
-                               {
-                                       alarm2time = time + 1;
-                                       vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm_shield.wav");
-                               }
-                               drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
-                       }
-                       else
-                       {
-                               drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-                               if(alarm2time)
-                               {
-                                       vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
-                                       alarm2time = 0;
-                               }
+                               case SBRM_VOLLY:     crosshair = vCROSS_BURST; break;
+                               case SBRM_GUIDE:     crosshair = vCROSS_GUIDE; break;
+                               case SBRM_ARTILLERY: crosshair = vCROSS_RAIN;  break;
+                               default:             crosshair = vCROSS_BURST;
                        }
 
-               // Minigun bar
-                       picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
-                       picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
-                       drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
-                       drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-                       drawresetcliparea();
-               // ..  and icon
-                       picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
-                       picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
-                       if(ammo1 < 0.2)
-                               drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
-                       else
-                               drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-
-               // Rocket ammo bar
-                       picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
-                       ammo1 = picsize_x / 8;
-                       picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
-                       drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
-                       drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
-                       drawresetcliparea();
-
-               // ..  and icons
-                       pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
-                       picloc_x -= pic2size_x;
-                       picloc_y += pic2size_y * 2.25;
-                       if(ammo2 == 9)
-                       {
-                               for(i = 1; i < 9; ++i)
-                               {
-                                       picloc_x += ammo1;
-                                       drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
-                               }
-                       }
-                       else
-                       {
-                               for(i = 1; i < 9; ++i)
-                               {
-                                       picloc_x += ammo1;
-                                       drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
-                               }
-                       }
-                       pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
-                       picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
-                       if(ammo2 == 9)
-                               drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
-                       else
-                               drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
-
-                       if (scoreboard_showscores)
-                               HUD_DrawScoreboard();
-                       else
-                       {
-                               switch(getstati(STAT_VEHICLESTAT_W2MODE))
-                               {
-                                       case SBRM_VOLLY:
-                                               spider_xhair = "gfx/vehicles/axh-bracket.tga";
-                                               break;
-                                       case SBRM_GUIDE:
-                                               spider_xhair = "gfx/vehicles/axh-cross.tga";
-                                               break;
-                                       case SBRM_ARTILLERY:
-                                               spider_xhair = "gfx/vehicles/axh-tag.tga";
-                                               break;
-                                       default:
-                                               spider_xhair= "gfx/vehicles/axh-tag.tga";
-                               }
-
-                               picsize = draw_getimagesize(spider_xhair);
-                               picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
-                               picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
-
-                               drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), spider_xhair, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
-                       }
-                       
-                       return TRUE;
+                       Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
+                                                        "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
+                                                        "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
+                                                        crosshair);
+                       return true;
                }
                case VR_SETUP:
                {
-                       // Minigun1
-                       AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
-                       AuxiliaryXhair[0].axh_scale   = 0.25;
-                       // Minigun2
-                       AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
-                       AuxiliaryXhair[1].axh_scale   = 0.25;
-                       // Rocket
-                       AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
-                       AuxiliaryXhair[2].axh_scale   = 0.5;
-               
-                       return TRUE;
+                       AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
+                       AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2
+
+                       return true;
                }
                case VR_PRECACHE:
                {
-                       return TRUE;
+                       return true;
                }
        }
 
-       return TRUE;
+       return true;
 }
 
 #endif // CSQC