From 2b18b279a8222a72ba713e6d3b72c2cba888407b Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 2 Nov 2020 01:02:55 +1000 Subject: [PATCH] Minor cleanup to vehicle code: make hover tags common code and exclude model data from the menu VM --- qcsrc/common/vehicles/cl_vehicles.qc | 20 ----------- qcsrc/common/vehicles/cl_vehicles.qh | 20 +++++++++++ qcsrc/common/vehicles/sv_vehicles.qc | 38 +-------------------- qcsrc/common/vehicles/sv_vehicles.qh | 5 --- qcsrc/common/vehicles/vehicle/bumblebee.qh | 2 ++ qcsrc/common/vehicles/vehicle/racer.qc | 22 ++++++++---- qcsrc/common/vehicles/vehicle/racer.qh | 2 ++ qcsrc/common/vehicles/vehicle/raptor.qh | 2 ++ qcsrc/common/vehicles/vehicle/spiderbot.qh | 2 ++ qcsrc/common/vehicles/vehicles.qc | 39 ++++++++++++++++++++++ qcsrc/common/vehicles/vehicles.qh | 12 +++++++ 11 files changed, 96 insertions(+), 68 deletions(-) diff --git a/qcsrc/common/vehicles/cl_vehicles.qc b/qcsrc/common/vehicles/cl_vehicles.qc index 971a5ebad..a9f44a2c2 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qc +++ b/qcsrc/common/vehicles/cl_vehicles.qc @@ -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); diff --git a/qcsrc/common/vehicles/cl_vehicles.qh b/qcsrc/common/vehicles/cl_vehicles.qh index f455e86c6..ff9448fdd 100644 --- a/qcsrc/common/vehicles/cl_vehicles.qh +++ b/qcsrc/common/vehicles/cl_vehicles.qh @@ -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; diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 8adfb4f0c..bbecb83da 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -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) { diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index a92da29fb..95ab1cfa2 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qh b/qcsrc/common/vehicles/vehicle/bumblebee.qh index 4c226f97a..d71dcd6c3 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qh +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qh @@ -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"); diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 606d11505..59c4c9333 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/racer.qh b/qcsrc/common/vehicles/vehicle/racer.qh index 3c348ae1c..e87d1714b 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qh +++ b/qcsrc/common/vehicles/vehicle/racer.qh @@ -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"); diff --git a/qcsrc/common/vehicles/vehicle/raptor.qh b/qcsrc/common/vehicles/vehicle/raptor.qh index 954d54aea..2532a9cbe 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qh +++ b/qcsrc/common/vehicles/vehicle/raptor.qh @@ -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"); diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qh b/qcsrc/common/vehicles/vehicle/spiderbot.qh index 414e0f805..8301cd607 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qh +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qh @@ -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"); diff --git a/qcsrc/common/vehicles/vehicles.qc b/qcsrc/common/vehicles/vehicles.qc index 5e7736501..c96fff633 100644 --- a/qcsrc/common/vehicles/vehicles.qc +++ b/qcsrc/common/vehicles/vehicles.qc @@ -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 diff --git a/qcsrc/common/vehicles/vehicles.qh b/qcsrc/common/vehicles/vehicles.qh index 6f70f09be..6e1bcd1a1 100644 --- a/qcsrc/common/vehicles/vehicles.qh +++ b/qcsrc/common/vehicles/vehicles.qh @@ -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 -- 2.39.2