]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/vehicle/raptor.qc
Fix raptor landing not taking the full time with very high ticrates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / raptor.qc
index 5424d1cdf5cd132479d44fdcf407efb2c8f0bfef..f0c4dc1ec7afd47a21f5d753d6427971237a4eb5 100644 (file)
@@ -1,7 +1,5 @@
 #include "raptor.qh"
 
-#ifdef IMPLEMENTATION
-
 #ifdef SVQC
 
 bool autocvar_g_vehicle_raptor = true;
@@ -17,9 +15,9 @@ float autocvar_g_vehicle_raptor_pitchspeed = 50;
 float autocvar_g_vehicle_raptor_pitchlimit = 45;
 
 float autocvar_g_vehicle_raptor_speed_forward = 1700;
-float autocvar_g_vehicle_raptor_speed_strafe = 900;
-float autocvar_g_vehicle_raptor_speed_up = 1700;
-float autocvar_g_vehicle_raptor_speed_down = 1700;
+float autocvar_g_vehicle_raptor_speed_strafe = 2200;
+float autocvar_g_vehicle_raptor_speed_up = 2300;
+float autocvar_g_vehicle_raptor_speed_down = 2000;
 float autocvar_g_vehicle_raptor_friction = 2;
 
 bool autocvar_g_vehicle_raptor_swim = false;
@@ -29,7 +27,7 @@ float autocvar_g_vehicle_raptor_cannon_turnlimit = 20;
 float autocvar_g_vehicle_raptor_cannon_pitchlimit_up = 12;
 float autocvar_g_vehicle_raptor_cannon_pitchlimit_down = 32;
 
-float autocvar_g_vehicle_raptor_cannon_locktarget = 0;
+bool autocvar_g_vehicle_raptor_cannon_locktarget = true;
 float autocvar_g_vehicle_raptor_cannon_locking_time = 0.2;
 float autocvar_g_vehicle_raptor_cannon_locking_releasetime = 0.45;
 float autocvar_g_vehicle_raptor_cannon_locked_time = 1;
@@ -39,11 +37,11 @@ float autocvar_g_vehicle_raptor_energy = 100;
 float autocvar_g_vehicle_raptor_energy_regen = 25;
 float autocvar_g_vehicle_raptor_energy_regen_pause = 0.25;
 
-float autocvar_g_vehicle_raptor_health = 150;
+float autocvar_g_vehicle_raptor_health = 250;
 float autocvar_g_vehicle_raptor_health_regen = 0;
 float autocvar_g_vehicle_raptor_health_regen_pause = 0;
 
-float autocvar_g_vehicle_raptor_shield = 75;
+float autocvar_g_vehicle_raptor_shield = 200;
 float autocvar_g_vehicle_raptor_shield_regen = 25;
 float autocvar_g_vehicle_raptor_shield_regen_pause = 1.5;
 
@@ -204,8 +202,8 @@ bool raptor_frame(entity this, float dt)
 
        // Pitch
        ftmp = 0;
-       if(this.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
-       else if(this.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
+       if(CS(this).movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
+       else if(CS(this).movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
 
        df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit);
        ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit);
@@ -222,22 +220,22 @@ bool raptor_frame(entity this, float dt)
 
        df = vehic.velocity * -autocvar_g_vehicle_raptor_friction;
 
-       if(this.movement_x != 0)
+       if(CS(this).movement_x != 0)
        {
-               if(this.movement_x > 0)
+               if(CS(this).movement_x > 0)
                        df += v_forward  * autocvar_g_vehicle_raptor_speed_forward;
-               else if(this.movement_x < 0)
+               else if(CS(this).movement_x < 0)
                        df -= v_forward  * autocvar_g_vehicle_raptor_speed_forward;
        }
 
-       if(this.movement_y != 0)
+       if(CS(this).movement_y != 0)
        {
-               if(this.movement_y < 0)
+               if(CS(this).movement_y < 0)
                        df -= v_right * autocvar_g_vehicle_raptor_speed_strafe;
-               else if(this.movement_y > 0)
+               else if(CS(this).movement_y > 0)
                        df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
 
-               vehic.angles_z = bound(-30,vehic.angles_z + (this.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
+               vehic.angles_z = bound(-30,vehic.angles_z + (CS(this).movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
        }
        else
        {
@@ -252,11 +250,11 @@ bool raptor_frame(entity this, float dt)
                df +=  v_up * autocvar_g_vehicle_raptor_speed_up;
 
        vehic.velocity  += df * dt;
-       this.velocity = this.movement  = vehic.velocity;
+       this.velocity = CS(this).movement  = vehic.velocity;
        setorigin(this, vehic.origin + '0 0 32');
        this.oldorigin = this.origin; // negate fall damage
 
-       this.vehicle_weapon2mode = vehic.vehicle_weapon2mode;
+       STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
 
        vector vf, ad;
        // Target lock & predict
@@ -345,11 +343,11 @@ bool raptor_frame(entity this, float dt)
 
        vehicle_aimturret(vehic, trace_endpos, vehic.gun1, "fire1",
                                                  autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
-                                                 autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
+                                                 autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed, dt);
 
        vehicle_aimturret(vehic, trace_endpos, vehic.gun2, "fire1",
                                                  autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
-                                                 autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
+                                                 autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed, dt);
 
        /*
        ad = ad * 0.5;
@@ -360,7 +358,7 @@ bool raptor_frame(entity this, float dt)
 
        Weapon wep1 = WEP_RAPTOR;
        .entity weaponentity = weaponentities[0];
-       if(!forbidWeaponUse(this))
+       if(!weaponLocked(this) && !weaponUseForbidden(this))
        if(PHYS_INPUT_BUTTON_ATCK(this))
        if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
        {
@@ -371,14 +369,14 @@ bool raptor_frame(entity this, float dt)
                vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true);
 
        if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false);
+               vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RES_HEALTH);
 
        if(vehic.vehicle_flags  & VHF_ENERGYREGEN)
                vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false);
 
        Weapon wep2a = WEP_RAPTOR_BOMB;
-       if(!forbidWeaponUse(this))
-       if(vehic.vehicle_weapon2mode == RSM_BOMB)
+       if(!weaponLocked(this) && !weaponUseForbidden(this))
+       if(STAT(VEHICLESTAT_W2MODE, vehic) == RSM_BOMB)
        {
                if(time > vehic.lip + autocvar_g_vehicle_raptor_bombs_refire)
                if(PHYS_INPUT_BUTTON_ATCK2(this))
@@ -429,7 +427,7 @@ bool raptor_frame(entity this, float dt)
        }
 
 
-       VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor);
+       VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
        VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
        if(vehic.vehicle_flags & VHF_HASSHIELD)
                VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
@@ -455,7 +453,7 @@ bool raptor_takeoff(entity this, float dt)
        // Takeoff sequense
        if(vehic.frame < 25)
        {
-               vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / PHYS_INPUT_FRAMETIME);
+               vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / dt);
                vehic.velocity_z = min(vehic.velocity_z * 1.5, 256);
                vehic.bomb1.gun1.avelocity_y = 90 + ((vehic.frame / 25) * 25000);
                vehic.bomb1.gun2.avelocity_y = -vehic.bomb1.gun1.avelocity_y;
@@ -467,13 +465,13 @@ bool raptor_takeoff(entity this, float dt)
        else
                this.PlayerPhysplug = raptor_frame;
 
-       this.vehicle_weapon2mode = vehic.vehicle_weapon2mode;
+       STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
 
        if(vehic.vehicle_flags  & VHF_SHIELDREGEN)
                vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true);
 
        if(vehic.vehicle_flags  & VHF_HEALTHREGEN)
-               vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false);
+               vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false, RES_HEALTH);
 
        if(vehic.vehicle_flags  & VHF_ENERGYREGEN)
                vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false);
@@ -483,7 +481,7 @@ bool raptor_takeoff(entity this, float dt)
        this.vehicle_reload2 = bound(0, vehic.bomb1.alpha * 100, 100);
        this.vehicle_ammo2 = (this.vehicle_reload2 == 100) ? 100 : 0;
 
-       VEHICLE_UPDATE_PLAYER(this, vehic, health, raptor);
+       VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, raptor, RES_HEALTH);
        VEHICLE_UPDATE_PLAYER(this, vehic, energy, raptor);
        if(vehic.vehicle_flags & VHF_HASSHIELD)
                VEHICLE_UPDATE_PLAYER(this, vehic, shield, raptor);
@@ -495,7 +493,7 @@ void raptor_blowup(entity this, entity toucher)
 {
        this.deadflag   = DEAD_DEAD;
        this.vehicle_exit(this, VHEF_NORMAL);
-       RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_RAPT_DEATH.m_id, NULL);
+       RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_RAPT_DEATH.m_id, DMG_NOWEP, NULL);
 
        this.alpha                = -1;
        set_movetype(this, MOVETYPE_NONE);
@@ -541,20 +539,20 @@ bool raptor_impulse(entity this, int _imp)
        switch(_imp)
        {
                case IMP_weapon_group_1.impulse:
-                       this.vehicle.vehicle_weapon2mode = RSM_BOMB;
+                       STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_BOMB;
                        CSQCVehicleSetup(this, 0);
                        return true;
                case IMP_weapon_group_2.impulse:
-                       this.vehicle.vehicle_weapon2mode = RSM_FLARE;
+                       STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FLARE;
                        CSQCVehicleSetup(this, 0);
                        return true;
 
                case IMP_weapon_next_byid.impulse:
                case IMP_weapon_next_bypriority.impulse:
                case IMP_weapon_next_bygroup.impulse:
-                       this.vehicle.vehicle_weapon2mode += 1;
-                       if(this.vehicle.vehicle_weapon2mode > RSM_LAST)
-                               this.vehicle.vehicle_weapon2mode = RSM_FIRST;
+                       STAT(VEHICLESTAT_W2MODE, this.vehicle) += 1;
+                       if(STAT(VEHICLESTAT_W2MODE, this.vehicle) > RSM_LAST)
+                               STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_FIRST;
 
                        CSQCVehicleSetup(this, 0);
                        return true;
@@ -562,9 +560,9 @@ bool raptor_impulse(entity this, int _imp)
                case IMP_weapon_prev_byid.impulse:
                case IMP_weapon_prev_bypriority.impulse:
                case IMP_weapon_prev_bygroup.impulse:
-                       this.vehicle.vehicle_weapon2mode -= 1;
-                       if(this.vehicle.vehicle_weapon2mode < RSM_FIRST)
-                               this.vehicle.vehicle_weapon2mode = RSM_LAST;
+                       STAT(VEHICLESTAT_W2MODE, this.vehicle) -= 1;
+                       if(STAT(VEHICLESTAT_W2MODE, this.vehicle) < RSM_FIRST)
+                               STAT(VEHICLESTAT_W2MODE, this.vehicle) = RSM_LAST;
 
                        CSQCVehicleSetup(this, 0);
                        return true;
@@ -592,11 +590,11 @@ METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance))
 }
 METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
 {
-    instance.vehicle_weapon2mode = RSM_BOMB;
+    STAT(VEHICLESTAT_W2MODE, instance) = RSM_BOMB;
     instance.owner.PlayerPhysplug = raptor_takeoff;
     set_movetype(instance, MOVETYPE_BOUNCEMISSILE);
     instance.solid               = SOLID_SLIDEBOX;
-    instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_raptor_health) * 100;
+    instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_raptor_health) * 100;
     instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
     instance.velocity = '0 0 1'; // nudge upwards so takeoff sequence can work
     instance.tur_head.exteriormodeltoclient = instance.owner;
@@ -611,7 +609,7 @@ METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance))
 }
 METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance))
 {
-    instance.health                            = 0;
+       SetResourceExplicit(instance, RES_HEALTH, 0);
     instance.event_damage              = func_null;
     instance.solid                             = SOLID_CORPSE;
     instance.takedamage                        = DAMAGE_NO;
@@ -703,7 +701,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
     }
 
     instance.frame               = 0;
-    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
     set_movetype(instance, MOVETYPE_TOSS);
     instance.solid               = SOLID_SLIDEBOX;
@@ -722,7 +720,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance))
     instance.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
     instance.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
     instance.damageforcescale = 0.25;
-    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
 }
 METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
@@ -741,9 +739,9 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
 
     instance.vehicle_exit = raptor_exit;
     instance.respawntime = autocvar_g_vehicle_raptor_respawntime;
-    instance.vehicle_health = autocvar_g_vehicle_raptor_health;
+    SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_raptor_health);
     instance.vehicle_shield = autocvar_g_vehicle_raptor_shield;
-    instance.max_health = instance.vehicle_health;
+    instance.max_health = GetResource(instance, RES_HEALTH);
 
     if(!autocvar_g_vehicle_raptor_swim)
        instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
@@ -794,10 +792,10 @@ METHOD(Raptor, vr_crosshair, void(Raptor thisveh, entity player))
             where = project_3d_to_2d(trace_endpos);
 
             setorigin(dropmark, trace_endpos);
-            tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
 
             if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
             {
+                tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size;
                 where.x -= tmpSize.x * 0.5;
                 where.y -= tmpSize.y * 0.5;
                 where.z = 0;
@@ -811,10 +809,10 @@ METHOD(Raptor, vr_crosshair, void(Raptor thisveh, entity player))
             if(dropmark.cnt > time)
             {
                 where = project_3d_to_2d(dropmark.origin);
-                tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
 
                 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
                 {
+                    tmpSize = draw_getimagesize(vCROSS_DROP) * autocvar_cl_vehicles_crosshair_size * 1.25;
                     where.x -= tmpSize.x * 0.5;
                     where.y -= tmpSize.y * 0.5;
                     where.z = 0;
@@ -833,4 +831,3 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance))
 }
 
 #endif
-#endif