]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up racer code a little bit, allow customising racer hover type without restarti...
authorMario <mario.mario@y7mail.com>
Sat, 25 Jan 2020 05:12:34 +0000 (15:12 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 25 Jan 2020 05:12:34 +0000 (15:12 +1000)
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc

index 88713e77d70921dd0727b30c79286a0210cf5a01..224f96564e7a0fc7347decf2350fc268b8af92e6 100644 (file)
@@ -1,5 +1,7 @@
 #include "bumblebee.qh"
 
+#ifdef GAMEQC
+
 #ifdef SVQC
        #include <common/mutators/mutator/instagib/sv_instagib.qh>
 #endif
@@ -970,3 +972,5 @@ METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance))
 }
 
 #endif
+
+#endif
index 87804586a2c13130688fc699952e4c6701bc9d0b..21069a94997a4fbf5e93a75c061ffcfeaad74081 100644 (file)
@@ -1,5 +1,7 @@
 #include "racer.qh"
 
+#ifdef GAMEQC
+
 #ifdef SVQC
 #include <common/mapobjects/trigger/impulse.qh>
 
@@ -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
index f0c4dc1ec7afd47a21f5d753d6427971237a4eb5..015f947b2d62bf94ff1a0e4806edc076fa01703e 100644 (file)
@@ -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
index 68b422fad820bac87b4aaf2d276bf64458e82534..ca72ec1b23b034658bcb8617a9e60a2f9a4c9a21 100644 (file)
@@ -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