From 84c3f67bf77fcdc6025f9d3a0305190b137ff161 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 17 May 2011 12:06:25 +0200 Subject: [PATCH] give it a name: sv_airaccel_qw_stretchfactor ("stretch factor" of QW based bunnyhop accel, values <= 0 mean unlimited accel, values > 0 limit strafing, 1 means like Xonotic currently does) --- qcsrc/server/autocvars.qh | 1 + qcsrc/server/cl_physics.qc | 36 ++++++++++++++++-------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 26bd176b6..d3112f73d 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1118,6 +1118,7 @@ float autocvar_sv_accelerate; var float autocvar_sv_accuracy_data_share = 1; string autocvar_sv_adminnick; float autocvar_sv_airaccel_qw; +float autocvar_sv_airaccel_qw_stretchfactor; float autocvar_sv_airaccel_sideways_friction; float autocvar_sv_airaccelerate; float autocvar_sv_aircontrol; diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index b28073b9d..c706d2595 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -516,20 +516,15 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce float vel_xy_backward, vel_xy_forward; float speedclamp; + if(autocvar_sv_airaccel_qw_stretchfactor > 0) + speedclamp = autocvar_sv_airaccel_qw_stretchfactor; + else if(accelqw < 0) + speedclamp = 1; // full clamping, no stretch + else + speedclamp = -1; // no clamping + if(accelqw < 0) - { -#ifdef SPEEDCLAMP - speedclamp = SPEEDCLAMP; -#else - speedclamp = 0.000001; // no strafe accel -#endif accelqw = -accelqw; - } - else - speedclamp = 0; - // speedclamp usage: - // > 0: max acceleration in qu/s^2 in excess of regular (try 50, 100) - // < 0: max acceleration factor in excess of regular (try -0.1) if(autocvar_sv_gameplayfix_q2airaccelerate) wishspeed0 = wishspeed; @@ -571,15 +566,16 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce vel_xy = vel_straight * wishdir + vel_perpend; - if(speedclamp != 0) + if(speedclamp >= 0) { - // ensure we don't get too fast or decelerate faster than we should - if(speedclamp > 0) - vel_xy_current = min(vlen(vel_xy), vel_xy_forward + frametime * speedclamp); - else - vel_xy_current = min(vlen(vel_xy), vel_xy_current + (vel_xy_forward - vel_xy_current) * (1 - frametime * speedclamp)); - 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'; -- 2.39.2