]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/vehicle/spiderbot.qc
Vehicles: always show smoke when low on health, even when empty
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / spiderbot.qc
index 8a15d0a114ba14987ba366872fc21b636bcf45ab..d7d5e1d6220d166252ab4fc07db815b7c4b2a54d 100644 (file)
@@ -13,7 +13,7 @@ CLASS(Spiderbot, Vehicle)
 /* hud_model  */ ATTRIB(Spiderbot, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
 /* tags       */ ATTRIB(Spiderbot, tag_head, string, "tag_head");
 /* tags       */ ATTRIB(Spiderbot, tag_hud, string, "tag_hud");
-/* tags       */ ATTRIB(Spiderbot, tag_hview, string, "");
+/* tags       */ ATTRIB(Spiderbot, tag_view, string, "");
 /* netname    */ ATTRIB(Spiderbot, netname, string, "spiderbot");
 /* fullname   */ ATTRIB(Spiderbot, vehicle_name, string, _("Spiderbot"));
 /* icon       */ ATTRIB(Spiderbot, m_icon, string, "vehicle_spider");
@@ -82,13 +82,14 @@ float spiderbot_frame()
 
        player = self;
        spider = self.vehicle;
-       setself(spider);
 
-       vehicles_painframe();
+       vehicles_frame(spider, player);
+
+       setself(spider);
 
        player.BUTTON_ZOOM        = 0;
        player.BUTTON_CROUCH    = 0;
-       player.switchweapon      = 0;
+       PS(player).m_switchweapon = WEP_Null;
        player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
 
 
@@ -134,12 +135,12 @@ 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)
+       if(IS_ONGROUND(spider))
                spider.jump_delay = time; // reset now so movement can begin
 
-       //if(spider.flags & FL_ONGROUND)
+       //if(IS_ONGROUND(spider))
        {
-               if(spider.flags & FL_ONGROUND)
+               if(IS_ONGROUND(spider))
                if(spider.frame == 4 && self.tur_head.wait != 0)
                {
                        sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
@@ -149,7 +150,7 @@ float spiderbot_frame()
                if(!player.BUTTON_JUMP)
                        spider.BUTTON_JUMP = 0;
 
-               if((spider.flags & FL_ONGROUND) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
+               if((IS_ONGROUND(spider)) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
                {
                        sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
                        //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
@@ -171,7 +172,7 @@ float spiderbot_frame()
                        if(movefix_y == 0 && movefix_x == 0)
                                sd = v_forward; // always do forward
 
-                       spider.flags &= ~FL_ONGROUND;
+                       UNSET_ONGROUND(spider);
 
                        spider.velocity = sd * 700 + rt * 600 + v_up * 600;
                        spider.frame = 4;
@@ -180,7 +181,7 @@ float spiderbot_frame()
                {
                        if(vlen(player.movement) == 0)
                        {
-                               if(spider.flags & FL_ONGROUND)
+                               if(IS_ONGROUND(spider))
                                {
                                        if(self.sound_nexttime < time || self.delay != 3)
                                        {
@@ -189,7 +190,7 @@ float spiderbot_frame()
                                                //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
                                                sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
                                        }
-                                       movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
+                                       movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop);
                                        spider.frame = 5;
                                }
                        }
@@ -210,13 +211,13 @@ float spiderbot_frame()
                                        if(player.movement_x > 0)
                                        {
                                                player.movement_x = 1;
-                                               if(spider.flags & FL_ONGROUND)
+                                               if(IS_ONGROUND(spider))
                                                        spider.frame = 0;
                                        }
                                        else if(player.movement_x < 0)
                                        {
                                                player.movement_x = -1;
-                                               if(spider.flags & FL_ONGROUND)
+                                               if(IS_ONGROUND(spider))
                                                        spider.frame = 1;
                                        }
                                        player.movement_y = 0;
@@ -226,7 +227,7 @@ float spiderbot_frame()
                                        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(IS_ONGROUND(spider))
                                        if(self.sound_nexttime < time || self.delay != 1)
                                        {
                                                self.delay = 1;
@@ -240,13 +241,13 @@ float spiderbot_frame()
                                        if(player.movement_y < 0)
                                        {
                                                player.movement_y = -1;
-                                               if(spider.flags & FL_ONGROUND)
+                                               if(IS_ONGROUND(spider))
                                                        spider.frame = 2;
                                        }
                                        else if(player.movement_y > 0)
                                        {
                                                player.movement_y = 1;
-                                               if(spider.flags & FL_ONGROUND)
+                                               if(IS_ONGROUND(spider))
                                                        spider.frame = 3;
                                        }
 
@@ -256,7 +257,7 @@ float spiderbot_frame()
                                        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(IS_ONGROUND(spider))
                                        if(self.sound_nexttime < time || self.delay != 2)
                                        {
                                                self.delay = 2;
@@ -276,7 +277,7 @@ float spiderbot_frame()
        if(player.BUTTON_ATCK)
        {
                spider.cnt = time;
-               if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
+               if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single[0] <= time)
                {
                        entity gun;
                        vector v;
@@ -291,16 +292,16 @@ float spiderbot_frame()
                        v += v_forward * 50;
 
                        fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
-                                autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
+                                autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, 0);
 
                        sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
                        //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
-                       pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH), v, v_forward * 2500, 1);
+                       pointparticles(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
 
                        setself(spider);
 
                        spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
-                       spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
+                       spider.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
                        player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
                        spider.gun1.angles_z += 45;
                        spider.gun2.angles_z -= 45;
@@ -332,7 +333,7 @@ float spiderbot_frame()
        if(spider.gun2.cnt <= time)
                player.vehicle_reload2 = 100;
        else
-               player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
+               player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single[0]) * 100;
 
        setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
        player.velocity = spider.velocity;
@@ -449,7 +450,8 @@ void spiderbot_blowup()
        b.angles = self.angles;
        setsize(b, self.mins, self.maxs);
 
-       setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
+       vector org = gettaginfo(self, gettagindex(self, "tag_head"));
+       setorigin(h, org);
        h.movetype = MOVETYPE_BOUNCE;
        h.solid = SOLID_BBOX;
        h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
@@ -464,13 +466,15 @@ void spiderbot_blowup()
        h.think = spiderbot_headfade;
        h.nextthink = time;
 
-       setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
+       org = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01"));
+       setorigin(g1, org);
        g1.movetype = MOVETYPE_TOSS;
        g1.solid = SOLID_CORPSE;
        g1.velocity = v_forward * 700 + (randomvec() * 32);
        g1.avelocity = randomvec() * 180;
 
-       setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
+       org = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02"));
+       setorigin(g2, org);
        g2.movetype = MOVETYPE_TOSS;
        g2.solid = SOLID_CORPSE;
        g2.velocity = v_forward * 700 + (randomvec() * 32);
@@ -483,7 +487,7 @@ void spiderbot_blowup()
        SUB_SetFade(g1, time, min(self.respawntime, 10));
        SUB_SetFade(g2, time, min(self.respawntime, 10));
 
-       RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_SPID_DEATH, world);
+       RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_SPID_DEATH.m_id, world);
 
        self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
        self.movetype = MOVETYPE_NONE;
@@ -497,26 +501,22 @@ bool spiderbot_impulse(int _imp)
 {SELFPARAM();
        switch(_imp)
        {
-               case 1:
-               case 230:
+               case IMP_weapon_group_1.impulse:
                        self.vehicle.vehicle_weapon2mode = SBRM_VOLLY;
                        CSQCVehicleSetup(self, 0);
                        return true;
-               case 2:
-               case 231:
+               case IMP_weapon_group_2.impulse:
                        self.vehicle.vehicle_weapon2mode = SBRM_GUIDE;
                        CSQCVehicleSetup(self, 0);
                        return true;
-               case 3:
-               case 232:
-               case 251:
+               case IMP_weapon_group_3.impulse:
                        self.vehicle.vehicle_weapon2mode = SBRM_ARTILLERY;
                        CSQCVehicleSetup(self, 0);
                        return true;
 
-               case 10:
-               case 15:
-               case 18:
+               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 > SBRM_LAST)
                                self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
@@ -524,10 +524,10 @@ bool spiderbot_impulse(int _imp)
                        //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
                        CSQCVehicleSetup(self, 0);
                        return true;
-               case 11:
-               case 12:
-               case 16:
-               case 19:
+               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 < SBRM_FIRST)
                                self.vehicle.vehicle_weapon2mode = SBRM_LAST;
@@ -537,17 +537,17 @@ bool spiderbot_impulse(int _imp)
                        return true;
 
                /*
-               case 17: // toss gun, could be used to exit?
+               case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
                        break;
-               case 20: // Manual minigun reload?
+               case IMP_weapon_reload.impulse: // Manual minigun reload?
                        break;
                */
        }
        return false;
 }
 
-void spawnfunc_vehicle_spiderbot()
-{SELFPARAM();
+spawnfunc(vehicle_spiderbot)
+{
        if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
        if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
 }
@@ -573,8 +573,8 @@ void spawnfunc_vehicle_spiderbot()
                }
                METHOD(Spiderbot, vr_think, void(Spiderbot thisveh))
                {
-                       if(self.flags & FL_ONGROUND)
-                               movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
+                       if(IS_ONGROUND(self))
+                               movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop);
                }
                METHOD(Spiderbot, vr_death, void(Spiderbot thisveh))
                {
@@ -592,7 +592,7 @@ void spawnfunc_vehicle_spiderbot()
                        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
                }
                METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh))
                {
@@ -649,6 +649,12 @@ float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
 float autocvar_cl_vehicle_spiderbot_cross_size = 1;
 
                METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
+               {
+                       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);
+               }
+               METHOD(Spiderbot, vr_crosshair, void(Spiderbot thisveh))
                {
                        string crosshair;
 
@@ -660,10 +666,7 @@ float autocvar_cl_vehicle_spiderbot_cross_size = 1;
                                default:             crosshair = vCROSS_BURST;
                        }
 
-                       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);
+                       Vehicles_drawCrosshair(crosshair);
                }
                METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
                {