diff --git a/changelog/snippets/ai.7256.md b/changelog/snippets/ai.7256.md new file mode 100644 index 0000000000..04f77b83d8 --- /dev/null +++ b/changelog/snippets/ai.7256.md @@ -0,0 +1 @@ +- Fix error when an army is defeated related to missing AI platoon functions (#7256). \ No newline at end of file diff --git a/lua/SimUtils.lua b/lua/SimUtils.lua index 8402216e73..06f2a29d1c 100644 --- a/lua/SimUtils.lua +++ b/lua/SimUtils.lua @@ -1437,8 +1437,12 @@ function DisableAI(self) if not unit.Dead then local handle = unit.PlatoonHandle if handle and self:PlatoonExists(handle) then - handle:Stop() - handle:PlatoonDisbandNoAssign() + if handle.Stop then + handle:Stop() + end + if handle.PlatoonDisbandNoAssign then + handle:PlatoonDisbandNoAssign() + end end IssueStop({ unit }) IssueToUnitClearCommands(unit)