This commit is contained in:
speedvoltage 2025-03-29 21:45:24 +01:00 committed by GitHub
commit 569aefe4e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 75 additions and 9 deletions

View file

@ -795,6 +795,24 @@ void C_HL2MP_Player::HandleSpeedChanges( CMoveData *mv )
const bool bWantsToChangeSprinting = ( m_HL2Local.m_bNewSprinting != bWantSprint ) && ( nChangedButtons & IN_SPEED ) != 0;
bool bSprinting = m_HL2Local.m_bNewSprinting;
// Fixes:
// 1) Completely stop sprinting when going underwater
// 2) Fix sprint not starting during unducking
if ( GetWaterLevel() == 3 )
bSprinting = false;
// Putting those here instead of within bWantsToChangeSprinting to ensure sprint properly starts when summoned!
if ( GetGroundEntity() == NULL && ( mv->m_nButtons & IN_SPEED ) )
bSprinting = true;
if ( m_Local.m_bDucked && !m_Local.m_bDucking && bSprinting )
bSprinting = false;
if ( m_Local.m_bDucked && m_Local.m_bDucking && !bSprinting && ( mv->m_nButtons & IN_SPEED ) )
bSprinting = true;
if ( bWantsToChangeSprinting )
{
if ( bWantSprint )

View file

@ -99,6 +99,10 @@ public:
bool SuitPower_ShouldRecharge( void );
float SuitPower_GetCurrentPercentage( void ) { return m_HL2Local.m_flSuitPower; }
bool IsNewSprinting() const
{
return m_HL2Local.m_bNewSprinting;
}
bool CanSprint( void );
void StartSprinting( void );
void StopSprinting( void );

View file

@ -505,6 +505,26 @@ void CHL2_Player::HandleSpeedChanges( CMoveData *mv )
const bool bWantsToChangeSprinting = ( m_HL2Local.m_bNewSprinting != bWantSprint ) && ( nChangedButtons & IN_SPEED ) != 0;
bool bSprinting = m_HL2Local.m_bNewSprinting;
// Fixes:
// 1) Completely stop sprinting when going underwater
// 2) Fix sprint not starting during unducking
if ( GetWaterLevel() == 3 )
bSprinting = false;
// Putting those here instead of within bWantsToChangeSprinting to ensure sprint properly starts when summoned!
// Restoring pre-OB (2010) working sprinting behavior.
if ( GetGroundEntity() == NULL && ( mv->m_nButtons & IN_SPEED ) )
bSprinting = true;
if ( m_Local.m_bDucked && !m_Local.m_bDucking && bSprinting )
bSprinting = false;
if ( m_Local.m_bDucked && m_Local.m_bDucking && !bSprinting && ( mv->m_nButtons & IN_SPEED ) )
bSprinting = true;
if ( bWantsToChangeSprinting )
{
if ( bWantSprint )

View file

@ -172,6 +172,11 @@ public:
bool CanSprint( void );
void EnableSprint( bool bEnable);
bool IsNewSprinting() const
{
return m_HL2Local.m_bNewSprinting;
}
bool CanZoom( CBaseEntity *pRequester );
void ToggleZoom(void);
void StartZooming( void );

View file

@ -14,6 +14,11 @@
#include "decals.h"
#include "coordsize.h"
#include "rumble_shared.h"
#ifdef GAME_DLL
#include "hl2_player.h"
#else
#include "c_hl2mp_player.h"
#endif
#ifdef CLIENT_DLL
#include "prediction.h"
#endif
@ -4204,9 +4209,6 @@ void CGameMovement::FinishUnDuckJump( trace_t &trace )
//-----------------------------------------------------------------------------
void CGameMovement::FinishDuck( void )
{
if ( player->GetFlags() & FL_DUCKING )
return;
player->AddFlag( FL_DUCKING );
player->m_Local.m_bDucked = true;
player->m_Local.m_bDucking = false;
@ -4297,16 +4299,33 @@ void CGameMovement::SetDuckedEyeOffset( float duckFraction )
//-----------------------------------------------------------------------------
void CGameMovement::HandleDuckingSpeedCrop( void )
{
if ( !( m_iSpeedCropped & SPEED_CROPPED_DUCK ) && ( player->GetFlags() & FL_DUCKING ) && ( player->GetGroundEntity() != NULL ) )
#ifdef GAME_DLL
CHL2_Player *pHL2Player = dynamic_cast< CHL2_Player * >( player );
#else
C_HL2MP_Player *pHL2Player = dynamic_cast< C_HL2MP_Player * >( player );
#endif
if ( ( m_iSpeedCropped & SPEED_CROPPED_DUCK ) ||
!( player->GetFlags() & FL_DUCKING ) ||
( player->GetGroundEntity() == NULL ) )
{
float frac = 0.33333333f;
mv->m_flForwardMove *= frac;
mv->m_flSideMove *= frac;
mv->m_flUpMove *= frac;
m_iSpeedCropped |= SPEED_CROPPED_DUCK;
return;
}
// Let sprint happen during unducking if requested
if ( pHL2Player && pHL2Player->IsNewSprinting() )
{
return; // No speed crop if sprinting.
}
float frac = 0.33333333f;
mv->m_flForwardMove *= frac;
mv->m_flSideMove *= frac;
mv->m_flUpMove *= frac;
m_iSpeedCropped |= SPEED_CROPPED_DUCK;
}
//-----------------------------------------------------------------------------
// Purpose: Check to see if we are in a situation where we can unduck jump.
//-----------------------------------------------------------------------------