diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp index 9e441acd87..a89f6d9612 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp @@ -112,6 +112,9 @@ CHL2MPPlayerAnimState::~CHL2MPPlayerAnimState() void CHL2MPPlayerAnimState::InitHL2MPAnimState( CHL2MP_Player *pPlayer ) { m_pHL2MPPlayer = pPlayer; +#if defined( NEO ) && defined( CLIENT_DLL ) + m_flJumpGroundFlagTime = 0.0f; +#endif } //----------------------------------------------------------------------------- @@ -417,14 +420,9 @@ bool CHL2MPPlayerAnimState::HandleMoving( Activity &idealActivity ) { idealActivity = ACT_RUN; } - else + else if (GetMovingSpeed() > 0.5) { - Vector vecVelocity; - GetOuterAbsVelocity(vecVelocity); - if (vecVelocity.Length() > 0.5) - { - idealActivity = ACT_WALK; - } + idealActivity = ACT_WALK; } return true; @@ -433,6 +431,24 @@ bool CHL2MPPlayerAnimState::HandleMoving( Activity &idealActivity ) #endif } +#ifdef NEO +//----------------------------------------------------------------------------- +// Purpose: The speed that counts as moving for the legs and feet: rising or falling is not walking, +// as in classic NEOTOKYO, but climbing a ladder keeps the walk animation it has always had. +//----------------------------------------------------------------------------- +float CHL2MPPlayerAnimState::GetMovingSpeed() +{ + if ( m_pHL2MPPlayer->GetMoveType() == MOVETYPE_LADDER ) + { + Vector vecVelocity; + GetOuterAbsVelocity( vecVelocity ); + return vecVelocity.Length(); + } + + return GetOuterXYSpeed(); +} +#endif // NEO + //----------------------------------------------------------------------------- // Purpose: // Input : *idealActivity - @@ -480,6 +496,9 @@ bool CHL2MPPlayerAnimState::HandleJumping( Activity &idealActivity ) { m_bFirstJumpFrame = false; RestartMainSequence(); // Reset the animation. +#if defined( NEO ) && defined( CLIENT_DLL ) + m_flJumpGroundFlagTime = 0.0f; +#endif } // Reset if we hit water and start swimming. @@ -492,7 +511,11 @@ bool CHL2MPPlayerAnimState::HandleJumping( Activity &idealActivity ) // on-ground flag set right when the message comes in. else if ( gpGlobals->curtime - m_flJumpStartTime > 0.2f ) { +#ifdef NEO + if ( HasLandedFromJump() ) +#else if ( m_pHL2MPPlayer->GetFlags() & FL_ONGROUND ) +#endif { m_bJumping = false; RestartMainSequence(); @@ -539,6 +562,52 @@ bool CHL2MPPlayerAnimState::HandleJumping( Activity &idealActivity ) return false; } +#ifdef NEO +#ifdef CLIENT_DLL +// A jump has landed when the drawn body is this close above the ground (the ground check of player movement), +static constexpr float JUMP_LAND_GROUND_DIST = 2.0f; +// or when the ground flag has been set this long and the trace still finds no ground under the drawn body +static constexpr float JUMP_LAND_MAX_FLAG_LEAD = 0.5f; +#endif + +//----------------------------------------------------------------------------- +// Purpose: Whether a jumping player has landed. The client draws other players a few tenths of a second behind +// their networked ground flag, so there the jump lasts until the drawn body reaches the ground. +//----------------------------------------------------------------------------- +bool CHL2MPPlayerAnimState::HasLandedFromJump() +{ + if ( !( m_pHL2MPPlayer->GetFlags() & FL_ONGROUND ) ) + { +#ifdef CLIENT_DLL + m_flJumpGroundFlagTime = 0.0f; +#endif + return false; + } + +#ifdef CLIENT_DLL + if ( m_flJumpGroundFlagTime <= 0.0f ) + { + m_flJumpGroundFlagTime = gpGlobals->curtime; + } + + if ( gpGlobals->curtime - m_flJumpGroundFlagTime > JUMP_LAND_MAX_FLAG_LEAD ) + { + return true; + } + + const Vector &vecOrigin = m_pHL2MPPlayer->GetAbsOrigin(); + trace_t tr; + UTIL_TraceHull( vecOrigin, vecOrigin - Vector( 0, 0, JUMP_LAND_GROUND_DIST ), + m_pHL2MPPlayer->GetPlayerMins(), m_pHL2MPPlayer->GetPlayerMaxs(), + MASK_PLAYERSOLID, m_pHL2MPPlayer, COLLISION_GROUP_PLAYER_MOVEMENT, &tr ); + + return tr.fraction < 1.0f || tr.startsolid; +#else + return true; +#endif // CLIENT_DLL +} +#endif // NEO + bool CHL2MPPlayerAnimState::SetupPoseParameters( CStudioHdr *pStudioHdr ) { #ifdef NEO @@ -745,12 +814,17 @@ void CHL2MPPlayerAnimState::ComputePoseParam_AimPitch( CStudioHdr *pStudioHdr ) //----------------------------------------------------------------------------- void CHL2MPPlayerAnimState::ComputePoseParam_AimYaw( CStudioHdr *pStudioHdr ) { +#ifdef NEO + // Check to see if we are moving. + bool bMoving = GetMovingSpeed() > 1.0f; +#else // Get the movement velocity. Vector vecVelocity; GetOuterAbsVelocity( vecVelocity ); // Check to see if we are moving. bool bMoving = ( vecVelocity.Length() > 1.0f ) ? true : false; +#endif #ifdef NEO // If we are moving or leaning or are prone and undeployed. diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.h b/src/game/shared/hl2mp/hl2mp_playeranimstate.h index 9a05125539..4abf7842a6 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.h +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.h @@ -64,9 +64,14 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO bool IsLeaning(CStudioHdr *pStudioHdr); + float GetMovingSpeed(); + bool HasLandedFromJump(); #endif // NEO CHL2MP_Player *m_pHL2MPPlayer; +#if defined( NEO ) && defined( CLIENT_DLL ) + float m_flJumpGroundFlagTime; // when the client first saw the ground flag during a jump, 0 while in the air +#endif #ifndef NEO bool m_bInAirWalk; float m_flHoldDeployedPoseUntilTime;