]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc
Remove the g_ prefix from some server code files and rename sv_main to main
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / bugrigs / bugrigs.qc
index 9eb16b040d7d3d64a0fcc1aadae974b7ae6f3d08..38a687f014556ec386a130e42adb7478fc9e5bb2 100644 (file)
@@ -1,20 +1,21 @@
-#ifdef IMPLEMENTATION
+#include "bugrigs.qh"
+
+#ifdef GAMEQC
+
 #ifdef SVQC
-       #include "../../../../server/antilag.qh"
+       #include <server/antilag.qh>
 #endif
-#include "../../../physics.qh"
+#include <common/physics/player.qh>
 
 
 #if defined(SVQC)
 void bugrigs_SetVars();
-void bugrigs_AddStats();
 
 REGISTER_MUTATOR(bugrigs, cvar("g_bugrigs"))
 {
        MUTATOR_ONADD
        {
                bugrigs_SetVars();
-               bugrigs_AddStats();
        }
        return false;
 }
@@ -23,73 +24,23 @@ REGISTER_MUTATOR(bugrigs, true);
 #endif
 
 
-#ifdef CSQC
-
-#define PHYS_BUGRIGS                                           getstati(STAT_BUGRIGS)
-#define PHYS_BUGRIGS_ANGLE_SMOOTHING           getstati(STAT_BUGRIGS_ANGLE_SMOOTHING)
-#define PHYS_BUGRIGS_PLANAR_MOVEMENT           getstati(STAT_BUGRIGS_PLANAR_MOVEMENT)
-#define PHYS_BUGRIGS_REVERSE_SPEEDING          getstati(STAT_BUGRIGS_REVERSE_SPEEDING)
-#define PHYS_BUGRIGS_FRICTION_FLOOR            getstatf(STAT_BUGRIGS_FRICTION_FLOOR)
-#define PHYS_BUGRIGS_AIR_STEERING                      getstati(STAT_BUGRIGS_AIR_STEERING)
-#define PHYS_BUGRIGS_FRICTION_BRAKE            getstatf(STAT_BUGRIGS_FRICTION_BRAKE)
-#define PHYS_BUGRIGS_ACCEL                                     getstatf(STAT_BUGRIGS_ACCEL)
-#define PHYS_BUGRIGS_SPEED_REF                                 getstatf(STAT_BUGRIGS_SPEED_REF)
-#define PHYS_BUGRIGS_SPEED_POW                                 getstatf(STAT_BUGRIGS_SPEED_POW)
-#define PHYS_BUGRIGS_STEER                                     getstatf(STAT_BUGRIGS_STEER)
-#define PHYS_BUGRIGS_FRICTION_AIR                      getstatf(STAT_BUGRIGS_FRICTION_AIR)
-#define PHYS_BUGRIGS_CAR_JUMPING                       getstatf(STAT_BUGRIGS_CAR_JUMPING)
-#define PHYS_BUGRIGS_REVERSE_SPINNING          getstatf(STAT_BUGRIGS_REVERSE_SPINNING)
-#define PHYS_BUGRIGS_REVERSE_STOPPING          getstatf(STAT_BUGRIGS_REVERSE_STOPPING)
-
-#elif defined(SVQC)
-
-bool g_bugrigs;
-bool g_bugrigs_planar_movement;
-bool g_bugrigs_planar_movement_car_jumping;
-float g_bugrigs_reverse_spinning;
-float g_bugrigs_reverse_speeding;
-float g_bugrigs_reverse_stopping;
-float g_bugrigs_air_steering;
-float g_bugrigs_angle_smoothing;
-float g_bugrigs_friction_floor;
-float g_bugrigs_friction_brake;
-float g_bugrigs_friction_air;
-float g_bugrigs_accel;
-float g_bugrigs_speed_ref;
-float g_bugrigs_speed_pow;
-float g_bugrigs_steer;
-
-#define PHYS_BUGRIGS                                           g_bugrigs
-#define PHYS_BUGRIGS_ANGLE_SMOOTHING           g_bugrigs_angle_smoothing
-#define PHYS_BUGRIGS_PLANAR_MOVEMENT           g_bugrigs_planar_movement
-#define PHYS_BUGRIGS_REVERSE_SPEEDING          g_bugrigs_reverse_speeding
-#define PHYS_BUGRIGS_FRICTION_FLOOR                    g_bugrigs_friction_floor
-#define PHYS_BUGRIGS_AIR_STEERING                      g_bugrigs_air_steering
-#define PHYS_BUGRIGS_FRICTION_BRAKE                    g_bugrigs_friction_brake
-#define PHYS_BUGRIGS_ACCEL                                     g_bugrigs_accel
-#define PHYS_BUGRIGS_SPEED_REF                         g_bugrigs_speed_ref
-#define PHYS_BUGRIGS_SPEED_POW                         g_bugrigs_speed_pow
-#define PHYS_BUGRIGS_STEER                                     g_bugrigs_steer
-#define PHYS_BUGRIGS_FRICTION_AIR                      g_bugrigs_friction_air
-#define PHYS_BUGRIGS_CAR_JUMPING                       g_bugrigs_planar_movement_car_jumping
-#define PHYS_BUGRIGS_REVERSE_SPINNING          g_bugrigs_reverse_spinning
-#define PHYS_BUGRIGS_REVERSE_STOPPING          g_bugrigs_reverse_stopping
-
-.float stat_bugrigs;
-.float stat_bugrigs_angle_smoothing;
-.float stat_bugrigs_planar_movement;
-.float stat_bugrigs_reverse_speeding;
-.float stat_bugrigs_friction_floor;
-.float stat_bugrigs_air_steering;
-.float stat_bugrigs_friction_brake;
-.float stat_bugrigs_accel;
-.float stat_bugrigs_speed_ref;
-.float stat_bugrigs_speed_pow;
-.float stat_bugrigs_steer;
-.float stat_bugrigs_friction_air;
-.float stat_bugrigs_car_jumping;
-.float stat_bugrigs_reverse_spinning;
-.float stat_bugrigs_reverse_stopping;
+#define PHYS_BUGRIGS(s)                        STAT(BUGRIGS, s)
+#define PHYS_BUGRIGS_ACCEL(s)                  STAT(BUGRIGS_ACCEL, s)
+#define PHYS_BUGRIGS_AIR_STEERING(s)           STAT(BUGRIGS_AIR_STEERING, s)
+#define PHYS_BUGRIGS_ANGLE_SMOOTHING(s)        STAT(BUGRIGS_ANGLE_SMOOTHING, s)
+#define PHYS_BUGRIGS_CAR_JUMPING(s)            STAT(BUGRIGS_CAR_JUMPING, s)
+#define PHYS_BUGRIGS_FRICTION_AIR(s)           STAT(BUGRIGS_FRICTION_AIR, s)
+#define PHYS_BUGRIGS_FRICTION_BRAKE(s)         STAT(BUGRIGS_FRICTION_BRAKE, s)
+#define PHYS_BUGRIGS_FRICTION_FLOOR(s)         STAT(BUGRIGS_FRICTION_FLOOR, s)
+#define PHYS_BUGRIGS_PLANAR_MOVEMENT(s)        STAT(BUGRIGS_PLANAR_MOVEMENT, s)
+#define PHYS_BUGRIGS_REVERSE_SPEEDING(s)       STAT(BUGRIGS_REVERSE_SPEEDING, s)
+#define PHYS_BUGRIGS_REVERSE_SPINNING(s)       STAT(BUGRIGS_REVERSE_SPINNING, s)
+#define PHYS_BUGRIGS_REVERSE_STOPPING(s)       STAT(BUGRIGS_REVERSE_STOPPING, s)
+#define PHYS_BUGRIGS_SPEED_POW(s)              STAT(BUGRIGS_SPEED_POW, s)
+#define PHYS_BUGRIGS_SPEED_REF(s)              STAT(BUGRIGS_SPEED_REF, s)
+#define PHYS_BUGRIGS_STEER(s)                  STAT(BUGRIGS_STEER, s)
+
+#if defined(SVQC)
 
 void bugrigs_SetVars()
 {
@@ -110,47 +61,27 @@ void bugrigs_SetVars()
        g_bugrigs_steer = cvar("g_bugrigs_steer");
 }
 
-void bugrigs_UpdateStats(entity this)
-{
-       this.stat_bugrigs = PHYS_BUGRIGS;
-       this.stat_bugrigs_angle_smoothing = PHYS_BUGRIGS_ANGLE_SMOOTHING;
-       this.stat_bugrigs_planar_movement = PHYS_BUGRIGS_PLANAR_MOVEMENT;
-       this.stat_bugrigs_reverse_speeding = PHYS_BUGRIGS_REVERSE_SPEEDING;
-       this.stat_bugrigs_friction_floor = PHYS_BUGRIGS_FRICTION_FLOOR;
-       this.stat_bugrigs_air_steering = PHYS_BUGRIGS_AIR_STEERING;
-       this.stat_bugrigs_friction_brake = PHYS_BUGRIGS_FRICTION_BRAKE;
-       this.stat_bugrigs_accel = PHYS_BUGRIGS_ACCEL;
-       this.stat_bugrigs_speed_ref = PHYS_BUGRIGS_SPEED_REF;
-       this.stat_bugrigs_speed_pow = PHYS_BUGRIGS_SPEED_POW;
-       this.stat_bugrigs_steer = PHYS_BUGRIGS_STEER;
-       this.stat_bugrigs_friction_air = PHYS_BUGRIGS_FRICTION_AIR;
-       this.stat_bugrigs_car_jumping = PHYS_BUGRIGS_CAR_JUMPING;
-       this.stat_bugrigs_reverse_spinning = PHYS_BUGRIGS_REVERSE_SPINNING;
-       this.stat_bugrigs_reverse_stopping = PHYS_BUGRIGS_REVERSE_STOPPING;
-}
+#endif
 
-void bugrigs_AddStats()
+float racecar_angle(float forward, float down)
 {
-       addstat(STAT_BUGRIGS, AS_INT, stat_bugrigs);
-       addstat(STAT_BUGRIGS_ANGLE_SMOOTHING, AS_INT, stat_bugrigs_angle_smoothing);
-       addstat(STAT_BUGRIGS_PLANAR_MOVEMENT, AS_INT, stat_bugrigs_planar_movement);
-       addstat(STAT_BUGRIGS_REVERSE_SPEEDING, AS_INT, stat_bugrigs_reverse_speeding);
-       addstat(STAT_BUGRIGS_FRICTION_FLOOR, AS_FLOAT, stat_bugrigs_friction_floor);
-       addstat(STAT_BUGRIGS_AIR_STEERING, AS_INT, stat_bugrigs_air_steering);
-       addstat(STAT_BUGRIGS_FRICTION_BRAKE, AS_FLOAT, stat_bugrigs_friction_brake);
-       addstat(STAT_BUGRIGS_ACCEL, AS_FLOAT, stat_bugrigs_accel);
-       addstat(STAT_BUGRIGS_SPEED_REF, AS_FLOAT, stat_bugrigs_speed_ref);
-       addstat(STAT_BUGRIGS_SPEED_POW, AS_FLOAT, stat_bugrigs_speed_pow);
-       addstat(STAT_BUGRIGS_STEER, AS_FLOAT, stat_bugrigs_steer);
-       addstat(STAT_BUGRIGS_FRICTION_AIR, AS_FLOAT, stat_bugrigs_friction_air);
-       addstat(STAT_BUGRIGS_CAR_JUMPING, AS_FLOAT, stat_bugrigs_car_jumping);
-       addstat(STAT_BUGRIGS_REVERSE_SPINNING, AS_FLOAT, stat_bugrigs_reverse_spinning);
-       addstat(STAT_BUGRIGS_REVERSE_STOPPING, AS_FLOAT, stat_bugrigs_reverse_stopping);
-}
+       if (forward < 0)
+       {
+               forward = -forward;
+               down = -down;
+       }
 
-#endif
+       float ret = vectoyaw('0 1 0' * down + '1 0 0' * forward);
+
+       float angle_mult = forward / (800 + forward);
 
-void RaceCarPhysics(entity this)
+       if (ret > 180)
+               return ret * angle_mult + 360 * (1 - angle_mult);
+       else
+               return ret * angle_mult;
+}
+
+void RaceCarPhysics(entity this, float dt)
 {
        // using this move type for "big rigs"
        // the engine does not push the entity!
@@ -158,10 +89,10 @@ void RaceCarPhysics(entity this)
        vector rigvel;
 
        vector angles_save = this.angles;
-       float accel = bound(-1, this.movement.x / PHYS_MAXSPEED(this), 1);
-       float steer = bound(-1, this.movement.y / PHYS_MAXSPEED(this), 1);
+       float accel = bound(-1, PHYS_CS(this).movement.x / PHYS_MAXSPEED(this), 1);
+       float steer = bound(-1, PHYS_CS(this).movement.y / PHYS_MAXSPEED(this), 1);
 
-       if (PHYS_BUGRIGS_REVERSE_SPEEDING)
+       if (PHYS_BUGRIGS_REVERSE_SPEEDING(this))
        {
                if (accel < 0)
                {
@@ -178,61 +109,61 @@ void RaceCarPhysics(entity this)
        this.angles_z = 0;
        makevectors(this.angles); // new forward direction!
 
-       if (IS_ONGROUND(this) || PHYS_BUGRIGS_AIR_STEERING)
+       if (IS_ONGROUND(this) || PHYS_BUGRIGS_AIR_STEERING(this))
        {
                float myspeed = this.velocity * v_forward;
                float upspeed = this.velocity * v_up;
 
                // responsiveness factor for steering and acceleration
-               float f = 1 / (1 + pow(max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF, PHYS_BUGRIGS_SPEED_POW));
-               //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF) ^ PHYS_BUGRIGS_SPEED_POW);
+               float f = 1 / (1 + ((max(-myspeed, myspeed) / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this)));
+               //MAXIMA: f(v) := 1 / (1 + (v / PHYS_BUGRIGS_SPEED_REF(this)) ^ PHYS_BUGRIGS_SPEED_POW(this));
 
                float steerfactor;
-               if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPINNING)
-                       steerfactor = -myspeed * PHYS_BUGRIGS_STEER;
+               if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPINNING(this))
+                       steerfactor = -myspeed * PHYS_BUGRIGS_STEER(this);
                else
-                       steerfactor = -myspeed * f * PHYS_BUGRIGS_STEER;
+                       steerfactor = -myspeed * f * PHYS_BUGRIGS_STEER(this);
 
                float accelfactor;
-               if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPEEDING)
-                       accelfactor = PHYS_BUGRIGS_ACCEL;
+               if (myspeed < 0 && PHYS_BUGRIGS_REVERSE_SPEEDING(this))
+                       accelfactor = PHYS_BUGRIGS_ACCEL(this);
                else
-                       accelfactor = f * PHYS_BUGRIGS_ACCEL;
-               //MAXIMA: accel(v) := f(v) * PHYS_BUGRIGS_ACCEL;
+                       accelfactor = f * PHYS_BUGRIGS_ACCEL(this);
+               //MAXIMA: accel(v) := f(v) * PHYS_BUGRIGS_ACCEL(this);
 
                if (accel < 0)
                {
                        if (myspeed > 0)
                        {
-                               myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR - PHYS_BUGRIGS_FRICTION_BRAKE * accel));
+                               myspeed = max(0, myspeed - dt * (PHYS_BUGRIGS_FRICTION_FLOOR(this) - PHYS_BUGRIGS_FRICTION_BRAKE(this) * accel));
                        }
                        else
                        {
-                               if (!PHYS_BUGRIGS_REVERSE_SPEEDING)
-                                       myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR);
+                               if (!PHYS_BUGRIGS_REVERSE_SPEEDING(this))
+                                       myspeed = min(0, myspeed + dt * PHYS_BUGRIGS_FRICTION_FLOOR(this));
                        }
                }
                else
                {
                        if (myspeed >= 0)
                        {
-                               myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_FRICTION_FLOOR);
+                               myspeed = max(0, myspeed - dt * PHYS_BUGRIGS_FRICTION_FLOOR(this));
                        }
                        else
                        {
-                               if (PHYS_BUGRIGS_REVERSE_STOPPING)
+                               if (PHYS_BUGRIGS_REVERSE_STOPPING(this))
                                        myspeed = 0;
                                else
-                                       myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (PHYS_BUGRIGS_FRICTION_FLOOR + PHYS_BUGRIGS_FRICTION_BRAKE * accel));
+                                       myspeed = min(0, myspeed + dt * (PHYS_BUGRIGS_FRICTION_FLOOR(this) + PHYS_BUGRIGS_FRICTION_BRAKE(this) * accel));
                        }
                }
                // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec
-               //MAXIMA: friction(v) := PHYS_BUGRIGS_FRICTION_FLOOR;
+               //MAXIMA: friction(v) := PHYS_BUGRIGS_FRICTION_FLOOR(this);
 
-               this.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
+               this.angles_y += steer * dt * steerfactor; // apply steering
                makevectors(this.angles); // new forward direction!
 
-               myspeed += accel * accelfactor * PHYS_INPUT_TIMELENGTH;
+               myspeed += accel * accelfactor * dt;
 
                rigvel = myspeed * v_forward + '0 0 1' * upspeed;
        }
@@ -241,28 +172,28 @@ void RaceCarPhysics(entity this)
                float myspeed = vlen(this.velocity);
 
                // responsiveness factor for steering and acceleration
-               float f = 1 / (1 + pow(max(0, myspeed / PHYS_BUGRIGS_SPEED_REF), PHYS_BUGRIGS_SPEED_POW));
+               float f = 1 / (1 + (max(0, myspeed / PHYS_BUGRIGS_SPEED_REF(this)) ** PHYS_BUGRIGS_SPEED_POW(this)));
                float steerfactor = -myspeed * f;
-               this.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering
+               this.angles_y += steer * dt * steerfactor; // apply steering
 
                rigvel = this.velocity;
                makevectors(this.angles); // new forward direction!
        }
 
-       rigvel *= max(0, 1 - vlen(rigvel) * PHYS_BUGRIGS_FRICTION_AIR * PHYS_INPUT_TIMELENGTH);
-       //MAXIMA: airfriction(v) := v * v * PHYS_BUGRIGS_FRICTION_AIR;
+       rigvel *= max(0, 1 - vlen(rigvel) * PHYS_BUGRIGS_FRICTION_AIR(this) * dt);
+       //MAXIMA: airfriction(v) := v * v * PHYS_BUGRIGS_FRICTION_AIR(this);
        //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v);
        //MAXIMA: solve(total_acceleration(v) = 0, v);
 
-       if (PHYS_BUGRIGS_PLANAR_MOVEMENT)
+       if (PHYS_BUGRIGS_PLANAR_MOVEMENT(this))
        {
                vector rigvel_xy, neworigin, up;
                float mt;
 
-               rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
+               rigvel_z -= dt * PHYS_GRAVITY(this); // 4x gravity plays better
                rigvel_xy = vec2(rigvel);
 
-               if (PHYS_BUGRIGS_CAR_JUMPING)
+               if (PHYS_BUGRIGS_CAR_JUMPING(this))
                        mt = MOVE_NORMAL;
                else
                        mt = MOVE_NOMONSTERS;
@@ -272,10 +203,10 @@ void RaceCarPhysics(entity this)
 
                // BUG RIGS: align the move to the surface instead of doing collision testing
                // can we move?
-               tracebox(trace_endpos, this.mins, this.maxs, trace_endpos + rigvel_xy * PHYS_INPUT_TIMELENGTH, mt, this);
+               tracebox(trace_endpos, this.mins, this.maxs, trace_endpos + rigvel_xy * dt, mt, this);
 
                // align to surface
-               tracebox(trace_endpos, this.mins, this.maxs, trace_endpos - up + '0 0 1' * rigvel_z * PHYS_INPUT_TIMELENGTH, mt, this);
+               tracebox(trace_endpos, this.mins, this.maxs, trace_endpos - up + '0 0 1' * rigvel_z * dt, mt, this);
 
                if (trace_fraction < 0.5)
                {
@@ -289,11 +220,11 @@ void RaceCarPhysics(entity this)
                {
                        // now set angles_x so that the car points parallel to the surface
                        this.angles = vectoangles(
-                                       '1 0 0' * v_forward_x * trace_plane_normal_z
+                                       '1 0 0' * v_forward.x * trace_plane_normal.z
                                        +
-                                       '0 1 0' * v_forward_y * trace_plane_normal_z
+                                       '0 1 0' * v_forward.y * trace_plane_normal.z
                                        +
-                                       '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
+                                       '0 0 1' * -(v_forward.x * trace_plane_normal.x + v_forward.y * trace_plane_normal.y)
                                        );
                        SET_ONGROUND(this);
                }
@@ -303,14 +234,14 @@ void RaceCarPhysics(entity this)
                        UNSET_ONGROUND(this);
                }
 
-               this.velocity = (neworigin - this.origin) * (1.0 / PHYS_INPUT_TIMELENGTH);
-               this.movetype = MOVETYPE_NOCLIP;
+               this.velocity = (neworigin - this.origin) * (1.0 / dt);
+               set_movetype(this, MOVETYPE_NOCLIP);
        }
        else
        {
-               rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better
+               rigvel_z -= dt * PHYS_GRAVITY(this); // 4x gravity plays better
                this.velocity = rigvel;
-               this.movetype = MOVETYPE_FLY;
+               set_movetype(this, MOVETYPE_FLY);
        }
 
        trace_fraction = 1;
@@ -318,11 +249,11 @@ void RaceCarPhysics(entity this)
        if (trace_fraction != 1)
        {
                this.angles = vectoangles2(
-                               '1 0 0' * v_forward_x * trace_plane_normal_z
+                               '1 0 0' * v_forward.x * trace_plane_normal.z
                                +
-                               '0 1 0' * v_forward_y * trace_plane_normal_z
+                               '0 1 0' * v_forward.y * trace_plane_normal.z
                                +
-                               '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y),
+                               '0 0 1' * -(v_forward.x * trace_plane_normal.x + v_forward.y * trace_plane_normal.y),
                                trace_plane_normal
                                );
        }
@@ -330,18 +261,18 @@ void RaceCarPhysics(entity this)
        {
                vector vel_local;
 
-               vel_local_x = v_forward * this.velocity;
-               vel_local_y = v_right * this.velocity;
-               vel_local_z = v_up * this.velocity;
+               vel_local.x = v_forward * this.velocity;
+               vel_local.y = v_right * this.velocity;
+               vel_local.z = v_up * this.velocity;
 
-               this.angles_x = racecar_angle(vel_local_x, vel_local_z);
-               this.angles_z = racecar_angle(-vel_local_y, vel_local_z);
+               this.angles_x = racecar_angle(vel_local.x, vel_local.z);
+               this.angles_z = racecar_angle(-vel_local.y, vel_local.z);
        }
 
        // smooth the angles
        vector vf1, vu1, smoothangles;
        makevectors(this.angles);
-       float f = bound(0, PHYS_INPUT_TIMELENGTH * PHYS_BUGRIGS_ANGLE_SMOOTHING, 1);
+       float f = bound(0, dt * PHYS_BUGRIGS_ANGLE_SMOOTHING(this), 1);
        if (f == 0)
                f = 1;
        vf1 = v_forward * f;
@@ -350,10 +281,8 @@ void RaceCarPhysics(entity this)
        vf1 = vf1 + v_forward * (1 - f);
        vu1 = vu1 + v_up * (1 - f);
        smoothangles = vectoangles2(vf1, vu1);
-       this.angles_x = -smoothangles_x;
-       this.angles_z =  smoothangles_z;
-
-       PM_ClientMovement_Move(this);
+       this.angles_x = -smoothangles.x;
+       this.angles_z =  smoothangles.z;
 }
 
 #ifdef SVQC
@@ -361,46 +290,49 @@ void RaceCarPhysics(entity this)
 #endif
 MUTATOR_HOOKFUNCTION(bugrigs, PM_Physics)
 {
-       if(!PHYS_BUGRIGS || !IS_PLAYER(self)) { return false; }
+    entity player = M_ARGV(0, entity);
+    float dt = M_ARGV(2, float);
+
+       if(!PHYS_BUGRIGS(player) || !IS_PLAYER(player)) { return; }
 
 #ifdef SVQC
-       self.angles = self.bugrigs_prevangles;
+       player.angles = player.bugrigs_prevangles;
 #endif
 
-       RaceCarPhysics(self);
+       RaceCarPhysics(player, dt);
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(bugrigs, PlayerPhysics)
 {
-       if(!PHYS_BUGRIGS) { return false; }
+       if(!PHYS_BUGRIGS(M_ARGV(0, entity))) { return; }
 #ifdef SVQC
-       self.bugrigs_prevangles = self.angles;
+       entity player = M_ARGV(0, entity);
+       player.bugrigs_prevangles = player.angles;
 
-       bugrigs_UpdateStats(self);
+       player.disableclientprediction = 2;
 #endif
-       return false;
 }
 
 #ifdef SVQC
 
 MUTATOR_HOOKFUNCTION(bugrigs, ClientConnect)
 {
-       stuffcmd(self, "cl_cmd settemp chase_active 1\n");
-       return false;
+    entity player = M_ARGV(0, entity);
+
+       stuffcmd(player, "cl_cmd settemp chase_active 1\n");
 }
 
 MUTATOR_HOOKFUNCTION(bugrigs, BuildMutatorsString)
 {
-       ret_string = strcat(ret_string, ":bugrigs");
-       return false;
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ":bugrigs");
 }
 
 MUTATOR_HOOKFUNCTION(bugrigs, BuildMutatorsPrettyString)
 {
-       ret_string = strcat(ret_string, ", Bug rigs");
-       return false;
+       M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Bug rigs");
 }
 
 #endif
+
 #endif