From 990066dea1577cfefd63407f6ecb9048b26dc2cc Mon Sep 17 00:00:00 2001 From: Shpoike Date: Wed, 25 Jan 2023 23:14:13 +0000 Subject: [PATCH] Add pm_bunnyfriction cvar to better mimic nq player physics with predictable QW physics. --- engine/client/cl_main.c | 1 + engine/client/m_options.c | 45 +++++++++++++++++++++++++++++---------- engine/client/pr_csqc.c | 1 + engine/common/pmove.c | 6 +++++- engine/common/pmove.h | 1 + engine/server/sv_main.c | 2 ++ engine/server/sv_phys.c | 5 +++-- engine/server/sv_user.c | 2 ++ 8 files changed, 49 insertions(+), 14 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index ad9982214..7bc15cafa 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -2570,6 +2570,7 @@ void CL_CheckServerInfo(void) cl.bunnyspeedcap = Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_bunnyspeedcap")); movevars.slidefix = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_slidefix")) != 0); movevars.slidyslopes = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_slidyslopes")) != 0); + movevars.bunnyfriction = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_bunnyfriction")) != 0); movevars.airstep = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_airstep")) != 0); movevars.pground = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_pground")) != 0); movevars.stepdown = (Q_atof(InfoBuf_ValueForKey(&cl.serverinfo, "pm_stepdown")) != 0); diff --git a/engine/client/m_options.c b/engine/client/m_options.c index 69d268f38..221f765b6 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -1078,17 +1078,18 @@ const char *presetexec[] = struct { const char *name; + qboolean dorestart; const char *desc; const char *settings; } builtinpresets[] = { - { "hdr", + { "hdr", true, "Don't let colour depth stop you!", "set vid_srgb 2\n" "set r_hdr_irisadaptation 1\n" }, - { "shib", + { "shib", true, "Performance optimisations for large/detailed maps.", "set r_temporalscenecache 1\n" //the main speedup. @@ -1096,7 +1097,7 @@ struct "set sv_autooffload 1\n" //Needs polish still. "set gl_pbolightmaps 1\n" //FIXME: this needs to be the default eventually. }, - { "dm", + { "dm", false, "Various settings to make you more competitive." "set cl_yieldcpu 0\n" @@ -1110,20 +1111,42 @@ struct "set sys_clockprecision 1\n" //windows kinda sucks otherwise #endif }, - { "qw", - "Enable QuakeWorld-isms, for better gameplay.", + { "qw", false, + "Enable QuakeWorld physics, for better gameplay.", "set sv_nqplayerphysics 0\n" "set sv_gameplayfix_multiplethinks 1\n" + "cvarreset pm_bunnyfriction\n" + "cvarreset pm_edgefriction\n" + "cvarreset pm_slidefix\n" + "cvarreset pm_slidyslopes\n" }, - { "nq" - "Disable QuakeWorld-isms, for nq mod compat.", + { "hybridphysics", false, + "Tweak QuakeWorld player physics to feel like nq physics, while still supporting prediction.", + + "set sv_nqplayerphysics 0\n" + "set sv_gameplayfix_multiplethinks 1\n" + "set pm_bunnyfriction 1\n" //don't need bunnyspeedcap with this. + "set pm_edgefriction 2\n" //forces traceline instead of tracebox, to match nq (applies earlier, making it more aggressive) + "set pm_slidefix 1\n" //smoother running down slopes + "set pm_slidyslopes 1\n" //*sigh* + "set pm_noround 1\n" //lame + "set sv_maxtic 0\n" //fixed tick rates. + }, + { "nq", false, + "Disable QuakeWorld physics, for nq mod compat.", "set sv_nqplayerphysics 1\n" "set sv_gameplayfix_multiplethinks 0\n" + //*also* set these, in case they use nqplayerphysics 2 after, which should give better hints. + "set pm_bunnyfriction 1\n" //don't need bunnyspeedcap with this. + "set pm_edgefriction 2\n" //forces traceline instead of tracebox, to match nq (applies earlier, making it more aggressive) + "set pm_slidefix 1\n" //smoother running down slopes + "set pm_slidyslopes 1\n" //*sigh* + "set pm_noround 1\n" //lame }, - { "dp", + { "dp", false, "Reconfigures FTE to mimic DP for compat reasons.", "if $server then echo Be sure to restart your server\n" @@ -1153,7 +1176,7 @@ struct // "sv_listen_dp 1\nsv_listen_nq 0\nsv_listen_qw 0\ncl_loopbackprotocol dpp7\ndpcompat_nopreparse 1\n" }, - { "tenebrae", + { "tenebrae", true, "Reconfigures FTE to mimic Tenebrae for compat/style reasons.", //for the luls. combine with the tenebrae mod for maximum effect. "fps_preset nq\n" @@ -1169,7 +1192,7 @@ struct "set r_nolerp 1\n" //well, that matches tenebrae. for the luls, right? }, - { "timedemo", + { "timedemo", false, "Reconfigure some stuff to get through timedemos really fast. Some people might consider this cheating.", //some extra things to pwn timedemos. "fps_preset fast\n" @@ -1457,7 +1480,7 @@ void FPS_Preset_f (void) { if (!stricmp(builtinpresets[i].name, arg)) { - if (doreload) + if (doreload && builtinpresets[i].dorestart) Cbuf_InsertText("\nfs_restart\nvid_reload\n", RESTRICT_LOCAL, false); Cbuf_InsertText(builtinpresets[i].settings, RESTRICT_LOCAL, false); return; diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index a6b48299a..53ea4d0bc 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -8324,6 +8324,7 @@ qboolean CSQC_Init (qboolean anycsqc, const char *csprogsname, unsigned int chec movevars.stepdown = true; movevars.walljump = false;//(pm_walljump.value); movevars.slidyslopes = false;//(pm_slidyslopes.value!=0); + movevars.bunnyfriction = false; movevars.autobunny = false; //pm_autobunny.value!=0 movevars.watersinkspeed = 60;//*pm_watersinkspeed.string?pm_watersinkspeed.value:60; movevars.flyfriction = 4;//*pm_flyfriction.string?pm_flyfriction.value:4; diff --git a/engine/common/pmove.c b/engine/common/pmove.c index be2ebbb6b..f3a1f6175 100644 --- a/engine/common/pmove.c +++ b/engine/common/pmove.c @@ -1473,8 +1473,9 @@ void PM_PlayerMove (float gamespeed) pmove.jump_msec = 0; } - PM_CheckJump (); + if (!movevars.bunnyfriction) + PM_CheckJump (); //qw-style bunny PM_Friction (); if (pmove.waterlevel >= 2) @@ -1486,6 +1487,9 @@ void PM_PlayerMove (float gamespeed) else PM_AirMove (); + if (movevars.bunnyfriction) + PM_CheckJump (); //nq-style bunny. note tick rate differences too. + /* //round to network precision for (i = 0; i < 3; i++) { diff --git a/engine/common/pmove.h b/engine/common/pmove.h index c307cf7cb..e3275c4aa 100644 --- a/engine/common/pmove.h +++ b/engine/common/pmove.h @@ -119,6 +119,7 @@ typedef struct { qboolean stepdown; qboolean slidyslopes; qboolean autobunny; + qboolean bunnyfriction; //force at least one frame of friction when bunnying. int stepheight; qbyte coordtype; //FIXME: EZPEXT1_FLOATENTCOORDS should mean 4, but the result does not match ezquake/mvdsv's round-towards-origin which would result in inconsistencies. so player coords are rounded inconsistently. diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index a53adf56e..9e0584bf9 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -5690,6 +5690,7 @@ void SV_InitLocal (void) extern cvar_t sv_aim; extern cvar_t pm_bunnyspeedcap; + extern cvar_t pm_bunnyfriction; extern cvar_t pm_ktjump; extern cvar_t pm_slidefix; extern cvar_t pm_airstep; @@ -5766,6 +5767,7 @@ void SV_InitLocal (void) Cvar_Register (&sv_bigcoords, cvargroup_serverphysics); Cvar_Register (&pm_bunnyspeedcap, cvargroup_serverphysics); + Cvar_Register (&pm_bunnyfriction, cvargroup_serverphysics); Cvar_Register (&pm_watersinkspeed, cvargroup_serverphysics); Cvar_Register (&pm_flyfriction, cvargroup_serverphysics); Cvar_Register (&pm_ktjump, cvargroup_serverphysics); diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 9c0903d07..6d4911d62 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -73,13 +73,14 @@ cvar_t pm_bunnyspeedcap = CVARFD("pm_bunnyspeedcap", "", CVAR_SERVERINFO, "0 or cvar_t pm_watersinkspeed = CVARFD("pm_watersinkspeed", "", CVAR_SERVERINFO, "This is the speed that players will sink at while inactive in water. Empty means 60."); cvar_t pm_flyfriction = CVARFD("pm_flyfriction", "", CVAR_SERVERINFO, "Amount of friction that applies in fly or 6dof mode. Empty means 4."); cvar_t pm_slidefix = CVARFD("pm_slidefix", "", CVAR_SERVERINFO, "Fixes an issue when walking down slopes (ie: so they act more like slopes and not a series of steps)"); -cvar_t pm_slidyslopes = CVARFD("pm_slidyslopes", "", CVAR_SERVERINFO, "Replicates NQ behaviour, where players will slowly slide down ramps"); +cvar_t pm_slidyslopes = CVARFD("pm_slidyslopes", "", CVAR_SERVERINFO, "Replicates NQ behaviour, where players will slowly slide down ramps. Generally requires 'pm_noround 1' too, otherwise the effect rounds to nothing."); +cvar_t pm_bunnyfriction = CVARFD("pm_bunnyfriction", "", CVAR_SERVERINFO, "Replicates NQ behaviour, ensuring that there's at least a frame of friction while jumping - friction is proportional to tick rate."); cvar_t pm_autobunny = CVARFD("pm_autobunny", "", CVAR_SERVERINFO, "Players will continue jumping without needing to release the jump button."); cvar_t pm_airstep = CVARAFD("pm_airstep", "", /*dp*/"sv_jumpstep", CVAR_SERVERINFO, "Allows players to step up while jumping. This makes stairs more graceful but also increases potential jump heights."); cvar_t pm_pground = CVARFD("pm_pground", "", CVAR_SERVERINFO, "Use persisten onground state instead of recalculating every frame."CON_WARNING"Do NOT use with nq mods, as most nq mods will interfere with onground state, resulting in glitches."); cvar_t pm_stepdown = CVARFD("pm_stepdown", "", CVAR_SERVERINFO, "Causes physics to stick to the ground, instead of constantly losing traction whiloe going down steps."); cvar_t pm_walljump = CVARFD("pm_walljump", "", CVAR_SERVERINFO, "Allows the player to bounce off walls while arborne."); -cvar_t pm_edgefriction = CVARAFD("pm_edgefriction", "", /*nq*/"edgefriction", CVAR_SERVERINFO, "Default value of 2"); +cvar_t pm_edgefriction = CVARAFD("pm_edgefriction", "", /*nq*/"edgefriction", CVAR_SERVERINFO, "Increases friction when about to walk over a cliff, so you're less likely to plummet by mistake. When empty defaults to 2, but uses a tracebox instead of a traceline to detect the drop."); #define cvargroup_serverphysics "server physics variables" void WPhys_Init(void) diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 66881913b..1927bfad0 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -115,6 +115,7 @@ extern cvar_t pm_bunnyspeedcap; extern cvar_t pm_ktjump; extern cvar_t pm_slidefix; extern cvar_t pm_slidyslopes; +extern cvar_t pm_bunnyfriction; extern cvar_t pm_autobunny; extern cvar_t pm_airstep; extern cvar_t pm_pground; @@ -7608,6 +7609,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) movevars.stepdown = (pm_stepdown.value != 0); movevars.walljump = (pm_walljump.value); movevars.slidyslopes = (pm_slidyslopes.value!=0); + movevars.bunnyfriction = (pm_bunnyfriction.value!=0); movevars.autobunny = (pm_autobunny.value!=0); movevars.watersinkspeed = *pm_watersinkspeed.string?pm_watersinkspeed.value:60; movevars.flyfriction = *pm_flyfriction.string?pm_flyfriction.value:4;