From bacad9b4c023ccf06088881c0837574ca56a09b9 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:41:41 +0300 Subject: [PATCH] Prevent AI deadlock when they try to shoot and player gets an interrupt --- TacticalAI/AIMain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 8952ee147..827515f58 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -675,6 +675,13 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named // make sure we're not using combat AI pSoldier->aiData.bAlertStatus = STATUS_GREEN; } + // Poor hack to prevent AI deadlocking in case they change stance before firing and player gets an interrupt. + // Without this, if player doesn't move any mercs, the AI soldier won't fire and will wait until the deadlock is broken + // By canceling the AI action, the AI can reconsider actions and oddly enough, usually decides to fire but this time successfully. + if (pSoldier->aiData.bAction == AI_ACTION_FIRE_GUN && pSoldier->aiData.bLastAction == AI_ACTION_NONE) + { + CancelAIAction(pSoldier, FALSE); + } pSoldier->aiData.bNewSituation = WAS_NEW_SITUATION; } }