]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/unit/spiderbot.qc
Add support for traileffect on CSQC models
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / spiderbot.qc
index 8e0904d821fc7f0d0226f312ae81976bb2ce036a..ea0a34fd60df78a7d5980f2bd3584f9459d270cf 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;
@@ -76,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;
@@ -98,7 +108,7 @@ void spiderbot_rocket_unguided()
 }
 
 void spiderbot_rocket_guided()
-{
+{SELFPARAM();
        vector newdir, olddir;
 
        self.nextthink  = time;
@@ -118,7 +128,7 @@ void spiderbot_rocket_guided()
 }
 
 void spiderbot_guide_release()
-{
+{SELFPARAM();
        entity rkt;
        rkt = findchainentity(realowner, self.owner);
        if(!rkt)
@@ -211,7 +221,7 @@ vector spiberbot_calcartillery(vector org, vector tgt, float ht)
 }
 
 void spiderbot_rocket_do()
-{
+{SELFPARAM();
        vector v;
        entity rocket = world;
 
@@ -250,7 +260,7 @@ void spiderbot_rocket_do()
        if(self.wait != -10)
        if(!self.owner.BUTTON_ATCK2)
                return;
-               
+
        if(forbidWeaponUse(self.owner))
                return;
 
@@ -259,7 +269,7 @@ 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, SND(ROCKET_FIRE),
                                                                   v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
@@ -273,7 +283,7 @@ 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, SND(ROCKET_FIRE),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, false, self.owner);
@@ -285,7 +295,7 @@ 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, SND(ROCKET_FIRE),
                                                                   v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
                                                                   autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
                                                                   DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
@@ -323,7 +333,7 @@ void spiderbot_rocket_do()
 
 .float jump_delay;
 float spiderbot_frame()
-{
+{SELFPARAM();
        vector ad, vf;
        entity player, spider;
        float ftmp;
@@ -337,7 +347,7 @@ float spiderbot_frame()
 
        player = self;
        spider = self.vehicle;
-       self   = spider;
+       setself(spider);
 
        vehicles_painframe();
 
@@ -397,7 +407,7 @@ float spiderbot_frame()
                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);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
                        spider.frame = 5;
                }
 
@@ -406,7 +416,7 @@ float spiderbot_frame()
 
                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);
+                       sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
                        //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
                        self.delay = 0;
 
@@ -442,7 +452,7 @@ float spiderbot_frame()
                                                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);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                        }
                                        movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
                                        spider.frame = 5;
@@ -486,7 +496,7 @@ float spiderbot_frame()
                                        {
                                                self.delay = 1;
                                                self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
                                        }
                                }
@@ -516,7 +526,7 @@ float spiderbot_frame()
                                        {
                                                self.delay = 2;
                                                self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
-                                               sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
+                                               sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                                //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
                                        }
                                }
@@ -537,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;
 
@@ -548,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, SND_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;
@@ -581,7 +591,8 @@ float spiderbot_frame()
                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;
@@ -596,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;
 
@@ -658,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;
@@ -667,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, SND_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, SND_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;
@@ -693,10 +704,10 @@ void spiderbot_blowup()
        g1 = spawn();
        g2 = spawn();
 
-       setmodel(b, "models/vehicles/spiderbot.dpm");
-       setmodel(h, "models/vehicles/spiderbot_top.dpm");
-       setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
-       setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
+       setmodel(b, MDL_VEH_SPIDERBOT_BODY);
+       setmodel(h, MDL_VEH_SPIDERBOT_TOP);
+       setmodel(g1, MDL_VEH_SPIDERBOT_GUN);
+       setmodel(g2, MDL_VEH_SPIDERBOT_GUN);
 
        setorigin(b, self.origin);
        b.frame = 11;
@@ -748,7 +759,7 @@ void spiderbot_blowup()
 }
 
 bool spiderbot_impulse(int _imp)
-{
+{SELFPARAM();
        switch(_imp)
        {
                case 1:
@@ -800,21 +811,21 @@ bool spiderbot_impulse(int _imp)
        return false;
 }
 
-void spawnfunc_vehicle_spiderbot()
+spawnfunc(vehicle_spiderbot)
 {
        if(!autocvar_g_vehicle_spiderbot) { 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;
                }
                case VR_ENTER:
@@ -830,14 +841,14 @@ float v_spiderbot(float req)
                                setattachment(self.owner.flagcarried, self.tur_head, "");
                                setorigin(self.owner.flagcarried, '-20 0 120');
                        }
-               
+
                        return true;
                }
                case VR_THINK:
                {
                        if(self.flags & FL_ONGROUND)
                                movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
-                       
+
                        return true;
                }
                case VR_DEATH:
@@ -855,8 +866,8 @@ 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
+
+                       CSQCModel_UnlinkEntity(self); // networking the death scene would be a nightmare
 
                        return true;
                }
@@ -867,8 +878,8 @@ float v_spiderbot(float req)
                                self.vehicles_impulse = spiderbot_impulse;
                                self.gun1 = spawn();
                                self.gun2 = spawn();
-                               setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
-                               setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
+                               setmodel(self.gun1, MDL_VEH_SPIDERBOT_GUN);
+                               setmodel(self.gun2, MDL_VEH_SPIDERBOT_GUN);
                                setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
                                setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
                                self.gravity = 2;
@@ -888,7 +899,7 @@ 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;
@@ -914,22 +925,6 @@ float v_spiderbot(float req)
                }
                case VR_PRECACHE:
                {
-                       precache_model ("models/vhshield.md3");
-                       precache_model ("models/vehicles/spiderbot.dpm");
-                       precache_model ("models/vehicles/spiderbot_top.dpm");
-                       precache_model ("models/vehicles/spiderbot_barrels.dpm");
-                       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 ("vehicles/spiderbot_die.wav");
-                       precache_sound ("vehicles/spiderbot_idle.wav");
-                       precache_sound ("vehicles/spiderbot_jump.wav");
-                       precache_sound ("vehicles/spiderbot_strafe.wav");
-                       precache_sound ("vehicles/spiderbot_walk.wav");
-                       precache_sound ("vehicles/spiderbot_land.wav");
                        return true;
                }
        }
@@ -942,191 +937,33 @@ 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;
-
-                       // 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)
-                       {
-                               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;
-                               }
-                       }
+                       string crosshair;
 
-               // 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)
+                       switch(weapon2mode)
                        {
-                               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);
-                               }
+                               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;
                        }
-                       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);
-                       }
-                       
+                       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;
-               
+                       AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
+                       AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2
+
                        return true;
                }
                case VR_PRECACHE: