diff --git a/src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp b/src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp index 16a8c8ac89..b77d572e0f 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp @@ -36,7 +36,7 @@ CNEOBotCommandFollow::CNEOBotCommandFollow() : m_vGoalPos( CNEO_Player::VECTOR_I //--------------------------------------------------------------------------------------------- ActionResult< CNEOBot > CNEOBotCommandFollow::OnStart(CNEOBot *me, Action< CNEOBot > *priorAction) { - SendUpdateToCommander( me, "Joining your squad." ); + me->SendMessageToCommander( "Joining your squad" ); m_path.SetMinLookAheadDistance(me->GetDesiredPathLookAheadRange()); m_commanderLookingAtMeTimer.Invalidate(); m_bWasCommanderLookingAtMe = false; @@ -60,7 +60,7 @@ ActionResult< CNEOBot > CNEOBotCommandFollow::Update(CNEOBot *me, float interval ActionResult weaponRequestResult = CheckCommanderWeaponRequest(me); if (weaponRequestResult.IsRequestingChange()) { - SendUpdateToCommander( me, "Here, take this." ); + me->SendMessageToCommander( "Here, take this" ); return weaponRequestResult; } @@ -227,7 +227,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me) { if ( !me->m_hLeadingPlayer.Get() ) { - SendUpdateToCommander( me, "Following you." ); + me->SendMessageToCommander( "Following you" ); } // Use sv_neo_bot_cmdr_stop_distance_sq for consistent bot collection range @@ -242,7 +242,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me) // Check if there's been an update for this star's ping waypoint if (pCommander->m_vLastPingByStar.Get(me->GetStar()) != me->m_vLastPingByStar.Get(me->GetStar())) { - SendUpdateToCommander( me, "On my way." ); + me->SendMessageToCommander( "On my way" ); me->m_hLeadingPlayer = nullptr; // Stop following and start travelling to ping m_vGoalPos = pCommander->m_vLastPingByStar.Get(me->GetStar()); me->m_vLastPingByStar.GetForModify(me->GetStar()) = pCommander->m_vLastPingByStar.Get(me->GetStar()); @@ -468,17 +468,3 @@ bool CNEOBotCommandFollow::FanOutAndCover(CNEOBot* me, Vector& movementTarget, b return false; } -//--------------------------------------------------------------------------------------------- -void CNEOBotCommandFollow::SendUpdateToCommander( CNEOBot *me, const char *message ) -{ - CNEO_Player *pCommander = me->m_hCommandingPlayer.Get(); - if ( pCommander && pCommander->IsNetClient() ) - { - CSingleUserRecipientFilter user( pCommander ); - user.MakeReliable(); - - char szText[256]; - V_snprintf( szText, sizeof( szText ), "%s: %s\n", me->GetNeoPlayerName(), message ); - UTIL_SayTextFilter( user, szText, me, true ); - } -} diff --git a/src/game/server/neo/bot/behavior/neo_bot_command_follow.h b/src/game/server/neo/bot/behavior/neo_bot_command_follow.h index e4b90a6687..fe2afab06c 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_command_follow.h +++ b/src/game/server/neo/bot/behavior/neo_bot_command_follow.h @@ -23,7 +23,6 @@ class CNEOBotCommandFollow : public Action< CNEOBot > bool FollowCommandChain( CNEOBot *me ); bool FanOutAndCover( CNEOBot *me, Vector &movementTarget, bool bMoveToSeparate = true, float flArrivalZoneSizeSq = -1.0f ); ActionResult< CNEOBot > CheckCommanderWeaponRequest( CNEOBot *me ); - void SendUpdateToCommander( CNEOBot *me, const char *message ); PathFollower m_path; CountdownTimer m_repathTimer; diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index 3d6c42f6d4..d7246f97f8 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -3521,6 +3521,38 @@ void CNEO_Player::ResetBotCommandState() } } +void CNEO_Player::SendMessageToCommander( const char *message ) +{ + SendMessageToPlayer( m_hCommandingPlayer.Get(), message ); +} + +void CNEO_Player::SendMessageToPlayer( CNEO_Player *pPlayer, const char *message ) +{ + if ( pPlayer && pPlayer->IsNetClient() ) + { + CSingleUserRecipientFilter user( pPlayer ); + user.MakeReliable(); + + char szText[256]; + V_snprintf( szText, sizeof( szText ), "%s: %s\n", GetNeoPlayerName(), message ); + UTIL_SayTextFilter( user, szText, this, true ); + } +} + +const char *CNEO_Player::GetStarName( int iStar ) const +{ + switch ( iStar ) + { + case STAR_ALPHA: return "alpha"; + case STAR_BRAVO: return "bravo"; + case STAR_CHARLIE: return "charlie"; + case STAR_DELTA: return "delta"; + case STAR_ECHO: return "echo"; + case STAR_FOXTROT: return "foxtrot"; + default: return "unknown"; + } +} + void CNEO_Player::ToggleBotFollowCommander(CNEO_Player* pCommander) { if (!sv_neo_bot_cmdr_enable.GetBool()) @@ -3553,6 +3585,7 @@ void CNEO_Player::ToggleBotFollowCommander(CNEO_Player* pCommander) { // Commander is a player and stars are different, just update bot's star RequestSetStar(pCommander->GetStar()); + SendMessageToCommander( UTIL_VarArgs( "Joining %s squad", GetStarName( GetStar() ) ) ); // Behavior without resetting pings/commander/leader: // If this is a new squad star with no waypoint this round, bots will leave waypoint to come follow. @@ -3564,6 +3597,7 @@ void CNEO_Player::ToggleBotFollowCommander(CNEO_Player* pCommander) { // Bot is already following this player in same star, so toggle off. // Bot will return to following general uncommanded bot behavior. + SendMessageToCommander( "Leaving your squad" ); m_hLeadingPlayer = nullptr; m_hCommandingPlayer = nullptr; } @@ -3572,6 +3606,11 @@ void CNEO_Player::ToggleBotFollowCommander(CNEO_Player* pCommander) else { // Bot starts following this player. + if ( m_hCommandingPlayer.Get() && m_hCommandingPlayer.Get() != pCommander ) + { + SendMessageToCommander( UTIL_VarArgs( "Joining %s's squad", pCommander->GetNeoPlayerName() ) ); + } + m_hLeadingPlayer = pCommander; if (!pCommander->IsBot()) { diff --git a/src/game/server/neo/neo_player.h b/src/game/server/neo/neo_player.h index ba3252822b..d933504276 100644 --- a/src/game/server/neo/neo_player.h +++ b/src/game/server/neo/neo_player.h @@ -171,6 +171,7 @@ class CNEO_Player : public CHL2MP_Player int GetSkin() const { return m_iNeoSkin; } int GetClass() const { return m_iNeoClass; } int GetStar() const { return m_iNeoStar; } + const char *GetStarName( int iStar ) const; bool IsInAim() const { return m_bInAim; } int GetBotDetectableBleedingInjuryEvents() const { return m_iBotDetectableBleedingInjuryEvents; } @@ -322,6 +323,8 @@ class CNEO_Player : public CHL2MP_Player CNetworkArray(Vector, m_vLastPingByStar, STAR__TOTAL); // The last ping location from this player for each squad star // Bot Functions void ResetBotCommandState(); + void SendMessageToCommander( const char *message ); + void SendMessageToPlayer( CNEO_Player *pPlayer, const char *message ); void ToggleBotFollowCommander( CNEO_Player *pCommander ); static const Vector VECTOR_INVALID_WAYPOINT;