From: divverent Date: Fri, 4 Jun 2010 21:55:25 +0000 (+0000) Subject: sv_airspeedlimit_nonqw: a soft speedlimit for games using sv_airaccel_qw X-Git-Tag: xonotic-v0.1.0preview~230^2~253 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=e7b94ee742d220019c15cc5720215b75cf3fb24c sv_airspeedlimit_nonqw: a soft speedlimit for games using sv_airaccel_qw git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10225 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index 804a4043..d1841403 100644 --- a/cl_input.c +++ b/cl_input.c @@ -1151,7 +1151,15 @@ void CL_ClientMovement_Physics_CPM_PM_Aircontrol(cl_clientmovement_state_t *s, v s->velocity[2] = zspeed; } -void CL_ClientMovement_Physics_PM_Accelerate(cl_clientmovement_state_t *s, vec3_t wishdir, vec_t wishspeed, vec_t wishspeed0, vec_t accel, vec_t accelqw, vec_t sidefric) +float CL_ClientMovement_Physics_AdjustAirAccelQW(float accelqw, float factor) +{ + return + (accelqw < 0 ? -1 : +1) + * + bound(0.000001, 1 - (1 - fabs(accelqw)) * factor, 1); +} + +void CL_ClientMovement_Physics_PM_Accelerate(cl_clientmovement_state_t *s, vec3_t wishdir, vec_t wishspeed, vec_t wishspeed0, vec_t accel, vec_t accelqw, vec_t sidefric, vec_t speedlimit) { vec_t vel_straight; vec_t vel_z; @@ -1177,6 +1185,8 @@ void CL_ClientMovement_Physics_PM_Accelerate(cl_clientmovement_state_t *s, vec3_ step = accel * s->cmd.frametime * wishspeed0; vel_xy_current = VectorLength(vel_xy); + if(speedlimit > 0) + accelqw = CL_ClientMovement_Physics_AdjustAirAccelQW(accelqw, (speedlimit - bound(wishspeed, vel_xy_current, speedlimit)) / max(1, speedlimit - wishspeed)); vel_xy_forward = vel_xy_current + bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw); vel_xy_backward = vel_xy_current - bound(0, wishspeed + vel_xy_current, step) * accelqw - step * (1 - accelqw); if(vel_xy_backward < 0) @@ -1404,7 +1414,7 @@ void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s) if(cl.movevars_warsowbunny_turnaccel && accelerating && s->cmd.sidemove == 0 && s->cmd.forwardmove != 0) CL_ClientMovement_Physics_PM_AirAccelerate(s, wishdir, wishspeed2); else - CL_ClientMovement_Physics_PM_Accelerate(s, wishdir, wishspeed, wishspeed0, accel, accelqw, cl.movevars_airaccel_sideways_friction / cl.movevars_maxairspeed); + CL_ClientMovement_Physics_PM_Accelerate(s, wishdir, wishspeed, wishspeed0, accel, accelqw, cl.movevars_airaccel_sideways_friction / cl.movevars_maxairspeed, cl.movevars_airspeedlimit_nonqw); if(cl.movevars_aircontrol) CL_ClientMovement_Physics_CPM_PM_Aircontrol(s, wishdir, wishspeed2); @@ -1473,6 +1483,7 @@ void CL_UpdateMoveVars(void) cl.movevars_warsowbunny_topspeed = cl.statsf[STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED]; cl.movevars_warsowbunny_turnaccel = cl.statsf[STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL]; cl.movevars_warsowbunny_backtosideratio = cl.statsf[STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO]; + cl.movevars_airspeedlimit_nonqw = cl.statsf[STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW]; } else { @@ -1507,6 +1518,7 @@ void CL_UpdateMoveVars(void) cl.movevars_warsowbunny_topspeed = 0; cl.movevars_warsowbunny_turnaccel = 0; cl.movevars_warsowbunny_backtosideratio = 0; + cl.movevars_airspeedlimit_nonqw = 0; } if(!(cl.moveflags & MOVEFLAG_VALID)) diff --git a/client.h b/client.h index 8a8e192c..270db45b 100644 --- a/client.h +++ b/client.h @@ -1200,6 +1200,7 @@ typedef struct client_state_s float movevars_warsowbunny_turnaccel; float movevars_warsowbunny_backtosideratio; float movevars_ticrate; + float movevars_airspeedlimit_nonqw; // models used by qw protocol int qw_modelindex_spike; diff --git a/quakedef.h b/quakedef.h index 97554967..f36f97b5 100644 --- a/quakedef.h +++ b/quakedef.h @@ -229,6 +229,7 @@ extern char engineversion[128]; //#define STAT_TIME 17 ///< FTE //#define STAT_VIEW2 20 ///< FTE #define STAT_VIEWZOOM 21 ///< DP +#define STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW 222 ///< DP #define STAT_MOVEVARS_AIRSTRAFEACCEL_QW 223 ///< DP #define STAT_MOVEVARS_AIRCONTROL_POWER 224 ///< DP #define STAT_MOVEFLAGS 225 ///< DP diff --git a/server.h b/server.h index db72d41d..bce966e4 100644 --- a/server.h +++ b/server.h @@ -393,6 +393,7 @@ extern cvar_t sv_maxairstrafespeed; extern cvar_t sv_airstrafeaccel_qw; extern cvar_t sv_aircontrol; extern cvar_t sv_aircontrol_power; +extern cvar_t sv_airspeedlimit_nonqw; extern cvar_t sv_allowdownloads; extern cvar_t sv_allowdownloads_archive; extern cvar_t sv_allowdownloads_config; diff --git a/sv_main.c b/sv_main.c index ad9a3a13..119fc9ed 100644 --- a/sv_main.c +++ b/sv_main.c @@ -56,6 +56,7 @@ cvar_t sv_airaccel_qw = {0, "sv_airaccel_qw", "1", "ratio of QW-style air contro cvar_t sv_airaccel_sideways_friction = {0, "sv_airaccel_sideways_friction", "", "anti-sideways movement stabilization (reduces speed gain when zigzagging); when < 0, only so much friction is applied that braking (by accelerating backwards) cannot be stronger"}; cvar_t sv_airaccelerate = {0, "sv_airaccelerate", "-1", "rate at which a player accelerates to sv_maxairspeed while in the air, if less than 0 the sv_accelerate variable is used instead"}; cvar_t sv_airstopaccelerate = {0, "sv_airstopaccelerate", "0", "when set, replacement for sv_airaccelerate when moving backwards"}; +cvar_t sv_airspeedlimit_nonqw = {0, "sv_airspeedlimit_nonqw", "0", "when set, this is a soft speed limit while in air when using airaccel_qw not equal to 1"}; cvar_t sv_airstrafeaccelerate = {0, "sv_airstrafeaccelerate", "0", "when set, replacement for sv_airaccelerate when just strafing"}; cvar_t sv_maxairstrafespeed = {0, "sv_maxairstrafespeed", "0", "when set, replacement for sv_maxairspeed when just strafing"}; cvar_t sv_airstrafeaccel_qw = {0, "sv_airstrafeaccel_qw", "0", "when set, replacement for sv_airaccel_qw when just strafing"}; @@ -381,6 +382,7 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_airstrafeaccelerate); Cvar_RegisterVariable (&sv_maxairstrafespeed); Cvar_RegisterVariable (&sv_airstrafeaccel_qw); + Cvar_RegisterVariable (&sv_airspeedlimit_nonqw); Cvar_RegisterVariable (&sv_aircontrol); Cvar_RegisterVariable (&sv_aircontrol_power); Cvar_RegisterVariable (&sv_allowdownloads); @@ -1976,6 +1978,7 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t statsf[STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED] = sv_warsowbunny_topspeed.value; statsf[STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL] = sv_warsowbunny_turnaccel.value; statsf[STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO] = sv_warsowbunny_backtosideratio.value; + statsf[STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW] = sv_airspeedlimit_nonqw.value; statsf[STAT_FRAGLIMIT] = fraglimit.value; statsf[STAT_TIMELIMIT] = timelimit.value;