From 86483fc81a616ba2980af1b52b118cfac2d1eafd Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 12 Nov 2026 19:43:38 -0700 Subject: [PATCH 1/5] Bots respawned in JGR seek the juggernaut A bot switched to the juggernaut behavior only during the pre-round freeze. JGR respawns players mid-round, and a respawned bot restarts its behavior tree, so it roamed spawn points for the rest of its life: it never went for the juggernaut item, never attacked the enemy juggernaut and never escorted a friendly one. Switch whenever the game type is JGR. --- .../neo/bot/behavior/neo_bot_seek_and_destroy.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index 023f7bf621..1e23ab2b2b 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -171,6 +171,12 @@ ActionResult< CNEOBot > CNEOBotSeekAndDestroy::OnStart( CNEOBot *me, Action< CNE //--------------------------------------------------------------------------------------------- ActionResult< CNEOBot > CNEOBotSeekAndDestroy::Update( CNEOBot *me, float interval ) { + // Bots respawn mid-round in JGR, so the switch cannot wait for the pre-round freeze + if ( NEORules()->GetGameType() == NEO_GAME_TYPE_JGR ) + { + return SuspendFor( new CNEOBotJgrSeek, "Switching to Juggernaut-related Seek and Destroy" ); + } + // Check for Game Type Specific behaviors and suspend for them if ( NEORules()->GetRemainingPreRoundFreezeTime( true ) > 0.0f ) { @@ -184,10 +190,6 @@ ActionResult< CNEOBot > CNEOBotSeekAndDestroy::Update( CNEOBot *me, float interv } } - else if (NEORules()->GetGameType() == NEO_GAME_TYPE_JGR) - { - return SuspendFor( new CNEOBotJgrSeek, "Switching to Juggernaut-related Seek and Destroy" ); - } return Continue(); } From 67f1248e73b92378b18df906596f3da264fe8cd6 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 12 Nov 2026 19:44:22 -0700 Subject: [PATCH 2/5] Bots roam to goals out of view A roaming bot picked random spawn points. On maps whose spawns stand in one room, a bot in that room picked the next spawn there and walked spawn to spawn for minutes. A protected spawn room that no route reaches made it worse: each failed pick was re-rolled, so the picks piled onto the reachable room. Refuse a roam goal the bot can already potentially see, wander to a random nav area once a spawn pick has no route, and exclude info_player_start by classname (the old test compared the targetname). --- .../bot/behavior/neo_bot_seek_and_destroy.cpp | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index 1e23ab2b2b..9d86ecdfae 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -127,6 +127,8 @@ bool CNEOBotSeekAndDestroy::TryPathToCombatSound( CNEOBot *me ) } +constexpr int ROAM_GOAL_TRIES = 10; + //--------------------------------------------------------------------------------------------- // Roam goals are picked at random, so skip one that no route reaches instead of walking at it. A refused // attempt stays in m_path: the wander loop's last resort keeps it. @@ -136,6 +138,21 @@ bool CNEOBotSeekAndDestroy::TryPathToRoamGoal( CNEOBot *me, const Vector &vGoal } +//--------------------------------------------------------------------------------------------- +// A place the bot can already see is not worth the walk, and picking one keeps it circling in one room +static bool IsRoamGoalInView( CNEOBot *me, const Vector &vGoal ) +{ + const CNavArea *pMyArea = me->GetLastKnownArea(); + if ( !pMyArea ) + { + return false; + } + + const CNavArea *pGoalArea = TheNavMesh->GetNearestNavArea( vGoal ); + return pGoalArea && pMyArea->IsPotentiallyVisible( pGoalArea ); +} + + //--------------------------------------------------------------------------------------------- CNEOBotSeekAndDestroy::CNEOBotSeekAndDestroy( float duration ) { @@ -590,29 +607,55 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) CBaseEntity* pSearch = NULL; while ( ( pSearch = gEntList.FindEntityByClassname( pSearch, "info_player_*", &spawnFilter ) ) != NULL ) { - if ( pSearch && Q_strcmp(pSearch->GetEntityName().ToCStr(), "info_player_start")) + if ( pSearch && !FClassnameIs( pSearch, "info_player_start" ) ) + { pSpawns.AddToTail( pSearch ); + } } // Don't wander between spawns if there aren't that many. if ( pSpawns.Size() >= 3 ) { - for ( int i = 0; i < 10; i++ ) + for ( int i = 0; i < ROAM_GOAL_TRIES; i++ ) { - m_hTargetEntity = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )]; + CBaseEntity *pSpawn = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )]; + const Vector vSpawn = pSpawn->WorldSpaceCenter(); + if ( IsRoamGoalInView( me, vSpawn ) ) + { + continue; + } + + m_hTargetEntity = pSpawn; m_bGoingToTargetEntity = true; - m_vGoalPos = m_hTargetEntity->WorldSpaceCenter(); + m_vGoalPos = vSpawn; if ( TryPathToRoamGoal( me, m_vGoalPos ) ) + { return; + } + + // No route reaches this spawn (a protected spawn room). Re-rolling would only pile + // the picks onto the spawns that are left, so wander instead. + break; } } } - for ( int i = 0; i < 10; i++ ) + m_hTargetEntity = nullptr; + m_bGoingToTargetEntity = false; + + for ( int i = 0; i < ROAM_GOAL_TRIES; i++ ) { // No spawns we can get to? Just wander... somewhere! Vector vWanderPoint = TheNavAreas[RandomInt( 0, TheNavAreas.Size() - 1 )]->GetCenter(); + + // The last try takes any point, so a bot that sees most of a small map still gets a path + const bool bLastTry = ( i == ROAM_GOAL_TRIES - 1 ); + if ( !bLastTry && IsRoamGoalInView( me, vWanderPoint ) ) + { + continue; + } + m_vGoalPos = vWanderPoint; if ( TryPathToRoamGoal( me, vWanderPoint ) ) return; From c53212a5a9b68c1ed31be68985de27c89d69e9dc Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 12 Nov 2026 20:57:08 -0700 Subject: [PATCH 3/5] Bots skip roam goals right below or above them The view check counts a spawn point on the floor below as hidden, so a bot on a two-floor spawn cluster kept picking the spawn under it and had to take a ladder to get there. Skip a roam goal closer than sv_neo_bot_seek_and_destroy_roam_min_dist horizontally, like one in view. The last wander try still takes any point. --- .../bot/behavior/neo_bot_seek_and_destroy.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index 9d86ecdfae..d4c6f6ce23 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -25,6 +25,8 @@ ConVar sv_neo_bot_seek_and_destroy_combat_sound_detour_ratio( "sv_neo_bot_seek_a "When racing for an objective, divert only if going via the combat sound costs at most this multiple of direct distance.", true, 0, false, 0 ); ConVar sv_neo_bot_seek_and_destroy_combat_sound_arrive_range( "sv_neo_bot_seek_and_destroy_combat_sound_arrive_range", "200.0", FCVAR_CHEAT, "Combat sound close enough to count as investigated.", true, 0, false, 0 ); +ConVar sv_neo_bot_seek_and_destroy_roam_min_dist( "sv_neo_bot_seek_and_destroy_roam_min_dist", "512.0", FCVAR_CHEAT, + "Roaming bots skip a goal closer than this horizontally, such as a spawn point on the floor right below them.", true, 0, false, 0 ); //--------------------------------------------------------------------------------------------- @@ -138,6 +140,16 @@ bool CNEOBotSeekAndDestroy::TryPathToRoamGoal( CNEOBot *me, const Vector &vGoal } +//--------------------------------------------------------------------------------------------- +// The visibility check misses a goal on another floor right above or below the bot, which is often +// only reached by a detour or a ladder and gains the bot nothing +static bool IsRoamGoalNearby( CNEOBot *me, const Vector &vGoal ) +{ + const float flMinDist = sv_neo_bot_seek_and_destroy_roam_min_dist.GetFloat(); + return me->GetAbsOrigin().AsVector2D().DistToSqr( vGoal.AsVector2D() ) < flMinDist * flMinDist; +} + + //--------------------------------------------------------------------------------------------- // A place the bot can already see is not worth the walk, and picking one keeps it circling in one room static bool IsRoamGoalInView( CNEOBot *me, const Vector &vGoal ) @@ -620,7 +632,7 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) { CBaseEntity *pSpawn = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )]; const Vector vSpawn = pSpawn->WorldSpaceCenter(); - if ( IsRoamGoalInView( me, vSpawn ) ) + if ( IsRoamGoalNearby( me, vSpawn ) || IsRoamGoalInView( me, vSpawn ) ) { continue; } @@ -651,7 +663,7 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) // The last try takes any point, so a bot that sees most of a small map still gets a path const bool bLastTry = ( i == ROAM_GOAL_TRIES - 1 ); - if ( !bLastTry && IsRoamGoalInView( me, vWanderPoint ) ) + if ( !bLastTry && ( IsRoamGoalNearby( me, vWanderPoint ) || IsRoamGoalInView( me, vWanderPoint ) ) ) { continue; } From 65d703c6404d452d97522f9c864006ed84f6f1ec Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 12 Nov 2026 21:42:11 -0700 Subject: [PATCH 4/5] Drop the roam goal minimum distance A goal on another floor right above or below the bot is a legitimate place to look around: skipping it threw away an unseen area to explore. Remove the horizontal distance check and its ConVar; the ladder stuck spot it targeted on ntre_bullet_tdm is a separate fix. --- .../bot/behavior/neo_bot_seek_and_destroy.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index d4c6f6ce23..9d86ecdfae 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -25,8 +25,6 @@ ConVar sv_neo_bot_seek_and_destroy_combat_sound_detour_ratio( "sv_neo_bot_seek_a "When racing for an objective, divert only if going via the combat sound costs at most this multiple of direct distance.", true, 0, false, 0 ); ConVar sv_neo_bot_seek_and_destroy_combat_sound_arrive_range( "sv_neo_bot_seek_and_destroy_combat_sound_arrive_range", "200.0", FCVAR_CHEAT, "Combat sound close enough to count as investigated.", true, 0, false, 0 ); -ConVar sv_neo_bot_seek_and_destroy_roam_min_dist( "sv_neo_bot_seek_and_destroy_roam_min_dist", "512.0", FCVAR_CHEAT, - "Roaming bots skip a goal closer than this horizontally, such as a spawn point on the floor right below them.", true, 0, false, 0 ); //--------------------------------------------------------------------------------------------- @@ -140,16 +138,6 @@ bool CNEOBotSeekAndDestroy::TryPathToRoamGoal( CNEOBot *me, const Vector &vGoal } -//--------------------------------------------------------------------------------------------- -// The visibility check misses a goal on another floor right above or below the bot, which is often -// only reached by a detour or a ladder and gains the bot nothing -static bool IsRoamGoalNearby( CNEOBot *me, const Vector &vGoal ) -{ - const float flMinDist = sv_neo_bot_seek_and_destroy_roam_min_dist.GetFloat(); - return me->GetAbsOrigin().AsVector2D().DistToSqr( vGoal.AsVector2D() ) < flMinDist * flMinDist; -} - - //--------------------------------------------------------------------------------------------- // A place the bot can already see is not worth the walk, and picking one keeps it circling in one room static bool IsRoamGoalInView( CNEOBot *me, const Vector &vGoal ) @@ -632,7 +620,7 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) { CBaseEntity *pSpawn = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )]; const Vector vSpawn = pSpawn->WorldSpaceCenter(); - if ( IsRoamGoalNearby( me, vSpawn ) || IsRoamGoalInView( me, vSpawn ) ) + if ( IsRoamGoalInView( me, vSpawn ) ) { continue; } @@ -663,7 +651,7 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) // The last try takes any point, so a bot that sees most of a small map still gets a path const bool bLastTry = ( i == ROAM_GOAL_TRIES - 1 ); - if ( !bLastTry && ( IsRoamGoalNearby( me, vWanderPoint ) || IsRoamGoalInView( me, vWanderPoint ) ) ) + if ( !bLastTry && IsRoamGoalInView( me, vWanderPoint ) ) { continue; } From aa4f02f964ea44b94f78fa3a158b67b693d516be Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 12 Nov 2026 21:50:24 -0700 Subject: [PATCH 5/5] Make the roam goal try count a ConVar Expose the number of random roam goals to try as sv_neo_bot_seek_and_destroy_roam_goal_tries (cheat, default 10) and reword the roam comments. --- .../bot/behavior/neo_bot_seek_and_destroy.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp index 9d86ecdfae..e036e4be4b 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_and_destroy.cpp @@ -25,6 +25,8 @@ ConVar sv_neo_bot_seek_and_destroy_combat_sound_detour_ratio( "sv_neo_bot_seek_a "When racing for an objective, divert only if going via the combat sound costs at most this multiple of direct distance.", true, 0, false, 0 ); ConVar sv_neo_bot_seek_and_destroy_combat_sound_arrive_range( "sv_neo_bot_seek_and_destroy_combat_sound_arrive_range", "200.0", FCVAR_CHEAT, "Combat sound close enough to count as investigated.", true, 0, false, 0 ); +ConVar sv_neo_bot_seek_and_destroy_roam_goal_tries( "sv_neo_bot_seek_and_destroy_roam_goal_tries", "10", FCVAR_CHEAT, + "Random roam goals to try before settling on one the bot can already see.", true, 1, false, 0 ); //--------------------------------------------------------------------------------------------- @@ -127,8 +129,6 @@ bool CNEOBotSeekAndDestroy::TryPathToCombatSound( CNEOBot *me ) } -constexpr int ROAM_GOAL_TRIES = 10; - //--------------------------------------------------------------------------------------------- // Roam goals are picked at random, so skip one that no route reaches instead of walking at it. A refused // attempt stays in m_path: the wander loop's last resort keeps it. @@ -139,7 +139,7 @@ bool CNEOBotSeekAndDestroy::TryPathToRoamGoal( CNEOBot *me, const Vector &vGoal //--------------------------------------------------------------------------------------------- -// A place the bot can already see is not worth the walk, and picking one keeps it circling in one room +// A place the bot can already see is not worth the walk, so pick an area outside of PVS static bool IsRoamGoalInView( CNEOBot *me, const Vector &vGoal ) { const CNavArea *pMyArea = me->GetLastKnownArea(); @@ -616,7 +616,8 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) // Don't wander between spawns if there aren't that many. if ( pSpawns.Size() >= 3 ) { - for ( int i = 0; i < ROAM_GOAL_TRIES; i++ ) + const int iTries = sv_neo_bot_seek_and_destroy_roam_goal_tries.GetInt(); + for ( int i = 0; i < iTries; i++ ) { CBaseEntity *pSpawn = pSpawns[RandomInt( 0, pSpawns.Size() - 1 )]; const Vector vSpawn = pSpawn->WorldSpaceCenter(); @@ -633,8 +634,8 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) return; } - // No route reaches this spawn (a protected spawn room). Re-rolling would only pile - // the picks onto the spawns that are left, so wander instead. + // An unreachable spawn usually indicates a spawn protected area. + // Re-rolling would likely pick other spawn protected areas, so wander instead. break; } } @@ -643,14 +644,15 @@ void CNEOBotSeekAndDestroy::RecomputeSeekPath( CNEOBot *me ) m_hTargetEntity = nullptr; m_bGoingToTargetEntity = false; - for ( int i = 0; i < ROAM_GOAL_TRIES; i++ ) + const int iTries = sv_neo_bot_seek_and_destroy_roam_goal_tries.GetInt(); + for ( int i = 0; i < iTries; i++ ) { // No spawns we can get to? Just wander... somewhere! Vector vWanderPoint = TheNavAreas[RandomInt( 0, TheNavAreas.Size() - 1 )]->GetCenter(); // The last try takes any point, so a bot that sees most of a small map still gets a path - const bool bLastTry = ( i == ROAM_GOAL_TRIES - 1 ); + const bool bLastTry = ( i == iTries - 1 ); if ( !bLastTry && IsRoamGoalInView( me, vWanderPoint ) ) { continue;