]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Minor cleanup to vehicle code: make hover tags common code and exclude model data...
authorMario <mario.mario@y7mail.com>
Sun, 1 Nov 2020 15:02:55 +0000 (01:02 +1000)
committerMario <mario.mario@y7mail.com>
Sun, 1 Nov 2020 15:02:55 +0000 (01:02 +1000)
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/cl_vehicles.qh
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh
qcsrc/common/vehicles/vehicle/bumblebee.qh
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/racer.qh
qcsrc/common/vehicles/vehicle/raptor.qh
qcsrc/common/vehicles/vehicle/spiderbot.qh
qcsrc/common/vehicles/vehicles.qc
qcsrc/common/vehicles/vehicles.qh

index 971a5ebad6911bc28abd53b1f26958c614b0f4d1..a9f44a2c2473b090967b8daa3e7fa15625704133 100644 (file)
@@ -1,25 +1,5 @@
 #include "cl_vehicles.qh"
 
-const string vCROSS_BURST = "gfx/vehicles/crosshair_burst.tga";
-const string vCROSS_DROP  = "gfx/vehicles/crosshair_drop.tga";
-const string vCROSS_GUIDE = "gfx/vehicles/crosshair_guide.tga";
-const string vCROSS_HEAL  = "gfx/vehicles/crosshair_heal.tga";
-const string vCROSS_HINT  = "gfx/vehicles/crosshair_hint.tga";
-const string vCROSS_LOCK  = "gfx/vehicles/crosshair_lock.tga";
-const string vCROSS_RAIN  = "gfx/vehicles/crosshair_rain.tga";
-
-entity dropmark;
-
-const int MAX_AXH = 4;
-entity AuxiliaryXhair[MAX_AXH];
-
-.string axh_image;
-.float  axh_fadetime;
-.int    axh_drawflag;
-
-float alarm1time;
-float alarm2time;
-
 void vehicle_alarm(entity e, int ch, Sound s0und)
 {
        TC(Sound, s0und);
index f455e86c68327646456ac32552286e60b229c385..ff9448fdd856f2e26e2477723f470db8b687e836 100644 (file)
@@ -10,6 +10,26 @@ bool autocvar__vehicles_shownchasemessage;
 vector autocvar_hud_progressbar_vehicles_ammo1_color;
 vector autocvar_hud_progressbar_vehicles_ammo2_color;
 
+const string vCROSS_BURST = "gfx/vehicles/crosshair_burst.tga";
+const string vCROSS_DROP  = "gfx/vehicles/crosshair_drop.tga";
+const string vCROSS_GUIDE = "gfx/vehicles/crosshair_guide.tga";
+const string vCROSS_HEAL  = "gfx/vehicles/crosshair_heal.tga";
+const string vCROSS_HINT  = "gfx/vehicles/crosshair_hint.tga";
+const string vCROSS_LOCK  = "gfx/vehicles/crosshair_lock.tga";
+const string vCROSS_RAIN  = "gfx/vehicles/crosshair_rain.tga";
+
+entity dropmark;
+
+const int MAX_AXH = 4;
+entity AuxiliaryXhair[MAX_AXH];
+
+.string axh_image;
+.float  axh_fadetime;
+.int    axh_drawflag;
+
+float alarm1time;
+float alarm2time;
+
 vector vehicleHud_Size;
 vector vehicleHud_Pos;
 
index 8adfb4f0c98f46206215fafbc52f258cae5c775b..bbecb83da6efe8b9cb65641dc66e6f38977e3cab 100644 (file)
@@ -4,6 +4,7 @@
 #include <common/mapobjects/defs.qh>
 #include <common/mapobjects/teleporters.qh>
 #include <common/mapobjects/triggers.qh>
+#include <common/vehicles/vehicles.qh>
 #include <server/bot/api.qh>
 #include <server/client.qh>
 #include <server/damage.qh>
@@ -172,43 +173,6 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
        }
 }
 
-float vehicle_altitude(entity this, float amax)
-{
-       tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * amax), MOVE_WORLDONLY, this);
-       return vlen(this.origin - trace_endpos);
-}
-
-vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power)
-{
-       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
-       v_forward  = normalize(v_forward) * -1;
-       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
-
-       force_fromtag_power = (1 - trace_fraction) * max_power;
-       force_fromtag_normpower = force_fromtag_power / max_power;
-
-       return v_forward  * force_fromtag_power;
-}
-
-vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_length, float max_power)
-{
-       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
-       v_forward  = normalize(v_forward) * -1;
-       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
-
-       // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
-       if(trace_fraction == 1.0)
-       {
-               force_fromtag_normpower = -0.25;
-               return '0 0 -200';
-       }
-
-       force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
-       force_fromtag_normpower = force_fromtag_power / max_power;
-
-       return v_forward  * force_fromtag_power;
-}
-
 // projectile handling
 void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
 {
index a92da29fb03b237f34ba4a4d8be5b0fbc8e90a84..95ab1cfa28777bf1479a9966e7cfa06cf0dd4c06 100644 (file)
@@ -92,10 +92,6 @@ const int VHEF_NORMAL = 0;  /// User pressed exit key
 const int VHEF_EJECT  = 1;  /// User pressed exit key 3 times fast (not implemented) or vehicle is dying
 const int VHEF_RELEASE = 2;  /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented)
 
-float  force_fromtag_power;
-float  force_fromtag_normpower;
-vector force_fromtag_origin;
-
 float vehicles_exit_running;
 
 // macros
@@ -111,7 +107,6 @@ void vehicles_exit(entity vehic, int eject);
 bool vehicle_initialize(entity this, Vehicle info, float nodrop);
 bool vehicle_impulse(entity this, int imp);
 bool vehicles_crushable(entity e);
-float vehicle_altitude(entity this, float amax);
 void vehicles_enter(entity pl, entity veh);
 
 IntrusiveList g_vehicle_returners;
index 4c226f97a86c97fa7adb9a272552d506f6697305..d71dcd6c3f7d18a75fc1a0fe114f30a5c0e0385b 100644 (file)
@@ -8,6 +8,7 @@ CLASS(Bumblebee, Vehicle)
 /* maxs       */ ATTRIB(Bumblebee, m_maxs, vector, '230 130 130');
 /* view offset*/ ATTRIB(Bumblebee, view_ofs, vector, '0 0 300');
 /* view dist  */ ATTRIB(Bumblebee, height, float, 450);
+#ifdef GAMEQC
 /* model         */ ATTRIB(Bumblebee, mdl, string, "models/vehicles/bumblebee_body.dpm");
 /* model         */ ATTRIB(Bumblebee, model, string, "models/vehicles/bumblebee_body.dpm");
 /* head_model */ ATTRIB(Bumblebee, head_model, string, "");
@@ -15,6 +16,7 @@ CLASS(Bumblebee, Vehicle)
 /* tags       */ ATTRIB(Bumblebee, tag_head, string, "");
 /* tags       */ ATTRIB(Bumblebee, tag_hud, string, "");
 /* tags       */ ATTRIB(Bumblebee, tag_view, string, "tag_viewport");
+#endif
 /* netname    */ ATTRIB(Bumblebee, netname, string, "bumblebee");
 /* fullname   */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
 /* icon       */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
index 606d11505a74da5d05e2f19e185a12ad342bcb9d..59c4c9333d25beebc2ee48bcfb31b62ea1862cda 100644 (file)
@@ -155,6 +155,7 @@ bool racer_frame(entity this, float dt)
        entity vehic = player.vehicle;
        return = true;
 
+#ifdef SVQC
        if(game_stopped)
        {
                vehic.solid = SOLID_NOT;
@@ -162,6 +163,7 @@ bool racer_frame(entity this, float dt)
                set_movetype(vehic, MOVETYPE_NONE);
                return;
        }
+#endif
 
        vehicles_frame(vehic, player);
 
@@ -171,15 +173,19 @@ bool racer_frame(entity this, float dt)
        else if (!vehic.racer_air_finished)
                vehic.racer_air_finished = time + autocvar_g_vehicle_racer_water_time;
 
+#ifdef SVQC
        if(IS_DEAD(vehic))
        {
                PHYS_INPUT_BUTTON_ATCK(player) = PHYS_INPUT_BUTTON_ATCK2(player) = false;
                return;
        }
+#endif
 
        racer_align4point(vehic, player, dt);
 
+#ifdef SVQC
        PHYS_INPUT_BUTTON_ZOOM(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false;
+#endif
 
        vehic.angles_x *= -1;
 
@@ -203,17 +209,17 @@ bool racer_frame(entity this, float dt)
        vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction;
        //vehic.velocity_z = ftmp;
 
-       if(CS(player).movement)
+       if(PHYS_CS(player).movement)
        {
                if(cont & DPCONTENTS_LIQUIDSMASK)
                {
-                       if(CS(player).movement_x) { df += v_forward * ((CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
-                       if(CS(player).movement_y) { df += v_right * ((CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
+                       if(PHYS_CS(player).movement_x) { df += v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
+                       if(PHYS_CS(player).movement_y) { df += v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
                }
                else
                {
-                       if(CS(player).movement_x) { df += v_forward * ((CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
-                       if(CS(player).movement_y) { df += v_right * ((CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
+                       if(PHYS_CS(player).movement_x) { df += v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
+                       if(PHYS_CS(player).movement_y) { df += v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
                }
 
 #ifdef SVQC
@@ -291,7 +297,7 @@ bool racer_frame(entity this, float dt)
                dforce = autocvar_g_vehicle_racer_water_downforce;
 
        df -= v_up * (vlen(vehic.velocity) * dforce);
-       CS(player).movement = vehic.velocity += df * dt;
+       PHYS_CS(player).movement = vehic.velocity += df * dt;
 
 #ifdef SVQC
 
@@ -375,10 +381,14 @@ bool racer_frame(entity this, float dt)
 #endif
 
        setorigin(player, vehic.origin + '0 0 32');
+#ifdef SVQC
        player.oldorigin = player.origin; // negate fall damage
+#endif
        player.velocity = vehic.velocity;
 }
+#endif
 
+#ifdef SVQC
 void racer_think(entity this)
 {
        float dt = autocvar_g_vehicle_racer_thinkrate;
index 3c348ae1c2bec1086f65976aa238209778ebd15b..e87d1714bf34d7050d89a586162aaeafa9a9ea57 100644 (file)
@@ -8,6 +8,7 @@ CLASS(Racer, Vehicle)
 /* maxs       */ ATTRIB(Racer, m_maxs, vector, '120 120 40' * 0.5);
 /* view offset*/ ATTRIB(Racer, view_ofs, vector, '0 0 50');
 /* view dist  */ ATTRIB(Racer, height, float, 200);
+#ifdef GAMEQC
 /* model         */ ATTRIB(Racer, mdl, string, "models/vehicles/wakizashi.dpm");
 /* model         */ ATTRIB(Racer, model, string, "models/vehicles/wakizashi.dpm");
 /* head_model */ ATTRIB(Racer, head_model, string, "null");
@@ -15,6 +16,7 @@ CLASS(Racer, Vehicle)
 /* tags       */ ATTRIB(Racer, tag_head, string, "");
 /* tags       */ ATTRIB(Racer, tag_hud, string, "");
 /* tags       */ ATTRIB(Racer, tag_view, string, "tag_viewport");
+#endif
 /* netname    */ ATTRIB(Racer, netname, string, "racer");
 /* fullname   */ ATTRIB(Racer, vehicle_name, string, _("Racer"));
 /* icon       */ ATTRIB(Racer, m_icon, string, "vehicle_racer");
index 954d54aea1e0fbf8f68276a1492952fb64a238ad..2532a9cbe969984dc6dd4ebcbdb32ed49af2d250 100644 (file)
@@ -8,6 +8,7 @@ CLASS(Raptor, Vehicle)
 /* maxs       */ ATTRIB(Raptor, m_maxs, vector, '80 80 70');
 /* view offset*/ ATTRIB(Raptor, view_ofs, vector, '0 0 160');
 /* view dist  */ ATTRIB(Raptor, height, float, 200);
+#ifdef GAMEQC
 /* model         */ ATTRIB(Raptor, mdl, string, "models/vehicles/raptor.dpm");
 /* model         */ ATTRIB(Raptor, model, string, "models/vehicles/raptor.dpm");
 /* head_model */ ATTRIB(Raptor, head_model, string, "");
@@ -15,6 +16,7 @@ CLASS(Raptor, Vehicle)
 /* tags       */ ATTRIB(Raptor, tag_head, string, "");
 /* tags       */ ATTRIB(Raptor, tag_hud, string, "tag_hud");
 /* tags       */ ATTRIB(Raptor, tag_view, string, "tag_camera");
+#endif
 /* netname    */ ATTRIB(Raptor, netname, string, "raptor");
 /* fullname   */ ATTRIB(Raptor, vehicle_name, string, _("Raptor"));
 /* icon       */ ATTRIB(Raptor, m_icon, string, "vehicle_raptor");
index 414e0f805fad1dfa23c92116c797cc37e26ca711..8301cd60754a8fa55e2b105b5e6832be0577617d 100644 (file)
@@ -8,6 +8,7 @@ CLASS(Spiderbot, Vehicle)
 /* maxs       */ ATTRIB(Spiderbot, m_maxs, vector, '75 75 125');
 /* view offset*/ ATTRIB(Spiderbot, view_ofs, vector, '0 0 70');
 /* view dist  */ ATTRIB(Spiderbot, height, float, 170);
+#ifdef GAMEQC
 /* 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");
@@ -15,6 +16,7 @@ CLASS(Spiderbot, Vehicle)
 /* tags       */ ATTRIB(Spiderbot, tag_head, string, "tag_head");
 /* tags       */ ATTRIB(Spiderbot, tag_hud, string, "tag_hud");
 /* tags       */ ATTRIB(Spiderbot, tag_view, string, "");
+#endif
 /* netname    */ ATTRIB(Spiderbot, netname, string, "spiderbot");
 /* fullname   */ ATTRIB(Spiderbot, vehicle_name, string, _("Spiderbot"));
 /* icon       */ ATTRIB(Spiderbot, m_icon, string, "vehicle_spider");
index 5e7736501b28e6c2ae3a8e6ed19ee0a521cd4b24..c96fff633999f006ed506adf785bc3c6c8fd3aac 100644 (file)
@@ -1 +1,40 @@
 #include "vehicles.qh"
+
+#ifdef GAMEQC
+float vehicle_altitude(entity this, float amax)
+{
+       tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * amax), MOVE_WORLDONLY, this);
+       return vlen(this.origin - trace_endpos);
+}
+
+vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power)
+{
+       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
+       v_forward  = normalize(v_forward) * -1;
+       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
+
+       force_fromtag_power = (1 - trace_fraction) * max_power;
+       force_fromtag_normpower = force_fromtag_power / max_power;
+
+       return v_forward  * force_fromtag_power;
+}
+
+vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_length, float max_power)
+{
+       force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name));
+       v_forward  = normalize(v_forward) * -1;
+       traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, this);
+
+       // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
+       if(trace_fraction == 1.0)
+       {
+               force_fromtag_normpower = -0.25;
+               return '0 0 -200';
+       }
+
+       force_fromtag_power = ((1 - trace_fraction) - trace_fraction) * max_power;
+       force_fromtag_normpower = force_fromtag_power / max_power;
+
+       return v_forward  * force_fromtag_power;
+}
+#endif
index 6f70f09beec2219624baeca92e2cd7deaa104fb4..6e1bcd1a1320bb7a2ca772f298e5dd39f657ec92 100644 (file)
@@ -1 +1,13 @@
 #pragma once
+
+#ifdef GAMEQC
+float force_fromtag_power;
+float force_fromtag_normpower;
+vector force_fromtag_origin;
+
+float vehicle_altitude(entity this, float amax);
+
+vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power);
+
+vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_length, float max_power);
+#endif