]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_physics.qc
Merge remote-tracking branch 'origin/master' into fruitiex/animations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_physics.qc
index 8e964054b7858f40d5158f4af0fc5a6ac6f4e694..d2203c241877754ca5b59e021b0ada1957dc3240 100644 (file)
@@ -23,7 +23,7 @@ When you press the jump key
 */
 void PlayerJump (void)
 {
-       if(g_freezetag && self.freezetag_frozen)
+       if(self.freezetag_frozen)
                return; // no jumping in freezetag when frozen
 
        float mjumpheight;
@@ -61,7 +61,7 @@ void PlayerJump (void)
        if(!doublejump && self.multijump_ready && self.multijump_count < autocvar_g_multijump && self.velocity_z > autocvar_g_multijump_speed)
        {
                // doublejump = FALSE; // checked above in the if
-               if (autocvar_g_multijump > 0)
+               if (autocvar_g_multijump)
                {
                        if (autocvar_g_multijump_add == 0) // in this case we make the z velocity == jumpvelocity
                        {
@@ -93,7 +93,8 @@ void PlayerJump (void)
                                        self.velocity_y = wishdir_y * curspeed;
                                        // keep velocity_z unchanged!
                                }
-                               self.multijump_count += 1;
+                               if (autocvar_g_multijump > 0)
+                                       self.multijump_count += 1;
                        }
                }
                self.multijump_ready = FALSE; // require releasing and pressing the jump button again for the next jump
@@ -162,7 +163,7 @@ void PlayerJump (void)
 
        if (self.crouch)
                setanim(self, self.anim_duckjump, FALSE, TRUE, TRUE);
-       else
+       else if (self.animstate_startframe != self.anim_melee_x) // jump animation shouldn't override melee until we have animation blending
                setanim(self, self.anim_jump, FALSE, TRUE, TRUE);
 
        if(g_jump_grunt)
@@ -503,7 +504,7 @@ float AdjustAirAccelQW(float accelqw, float factor)
 //   sv_airaccel_sideways_friction 0
 //   prvm_globalset server speedclamp_mode 1
 //     (or 2)
-void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float sidefric, float speedlimit)
+void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
 {
        float vel_straight;
        float vel_z;
@@ -515,8 +516,14 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce
        float vel_xy_backward, vel_xy_forward;
        float speedclamp;
 
-       speedclamp = (accelqw < 0);
-       if(speedclamp)
+       if(stretchfactor > 0)
+               speedclamp = stretchfactor;
+       else if(accelqw < 0)
+               speedclamp = 1; // full clamping, no stretch
+       else
+               speedclamp = -1; // no clamping
+
+       if(accelqw < 0)
                accelqw = -accelqw;
 
        if(autocvar_sv_gameplayfix_q2airaccelerate)
@@ -559,12 +566,16 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce
        
        vel_xy = vel_straight * wishdir + vel_perpend;
        
-       if(speedclamp)
+       if(speedclamp >= 0)
        {
-               // ensure we don't get too fast or decelerate faster than we should
-               vel_xy_current = min(vlen(vel_xy), vel_xy_forward);
-               if(vel_xy_current > 0) // prevent division by zero
-                       vel_xy = normalize(vel_xy) * vel_xy_current;
+               float vel_xy_preclamp;
+               vel_xy_preclamp = vlen(vel_xy);
+               if(vel_xy_preclamp > 0) // prevent division by zero
+               {
+                       vel_xy_current += (vel_xy_forward - vel_xy_current) * speedclamp;
+                       if(vel_xy_current < vel_xy_preclamp)
+                               vel_xy = vel_xy * (vel_xy_current / vel_xy_preclamp);
+               }
        }
 
        self.velocity = vel_xy + vel_z * '0 0 1';
@@ -666,6 +677,8 @@ void SV_PlayerPhysics()
        float buttons_prev;
        float not_allowed_to_move;
        string c;
+
+       WarpZone_PlayerPhysics_FixVAngle();
        
        maxspd_mod = 1;
        if(g_minstagib && (self.items & IT_INVINCIBLE))
@@ -767,7 +780,7 @@ void SV_PlayerPhysics()
                        self.angles_x = random() * 360;
                        self.angles_y = random() * 360;
                        // at least I'm not forcing retardedview by also assigning to angles_z
-                       self.fixangle = 1;
+                       self.fixangle = TRUE;
                }
        }
 
@@ -796,8 +809,6 @@ void SV_PlayerPhysics()
                bot_think();
        }
        
-       MUTATOR_CALLHOOK(PlayerPhysics);
-
        self.items &~= IT_USING_JETPACK;
 
        if(self.classname == "player")
@@ -835,6 +846,8 @@ void SV_PlayerPhysics()
        if(time < self.ladder_time)
                self.disableclientprediction = 1;
 
+       MUTATOR_CALLHOOK(PlayerPhysics);
+
        maxspd_mod = 1;
 
        swampspd_mod = 1;
@@ -964,7 +977,7 @@ void SV_PlayerPhysics()
                if (wishspeed > self.stat_sv_maxspeed*maxspd_mod)
                        wishspeed = self.stat_sv_maxspeed*maxspd_mod;
                if (time >= self.teleport_time)
-                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
        }
        else if (self.waterlevel >= WATERLEVEL_SWIMMING)
        {
@@ -987,7 +1000,7 @@ void SV_PlayerPhysics()
                self.velocity = self.velocity * (1 - frametime * autocvar_sv_friction);
 
                // water acceleration
-               PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+               PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
        }
        else if (time < self.ladder_time)
        {
@@ -1037,7 +1050,7 @@ void SV_PlayerPhysics()
                if (time >= self.teleport_time)
                {
                        // water acceleration
-                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
                }
        }
        else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!autocvar_g_jetpack_fuel || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO))
@@ -1197,7 +1210,7 @@ void SV_PlayerPhysics()
                if (self.crouch)
                        wishspeed = wishspeed * 0.5;
                if (time >= self.teleport_time)
-                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0);
+                       PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0);
        }
        else
        {
@@ -1268,7 +1281,7 @@ void SV_PlayerPhysics()
                        if(autocvar_sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0)
                                PM_AirAccelerate(wishdir, wishspeed);
                        else
-                               PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, autocvar_sv_airaccel_sideways_friction / maxairspd, self.stat_sv_airspeedlimit_nonqw);
+                               PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, autocvar_sv_airaccel_qw_stretchfactor, autocvar_sv_airaccel_sideways_friction / maxairspd, self.stat_sv_airspeedlimit_nonqw);
 
                        if(autocvar_sv_aircontrol)
                                CPM_PM_Aircontrol(wishdir, wishspeed2);