From 4a44920679ab23d574930ab5055ca6d2326c3000 Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Tue, 20 Apr 2021 02:56:41 +0700 Subject: [PATCH 1/6] Replace current KZ mode with SimpleKZ --- mp/src/game/client/momentum/c_mom_player.cpp | 12 +- mp/src/game/client/momentum/c_mom_player.h | 17 +- mp/src/game/server/momentum/mom_player.cpp | 12 +- mp/src/game/server/momentum/mom_player.h | 17 +- mp/src/game/shared/gamemovement.cpp | 24 +- .../game/shared/momentum/mom_gamemovement.cpp | 217 ++++++++++++++++-- .../shared/momentum/mom_system_gamemode.cpp | 1 + .../shared/momentum/mom_system_gamemode.h | 2 +- 8 files changed, 272 insertions(+), 30 deletions(-) diff --git a/mp/src/game/client/momentum/c_mom_player.cpp b/mp/src/game/client/momentum/c_mom_player.cpp index 98cfd4af49..3e0cc86c4b 100644 --- a/mp/src/game/client/momentum/c_mom_player.cpp +++ b/mp/src/game/client/momentum/c_mom_player.cpp @@ -54,7 +54,7 @@ C_MomentumPlayer::C_MomentumPlayer(): m_pSpecTarget(nullptr) m_afButtonDisabled = 0; m_flStartSpeed = 0.0f; m_flEndSpeed = 0.0f; - m_flStamina = 0.0f; + // m_flStamina = 0.0f; m_flGrabbableLadderTime = 0.0f; m_iLandTick = 0; @@ -70,6 +70,16 @@ C_MomentumPlayer::C_MomentumPlayer(): m_pSpecTarget(nullptr) m_nWallRunState = WALLRUN_NOT; m_bWasSprinting = false; + + m_bPSTurningLeft = false; + m_flPSBonusSpeed = 0.0f; + m_flPSTurnRate = 0.0f; + m_flPSVelMod = 1.0f; + m_flPSVelModLanding = 1.0f; + m_vecOldVelocity.Init(); + m_iTicksSinceIncrement = 0; + m_vecLandingVelocity.Init(); + m_nButtonsToggled = 0; } diff --git a/mp/src/game/client/momentum/c_mom_player.h b/mp/src/game/client/momentum/c_mom_player.h index fded1e2c3b..c0d480fe88 100644 --- a/mp/src/game/client/momentum/c_mom_player.h +++ b/mp/src/game/client/momentum/c_mom_player.h @@ -107,7 +107,22 @@ class C_MomentumPlayer : public C_BasePlayer, public CMomRunEntity Vector GetEscapeVel() const { return m_vecCornerEscapeVel; } void SetEscapeVel(const Vector &vecNewYaw) { m_vecCornerEscapeVel = vecNewYaw; } + void SetOldEyeAngles(const QAngle &ang) { m_qangOldEyeAngles = ang; } + const QAngle &OldEyeAngles() const { return m_qangOldEyeAngles; } + private: + + // KZ stuff (SKZ) + bool m_bPSTurningLeft; + float m_flPSBonusSpeed; + float m_flPSTurnRate; + float m_flPSVelMod; + float m_flPSVelModLanding; + Vector m_vecOldVelocity; + int m_iTicksSinceIncrement; + QAngle m_qangOldEyeAngles; + Vector m_vecLandingVelocity; + // Mobility mod (parkour) bool m_bWasSprinting; bool m_bIsPowerSliding; @@ -144,7 +159,7 @@ class C_MomentumPlayer : public C_BasePlayer, public CMomRunEntity SurfInt m_surfIntList[SurfInt::TYPE_COUNT]; // Stores interactions by type SurfInt::Type m_surfIntHistory[SurfInt::TYPE_COUNT]; // Keeps track of the history of interactions - float m_flStamina; + // float m_flStamina; CMomRunEntity *m_pSpecTarget; diff --git a/mp/src/game/server/momentum/mom_player.cpp b/mp/src/game/server/momentum/mom_player.cpp index 0dc7ed1893..b61762f55d 100644 --- a/mp/src/game/server/momentum/mom_player.cpp +++ b/mp/src/game/server/momentum/mom_player.cpp @@ -213,8 +213,7 @@ static MAKE_TOGGLE_CONVAR_C(mom_trail_enable, "0", FCVAR_CLIENTCMD_CAN_EXECUTE | static CMomentumPlayer *s_pPlayer = nullptr; CMomentumPlayer::CMomentumPlayer() - : m_flStamina(0.0f), - m_flLastVelocity(0.0f), m_nPerfectSyncTicks(0), m_nStrafeTicks(0), m_nAccelTicks(0), + : m_flLastVelocity(0.0f), m_nPerfectSyncTicks(0), m_nStrafeTicks(0), m_nAccelTicks(0), m_nPrevButtons(0), m_flTweenVelValue(1.0f), m_bInAirDueToJump(false), m_iProgressNumber(-1), m_cvarMapFinMoveEnable("mom_mapfinished_movement_enable") { @@ -255,6 +254,15 @@ CMomentumPlayer::CMomentumPlayer() m_bIsWalking = false; m_bIsSprinting = false; + m_bPSTurningLeft = false; + m_flPSBonusSpeed = 0.0f; + m_flPSTurnRate = 0.0f; + m_flPSVelMod = 1.0f; + m_flPSVelModLanding = 1.0f; + m_vecOldVelocity.Init(); + m_iTicksSinceIncrement = 0; + m_vecLandingVelocity.Init(); + m_bIsPowerSliding = false; m_nWallRunState = WALLRUN_NOT; diff --git a/mp/src/game/server/momentum/mom_player.h b/mp/src/game/server/momentum/mom_player.h index 87e378d755..b485596dda 100644 --- a/mp/src/game/server/momentum/mom_player.h +++ b/mp/src/game/server/momentum/mom_player.h @@ -275,6 +275,21 @@ class CMomentumPlayer : public CBasePlayer, public CGameEventListener, public CM SavedState_t *GetSavedRunState() { return &m_SavedRunState; } + // KZ stuff + + QAngle m_qangOldEyeAngles; + bool m_bPSTurningLeft; + float m_flPSBonusSpeed; + float m_flPSTurnRate; + float m_flPSVelMod; + float m_flPSVelModLanding; + Vector m_vecOldVelocity; + int m_iTicksSinceIncrement; + Vector m_vecLandingVelocity; + + void SetOldEyeAngles(const QAngle &ang) { m_qangOldEyeAngles = ang; } + const QAngle &OldEyeAngles() const { return m_qangOldEyeAngles; } + // Ahop stuff CNetworkVar(bool, m_bIsSprinting); CNetworkVar(bool, m_bIsWalking); @@ -384,7 +399,7 @@ class CMomentumPlayer : public CBasePlayer, public CGameEventListener, public CM QAngle m_qangLastAngle; // used by CMomentumGameMovement - float m_flStamina; + // float m_flStamina; bool m_bAllowUserTeleports; diff --git a/mp/src/game/shared/gamemovement.cpp b/mp/src/game/shared/gamemovement.cpp index 1c4c3cd891..7c41a2db45 100644 --- a/mp/src/game/shared/gamemovement.cpp +++ b/mp/src/game/shared/gamemovement.cpp @@ -1133,14 +1133,19 @@ void CGameMovement::ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) mv = pMove; mv->m_flMaxSpeed = pPlayer->GetPlayerMaxSpeed(); + // CSGO (and therefore SKZ) caps ground speed at CS_PLAYER_SPEED_RUN (250.0f) as well + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + mv->m_flMaxSpeed = MIN(250.0f, mv->m_flMaxSpeed); + } // CheckV( player->CurrentCommandNumber(), "StartPos", mv->GetAbsOrigin() ); DiffPrint( "start %f %f %f", mv->GetAbsOrigin().x, mv->GetAbsOrigin().y, mv->GetAbsOrigin().z ); - - // Run the command. + + // Run the command. PlayerMove(); - + FinishMove(); DiffPrint( "end %f %f %f", mv->GetAbsOrigin().x, mv->GetAbsOrigin().y, mv->GetAbsOrigin().z ); @@ -1849,10 +1854,17 @@ void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float accel ) // If not going to add any speed, done. if (addspeed <= 0) return; - // Determine amount of acceleration. - accelspeed = accel * gpGlobals->frametime * wishspeed * player->m_surfaceFriction; - + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + // Change acceleration based on movement modifiers (KZ) + const float kAccelerationScale = MAX(250.0f, wishspeed); + accelspeed = accel * gpGlobals->frametime * kAccelerationScale * player->m_surfaceFriction; + } + else + { + accelspeed = accel * gpGlobals->frametime * wishspeed * player->m_surfaceFriction; + } // Cap at addspeed if (accelspeed > addspeed) accelspeed = addspeed; diff --git a/mp/src/game/shared/momentum/mom_gamemovement.cpp b/mp/src/game/shared/momentum/mom_gamemovement.cpp index 6299ac1e31..465d9c8ac8 100755 --- a/mp/src/game/shared/momentum/mom_gamemovement.cpp +++ b/mp/src/game/shared/momentum/mom_gamemovement.cpp @@ -23,11 +23,22 @@ #define BHOP_DELAY_TIME 15 // Time to delay successive bhops by, in ticks #define STOP_EPSILON 0.1 #define MAX_CLIP_PLANES 5 - +/* #define STAMINA_MAX 100.0f #define STAMINA_COST_JUMP 25.0f #define STAMINA_COST_FALL 20.0f // not used #define STAMINA_RECOVER_RATE 19.0f +*/ +// SKZ prestrafe defines +#define PERF_TICKS 2 +#define PS_MAX_REWARD_TURN_RATE 0.703125 // Degrees per tick (90 degrees per second) +#define PS_MAX_TURN_RATE_DECREMENT 0.015625 // Degrees per tick (2 degrees per second) +#define PS_SPEED_MAX 26.54321 // Units +#define PS_SPEED_INCREMENT 0.35 // Units per tick +#define PS_SPEED_DECREMENT_MIDAIR 0.2824 // Units per tick (lose PS_SPEED_MAX in 0 offset jump i.e. 94 ticks) +#define PS_GRACE_TICKS 3 // No. of ticks allowed to fail prestrafe checks when prestrafing +#define CS_RUN_SPEED 250.0f + #define CS_WALK_SPEED 135.0f #define DUCK_SPEED_MULTIPLIER 0.34f @@ -64,7 +75,6 @@ void CMomentumGameMovement::ProcessMovement(CBasePlayer *pPlayer, CMoveData *dat { m_pPlayer = ToCMOMPlayer(pPlayer); Assert(m_pPlayer); - BaseClass::ProcessMovement(pPlayer, data); } @@ -161,9 +171,10 @@ void CMomentumGameMovement::WalkMove() Vector dest; trace_t pm; Vector forward, right, up; - + /* if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) { + if (m_pPlayer->m_flStamina > 0) { float flRatio = (STAMINA_MAX - ((m_pPlayer->m_flStamina / 1000.0f) * STAMINA_RECOVER_RATE)) / STAMINA_MAX; @@ -181,8 +192,9 @@ void CMomentumGameMovement::WalkMove() mv->m_vecVelocity.x *= flRatio; mv->m_vecVelocity.y *= flRatio; } + } - + */ AngleVectors(mv->m_vecViewAngles, &forward, &right, &up); // Determine movement angles CHandle oldground; @@ -244,6 +256,104 @@ void CMomentumGameMovement::WalkMove() wishspeed = VectorNormalize(wishdir); + // SKZ Prestrafe + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + m_pPlayer->m_iTicksSinceIncrement++; + if (mv->m_vecVelocity.Length2D() < 0.000001f) + { + // Short circuit if speed is 0 (also avoids divide by 0 errors) + m_pPlayer->m_flPSBonusSpeed = 0.0f; + m_pPlayer->m_flPSVelMod = 1.0f; + m_pPlayer->m_flPSTurnRate = 0.0f; + } + else + { + float baseSpeed = min(CS_RUN_SPEED, mv->m_vecVelocity.Length2D() / m_pPlayer->m_flPSVelMod); + + float newBonusSpeed = m_pPlayer->m_flPSBonusSpeed; + + float dtAngle = m_pPlayer->EyeAngles().y - m_pPlayer->OldEyeAngles().y; + if (dtAngle > 180.f) + dtAngle -= 360.f; + else if (dtAngle < -180.f) + dtAngle += 360.f; + // If player is turning at the required speed, and has the correct button inputs, reward it + bool bValidPrestrafeButtons = (mv->m_nButtons & (IN_FORWARD | IN_BACK) && !(mv->m_nButtons & IN_FORWARD && mv->m_nButtons & IN_BACK)) + || mv->m_nButtons & (IN_MOVELEFT | IN_MOVERIGHT) && !(mv->m_nButtons & IN_MOVELEFT && mv->m_nButtons & IN_MOVERIGHT); + if (dtAngle != 0 && bValidPrestrafeButtons) // player turned left + { + // If player changes their prestrafe direction, reset it + if (dtAngle > 0 && !m_pPlayer->m_bPSTurningLeft || dtAngle < 0 && m_pPlayer->m_bPSTurningLeft) + { + m_pPlayer->m_flPSBonusSpeed = 0.0f; + m_pPlayer->m_flPSVelMod = 1.0f; + m_pPlayer->m_flPSTurnRate = 0.0f; + newBonusSpeed = 0.0f; + } + // Keep track of the direction of the turn + m_pPlayer->m_bPSTurningLeft = (dtAngle > 0); + float newTurningRate = dtAngle; + float reward; + if (m_pPlayer->m_iTicksSinceIncrement <= PS_GRACE_TICKS) + { + // Also cap turn rate at maximum reward turn rate + newTurningRate = min(abs(newTurningRate) / m_pPlayer->m_iTicksSinceIncrement, PS_MAX_REWARD_TURN_RATE); + // Limit how fast turn rate can decrease (also scaled appropriately) + m_pPlayer->m_flPSTurnRate = max(newTurningRate, m_pPlayer->m_flPSTurnRate - PS_MAX_TURN_RATE_DECREMENT * m_pPlayer->m_iTicksSinceIncrement); + if (m_pPlayer->m_flPSTurnRate * m_pPlayer->m_iTicksSinceIncrement >= PS_MAX_REWARD_TURN_RATE) + { + reward = PS_SPEED_INCREMENT; + } + else + { + reward = PS_SPEED_INCREMENT * (m_pPlayer->m_flPSTurnRate * m_pPlayer->m_iTicksSinceIncrement / PS_MAX_REWARD_TURN_RATE); + } + } + else + { + // Cap turn rate at maximum reward turn rate + newTurningRate = min(abs(newTurningRate), PS_MAX_REWARD_TURN_RATE); + // Limit how fast turn rate can decrease + m_pPlayer->m_flPSTurnRate = max(newTurningRate, m_pPlayer->m_flPSTurnRate - PS_MAX_TURN_RATE_DECREMENT); + + if (m_pPlayer->m_flPSTurnRate >= PS_MAX_REWARD_TURN_RATE) + { + reward = PS_SPEED_INCREMENT; + } + else + { + reward = PS_SPEED_INCREMENT * (m_pPlayer->m_flPSTurnRate / PS_MAX_REWARD_TURN_RATE); + } + } + + newBonusSpeed += reward * baseSpeed / CS_RUN_SPEED; + m_pPlayer->m_iTicksSinceIncrement = 0; + } + else if (m_pPlayer->m_iTicksSinceIncrement > PS_GRACE_TICKS) + { + // They definitely aren't turning, but limit how fast turn rate can decrease + m_pPlayer->m_flPSTurnRate = max(0.0f, m_pPlayer->m_flPSTurnRate - PS_MAX_TURN_RATE_DECREMENT); + } + if (newBonusSpeed < 0.0f) + { + // Keep velocity modifier positive + newBonusSpeed = 0.0f; + } + else + { + // Scale the bonus speed based on current base speed and turn rate + float baseSpeedScaleFactor = baseSpeed / CS_RUN_SPEED; // Max 1.0 + float turnRateScaleFactor = min(1.0, m_pPlayer->m_flPSTurnRate / PS_MAX_REWARD_TURN_RATE); + float scaledMaxBonusSpeed = PS_SPEED_MAX * baseSpeedScaleFactor * turnRateScaleFactor; + newBonusSpeed = min(newBonusSpeed, scaledMaxBonusSpeed); + } + m_pPlayer->m_flPSBonusSpeed = newBonusSpeed; + m_pPlayer->m_flPSVelMod = 1.0f + (newBonusSpeed / baseSpeed); + } + + } + // // Clamp to server defined max speed // @@ -270,6 +380,16 @@ void CMomentumGameMovement::WalkMove() } } + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + // SKZ has no sliding on ground. + if ( mv->m_vecVelocity.LengthSqr() > mv->m_flMaxSpeed * mv->m_flMaxSpeed ) + { + float fRatio = mv->m_flMaxSpeed / mv->m_vecVelocity.Length(); + mv->m_vecVelocity *= fRatio; + } + } + // Cap ground movement speed in tf2 modes if (g_pGameModeSystem->IsTF2BasedMode()) { @@ -1157,7 +1277,7 @@ void CMomentumGameMovement::FinishDuck() void CMomentumGameMovement::PlayerMove() { BaseClass::PlayerMove(); - + if (player->IsAlive()) { // Check if our eye height is too close to the ceiling and lower it. @@ -1207,23 +1327,48 @@ void CMomentumGameMovement::PlayerMove() player->SetViewOffset(VEC_DUCK_VIEW); } } + // This isn't ideal, but just to absolutely sure that m_qangOldEyeAngles is updated after all movements + m_pPlayer->SetOldEyeAngles(m_pPlayer->EyeAngles()); } } #define RJ_BUNNYHOP_MAX_SPEED_FACTOR 1.2f void CMomentumGameMovement::PreventBunnyHopping() { - float maxscaledspeed = RJ_BUNNYHOP_MAX_SPEED_FACTOR * mv->m_flMaxSpeed; - if (maxscaledspeed <= 0.0f) - return; + float fraction = 1.0f; + float speed = mv->m_vecVelocity.Length();; - float speed = mv->m_vecVelocity.Length(); - if (speed <= maxscaledspeed) - return; + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + // SKZ formula + float landingspeed = m_pPlayer->m_vecLandingVelocity.Length2D(); + int cmdsSinceLanding = (gpGlobals->tickcount - m_pPlayer->m_iLandTick); + if (cmdsSinceLanding <= PERF_TICKS) + { + if (cmdsSinceLanding > 1) + { + // Restore prestrafe lost due to briefly being on the ground + m_pPlayer->m_flPSVelMod = m_pPlayer->m_flPSVelModLanding; + } + fraction = min(landingspeed, (0.2 * landingspeed + 200) * m_pPlayer->m_flPSVelMod) / speed; + } + } + else + { + speed = mv->m_vecVelocity.Length(); + float maxscaledspeed = RJ_BUNNYHOP_MAX_SPEED_FACTOR * mv->m_flMaxSpeed; - float fraction = maxscaledspeed / speed; + if (maxscaledspeed <= 0.0f) + return; + + if (speed <= maxscaledspeed) + return; + fraction = maxscaledspeed / speed; + } + mv->m_vecVelocity *= fraction; + } void CMomentumGameMovement::CheckWaterJump() @@ -1363,7 +1508,7 @@ bool CMomentumGameMovement::CheckJumpButton() return false; } - if (!g_pGameModeSystem->GetGameMode()->CanBhop()) + if (!g_pGameModeSystem->GetGameMode()->CanBhop() || g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) { PreventBunnyHopping(); } @@ -1448,6 +1593,7 @@ bool CMomentumGameMovement::CheckJumpButton() } // stamina stuff (scroll/kz gamemode only) + /* if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) { if (m_pPlayer->m_flStamina > 0) @@ -1458,7 +1604,7 @@ bool CMomentumGameMovement::CheckJumpButton() m_pPlayer->m_flStamina = (STAMINA_COST_JUMP / STAMINA_RECOVER_RATE) * 1000.0; } - + */ // Add the accelerated hop movement if (g_pGameModeSystem->GameModeIs(GAMEMODE_AHOP)) { @@ -1618,7 +1764,7 @@ bool CMomentumGameMovement::CheckJumpButton() { player->m_Local.m_flJumpTime = GAMEMOVEMENT_JUMP_TIME; player->m_Local.m_bInDuckJump = true; - + #ifdef GAME_DLL // Reset toggle duck if it's toggled m_pPlayer->ResetToggledInput(IN_DUCK); @@ -1654,6 +1800,10 @@ bool CMomentumGameMovement::CheckJumpButton() // Flag that we jumped. mv->m_nOldButtons |= IN_JUMP; + // This is a hack for KZ takeoff velocity HUD, there is probably a much better way of doing this + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + player->SetLocalVelocity(mv->m_vecVelocity); + #ifndef CLIENT_DLL m_pPlayer->SetIsInAirDueToJump(true); // Fire that we jumped @@ -2019,7 +2169,7 @@ void CMomentumGameMovement::FullWalkMove() { if (g_pGameModeSystem->IsTF2BasedMode()) mv->m_vecVelocity[2] = 0.f; - + WalkMove(); SurfInt::Action action = (player->GetFlags() & FL_DUCKING) ? SurfInt::ACTION_DUCKWALK : SurfInt::ACTION_WALK; @@ -2365,6 +2515,29 @@ void CMomentumGameMovement::AirMove() { PerformLurchChecks(); } + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + if (mv->m_vecVelocity.Length2D() < 0.000001f) + { + // Short circuit if speed is 0 (also avoids divide by 0 errors) + m_pPlayer->m_flPSBonusSpeed = 0.0f; + m_pPlayer->m_flPSVelMod = 1.0f; + m_pPlayer->m_flPSTurnRate = 0.0f; + } + else + { + float baseSpeed = min(CS_RUN_SPEED, mv->m_vecVelocity.Length2D() / m_pPlayer->m_flPSVelMod); + + m_pPlayer->m_flPSBonusSpeed -= PS_SPEED_DECREMENT_MIDAIR; + + if (m_pPlayer->m_flPSBonusSpeed < 0.0f) + { + m_pPlayer->m_flPSBonusSpeed = 0.0f; + } + + m_pPlayer->m_flPSVelMod = 1.0f + (m_pPlayer->m_flPSBonusSpeed / baseSpeed); + } + } BaseClass::AirMove(); @@ -3062,6 +3235,8 @@ void CMomentumGameMovement::SetGroundEntity(const trace_t *pm) // Doing this after the BaseClass call in case OnLand wants to use the new ground stuffs if (bLanded) { + m_pPlayer->m_vecLandingVelocity = mv->m_vecVelocity; + m_pPlayer->m_flPSVelModLanding = m_pPlayer->m_flPSVelMod; #ifdef GAME_DLL m_pPlayer->SetIsInAirDueToJump(false); @@ -3084,13 +3259,19 @@ void CMomentumGameMovement::CheckParameters() mv->m_flClientMaxSpeed = CS_WALK_SPEED; } + // SKZ velocity modifier + if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) + { + mv->m_flMaxSpeed *= m_pPlayer->m_flPSVelMod; + } BaseClass::CheckParameters(); } void CMomentumGameMovement::ReduceTimers() { float frame_msec = 1000.0f * gpGlobals->frametime; - + // Stamina removed + /* if (m_pPlayer->m_flStamina > 0) { m_pPlayer->m_flStamina -= frame_msec; @@ -3100,7 +3281,7 @@ void CMomentumGameMovement::ReduceTimers() m_pPlayer->m_flStamina = 0; } } - + */ if (m_pPlayer->m_Local.m_slideBoostCooldown > 0) { m_pPlayer->m_Local.m_slideBoostCooldown -= frame_msec; diff --git a/mp/src/game/shared/momentum/mom_system_gamemode.cpp b/mp/src/game/shared/momentum/mom_system_gamemode.cpp index ab4b5b8871..97a776b045 100644 --- a/mp/src/game/shared/momentum/mom_system_gamemode.cpp +++ b/mp/src/game/shared/momentum/mom_system_gamemode.cpp @@ -138,6 +138,7 @@ void CGameMode_KZ::SetGameModeVars() sv_friction.SetValue(5.2f); sv_maxspeed.SetValue(320); sv_maxvelocity.SetValue(3500); + sv_stopspeed.SetValue(80); } bool CGameMode_KZ::WeaponIsAllowed(WeaponID_t weapon) diff --git a/mp/src/game/shared/momentum/mom_system_gamemode.h b/mp/src/game/shared/momentum/mom_system_gamemode.h index fabf1a5a24..eaeb77470b 100644 --- a/mp/src/game/shared/momentum/mom_system_gamemode.h +++ b/mp/src/game/shared/momentum/mom_system_gamemode.h @@ -100,7 +100,7 @@ class CGameMode_KZ : public CGameModeBase const char* GetDiscordIcon() override { return "mom_icon_kz"; } const char* GetMapPrefix() override { return "kz_"; } const char* GetGameModeCfg() override { return "kz.cfg"; } - float GetIntervalPerTick() override { return 0.01f; } + float GetIntervalPerTick() override { return 0.0078125f; } void SetGameModeVars() override; bool PlayerHasAutoBhop() override { return false; } bool WeaponIsAllowed(WeaponID_t weapon) override; From fea2b822556be5ccf748cca0fe2a7c98f259e4a4 Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Wed, 21 Apr 2021 17:35:26 +0700 Subject: [PATCH 2/6] Re-add ledge grabbing (sv_consider_on_ground 2) --- mp/src/game/shared/momentum/mom_system_gamemode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mp/src/game/shared/momentum/mom_system_gamemode.cpp b/mp/src/game/shared/momentum/mom_system_gamemode.cpp index 97a776b045..d4b0b483f1 100644 --- a/mp/src/game/shared/momentum/mom_system_gamemode.cpp +++ b/mp/src/game/shared/momentum/mom_system_gamemode.cpp @@ -138,7 +138,9 @@ void CGameMode_KZ::SetGameModeVars() sv_friction.SetValue(5.2f); sv_maxspeed.SetValue(320); sv_maxvelocity.SetValue(3500); - sv_stopspeed.SetValue(80); + sv_stopspeed.SetValue(80); + + sv_considered_on_ground.SetValue(2); } bool CGameMode_KZ::WeaponIsAllowed(WeaponID_t weapon) From f513b5e9b1b0d99ba58c06b78325c556a1bc2d73 Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Wed, 21 Apr 2021 23:02:20 +0700 Subject: [PATCH 3/6] Fix parentheses for linux build --- mp/src/game/shared/momentum/mom_gamemovement.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mp/src/game/shared/momentum/mom_gamemovement.cpp b/mp/src/game/shared/momentum/mom_gamemovement.cpp index 465d9c8ac8..cd9fa26e28 100755 --- a/mp/src/game/shared/momentum/mom_gamemovement.cpp +++ b/mp/src/game/shared/momentum/mom_gamemovement.cpp @@ -279,12 +279,13 @@ void CMomentumGameMovement::WalkMove() else if (dtAngle < -180.f) dtAngle += 360.f; // If player is turning at the required speed, and has the correct button inputs, reward it - bool bValidPrestrafeButtons = (mv->m_nButtons & (IN_FORWARD | IN_BACK) && !(mv->m_nButtons & IN_FORWARD && mv->m_nButtons & IN_BACK)) - || mv->m_nButtons & (IN_MOVELEFT | IN_MOVERIGHT) && !(mv->m_nButtons & IN_MOVELEFT && mv->m_nButtons & IN_MOVERIGHT); + // Basically overlapping will result in false here + bool bValidPrestrafeButtons = (((mv->m_nButtons & (IN_FORWARD | IN_BACK)) && !(mv->m_nButtons & IN_FORWARD && mv->m_nButtons & IN_BACK)) + || ((mv->m_nButtons & (IN_MOVELEFT | IN_MOVERIGHT)) && !(mv->m_nButtons & IN_MOVELEFT && mv->m_nButtons & IN_MOVERIGHT))); if (dtAngle != 0 && bValidPrestrafeButtons) // player turned left { // If player changes their prestrafe direction, reset it - if (dtAngle > 0 && !m_pPlayer->m_bPSTurningLeft || dtAngle < 0 && m_pPlayer->m_bPSTurningLeft) + if ((dtAngle > 0 && !m_pPlayer->m_bPSTurningLeft) || (dtAngle < 0 && m_pPlayer->m_bPSTurningLeft)) { m_pPlayer->m_flPSBonusSpeed = 0.0f; m_pPlayer->m_flPSVelMod = 1.0f; From d4cf4516bdec23411ca263ccaced4363106987a7 Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Fri, 30 Jul 2021 17:05:17 +0700 Subject: [PATCH 4/6] Increase convar precision for tickrate convars --- mp/src/tier1/convar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mp/src/tier1/convar.cpp b/mp/src/tier1/convar.cpp index c8010535ee..0d637b5ba8 100644 --- a/mp/src/tier1/convar.cpp +++ b/mp/src/tier1/convar.cpp @@ -954,7 +954,7 @@ void ConVar::SetValue( float value ) return; char temp[32]; - Q_snprintf(temp, sizeof(temp), "%f", value); + Q_snprintf(temp, sizeof(temp), "%.8f", value); m_pParent->SetValue( temp ); } From 87534935c621df9996ea54b3f749ad521378be08 Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Fri, 30 Jul 2021 18:16:09 +0700 Subject: [PATCH 5/6] Add 3*-tick changes to SKZ --- mp/src/game/client/momentum/c_mom_player.cpp | 1 + mp/src/game/client/momentum/c_mom_player.h | 3 ++- mp/src/game/server/momentum/mom_player.cpp | 3 ++- mp/src/game/server/momentum/mom_player.h | 1 + mp/src/game/shared/momentum/mom_gamemovement.cpp | 10 +++++++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mp/src/game/client/momentum/c_mom_player.cpp b/mp/src/game/client/momentum/c_mom_player.cpp index 3e0cc86c4b..ea77a8363c 100644 --- a/mp/src/game/client/momentum/c_mom_player.cpp +++ b/mp/src/game/client/momentum/c_mom_player.cpp @@ -79,6 +79,7 @@ C_MomentumPlayer::C_MomentumPlayer(): m_pSpecTarget(nullptr) m_vecOldVelocity.Init(); m_iTicksSinceIncrement = 0; m_vecLandingVelocity.Init(); + m_iLastJumpButtonTick = 0; m_nButtonsToggled = 0; } diff --git a/mp/src/game/client/momentum/c_mom_player.h b/mp/src/game/client/momentum/c_mom_player.h index c0d480fe88..3abac7c3f7 100644 --- a/mp/src/game/client/momentum/c_mom_player.h +++ b/mp/src/game/client/momentum/c_mom_player.h @@ -122,7 +122,8 @@ class C_MomentumPlayer : public C_BasePlayer, public CMomRunEntity int m_iTicksSinceIncrement; QAngle m_qangOldEyeAngles; Vector m_vecLandingVelocity; - + int m_iLastJumpButtonTick; + // Mobility mod (parkour) bool m_bWasSprinting; bool m_bIsPowerSliding; diff --git a/mp/src/game/server/momentum/mom_player.cpp b/mp/src/game/server/momentum/mom_player.cpp index b61762f55d..a519f85aaf 100644 --- a/mp/src/game/server/momentum/mom_player.cpp +++ b/mp/src/game/server/momentum/mom_player.cpp @@ -262,7 +262,8 @@ CMomentumPlayer::CMomentumPlayer() m_vecOldVelocity.Init(); m_iTicksSinceIncrement = 0; m_vecLandingVelocity.Init(); - + m_iLastJumpButtonTick = 0; + m_bIsPowerSliding = false; m_nWallRunState = WALLRUN_NOT; diff --git a/mp/src/game/server/momentum/mom_player.h b/mp/src/game/server/momentum/mom_player.h index b485596dda..c3476c58e5 100644 --- a/mp/src/game/server/momentum/mom_player.h +++ b/mp/src/game/server/momentum/mom_player.h @@ -286,6 +286,7 @@ class CMomentumPlayer : public CBasePlayer, public CGameEventListener, public CM Vector m_vecOldVelocity; int m_iTicksSinceIncrement; Vector m_vecLandingVelocity; + int m_iLastJumpButtonTick; void SetOldEyeAngles(const QAngle &ang) { m_qangOldEyeAngles = ang; } const QAngle &OldEyeAngles() const { return m_qangOldEyeAngles; } diff --git a/mp/src/game/shared/momentum/mom_gamemovement.cpp b/mp/src/game/shared/momentum/mom_gamemovement.cpp index cd9fa26e28..a80c55dc0c 100755 --- a/mp/src/game/shared/momentum/mom_gamemovement.cpp +++ b/mp/src/game/shared/momentum/mom_gamemovement.cpp @@ -1337,14 +1337,15 @@ void CMomentumGameMovement::PlayerMove() void CMomentumGameMovement::PreventBunnyHopping() { float fraction = 1.0f; - float speed = mv->m_vecVelocity.Length();; - + float speed = mv->m_vecVelocity.Length(); if (g_pGameModeSystem->GameModeIs(GAMEMODE_KZ)) { // SKZ formula float landingspeed = m_pPlayer->m_vecLandingVelocity.Length2D(); int cmdsSinceLanding = (gpGlobals->tickcount - m_pPlayer->m_iLandTick); - if (cmdsSinceLanding <= PERF_TICKS) + // Original formula uses cmdnum instead of tickcount. They should both behave similarly to each other in Momentum. + bool hitTweakedPerf = ((cmdsSinceLanding == 1) || (cmdsSinceLanding <= 3 && gpGlobals->tickcount - m_pPlayer->m_iLastJumpButtonTick <= 3)); + if (hitTweakedPerf) { if (cmdsSinceLanding > 1) { @@ -1427,6 +1428,9 @@ bool CMomentumGameMovement::CheckJumpButton() // Avoid nullptr access, return false if somehow we don't have a player if (!player) return false; + + // SimpleKZ stuff. Track the last jump input from the player. + m_pPlayer->m_iLastJumpButtonTick = gpGlobals->tickcount; if (player->pl.deadflag) { From 660531f84100dbaa1145e5cd0a2efbb909f25e8f Mon Sep 17 00:00:00 2001 From: "zer0.k" Date: Fri, 30 Jul 2021 18:17:41 +0700 Subject: [PATCH 6/6] Give knife and pistol to KZ --- mp/src/game/shared/momentum/mom_system_gamemode.cpp | 11 ++++++++++- mp/src/game/shared/momentum/mom_system_gamemode.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mp/src/game/shared/momentum/mom_system_gamemode.cpp b/mp/src/game/shared/momentum/mom_system_gamemode.cpp index d4b0b483f1..c6f6bbf55a 100644 --- a/mp/src/game/shared/momentum/mom_system_gamemode.cpp +++ b/mp/src/game/shared/momentum/mom_system_gamemode.cpp @@ -145,12 +145,21 @@ void CGameMode_KZ::SetGameModeVars() bool CGameMode_KZ::WeaponIsAllowed(WeaponID_t weapon) { - // KZ only blacklists weapons return weapon != WEAPON_ROCKETLAUNCHER && weapon != WEAPON_STICKYLAUNCHER && weapon != WEAPON_CONCGRENADE; } +void CGameMode_KZ::OnPlayerSpawn(CMomentumPlayer *pPlayer) +{ + CGameModeBase::OnPlayerSpawn(pPlayer); + +#ifdef GAME_DLL + pPlayer->GiveWeapon(WEAPON_PISTOL); + pPlayer->GiveWeapon(WEAPON_KNIFE); +#endif +} + bool CGameMode_KZ::HasCapability(GameModeHUDCapability_t capability) { return capability == GameModeHUDCapability_t::CAP_HUD_KEYPRESS_JUMPS || diff --git a/mp/src/game/shared/momentum/mom_system_gamemode.h b/mp/src/game/shared/momentum/mom_system_gamemode.h index eaeb77470b..14d9a61447 100644 --- a/mp/src/game/shared/momentum/mom_system_gamemode.h +++ b/mp/src/game/shared/momentum/mom_system_gamemode.h @@ -103,6 +103,7 @@ class CGameMode_KZ : public CGameModeBase float GetIntervalPerTick() override { return 0.0078125f; } void SetGameModeVars() override; bool PlayerHasAutoBhop() override { return false; } + void OnPlayerSpawn(CMomentumPlayer *pPlayer) override; bool WeaponIsAllowed(WeaponID_t weapon) override; bool HasCapability(GameModeHUDCapability_t capability) override; };