From ef69f9b2e65ae0a0b35ff774c40a1948a5400d0c Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 11 Feb 2024 00:27:14 +0200 Subject: [PATCH] Allow enemy to retreat (#279) This check was preventing enemies from retreating into another sector if tactical AI retreat was enabled, leading into AI deadlock every time AI_ACTION_RUNAWAY was the decision. --- Tactical/Overhead.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 36e5881de..3052c2bb1 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -5081,11 +5081,17 @@ BOOLEAN NewOKDestination( SOLDIERTYPE * pCurrSoldier, INT32 sGridNo, BOOLEAN fPe INT16 sDesiredLevel; BOOLEAN fOKCheckStruct; - // sevenfm: allow civilians and NPCs with profile to go off screen - if (!GridNoOnVisibleWorldTile(sGridNo) && (pCurrSoldier->bTeam != CIV_TEAM || pCurrSoldier->ubProfile == NO_PROFILE)) - { - return(FALSE); - } + // Allow civilians and NPCs with profile to go off screen, and also enemies if tactical retreat is enabled + auto destinationOffscreen = !(GridNoOnVisibleWorldTile(sGridNo)); + auto hasProfile = pCurrSoldier->ubProfile != NO_PROFILE; + auto isCivilian = pCurrSoldier->bTeam == CIV_TEAM; + auto isEnemy = pCurrSoldier->bTeam == ENEMY_TEAM; + auto retreatAllowed = gGameExternalOptions.fAITacticalRetreat == true; + + if (destinationOffscreen && !(isCivilian || hasProfile || (isEnemy && retreatAllowed))) + { + return(FALSE); + } if (fPeopleToo && ( bPerson = WhoIsThere2( sGridNo, bLevel ) ) != NOBODY ) {