Skip to content
Open
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
14 changes: 14 additions & 0 deletions src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ BEGIN_PREDICTION_DATA(C_NEO_Player)
DEFINE_PRED_FIELD_TOL(m_flVisionLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE),
DEFINE_PRED_FIELD_TOL(m_flJumpLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE),
DEFINE_PRED_FIELD_TOL(m_flNextPingTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE),
DEFINE_FIELD(m_iHeldStep, FIELD_INTEGER),
DEFINE_FIELD(m_nHeldStepKeysDown, FIELD_INTEGER),
DEFINE_FIELD(m_nHeldStepArmedKeys, FIELD_INTEGER),
DEFINE_FIELD(m_flHeldStepQuietTime, FIELD_FLOAT),
DEFINE_FIELD(m_flHeldStepDropTime, FIELD_FLOAT),
DEFINE_FIELD(m_flHeldStepWindow, FIELD_FLOAT),
DEFINE_FIELD(m_flFootstepAirTime, FIELD_FLOAT),
DEFINE_FIELD(m_bFootstepLanding, FIELD_BOOLEAN),
DEFINE_FIELD(m_flFootstepTurnRate, FIELD_FLOAT),
DEFINE_FIELD(m_flFootstepPrevYaw, FIELD_FLOAT),
DEFINE_FIELD(m_flFootstepTurnTime, FIELD_FLOAT),
DEFINE_FIELD(m_bFootstepForgivenessReady, FIELD_BOOLEAN),
DEFINE_FIELD(m_flSilentModeOnGroundTime, FIELD_FLOAT),
DEFINE_FIELD(m_flFootstepQuietTime, FIELD_FLOAT),
END_PREDICTION_DATA()

static void __MsgFunc_IdleRespawnShowMenu(bf_read &)
Expand Down
36 changes: 36 additions & 0 deletions src/game/client/neo/c_neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ class C_NEO_Player : public C_HL2MP_Player
virtual void StartWalking(void);
virtual void StopWalking(void);
bool IsMakingFootstepSounds(float* pVelRun={}, float* pSpeed={}, int* fLadder={}) const;
bool IsInSilentMoveMode() const;
int GetSilentMoveKeys(bool bCrouchFromPress) const;
bool IsOnFootstepGround() const;
bool IsQuietFootstep() const;
float GetSurfaceStepVolume(const surfacedata_t *psurface, bool bQuiet) const;
void UpdateFootstepTurnRate();
void UpdateFootstepLanding();
void OnFootstepDecided();
void UpdateHeldStep(bool bLoud, surfacedata_t *psurface, const Vector &vecOrigin);
void UpdateFootstepForgiveness(bool bLoud);
bool ForgiveStep();
bool HoldStep(surfacedata_t *psurface, const Vector &vecOrigin);

void Lean(void);

Expand Down Expand Up @@ -271,6 +283,30 @@ class C_NEO_Player : public C_HL2MP_Player

private:
C_NEO_Player(const C_NEO_Player &);

// Held step: the first audible step after pressing crouch, walk or aim, see UpdateHeldStep
bool IsHeldStepPending() const;
void PlayHeldStep(surfacedata_t *psurface, const Vector &vecOrigin);
int m_iHeldStep = NEO_FS_HELD_NONE;
int m_nHeldStepKeysDown = 0;
int m_nHeldStepArmedKeys = 0;
float m_flHeldStepQuietTime = -1.f;
float m_flHeldStepDropTime = 0.f;
float m_flHeldStepWindow = 0.f;

// Landing, see UpdateFootstepLanding
float m_flFootstepAirTime = -1.f;
bool m_bFootstepLanding = false;

// View turn rate in degrees per second, held at its peak and decaying, see UpdateFootstepTurnRate
float m_flFootstepTurnRate = 0.f;
float m_flFootstepPrevYaw = 0.f;
float m_flFootstepTurnTime = 0.f;

// First step forgiveness, see ForgiveStep
bool m_bFootstepForgivenessReady = true;
float m_flSilentModeOnGroundTime = -1.f;
float m_flFootstepQuietTime = -1.f;
};

inline C_NEO_Player *ToNEOPlayer(C_BaseEntity *pEntity)
Expand Down
35 changes: 35 additions & 0 deletions src/game/server/neo/neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ class CNEO_Player : public CHL2MP_Player
virtual void StartWalking(void) OVERRIDE;
virtual void StopWalking(void) OVERRIDE;
bool IsMakingFootstepSounds(float* pVelRun={}, float* pSpeed={}, int* fLadder={}) const;
bool IsInSilentMoveMode() const;
int GetSilentMoveKeys(bool bCrouchFromPress) const;
bool IsOnFootstepGround() const;
bool IsQuietFootstep() const;
float GetSurfaceStepVolume(const surfacedata_t *psurface, bool bQuiet) const;
void UpdateFootstepTurnRate();
void UpdateFootstepLanding();
void OnFootstepDecided();
void UpdateHeldStep(bool bLoud, surfacedata_t *psurface, const Vector &vecOrigin);
void UpdateFootstepForgiveness(bool bLoud);
bool ForgiveStep();
bool HoldStep(surfacedata_t *psurface, const Vector &vecOrigin);

// Cloak Power Interface
float CloakPower_Get(void) const ;
Expand Down Expand Up @@ -377,6 +389,29 @@ class CNEO_Player : public CHL2MP_Player
CNetworkHandle(CNEO_Player, m_hSpectatorTakeoverPlayerTarget);
CNetworkHandle(CNEO_Player, m_hSpectatorTakeoverPlayerImpersonatingMe);

// Held step: the first audible step after pressing crouch, walk or aim, see UpdateHeldStep
bool IsHeldStepPending() const;
void PlayHeldStep(surfacedata_t *psurface, const Vector &vecOrigin);
int m_iHeldStep = NEO_FS_HELD_NONE;
int m_nHeldStepKeysDown = 0;
int m_nHeldStepArmedKeys = 0;
float m_flHeldStepQuietTime = -1.f;
float m_flHeldStepDropTime = 0.f;
float m_flHeldStepWindow = 0.f;

// Landing, see UpdateFootstepLanding
float m_flFootstepAirTime = -1.f;
bool m_bFootstepLanding = false;

// View turn rate in degrees per second, held at its peak and decaying, see UpdateFootstepTurnRate
float m_flFootstepTurnRate = 0.f;
float m_flFootstepPrevYaw = 0.f;
float m_flFootstepTurnTime = 0.f;

// First step forgiveness, see ForgiveStep
bool m_bFootstepForgivenessReady = true;
float m_flSilentModeOnGroundTime = -1.f;
float m_flFootstepQuietTime = -1.f;
};

inline CNEO_Player *ToNEOPlayer(CBaseEntity *pEntity)
Expand Down
34 changes: 32 additions & 2 deletions src/game/shared/baseplayer_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,12 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri
int fLadder;

#ifdef NEO
const bool bSilent = !assert_cast<CNEO_Player*>(this)->IsMakingFootstepSounds(&velrun, &speed, &fLadder);
CNEO_Player *pNeoPlayer = assert_cast<CNEO_Player*>(this);
pNeoPlayer->UpdateFootstepTurnRate();
pNeoPlayer->UpdateFootstepLanding();
const bool bSilent = !pNeoPlayer->IsMakingFootstepSounds(&velrun, &speed, &fLadder);
pNeoPlayer->UpdateHeldStep(!bSilent, psurface, vecOrigin);
pNeoPlayer->UpdateFootstepForgiveness(!bSilent);
#endif


Expand All @@ -566,6 +571,12 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri

if ( m_flStepSoundTime > 0 )
return;
#ifdef NEO
pNeoPlayer->OnFootstepDecided();
// Off the ground the step timer waits at zero, as in the SDK, so the step lands on the tick the player does
if ( !fLadder && !( GetFlags() & FL_ONGROUND ) && GetWaterLevel() == WL_NotInWater )
return;
#endif

#ifndef NEO
if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS))
Expand Down Expand Up @@ -606,6 +617,11 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri

#endif
bWalking = speed < velrun;
#ifdef NEO
const bool bQuietStep = pNeoPlayer->IsQuietFootstep();
#else
const bool bQuietStep = bWalking;
#endif
#ifndef NEO

VectorCopy( vecOrigin, knee );
Expand Down Expand Up @@ -651,7 +667,7 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri
else if ( GetWaterLevel() == WL_Feet )
{
psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) );
fvol = bWalking ? 0.2 : 0.5;
fvol = bQuietStep ? 0.2 : 0.5;

SetStepSoundTime( STEPSOUNDTIME_WATER_FOOT, bWalking );
}
Expand All @@ -662,6 +678,9 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri

SetStepSoundTime( STEPSOUNDTIME_NORMAL, bWalking );

#ifdef NEO
fvol = pNeoPlayer->GetSurfaceStepVolume(psurface, bQuietStep);
#else
switch ( psurface->game.material )
{
default:
Expand Down Expand Up @@ -693,6 +712,7 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri
fvol = bWalking ? 0.2 : 0.5;
break;
}
#endif
}

#ifdef NEO
Expand All @@ -704,8 +724,18 @@ void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOri
// 65% volume if ducking
if ( GetFlags() & FL_DUCKING )
{
#ifdef NEO
fvol *= NEO_FS_CROUCH_VOLUME_SCALE;
#else
fvol *= 0.65;
#endif
}
#ifdef NEO
if (pNeoPlayer->HoldStep(psurface, feet))
return;
if (pNeoPlayer->ForgiveStep())
return;
#endif
PlayStepSound( feet, psurface, fvol, false );
}

Expand Down
12 changes: 12 additions & 0 deletions src/game/shared/gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4717,6 +4717,18 @@ void CGameMovement::Duck( void )
mv->m_nOldButtons &= ~IN_DUCK;
}

#ifdef NEO
// Networked to every client, so other players' footsteps can tell a crouch that is starting
if ( mv->m_nButtons & IN_DUCK )
{
player->AddFlag( FL_ANIMDUCKING );
}
else
{
player->RemoveFlag( FL_ANIMDUCKING );
}
#endif

// Handle death.
if ( IsDead() )
return;
Expand Down
Loading
Loading