Skip to content

Commit d8569f4

Browse files
committed
Bots message commander about their behavior
1 parent 8cfdc9f commit d8569f4

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/game/server/neo/bot/behavior/neo_bot_command_follow.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ CNEOBotCommandFollow::CNEOBotCommandFollow() : m_vGoalPos( CNEO_Player::VECTOR_I
3636
//---------------------------------------------------------------------------------------------
3737
ActionResult< CNEOBot > CNEOBotCommandFollow::OnStart(CNEOBot *me, Action< CNEOBot > *priorAction)
3838
{
39+
SendUpdateToCommander( me, "Joining your squad." );
3940
m_path.SetMinLookAheadDistance(me->GetDesiredPathLookAheadRange());
4041
m_commanderLookingAtMeTimer.Invalidate();
4142
m_bWasCommanderLookingAtMe = false;
@@ -59,6 +60,7 @@ ActionResult< CNEOBot > CNEOBotCommandFollow::Update(CNEOBot *me, float interval
5960
ActionResult<CNEOBot> weaponRequestResult = CheckCommanderWeaponRequest(me);
6061
if (weaponRequestResult.IsRequestingChange())
6162
{
63+
SendUpdateToCommander( me, "Here, take this." );
6264
return weaponRequestResult;
6365
}
6466

@@ -223,6 +225,11 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
223225
&& (me->GetStar() == pCommander->GetStar()) // only follow when commander is focused on your squad
224226
&& (me->GetAbsOrigin().DistToSqr(pCommander->GetAbsOrigin()) < sv_neo_bot_cmdr_stop_distance_sq.GetFloat()))
225227
{
228+
if ( !me->m_hLeadingPlayer.Get() )
229+
{
230+
SendUpdateToCommander( me, "Following you." );
231+
}
232+
226233
// Use sv_neo_bot_cmdr_stop_distance_sq for consistent bot collection range
227234
// follow_stop_distance_sq would be confusing if player doesn't know about distance tuning
228235
me->m_hLeadingPlayer = pCommander;
@@ -235,6 +242,7 @@ bool CNEOBotCommandFollow::FollowCommandChain(CNEOBot* me)
235242
// Check if there's been an update for this star's ping waypoint
236243
if (pCommander->m_vLastPingByStar.Get(me->GetStar()) != me->m_vLastPingByStar.Get(me->GetStar()))
237244
{
245+
SendUpdateToCommander( me, "On my way." );
238246
me->m_hLeadingPlayer = nullptr; // Stop following and start travelling to ping
239247
m_vGoalPos = pCommander->m_vLastPingByStar.Get(me->GetStar());
240248
me->m_vLastPingByStar.GetForModify(me->GetStar()) = pCommander->m_vLastPingByStar.Get(me->GetStar());
@@ -459,3 +467,18 @@ bool CNEOBotCommandFollow::FanOutAndCover(CNEOBot* me, Vector& movementTarget, b
459467
// Still moving to destination, path will be recomputed by the calling context
460468
return false;
461469
}
470+
471+
//---------------------------------------------------------------------------------------------
472+
void CNEOBotCommandFollow::SendUpdateToCommander( CNEOBot *me, const char *message )
473+
{
474+
CNEO_Player *pCommander = me->m_hCommandingPlayer.Get();
475+
if ( pCommander && pCommander->IsNetClient() )
476+
{
477+
CSingleUserRecipientFilter user( pCommander );
478+
user.MakeReliable();
479+
480+
char szText[256];
481+
V_snprintf( szText, sizeof( szText ), "%s: %s\n", me->GetNeoPlayerName(), message );
482+
UTIL_SayTextFilter( user, szText, me, true );
483+
}
484+
}

src/game/server/neo/bot/behavior/neo_bot_command_follow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CNEOBotCommandFollow : public Action< CNEOBot >
2323
bool FollowCommandChain( CNEOBot *me );
2424
bool FanOutAndCover( CNEOBot *me, Vector &movementTarget, bool bMoveToSeparate = true, float flArrivalZoneSizeSq = -1.0f );
2525
ActionResult< CNEOBot > CheckCommanderWeaponRequest( CNEOBot *me );
26+
void SendUpdateToCommander( CNEOBot *me, const char *message );
2627

2728
PathFollower m_path;
2829
CountdownTimer m_repathTimer;

0 commit comments

Comments
 (0)