diff --git a/changelog/snippets/fix.6629.md b/changelog/snippets/fix.6629.md new file mode 100644 index 0000000000..8e9b929f38 --- /dev/null +++ b/changelog/snippets/fix.6629.md @@ -0,0 +1 @@ +- (#6629) Fix a rare error that would cause the Fatboy to not finish dying. diff --git a/units/UEL0401/UEL0401_script.lua b/units/UEL0401/UEL0401_script.lua index 58156e03b9..f1e756a1bc 100644 --- a/units/UEL0401/UEL0401_script.lua +++ b/units/UEL0401/UEL0401_script.lua @@ -17,6 +17,8 @@ local EffectUtil = import("/lua/effectutilities.lua") local ExternalFactoryComponent = import("/lua/defaultcomponents.lua").ExternalFactoryComponent local DefaultExplosions = import("/lua/defaultexplosions.lua") +local IsDestroyed = IsDestroyed + ---@class UEL0401 : TMobileFactoryUnit, ExternalFactoryComponent ---@field UnitBeingBuilt Unit | nil ---@field AttachmentSliderManip moho.SlideManipulator @@ -258,7 +260,8 @@ UEL0401 = ClassUnit(TMobileFactoryUnit, ExternalFactoryComponent) { local explosionBones = {} local explosionBoneCount = table.getn(self.ExplosionBones) - if instigator then + -- Since this is a thread, it is delayed by 1 tick so the instigator may be destroyed + if not IsDestroyed(instigator) then -- if there is an instigator, favor exploding bits that are near the instigator local ix, iy, iz = instigator:GetPositionXYZ() for k, bone in self.ExplosionBones do