From 2b1d27605ee96dccb1da64bd83848f75def6c81c Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:55:20 -0800 Subject: [PATCH] Fix unit transfer enabling enhancement-locked weapons (#6544) For example Seraphim SACU TML was being enabled when transferred. --- changelog/snippets/fix.6544.md | 1 + lua/SimUtils.lua | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/snippets/fix.6544.md diff --git a/changelog/snippets/fix.6544.md b/changelog/snippets/fix.6544.md new file mode 100644 index 0000000000..0ce92396f7 --- /dev/null +++ b/changelog/snippets/fix.6544.md @@ -0,0 +1 @@ +- (#6544) Fix unit transfer enabling weapons locked by enhancements, such as the TML of the Seraphim SACU. diff --git a/lua/SimUtils.lua b/lua/SimUtils.lua index 66d92f082b..f006a8ca13 100644 --- a/lua/SimUtils.lua +++ b/lua/SimUtils.lua @@ -302,8 +302,12 @@ function TransferUnitsOwnership(units, toArmy, captured) -- disable all weapons, enable with a delay for k = 1, unit.WeaponCount do local weapon = unit:GetWeapon(k) - weapon:SetEnabled(false) - weapon:ForkThread(TransferUnitsOwnershipDelayedWeapons) + -- Weapons disabled by enhancement shouldn't be re-enabled unless the enhancement is built + local enablingEnhancement = weapon.Blueprint.EnabledByEnhancement + if not enablingEnhancement or (activeEnhancements and activeEnhancements[enablingEnhancement]) then + weapon:SetEnabled(false) + weapon:ForkThread(TransferUnitsOwnershipDelayedWeapons) + end end end