Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 81 additions & 7 deletions src/game/shared/hl2mp/hl2mp_playeranimstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand All @@ -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 -
Expand Down Expand Up @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/game/shared/hl2mp/hl2mp_playeranimstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading