From e2af38ba1ff57fa2a203cf049ddc195e7ad42acb Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Wed, 22 Jan 2025 15:56:51 +0000 Subject: [PATCH 01/10] proof of concept --- mp/src/game/client/neo/c_neo_player.cpp | 17 +++++++++++++++++ mp/src/game/server/neo/neo_player.cpp | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 5e8eb171a..0b7df2cb2 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -841,6 +841,23 @@ void C_NEO_Player::PreThink( void ) } SetMaxSpeed(MAX(speed, 56)); + Vector absoluteVelocity = GetAbsVelocity(); + absoluteVelocity.z = 0.f; + float currentSpeed = absoluteVelocity.Length(); + + engine->Con_NPrintf(0, "Max Speed: %f", GetPlayerMaxSpeed()); + engine->Con_NPrintf(1, "Current Speed minus upward velocity: %f", currentSpeed); + + if (GetMoveType() != MOVETYPE_LADDER && NEORules()->GetGhosterPlayer() == entindex() && NEO_WEP_GHOST && currentSpeed > GetPlayerMaxSpeed()) + { + float maxSpeed = GetPlayerMaxSpeed(); + float overSpeed = currentSpeed - maxSpeed; + + absoluteVelocity.NormalizeInPlace(); + absoluteVelocity *= -overSpeed; + ApplyAbsVelocityImpulse(absoluteVelocity); + } + CheckThermOpticButtons(); CheckVisionButtons(); diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index c44293b2c..aea127139 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -708,6 +708,20 @@ void CNEO_Player::PreThink(void) } SetMaxSpeed(MAX(speed, 56)); + Vector absoluteVelocity = GetAbsVelocity(); + absoluteVelocity.z = 0.f; + float currentSpeed = absoluteVelocity.Length(); + + if (GetMoveType() != MOVETYPE_LADDER && NEORules()->GetGhosterPlayer() == entindex() && currentSpeed > GetPlayerMaxSpeed()) + { + float maxSpeed = GetPlayerMaxSpeed(); + float overSpeed = currentSpeed - maxSpeed; + + absoluteVelocity.NormalizeInPlace(); + absoluteVelocity *= -overSpeed; + ApplyAbsVelocityImpulse(absoluteVelocity); + } + CheckThermOpticButtons(); CheckVisionButtons(); From 10120619c18c4b629d6b2db7118b4514c21dd2a5 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Thu, 23 Jan 2025 14:33:57 +0000 Subject: [PATCH 02/10] implement rains anti ghost bunnyhopping plugin natively. --- mp/src/game/client/neo/c_neo_player.cpp | 55 ++++++++++-------- mp/src/game/client/neo/c_neo_player.h | 1 + mp/src/game/server/neo/neo_player.cpp | 60 ++++++++++++-------- mp/src/game/server/neo/neo_player.h | 1 + mp/src/game/shared/neo/neo_player_shared.cpp | 2 + 5 files changed, 70 insertions(+), 49 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 0b7df2cb2..6040d19e5 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -798,15 +798,12 @@ void C_NEO_Player::PlayStepSound( Vector &vecOrigin, BaseClass::PlayStepSound(vecOrigin, psurface, fvol, force); } -extern ConVar sv_infinite_aux_power; -extern ConVar glow_outline_effect_enable; -void C_NEO_Player::PreThink( void ) +extern ConVar neo_ghost_bhopping; +void C_NEO_Player::CalculateSpeed(void) { - BaseClass::PreThink(); - float speed = GetNormSpeed(); static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; - if (m_nButtons & IN_DUCK) + if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) { speed *= DUCK_WALK_SPEED_MODIFIER; } @@ -830,34 +827,44 @@ void C_NEO_Player::PreThink( void ) speed *= pNeoWep->GetSpeedScale(); } - if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) - { - const float deltaTime = gpGlobals->curtime - m_flLastAirborneJumpOkTime; - const float leeway = 1.0f; - if (deltaTime < leeway) - { - speed = (speed / 2) + (deltaTime / 2 * (speed)); - } - } - SetMaxSpeed(MAX(speed, 56)); - Vector absoluteVelocity = GetAbsVelocity(); absoluteVelocity.z = 0.f; float currentSpeed = absoluteVelocity.Length(); - engine->Con_NPrintf(0, "Max Speed: %f", GetPlayerMaxSpeed()); - engine->Con_NPrintf(1, "Current Speed minus upward velocity: %f", currentSpeed); - - if (GetMoveType() != MOVETYPE_LADDER && NEORules()->GetGhosterPlayer() == entindex() && NEO_WEP_GHOST && currentSpeed > GetPlayerMaxSpeed()) + if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && Weapon_OwnsThisType("weapon_ghost")) { - float maxSpeed = GetPlayerMaxSpeed(); - float overSpeed = currentSpeed - maxSpeed; - + float overSpeed = currentSpeed - speed; absoluteVelocity.NormalizeInPlace(); absoluteVelocity *= -overSpeed; ApplyAbsVelocityImpulse(absoluteVelocity); } + // Slowdown after landing + if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) + { + const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + constexpr float INITIAL_SLOWDOWN_TIME = 0.25f; + constexpr float IMPAIRED_ACCELERATION_TIME = INITIAL_SLOWDOWN_TIME + (1 / 3.f); + if (timeSinceLanding < INITIAL_SLOWDOWN_TIME) + { + speed = MIN(speed, 75.f); + } + else if (timeSinceLanding < IMPAIRED_ACCELERATION_TIME) + { + speed *= timeSinceLanding / IMPAIRED_ACCELERATION_TIME; + } + } + SetMaxSpeed(MAX(speed, 56)); +} + +extern ConVar sv_infinite_aux_power; +extern ConVar glow_outline_effect_enable; +void C_NEO_Player::PreThink( void ) +{ + BaseClass::PreThink(); + + CalculateSpeed(); + CheckThermOpticButtons(); CheckVisionButtons(); diff --git a/mp/src/game/client/neo/c_neo_player.h b/mp/src/game/client/neo/c_neo_player.h index 67d550384..d78d5dbd5 100644 --- a/mp/src/game/client/neo/c_neo_player.h +++ b/mp/src/game/client/neo/c_neo_player.h @@ -64,6 +64,7 @@ class C_NEO_Player : public C_HL2MP_Player virtual void ClientThink( void ); virtual void PreThink( void ); + virtual void CalculateSpeed( void ); virtual void PostThink( void ); virtual void Spawn( void ); diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index aea127139..74e88892a 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -662,18 +662,12 @@ void CNEO_Player::CheckLeanButtons() } } -void CNEO_Player::PreThink(void) +extern ConVar neo_ghost_bhopping; +void CNEO_Player::CalculateSpeed(void) { - BaseClass::PreThink(); - - if (!m_bInThermOpticCamo) - { - CloakPower_Update(); - } - float speed = GetNormSpeed(); static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; - if (m_nButtons & IN_DUCK) + if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) { speed *= DUCK_WALK_SPEED_MODIFIER; } @@ -687,41 +681,57 @@ void CNEO_Player::PreThink(void) static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6; speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER; } - if (m_bInAim.Get()) + if (IsInAim()) { static constexpr float AIM_SPEED_MODIFIER = 0.6; speed *= AIM_SPEED_MODIFIER; } - if (auto pNeoWep = static_cast(GetActiveWeapon())) + if (auto pNeoWep = static_cast(GetActiveWeapon())) { speed *= pNeoWep->GetSpeedScale(); } + Vector absoluteVelocity = GetAbsVelocity(); + absoluteVelocity.z = 0.f; + float currentSpeed = absoluteVelocity.Length(); + + if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && Weapon_OwnsThisType("weapon_ghost")) + { + float overSpeed = currentSpeed - speed; + absoluteVelocity.NormalizeInPlace(); + absoluteVelocity *= -overSpeed; + ApplyAbsVelocityImpulse(absoluteVelocity); + } + + // Slowdown after landing if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) { - const float deltaTime = gpGlobals->curtime - m_flLastAirborneJumpOkTime; - const float leeway = 1.0f; - if (deltaTime < leeway) + const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + constexpr float INITIAL_SLOWDOWN_TIME = 0.25f; + constexpr float IMPAIRED_ACCELERATION_TIME = INITIAL_SLOWDOWN_TIME + (1 / 3.f); + if (timeSinceLanding < INITIAL_SLOWDOWN_TIME) + { + speed = MIN(speed, 75.f); + } + else if (timeSinceLanding < IMPAIRED_ACCELERATION_TIME) { - speed = (speed / 2) + (deltaTime / 2 * (speed)); + speed *= timeSinceLanding / IMPAIRED_ACCELERATION_TIME; } } SetMaxSpeed(MAX(speed, 56)); +} - Vector absoluteVelocity = GetAbsVelocity(); - absoluteVelocity.z = 0.f; - float currentSpeed = absoluteVelocity.Length(); +void CNEO_Player::PreThink(void) +{ + BaseClass::PreThink(); - if (GetMoveType() != MOVETYPE_LADDER && NEORules()->GetGhosterPlayer() == entindex() && currentSpeed > GetPlayerMaxSpeed()) + if (!m_bInThermOpticCamo) { - float maxSpeed = GetPlayerMaxSpeed(); - float overSpeed = currentSpeed - maxSpeed; - - absoluteVelocity.NormalizeInPlace(); - absoluteVelocity *= -overSpeed; - ApplyAbsVelocityImpulse(absoluteVelocity); + CloakPower_Update(); } + CalculateSpeed(); + CheckThermOpticButtons(); CheckVisionButtons(); diff --git a/mp/src/game/server/neo/neo_player.h b/mp/src/game/server/neo/neo_player.h index eadf33a81..c48d174de 100644 --- a/mp/src/game/server/neo/neo_player.h +++ b/mp/src/game/server/neo/neo_player.h @@ -60,6 +60,7 @@ class CNEO_Player : public CHL2MP_Player virtual void Precache(void) OVERRIDE; virtual void Spawn(void) OVERRIDE; virtual void PostThink(void) OVERRIDE; + virtual void CalculateSpeed(void); virtual void PreThink(void) OVERRIDE; virtual void PlayerDeathThink(void) OVERRIDE; virtual bool HandleCommand_JoinTeam(int team) OVERRIDE; diff --git a/mp/src/game/shared/neo/neo_player_shared.cpp b/mp/src/game/shared/neo/neo_player_shared.cpp index 072f0f719..79bbe32cf 100644 --- a/mp/src/game/shared/neo/neo_player_shared.cpp +++ b/mp/src/game/shared/neo/neo_player_shared.cpp @@ -39,6 +39,8 @@ ConVar neo_aim_hold("neo_aim_hold", "0", FCVAR_USERINFO | FCVAR_ARCHIVE, "Hold t ConVar neo_recon_superjump_intensity("neo_recon_superjump_intensity", "250", FCVAR_REPLICATED | FCVAR_CHEAT, "Recon superjump intensity multiplier.", true, 1.0, false, 0); +ConVar neo_ghost_bhopping("neo_ghost_bhopping", "0", FCVAR_REPLICATED, "Allow ghost bunnyhopping", true, 0, true, 1); + bool IsAllowedToZoom(CNEOBaseCombatWeapon *pWep) { if (!pWep || pWep->m_bInReload || pWep->GetRoundBeingChambered()) From b8345de7d259daf5a6a6d2a2045819dd6ad2e96b Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Mon, 27 Jan 2025 14:57:18 +0000 Subject: [PATCH 03/10] update sprint speed modifiers --- mp/src/game/client/neo/c_neo_player.cpp | 6 +++--- mp/src/game/server/neo/neo_player.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 6040d19e5..67e6665b1 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -813,9 +813,9 @@ void C_NEO_Player::CalculateSpeed(void) } if (IsSprinting() && !IsAirborne()) { - static constexpr float RECON_SPRINT_SPEED_MODIFIER = 0.75; - static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6; - speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER; + static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35; + static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 1.6; + speed *= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER; } if (IsInAim()) { diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index 74e88892a..a91182587 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -677,9 +677,9 @@ void CNEO_Player::CalculateSpeed(void) } if (IsSprinting() && !IsAirborne()) { - static constexpr float RECON_SPRINT_SPEED_MODIFIER = 0.75; - static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 0.6; - speed /= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER; + static constexpr float RECON_SPRINT_SPEED_MODIFIER = 1.35; + static constexpr float OTHER_CLASSES_SPRINT_SPEED_MODIFIER = 1.6; + speed *= m_iNeoClass == NEO_CLASS_RECON ? RECON_SPRINT_SPEED_MODIFIER : OTHER_CLASSES_SPRINT_SPEED_MODIFIER; } if (IsInAim()) { From 1490ad183e79844dfbe07b9aaf66af5c2f4f58b5 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Mon, 27 Jan 2025 15:28:38 +0000 Subject: [PATCH 04/10] weapon_ownsthisitem or some such too expensive to run every tick, instead keep track of whether player is carrying a weapon_ghost --- mp/src/game/client/neo/c_neo_player.cpp | 3 ++- mp/src/game/client/neo/c_neo_player.h | 1 + mp/src/game/server/neo/neo_player.cpp | 3 ++- mp/src/game/server/neo/neo_player.h | 1 + mp/src/game/shared/neo/neo_gamerules.cpp | 2 ++ mp/src/game/shared/neo/weapons/weapon_ghost.cpp | 7 +++++++ mp/src/game/shared/neo/weapons/weapon_ghost.h | 12 ++++++++++++ 7 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 67e6665b1..c24f5e326 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -439,6 +439,7 @@ C_NEO_Player::C_NEO_Player() m_bInThermOpticCamo = m_bInVision = false; m_bHasBeenAirborneForTooLongToSuperJump = false; m_bInAim = false; + m_bCarryingGhost = false; m_bIneligibleForLoadoutPick = false; m_bInLean = NEO_LEAN_NONE; @@ -831,7 +832,7 @@ void C_NEO_Player::CalculateSpeed(void) absoluteVelocity.z = 0.f; float currentSpeed = absoluteVelocity.Length(); - if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && Weapon_OwnsThisType("weapon_ghost")) + if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && m_bCarryingGhost) { float overSpeed = currentSpeed - speed; absoluteVelocity.NormalizeInPlace(); diff --git a/mp/src/game/client/neo/c_neo_player.h b/mp/src/game/client/neo/c_neo_player.h index d78d5dbd5..038a1f0a6 100644 --- a/mp/src/game/client/neo/c_neo_player.h +++ b/mp/src/game/client/neo/c_neo_player.h @@ -197,6 +197,7 @@ class C_NEO_Player : public C_HL2MP_Player CNetworkVar(bool, m_bInVision); CNetworkVar(bool, m_bInAim); CNetworkVar(int, m_bInLean); + CNetworkVar(bool, m_bCarryingGhost); CNetworkVar(bool, m_bIneligibleForLoadoutPick); CNetworkVar(int, m_iNeoClass); diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index a91182587..fd8fa10f7 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -399,6 +399,7 @@ CNEO_Player::CNEO_Player() m_bInThermOpticCamo = m_bInVision = false; m_bHasBeenAirborneForTooLongToSuperJump = false; m_bInAim = false; + m_bCarryingGhost = false; m_bInLean = NEO_LEAN_NONE; m_iLoadoutWepChoice = 0; @@ -695,7 +696,7 @@ void CNEO_Player::CalculateSpeed(void) absoluteVelocity.z = 0.f; float currentSpeed = absoluteVelocity.Length(); - if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && Weapon_OwnsThisType("weapon_ghost")) + if (!neo_ghost_bhopping.GetBool() && GetMoveType() != MOVETYPE_LADDER && currentSpeed > speed && m_bCarryingGhost) { float overSpeed = currentSpeed - speed; absoluteVelocity.NormalizeInPlace(); diff --git a/mp/src/game/server/neo/neo_player.h b/mp/src/game/server/neo/neo_player.h index c48d174de..c6c47a875 100644 --- a/mp/src/game/server/neo/neo_player.h +++ b/mp/src/game/server/neo/neo_player.h @@ -246,6 +246,7 @@ class CNEO_Player : public CHL2MP_Player CNetworkVar(bool, m_bHasBeenAirborneForTooLongToSuperJump); CNetworkVar(bool, m_bInAim); CNetworkVar(int, m_bInLean); + CNetworkVar(bool, m_bCarryingGhost); CNetworkVar(bool, m_bIneligibleForLoadoutPick); CNetworkVar(float, m_flCamoAuxLastTime); diff --git a/mp/src/game/shared/neo/neo_gamerules.cpp b/mp/src/game/shared/neo/neo_gamerules.cpp index 5e1789d9e..e3420ba51 100644 --- a/mp/src/game/shared/neo/neo_gamerules.cpp +++ b/mp/src/game/shared/neo/neo_gamerules.cpp @@ -815,6 +815,7 @@ void CNEORules::Think(void) if ((playerTeam == TEAM_JINRAI || playerTeam == TEAM_NSF) && RespawnWithRet(player, false)) { player->m_bInAim = false; + player->m_bCarryingGhost = false; player->m_bInThermOpticCamo = false; player->m_bInVision = false; player->m_bIneligibleForLoadoutPick = false; @@ -2026,6 +2027,7 @@ void CNEORules::StartNextRound() pPlayer->Spawn(); pPlayer->m_bInAim = false; + pPlayer->m_bCarryingGhost = false; pPlayer->m_bInThermOpticCamo = false; pPlayer->m_bInVision = false; pPlayer->m_bIneligibleForLoadoutPick = false; diff --git a/mp/src/game/shared/neo/weapons/weapon_ghost.cpp b/mp/src/game/shared/neo/weapons/weapon_ghost.cpp index 98b391651..d15d22daa 100644 --- a/mp/src/game/shared/neo/weapons/weapon_ghost.cpp +++ b/mp/src/game/shared/neo/weapons/weapon_ghost.cpp @@ -178,6 +178,8 @@ void CWeaponGhost::OnPickedUp(CBaseCombatCharacter *pNewOwner) neoOwner->StopSprinting(); } + neoOwner->m_bCarryingGhost = true; + #ifdef GAME_DLL CTeamRecipientFilter filter(NEORules()->GetOpposingTeam(neoOwner), true); EmitSound_t params; @@ -190,6 +192,11 @@ void CWeaponGhost::OnPickedUp(CBaseCombatCharacter *pNewOwner) void CWeaponGhost::Drop(const Vector &vecVelocity) { + if (GetOwner()) + { + auto neoOwner = static_cast(GetOwner()); + neoOwner->m_bCarryingGhost = false; + } BaseClass::Drop(vecVelocity); #if !defined( CLIENT_DLL ) SetRemoveable(false); diff --git a/mp/src/game/shared/neo/weapons/weapon_ghost.h b/mp/src/game/shared/neo/weapons/weapon_ghost.h index 9eff61cae..d1dc80d49 100644 --- a/mp/src/game/shared/neo/weapons/weapon_ghost.h +++ b/mp/src/game/shared/neo/weapons/weapon_ghost.h @@ -59,6 +59,18 @@ class CWeaponGhost : public CNEOBaseCombatWeapon void TryGhostPing(float closestEnemy); #endif + virtual void UpdateOnRemove() override + { + if (GetOwner()) + { + auto neoPlayer = static_cast(GetPlayerOwner()); + neoPlayer->m_bCarryingGhost = false; + } +#ifdef CLIENT_DLL + StopGhostSound(); +#endif //CLIENT_DLL + BaseClass::UpdateOnRemove(); + }; private: From 0ae5d6a4f7cad28bb3d08ede9e31f01b08504d55 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 14:51:27 +0000 Subject: [PATCH 05/10] calculation closer to original without the dip once speed passes 55 threshold --- mp/src/game/client/neo/c_neo_player.cpp | 38 +++++++++++-------------- mp/src/game/server/neo/neo_player.cpp | 38 +++++++++++-------------- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index c24f5e326..39e4b60bb 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -803,6 +803,22 @@ extern ConVar neo_ghost_bhopping; void C_NEO_Player::CalculateSpeed(void) { float speed = GetNormSpeed(); + + if (auto pNeoWep = static_cast(GetActiveWeapon())) + { + speed *= pNeoWep->GetSpeedScale(); + } + // Slowdown after landing + if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) + { + const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + constexpr float SLOWDOWN_TIME = 1.15f; + if (timeSinceLanding < SLOWDOWN_TIME) + { + speed = MAX(75, speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05))); + } + } + static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) { @@ -823,10 +839,6 @@ void C_NEO_Player::CalculateSpeed(void) static constexpr float AIM_SPEED_MODIFIER = 0.6; speed *= AIM_SPEED_MODIFIER; } - if (auto pNeoWep = static_cast(GetActiveWeapon())) - { - speed *= pNeoWep->GetSpeedScale(); - } Vector absoluteVelocity = GetAbsVelocity(); absoluteVelocity.z = 0.f; @@ -839,23 +851,7 @@ void C_NEO_Player::CalculateSpeed(void) absoluteVelocity *= -overSpeed; ApplyAbsVelocityImpulse(absoluteVelocity); } - - // Slowdown after landing - if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) - { - const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; - constexpr float INITIAL_SLOWDOWN_TIME = 0.25f; - constexpr float IMPAIRED_ACCELERATION_TIME = INITIAL_SLOWDOWN_TIME + (1 / 3.f); - if (timeSinceLanding < INITIAL_SLOWDOWN_TIME) - { - speed = MIN(speed, 75.f); - } - else if (timeSinceLanding < IMPAIRED_ACCELERATION_TIME) - { - speed *= timeSinceLanding / IMPAIRED_ACCELERATION_TIME; - } - } - SetMaxSpeed(MAX(speed, 56)); + SetMaxSpeed(MAX(speed, 55)); } extern ConVar sv_infinite_aux_power; diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index fd8fa10f7..97f39dcc3 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -667,6 +667,22 @@ extern ConVar neo_ghost_bhopping; void CNEO_Player::CalculateSpeed(void) { float speed = GetNormSpeed(); + + if (auto pNeoWep = static_cast(GetActiveWeapon())) + { + speed *= pNeoWep->GetSpeedScale(); + } + // Slowdown after landing + if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) + { + const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + constexpr float SLOWDOWN_TIME = 1.15f; + if (timeSinceLanding < SLOWDOWN_TIME) + { + speed = MAX(75,speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05))); + } + } + static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) { @@ -687,10 +703,6 @@ void CNEO_Player::CalculateSpeed(void) static constexpr float AIM_SPEED_MODIFIER = 0.6; speed *= AIM_SPEED_MODIFIER; } - if (auto pNeoWep = static_cast(GetActiveWeapon())) - { - speed *= pNeoWep->GetSpeedScale(); - } Vector absoluteVelocity = GetAbsVelocity(); absoluteVelocity.z = 0.f; @@ -703,23 +715,7 @@ void CNEO_Player::CalculateSpeed(void) absoluteVelocity *= -overSpeed; ApplyAbsVelocityImpulse(absoluteVelocity); } - - // Slowdown after landing - if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) - { - const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; - constexpr float INITIAL_SLOWDOWN_TIME = 0.25f; - constexpr float IMPAIRED_ACCELERATION_TIME = INITIAL_SLOWDOWN_TIME + (1 / 3.f); - if (timeSinceLanding < INITIAL_SLOWDOWN_TIME) - { - speed = MIN(speed, 75.f); - } - else if (timeSinceLanding < IMPAIRED_ACCELERATION_TIME) - { - speed *= timeSinceLanding / IMPAIRED_ACCELERATION_TIME; - } - } - SetMaxSpeed(MAX(speed, 56)); + SetMaxSpeed(MAX(speed, 55)); } void CNEO_Player::PreThink(void) From af2a74ca0b08c20fbd06c7b2449011fa7acf2041 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 15:19:54 +0000 Subject: [PATCH 06/10] little smaller --- mp/src/game/client/neo/c_neo_player.cpp | 2 +- mp/src/game/server/neo/neo_player.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 39e4b60bb..6469b3aad 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -815,7 +815,7 @@ void C_NEO_Player::CalculateSpeed(void) constexpr float SLOWDOWN_TIME = 1.15f; if (timeSinceLanding < SLOWDOWN_TIME) { - speed = MAX(75, speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05))); + speed = MAX(75, speed * MAX(0.01, 1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); } } diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index 97f39dcc3..6c132f0f3 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -679,7 +679,7 @@ void CNEO_Player::CalculateSpeed(void) constexpr float SLOWDOWN_TIME = 1.15f; if (timeSinceLanding < SLOWDOWN_TIME) { - speed = MAX(75,speed * MAX(0.01, 1 - (((SLOWDOWN_TIME - timeSinceLanding) * 35) * 0.05))); + speed = MAX(75,speed * MAX(0.01, 1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); } } From 8a8beda061d2cb8cf836714b0ae4a815e4456dec Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 15:24:35 +0000 Subject: [PATCH 07/10] unnecessary max --- mp/src/game/client/neo/c_neo_player.cpp | 2 +- mp/src/game/server/neo/neo_player.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 6469b3aad..2ca1e108b 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -815,7 +815,7 @@ void C_NEO_Player::CalculateSpeed(void) constexpr float SLOWDOWN_TIME = 1.15f; if (timeSinceLanding < SLOWDOWN_TIME) { - speed = MAX(75, speed * MAX(0.01, 1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); + speed = MAX(75, speed * (1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); } } diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index 6c132f0f3..f7e8e0bca 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -679,7 +679,7 @@ void CNEO_Player::CalculateSpeed(void) constexpr float SLOWDOWN_TIME = 1.15f; if (timeSinceLanding < SLOWDOWN_TIME) { - speed = MAX(75,speed * MAX(0.01, 1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); + speed = MAX(75,speed * (1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); } } From 52cfe4e855105e2fd8e7dd82ab53c58d7729ad18 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 16:00:42 +0000 Subject: [PATCH 08/10] landing slowdown actually jumping slowdown upon landing --- mp/src/game/client/neo/c_neo_player.cpp | 10 ++++++---- mp/src/game/client/neo/c_neo_player.h | 1 + mp/src/game/server/neo/neo_player.cpp | 10 ++++++---- mp/src/game/server/neo/neo_player.h | 1 + mp/src/game/shared/gamemovement.cpp | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 2ca1e108b..8bce8c76e 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -77,6 +77,7 @@ IMPLEMENT_CLIENTCLASS_DT(C_NEO_Player, DT_NEO_Player, CNEO_Player) RecvPropTime(RECVINFO(m_flCamoAuxLastTime)), RecvPropInt(RECVINFO(m_nVisionLastTick)), + RecvPropTime(RECVINFO(m_flJumpLastTime)), RecvPropArray(RecvPropVector(RECVINFO(m_rvFriendlyPlayerPositions[0])), m_rvFriendlyPlayerPositions), RecvPropArray(RecvPropInt(RECVINFO(m_rfAttackersScores[0])), m_rfAttackersScores), @@ -108,6 +109,7 @@ BEGIN_PREDICTION_DATA(C_NEO_Player) DEFINE_PRED_FIELD(m_bHasBeenAirborneForTooLongToSuperJump, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_nVisionLastTick, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flJumpLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE), END_PREDICTION_DATA() static void __MsgFunc_DamageInfo(bf_read& msg) @@ -808,14 +810,14 @@ void C_NEO_Player::CalculateSpeed(void) { speed *= pNeoWep->GetSpeedScale(); } - // Slowdown after landing + // Slowdown after jumping if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) { - const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + const float timeSinceJumping = gpGlobals->curtime - m_flJumpLastTime; constexpr float SLOWDOWN_TIME = 1.15f; - if (timeSinceLanding < SLOWDOWN_TIME) + if (timeSinceJumping < SLOWDOWN_TIME) { - speed = MAX(75, speed * (1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); + speed = MAX(75, speed * (1 - ((SLOWDOWN_TIME - timeSinceJumping) * 1.75))); } } diff --git a/mp/src/game/client/neo/c_neo_player.h b/mp/src/game/client/neo/c_neo_player.h index 038a1f0a6..06ce60e9e 100644 --- a/mp/src/game/client/neo/c_neo_player.h +++ b/mp/src/game/client/neo/c_neo_player.h @@ -191,6 +191,7 @@ class C_NEO_Player : public C_HL2MP_Player CNetworkVar(float, m_flCamoAuxLastTime); CNetworkVar(int, m_nVisionLastTick); + CNetworkVar(float, m_flJumpLastTime); CNetworkVar(bool, m_bInThermOpticCamo); CNetworkVar(bool, m_bLastTickInThermOpticCamo); diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index f7e8e0bca..753896c84 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -61,6 +61,7 @@ SendPropBool(SENDINFO(m_bIneligibleForLoadoutPick)), SendPropTime(SENDINFO(m_flCamoAuxLastTime)), SendPropInt(SENDINFO(m_nVisionLastTick)), +SendPropTime(SENDINFO(m_flJumpLastTime)), SendPropString(SENDINFO(m_pszTestMessage)), @@ -97,6 +98,7 @@ DEFINE_FIELD(m_bInAim, FIELD_BOOLEAN), DEFINE_FIELD(m_flCamoAuxLastTime, FIELD_TIME), DEFINE_FIELD(m_nVisionLastTick, FIELD_TICK), +DEFINE_FIELD(m_flJumpLastTime, FIELD_TIME), DEFINE_FIELD(m_pszTestMessage, FIELD_STRING), @@ -672,14 +674,14 @@ void CNEO_Player::CalculateSpeed(void) { speed *= pNeoWep->GetSpeedScale(); } - // Slowdown after landing + // Slowdown after jumping if (!IsAirborne() && m_iNeoClass != NEO_CLASS_RECON) { - const float timeSinceLanding = gpGlobals->curtime - m_flLastAirborneJumpOkTime; + const float timeSinceJumping = gpGlobals->curtime - m_flJumpLastTime; constexpr float SLOWDOWN_TIME = 1.15f; - if (timeSinceLanding < SLOWDOWN_TIME) + if (timeSinceJumping < SLOWDOWN_TIME) { - speed = MAX(75,speed * (1 - ((SLOWDOWN_TIME - timeSinceLanding) * 1.75))); + speed = MAX(75,speed * (1 - ((SLOWDOWN_TIME - timeSinceJumping) * 1.75))); } } diff --git a/mp/src/game/server/neo/neo_player.h b/mp/src/game/server/neo/neo_player.h index c6c47a875..dd048c415 100644 --- a/mp/src/game/server/neo/neo_player.h +++ b/mp/src/game/server/neo/neo_player.h @@ -251,6 +251,7 @@ class CNEO_Player : public CHL2MP_Player CNetworkVar(float, m_flCamoAuxLastTime); CNetworkVar(int, m_nVisionLastTick); + CNetworkVar(float, m_flJumpLastTime); CNetworkArray(Vector, m_rvFriendlyPlayerPositions, MAX_PLAYERS); CNetworkArray(int, m_rfAttackersScores, (MAX_PLAYERS + 1)); diff --git a/mp/src/game/shared/gamemovement.cpp b/mp/src/game/shared/gamemovement.cpp index 0a77e6043..108d1678f 100644 --- a/mp/src/game/shared/gamemovement.cpp +++ b/mp/src/game/shared/gamemovement.cpp @@ -2531,6 +2531,7 @@ bool CGameMovement::CheckJumpButton( void ) break; } neoPlayer->DoAnimationEvent(PLAYERANIMEVENT_JUMP); + neoPlayer->m_flJumpLastTime = gpGlobals->curtime; #endif // Acclerate upward From 7950f36af600f33e0270b8f365ffedeb2322a43e Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 16:27:53 +0000 Subject: [PATCH 09/10] use flags instead to work out if ducking, means duck speed modifier is only applied when ducked and unducking, same as in the original --- mp/src/game/client/neo/c_neo_player.cpp | 2 +- mp/src/game/server/neo/neo_player.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 8bce8c76e..9c0ba8bfe 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -822,7 +822,7 @@ void C_NEO_Player::CalculateSpeed(void) } static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; - if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) + if (GetFlags() & FL_DUCKING) { speed *= DUCK_WALK_SPEED_MODIFIER; } diff --git a/mp/src/game/server/neo/neo_player.cpp b/mp/src/game/server/neo/neo_player.cpp index 753896c84..baa7e2e1d 100644 --- a/mp/src/game/server/neo/neo_player.cpp +++ b/mp/src/game/server/neo/neo_player.cpp @@ -686,7 +686,7 @@ void CNEO_Player::CalculateSpeed(void) } static constexpr float DUCK_WALK_SPEED_MODIFIER = 0.75; - if (m_nButtons & IN_DUCK || IsDucked() || IsDucking()) + if (GetFlags() & FL_DUCKING) { speed *= DUCK_WALK_SPEED_MODIFIER; } From a01b3048abc983cf2e64215d96f6b330de436836 Mon Sep 17 00:00:00 2001 From: AdamTadeusz Date: Fri, 7 Feb 2025 16:30:52 +0000 Subject: [PATCH 10/10] wrong macro thank you linux --- mp/src/game/client/neo/c_neo_player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mp/src/game/client/neo/c_neo_player.cpp b/mp/src/game/client/neo/c_neo_player.cpp index 9c0ba8bfe..27a3dc950 100644 --- a/mp/src/game/client/neo/c_neo_player.cpp +++ b/mp/src/game/client/neo/c_neo_player.cpp @@ -109,7 +109,7 @@ BEGIN_PREDICTION_DATA(C_NEO_Player) DEFINE_PRED_FIELD(m_bHasBeenAirborneForTooLongToSuperJump, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_nVisionLastTick, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), - DEFINE_PRED_FIELD(m_flJumpLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE), + DEFINE_PRED_FIELD_TOL(m_flJumpLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE), END_PREDICTION_DATA() static void __MsgFunc_DamageInfo(bf_read& msg)