Skip to content

Commit

Permalink
Fix unit transfer enabling enhancement-locked weapons (#6544)
Browse files Browse the repository at this point in the history
For example Seraphim SACU TML was being enabled when transferred.
  • Loading branch information
lL1l1 authored Dec 26, 2024
1 parent 8946edc commit 2b1d276
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6544.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6544) Fix unit transfer enabling weapons locked by enhancements, such as the TML of the Seraphim SACU.
8 changes: 6 additions & 2 deletions lua/SimUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2b1d276

Please sign in to comment.