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
34 changes: 34 additions & 0 deletions src/game/server/NextBot/Player/NextBotPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ class INextBotPlayerInput
// This is just an "alias" to PressWalkButton
virtual void PressRunButton( float duration = -1.0f ) = 0;
virtual void ReleaseRunButton( void ) = 0;

// This is an alias for +walk because PressWalkButton is already taken
void PressSneakButton( float duration = -1.0f );
void ReleaseSneakButton( void );
bool IsSneakButtonDown( void ) const;
#endif // NEO

virtual void SetButtonScale( float forward, float right ) = 0;
Expand Down Expand Up @@ -256,6 +261,10 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
virtual void PressRunButton( float duration = -1.0f );
virtual void ReleaseRunButton( void );

void PressSneakButton( float duration = -1.0f );
void ReleaseSneakButton( void );
bool IsSneakButtonDown( void ) const;

void PressLeanLeftButton( float duration = -1.0f );
void ReleaseLeanLeftButton( void );

Expand Down Expand Up @@ -307,6 +316,7 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
CountdownTimer m_moveUpButtonTimer;
CountdownTimer m_moveDownButtonTimer;
CountdownTimer m_dropButtonTimer;
CountdownTimer m_sneakButtonTimer;
CountdownTimer m_thermopticButtonTimer;
CountdownTimer m_leanLeftButtonTimer;
CountdownTimer m_leanRightButtonTimer;
Expand Down Expand Up @@ -565,6 +575,26 @@ inline void NextBotPlayer< PlayerType >::ReleaseRunButton( void )
return NextBotPlayer<PlayerType>::ReleaseWalkButton();
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::PressSneakButton( float duration )
{
m_inputButtons |= IN_WALK;
m_sneakButtonTimer.Start( duration );
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::ReleaseSneakButton( void )
{
m_inputButtons &= ~IN_WALK;
m_sneakButtonTimer.Invalidate();
}

template < typename PlayerType >
inline bool NextBotPlayer< PlayerType >::IsSneakButtonDown( void ) const
{
return !m_sneakButtonTimer.IsElapsed();
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::PressLeanLeftButton( float duration )
{
Expand Down Expand Up @@ -704,6 +734,7 @@ inline void NextBotPlayer< PlayerType >::Spawn( void )
m_moveUpButtonTimer.Invalidate();
m_moveDownButtonTimer.Invalidate();
m_dropButtonTimer.Invalidate();
m_sneakButtonTimer.Invalidate();
m_thermopticButtonTimer.Invalidate();
m_leanLeftButtonTimer.Invalidate();
m_leanRightButtonTimer.Invalidate();
Expand Down Expand Up @@ -842,6 +873,9 @@ inline void NextBotPlayer< PlayerType >::PhysicsSimulate( void )
m_inputButtons |= IN_SPEED;

#ifdef NEO
if ( !m_sneakButtonTimer.IsElapsed() )
m_inputButtons |= IN_WALK;

if ( !m_dropButtonTimer.IsElapsed() )
m_inputButtons |= IN_DROP;

Expand Down
17 changes: 16 additions & 1 deletion src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ Vector CNEOBotMainAction::SelectTargetPoint( const INextBot *meBot, const CBaseC
//-----------------------------------------------------------------------------------------
void CNEOBotMainAction::ReconConsiderSuperJump( CNEOBot *me )
{
if (me->IsSneakButtonDown())
{
return;
}

if ( me->GetClass() != NEO_CLASS_RECON )
{
return;
Expand Down Expand Up @@ -704,7 +709,17 @@ QueryResultType CNEOBotMainAction::ShouldWalk(const CNEOBot *me, const QueryResu

// Walk if reloading or firing
CNEOBaseCombatWeapon *myWeapon = static_cast<CNEOBaseCombatWeapon*>(me->GetActiveWeapon());
return (myWeapon && (myWeapon->m_bInReload || me->m_bOnTarget || me->IsFiring())) ? ANSWER_YES : ANSWER_NO;
if (myWeapon && (myWeapon->m_bInReload || me->m_bOnTarget || me->IsFiring()))
{
return ANSWER_YES;
}

if (me->IsSneakButtonDown())
{
return ANSWER_YES;
}

return ANSWER_NO;
}

QueryResultType CNEOBotMainAction::ShouldAim(const CNEOBot *me, const bool bWepHasClip) const
Expand Down
18 changes: 18 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
{
me->ReleaseCrouchButton();
}

if (pPlayerToMirror->IsWalking())
{
me->PressSneakButton(0.5f);
}
else
{
me->ReleaseSneakButton();
}
}

// Calibrate dynamic follow distance
Expand All @@ -226,6 +235,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
// Use sv_neo_bot_cmdr_stop_distance_sq for consistent bot collection range
// follow_stop_distance_sq would be confusing if player doesn't know about distance tuning
me->m_hLeadingPlayer = pCommander;
m_bSneakWhenFollowingPing = false; // watch commander's stance
m_vGoalPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
pCommander->m_vLastPingByStar.GetForModify(me->GetStar()) = CNEO_Player::VECTOR_INVALID_WAYPOINT;
}
Expand All @@ -236,6 +246,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
if (pCommander->m_vLastPingByStar.Get(me->GetStar()) != me->m_vLastPingByStar.Get(me->GetStar()))
{
me->m_hLeadingPlayer = nullptr; // Stop following and start travelling to ping
m_bSneakWhenFollowingPing = pCommander->IsWalking();
m_vGoalPos = pCommander->m_vLastPingByStar.Get(me->GetStar());
me->m_vLastPingByStar.GetForModify(me->GetStar()) = pCommander->m_vLastPingByStar.Get(me->GetStar());

Expand All @@ -248,10 +259,16 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
else
{
me->m_hLeadingPlayer = pCommander; // fallback to following commander
m_bSneakWhenFollowingPing = false; // watch commander's stance
// continue with leader following logic below
}
}

if (m_bSneakWhenFollowingPing)
{
me->PressSneakButton(0.3f);
}

if (FanOutAndCover(me, m_vGoalPos))
{
// FanOutAndCover true: arrived at destination and settled, so don't recompute path
Expand All @@ -266,6 +283,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
else
{
me->m_hLeadingPlayer = pCommander; // fallback to following commander
m_bSneakWhenFollowingPing = false; // react to enemies at full speed
// continue with leader following logic below
}
}
Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/behavior/neo_bot_command_follow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CNEOBotCommandFollow : public Action< CNEOBot >
CNEOBotGhostEquipmentHandler m_ghostEquipmentHandler;

IntervalTimer m_commanderLookingAtMeTimer;
bool m_bSneakWhenFollowingPing = false;
bool m_bWasCommanderLookingAtMe = false;

EHANDLE m_hTargetEntity;
Expand Down
Loading