]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/vehicle/spiderbot.qc
Fix crash
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / spiderbot.qc
index b13c8b3ac4cffac92e5216b08f50285135050953..5bb26070d564e5d7d2523964339e85608b736641 100644 (file)
@@ -7,6 +7,8 @@ CLASS(Spiderbot, Vehicle)
 /* spawnflags */ ATTRIB(Spiderbot, spawnflags, int, VHF_DMGSHAKE);
 /* mins       */ ATTRIB(Spiderbot, mins, vector, '-75 -75 10');
 /* maxs       */ ATTRIB(Spiderbot, maxs, vector, '75 75 125');
+/* view offset*/ ATTRIB(Spiderbot, view_ofs, vector, '0 0 70');
+/* view dist  */ ATTRIB(Spiderbot, height, float, 170);
 /* model         */ ATTRIB(Spiderbot, mdl, string, "models/vehicles/spiderbot.dpm");
 /* model         */ ATTRIB(Spiderbot, model, string, "models/vehicles/spiderbot.dpm");
 /* head_model */ ATTRIB(Spiderbot, head_model, string, "models/vehicles/spiderbot_top.dpm");
@@ -82,9 +84,10 @@ 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;
@@ -134,12 +137,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 +152,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,16 +174,16 @@ 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;
                }
                else if(time >= spider.jump_delay)
                {
-                       if(vlen(player.movement) == 0)
+                       if(!player.movement)
                        {
-                               if(spider.flags & FL_ONGROUND)
+                               if(IS_ONGROUND(spider))
                                {
                                        if(self.sound_nexttime < time || self.delay != 3)
                                        {
@@ -189,7 +192,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_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop);
+                                       movelib_brake_simple(self, autocvar_g_vehicle_spiderbot_speed_stop);
                                        spider.frame = 5;
                                }
                        }
@@ -210,23 +213,23 @@ 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;
                                        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);
+                                       movelib_move_simple(self, 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(IS_ONGROUND(spider))
                                        if(self.sound_nexttime < time || self.delay != 1)
                                        {
                                                self.delay = 1;
@@ -240,23 +243,23 @@ 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;
                                        }
 
                                        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);
+                                       movelib_move_simple(self, 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(IS_ONGROUND(spider))
                                        if(self.sound_nexttime < time || self.delay != 2)
                                        {
                                                self.delay = 2;
@@ -381,7 +384,7 @@ void spiderbot_exit(float eject)
        }
        else
        {
-               if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
+               if(vdist(self.velocity, >, autocvar_g_vehicle_spiderbot_speed_strafe))
                {
                        self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
                        self.owner.velocity_z += 200;
@@ -449,7 +452,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 +468,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);
@@ -548,12 +554,12 @@ spawnfunc(vehicle_spiderbot)
        if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
 }
 
-               METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh, entity instance))
                {
                        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);
                }
-               METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance))
                {
                        self.vehicle_weapon2mode = SBRM_GUIDE;
                        self.movetype = MOVETYPE_WALK;
@@ -567,30 +573,30 @@ spawnfunc(vehicle_spiderbot)
                                setorigin(self.owner.flagcarried, '-20 0 120');
                        }
                }
-               METHOD(Spiderbot, vr_think, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance))
                {
-                       if(self.flags & FL_ONGROUND)
-                               movelib_brake_simple(autocvar_g_vehicle_spiderbot_speed_stop);
+                       if(IS_ONGROUND(self))
+                               movelib_brake_simple(self, autocvar_g_vehicle_spiderbot_speed_stop);
                }
-               METHOD(Spiderbot, vr_death, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
                {
-                       self.health                             = 0;
-                       self.event_damage               = func_null;
-                       self.takedamage                 = DAMAGE_NO;
-                       self.touch                              = func_null;
-                       self.cnt                                = 3.4 + time + random() * 2;
-                       self.think                              = spiderbot_blowup;
-                       self.nextthink                  = time;
-                       self.deadflag                   = DEAD_DYING;
-                       self.frame                              = 5;
-                       self.tur_head.effects  |= EF_FLAME;
-                       self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
-                       self.frame                              = 10;
-                       self.movetype                   = MOVETYPE_TOSS;
-
-                       CSQCModel_UnlinkEntity(self); // networking the death scene would be a nightmare
+                       instance.health                         = 0;
+                       instance.event_damage           = func_null;
+                       instance.takedamage                     = DAMAGE_NO;
+                       instance.touch                          = func_null;
+                       instance.cnt                            = 3.4 + time + random() * 2;
+                       instance.think                          = spiderbot_blowup;
+                       instance.nextthink                      = time;
+                       instance.deadflag                       = DEAD_DYING;
+                       instance.frame                          = 5;
+                       instance.tur_head.effects  |= EF_FLAME;
+                       instance.colormod                       = instance.tur_head.colormod = '-1 -1 -1';
+                       instance.frame                          = 10;
+                       instance.movetype                       = MOVETYPE_TOSS;
+
+                       CSQCModel_UnlinkEntity(instance); // networking the death scene would be a nightmare
                }
-               METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance))
                {
                        if(!self.gun1)
                        {
@@ -621,7 +627,7 @@ spawnfunc(vehicle_spiderbot)
 
                        self.PlayerPhysplug = spiderbot_frame;
                }
-               METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
                {
                        if(autocvar_g_vehicle_spiderbot_shield)
                                self.vehicle_flags |= VHF_HASSHIELD;
@@ -664,7 +670,7 @@ float autocvar_cl_vehicle_spiderbot_cross_size = 1;
 
                        Vehicles_drawCrosshair(crosshair);
                }
-               METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
+               METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
                {
                        AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
                        AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2