From ed14adcaf1f9ca9189c31405f573d1c58edf0a09 Mon Sep 17 00:00:00 2001 From: Void&Null <70048414+Void-n-Null@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:09:28 -0600 Subject: [PATCH] feat: Add bunnyhopping control CVars Introduce two new ConVars to control bunnyhopping behavior: - tf_restrict_bunnyhopping: Restricts speed gain from bunnyhopping (default: enabled) (Matches TF2 functionality by default) - tf_automatic_bunnyhopping: Allows automatic bunnyhopping when holding jump (default: disabled) (Matches TF2 functionality by default) Modified CheckJumpButton() to respect these new CVars, providing more flexibility in movement mechanics. The new CVars are labeled as cheats to match the rest of the movement based `tf_` CVars. --- src/game/shared/tf/tf_gamemovement.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/game/shared/tf/tf_gamemovement.cpp b/src/game/shared/tf/tf_gamemovement.cpp index 14d754f1ded..68d85e8e783 100644 --- a/src/game/shared/tf/tf_gamemovement.cpp +++ b/src/game/shared/tf/tf_gamemovement.cpp @@ -77,6 +77,10 @@ ConVar tf_movement_lost_footing_restick( "tf_movement_lost_footing_restick", "50 ConVar tf_movement_lost_footing_friction( "tf_movement_lost_footing_friction", "0.1", FCVAR_REPLICATED | FCVAR_CHEAT, "Ground friction for players who have lost their footing" ); +// Bunnyhopping related +ConVar tf_restrict_bunnyhopping( "tf_restrict_bunnyhopping", "1", FCVAR_REPLICATED | FCVAR_CHEAT,"Restrict speed gain from bunnyhopping" ); +ConVar tf_automatic_bunnyhopping( "tf_automatic_bunnyhopping", "0", FCVAR_REPLICATED | FCVAR_CHEAT,"Automatically bunnyhop when holding jump" ); + extern ConVar cl_forwardspeed; extern ConVar cl_backspeed; extern ConVar cl_sidespeed; @@ -1285,7 +1289,8 @@ bool CTFGameMovement::CheckJumpButton() return false; // Cannot jump again until the jump button has been released. - if ( mv->m_nOldButtons & IN_JUMP ) + // Unless the automatic bunnyhopping cvar is enabled and the player is on the ground. + if ( mv->m_nOldButtons & IN_JUMP && (!tf_automatic_bunnyhopping.GetBool() || !bOnGround) ) return false; // In air, so ignore jumps @@ -1312,7 +1317,12 @@ bool CTFGameMovement::CheckJumpButton() return true; } - PreventBunnyJumping(); + // We restrict bunnyhopping by default, the same as base TF2. + // But now the cvar can now be used to disable this restriction. + if ( tf_restrict_bunnyhopping.GetBool() ) + { + PreventBunnyJumping(); + } // Start jump animation and player sound (specific TF animation and flags). m_pTFPlayer->DoAnimationEvent( PLAYERANIMEVENT_JUMP );