From ca014cc0420a7bb21d98662f904fef231928b4e6 Mon Sep 17 00:00:00 2001 From: Dan Peavey Date: Thu, 20 Aug 2026 22:43:09 -0700 Subject: [PATCH] Invalidate stale cover paths when retreat destination changes When FindCoverArea picks a different cover area mid-retreat, the old path remained valid and kept steering the bot toward the abandoned, exposed cover until the path completed on its own (or, in the grenade case, until the 1.0s repath timer elapsed). Invalidate the path (and the repath timer, where one exists) whenever the cover area changes, matching the existing OnStuck/OnMoveToFailure handling. --- .../neo/bot/behavior/neo_bot_retreat_from_grenade.cpp | 8 ++++++++ .../server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/game/server/neo/bot/behavior/neo_bot_retreat_from_grenade.cpp b/src/game/server/neo/bot/behavior/neo_bot_retreat_from_grenade.cpp index a9b2d14b1..68ba8bb7e 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_retreat_from_grenade.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_retreat_from_grenade.cpp @@ -221,7 +221,15 @@ ActionResult< CNEOBot > CNEOBotRetreatFromGrenade::Update( CNEOBot *me, float in // track projectile and relation to escape destination every update if ( !m_coverArea || ( grenadeArea && grenadeArea->IsPotentiallyVisible( m_coverArea ) ) ) { + CNavArea *pPrevCoverArea = m_coverArea; m_coverArea = FindCoverArea( me ); + + // cover destination changed, stop following the path to the old spot + if ( m_coverArea != pPrevCoverArea ) + { + m_path.Invalidate(); + m_repathTimer.Invalidate(); + } } if (!m_coverArea) diff --git a/src/game/server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp b/src/game/server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp index 0557005cd..532e8652e 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_retreat_to_cover.cpp @@ -273,12 +273,19 @@ ActionResult< CNEOBot > CNEOBotRetreatToCover::Update( CNEOBot *me, float interv if ( threat ) { // threats are still visible - find new cover + CNavArea *pPrevCoverArea = m_coverArea; m_coverArea = FindCoverArea( me ); if ( m_coverArea == NULL ) { return Done( "My cover is exposed, and there is no other cover available!" ); } + + // cover destination changed, stop following the path to the old spot + if ( m_coverArea != pPrevCoverArea ) + { + m_path.Invalidate(); + } } else {