From 332093fd038d8de235e44c351b94a893ca0c0831 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Jan 2020 15:12:34 +1000 Subject: [PATCH] Clean up racer code a little bit, allow customising racer hover type without restarting the match --- qcsrc/common/vehicles/vehicle/bumblebee.qc | 4 ++ qcsrc/common/vehicles/vehicle/racer.qc | 65 +++++++++++----------- qcsrc/common/vehicles/vehicle/raptor.qc | 4 ++ qcsrc/common/vehicles/vehicle/spiderbot.qc | 4 ++ 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 88713e77d..224f96564 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -1,5 +1,7 @@ #include "bumblebee.qh" +#ifdef GAMEQC + #ifdef SVQC #include #endif @@ -970,3 +972,5 @@ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance)) } #endif + +#endif diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 87804586a..21069a949 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -1,5 +1,7 @@ #include "racer.qh" +#ifdef GAMEQC + #ifdef SVQC #include @@ -77,26 +79,26 @@ vector autocvar_g_vehicle_racer_bouncepain = '200 0.15 150'; .float racer_watertime; -var vector racer_force_from_tag(entity this, string tag_name, float spring_length, float max_power); +var .vector(entity this, string tag_name, float spring_length, float max_power) racer_force_from_tag; -void racer_align4point(entity this, float _delta) +void racer_align4point(entity this, entity player, float _delta) { vector push_vector; float fl_push, fr_push, bl_push, br_push; - push_vector = racer_force_from_tag(this, "tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector = this.racer_force_from_tag(this, "tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); fr_push = force_fromtag_normpower; //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag(this, "tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += this.racer_force_from_tag(this, "tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); fl_push = force_fromtag_normpower; //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag(this, "tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += this.racer_force_from_tag(this, "tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); br_push = force_fromtag_normpower; //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag(this, "tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += this.racer_force_from_tag(this, "tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); bl_push = force_fromtag_normpower; //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); @@ -109,7 +111,7 @@ void racer_align4point(entity this, float _delta) { uforce = autocvar_g_vehicle_racer_water_upforcedamper; - if(PHYS_INPUT_BUTTON_CROUCH(this.owner) && time < this.air_finished) + if(PHYS_INPUT_BUTTON_CROUCH(player) && time < this.air_finished) this.velocity_z += 30; else this.velocity_z += 200; @@ -169,7 +171,7 @@ bool racer_frame(entity this, float dt) return; } - racer_align4point(vehic, dt); + racer_align4point(vehic, player, dt); PHYS_INPUT_BUTTON_ZOOM(player) = PHYS_INPUT_BUTTON_CROUCH(player) = false; @@ -371,7 +373,9 @@ bool racer_frame(entity this, float dt) void racer_think(entity this) { - this.nextthink = time + autocvar_g_vehicle_racer_thinkrate; + float dt = autocvar_g_vehicle_racer_thinkrate; + + this.nextthink = time + dt; tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, this); @@ -389,12 +393,12 @@ void racer_think(entity this) this.velocity_z += 200; } - this.velocity += df * autocvar_g_vehicle_racer_thinkrate; + this.velocity += df * dt; if(this.velocity_z > 0) - this.velocity_z *= 1 - forced * autocvar_g_vehicle_racer_thinkrate; + this.velocity_z *= 1 - forced * dt; - this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * autocvar_g_vehicle_racer_thinkrate); - this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * autocvar_g_vehicle_racer_thinkrate); + this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt); + this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt); CSQCMODEL_AUTOUPDATE(this); } @@ -474,7 +478,7 @@ void racer_blowup_think(entity this) if(time >= this.delay) racer_blowup(this); - CSQCMODEL_AUTOUPDATE(this); + //CSQCMODEL_AUTOUPDATE(this); } void racer_deadtouch(entity this, entity toucher) @@ -503,35 +507,23 @@ METHOD(Racer, vr_impact, void(Racer thisveh, entity instance)) METHOD(Racer, vr_enter, void(Racer thisveh, entity instance)) { -#ifdef SVQC set_movetype(instance, MOVETYPE_BOUNCE); +#ifdef SVQC instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_racer_health) * 100; instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100; if(instance.owner.flagcarried) setorigin(instance.owner.flagcarried, '-190 0 96'); -#elif defined(CSQC) - set_movetype(instance, MOVETYPE_BOUNCE); #endif } METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance)) { #ifdef SVQC - if(instance.scale != 0.5) - { - if(autocvar_g_vehicle_racer_hovertype != 0) - racer_force_from_tag = vehicles_force_fromtag_maglev; - else - racer_force_from_tag = vehicles_force_fromtag_hover; - - // FIXME: this be hakkz, fix the models insted (scale body, add tag_viewport to the hudmodel). - instance.scale = 0.5; - setattachment(instance.vehicle_hudmodel, instance, ""); - setattachment(instance.vehicle_viewport, instance, "tag_viewport"); - - instance.mass = 900; - } + if(autocvar_g_vehicle_racer_hovertype != 0) + instance.racer_force_from_tag = vehicles_force_fromtag_maglev; + else + instance.racer_force_from_tag = vehicles_force_fromtag_hover; setthink(instance, racer_think); instance.nextthink = time; @@ -541,7 +533,11 @@ METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance)) set_movetype(instance, MOVETYPE_TOSS); instance.solid = SOLID_SLIDEBOX; instance.delay = time; - instance.scale = 0.5; + instance.scale = 0.5; // FIXME: this be hakkz, fix the models insted (scale body, add tag_viewport to the hudmodel). + instance.mass = 900; + + setattachment(instance.vehicle_hudmodel, instance, ""); + setattachment(instance.vehicle_viewport, instance, "tag_viewport"); instance.PlayerPhysplug = racer_frame; @@ -602,8 +598,7 @@ METHOD(Racer, vr_setup, void(Racer thisveh, entity instance)) instance.vehicle_exit = racer_exit; // we have no need to network energy - if(autocvar_g_vehicle_racer_energy) - if(autocvar_g_vehicle_racer_energy_regen) + if(autocvar_g_vehicle_racer_energy && autocvar_g_vehicle_racer_energy_regen) instance.vehicle_flags |= VHF_ENERGYREGEN; if(autocvar_g_vehicle_racer_shield) @@ -625,3 +620,5 @@ METHOD(Racer, vr_setup, void(Racer thisveh, entity instance)) AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Rocket #endif } + +#endif diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index f0c4dc1ec..015f947b2 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -1,5 +1,7 @@ #include "raptor.qh" +#ifdef GAMEQC + #ifdef SVQC bool autocvar_g_vehicle_raptor = true; @@ -831,3 +833,5 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance)) } #endif + +#endif diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 68b422fad..ca72ec1b2 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -1,5 +1,7 @@ #include "spiderbot.qh" +#ifdef GAMEQC + const int SBRM_FIRST = 1; const int SBRM_VOLLY = 1; const int SBRM_GUIDE = 2; @@ -637,3 +639,5 @@ METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance)) } #endif + +#endif -- 2.39.2