From 3ca4c74cba34d062549298e6fda565f685266fc6 Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 13:20:54 -0400 Subject: [PATCH 1/6] condense shoulder pod scripts --- lua/sim/units/uef/TConstructionPodUnit.lua | 38 ++++++++++++++++++++ lua/terranunits.lua | 1 + units/UEA0001/UEA0001_script.lua | 42 +++------------------- units/UEA0003/UEA0003_script.lua | 42 +++------------------- 4 files changed, 47 insertions(+), 76 deletions(-) create mode 100644 lua/sim/units/uef/TConstructionPodUnit.lua diff --git a/lua/sim/units/uef/TConstructionPodUnit.lua b/lua/sim/units/uef/TConstructionPodUnit.lua new file mode 100644 index 0000000000..13d76b5882 --- /dev/null +++ b/lua/sim/units/uef/TConstructionPodUnit.lua @@ -0,0 +1,38 @@ +local TConstructionUnit = import("/lua/terranunits.lua").TConstructionUnit + +---@class TConstructionPodUnit : TConstructionUnit +TConstructionPodUnit = ClassUnit(TConstructionUnit) { + Parent = nil, + + OnScriptBitSet = function(self, bit) + TConstructionUnit.OnScriptBitSet(self, bit) + if bit == 1 then + self.rebuildDrone = true + end + end, + + OnScriptBitClear = function(self, bit) + TConstructionUnit.OnScriptBitClear(self, bit) + if bit == 1 then + self.rebuildDrone = false + end + end, + + SetParent = function(self, parent, podName) + self.Parent = parent + self.Pod = podName + self:SetScriptBit('RULEUTC_WeaponToggle', true) + end, + + OnKilled = function(self, instigator, type, overkillRatio) + self.Parent:NotifyOfPodDeath(self.Pod, self.rebuildDrone) + self.Parent = nil + TConstructionUnit.OnKilled(self, instigator, type, overkillRatio) + end, + + -- Don't make wreckage + CreateWreckage = function (self, overkillRatio) + overkillRatio = 1.1 + TConstructionUnit.CreateWreckage(self, overkillRatio) + end, +} \ No newline at end of file diff --git a/lua/terranunits.lua b/lua/terranunits.lua index a97d7d61af..2706d18d63 100644 --- a/lua/terranunits.lua +++ b/lua/terranunits.lua @@ -14,6 +14,7 @@ TAirStagingPlatformUnit = import('/lua/sim/units/uef/TAirStagingPlatformUnit.lua TAirUnit = import('/lua/sim/units/uef/TAirUnit.lua').TAirUnit TConcreteStructureUnit = import('/lua/sim/units/uef/TConcreteStructureUnit.lua').TConcreteStructureUnit TConstructionUnit = import('/lua/sim/units/uef/TConstructionUnit.lua').TConstructionUnit +TConstructionPodUnit = import('/lua/sim/units/uef/TConstructionPodUnit.lua').TConstructionPodUnit TEnergyCreationUnit = import('/lua/sim/units/uef/TEnergyCreationUnit.lua').TEnergyCreationUnit TEnergyStorageUnit = import('/lua/sim/units/uef/TEnergyStorageUnit.lua').TEnergyStorageUnit THoverLandUnit = import('/lua/sim/units/uef/THoverLandUnit.lua').THoverLandUnit diff --git a/units/UEA0001/UEA0001_script.lua b/units/UEA0001/UEA0001_script.lua index 61777fc66d..1633b67240 100644 --- a/units/UEA0001/UEA0001_script.lua +++ b/units/UEA0001/UEA0001_script.lua @@ -5,43 +5,9 @@ -- Copyright © 2005 Gas Powered Games, Inc. All rights reserved. ----------------------------------------------------------------- -local TConstructionUnit = import("/lua/terranunits.lua").TConstructionUnit +local TConstructionPodUnit = import("/lua/terranunits.lua").TConstructionPodUnit ----@class UEA0001 : TConstructionUnit -UEA0001 = ClassUnit(TConstructionUnit) { - Parent = nil, +---@class UEA0001 : TConstructionPodUnit +UEA0001 = ClassUnit(TConstructionPodUnit) {} - OnScriptBitSet = function(self, bit) - TConstructionUnit.OnScriptBitSet(self, bit) - if bit == 1 then - self.rebuildDrone = true - end - end, - - OnScriptBitClear = function(self, bit) - TConstructionUnit.OnScriptBitClear(self, bit) - if bit == 1 then - self.rebuildDrone = false - end - end, - - SetParent = function(self, parent, podName) - self.Parent = parent - self.Pod = podName - self:SetScriptBit('RULEUTC_WeaponToggle', true) - end, - - OnKilled = function(self, instigator, type, overkillRatio) - self.Parent:NotifyOfPodDeath(self.Pod, self.rebuildDrone) - self.Parent = nil - TConstructionUnit.OnKilled(self, instigator, type, overkillRatio) - end, - - -- Don't make wreckage - CreateWreckage = function (self, overkillRatio) - overkillRatio = 1.1 - TConstructionUnit.CreateWreckage(self, overkillRatio) - end, -} - -TypeClass = UEA0001 +TypeClass = UEA0001 \ No newline at end of file diff --git a/units/UEA0003/UEA0003_script.lua b/units/UEA0003/UEA0003_script.lua index e80e2677ab..c46809f3bd 100644 --- a/units/UEA0003/UEA0003_script.lua +++ b/units/UEA0003/UEA0003_script.lua @@ -4,43 +4,9 @@ -- Copyright © 2005 Gas Powered Games, Inc. All rights reserved. ----------------------------------------------------------------- -local TConstructionUnit = import("/lua/terranunits.lua").TConstructionUnit +local TConstructionPodUnit = import("/lua/terranunits.lua").TConstructionPodUnit ----@class UEA0003 : TConstructionUnit -UEA0003 = ClassUnit(TConstructionUnit) { - Parent = nil, +---@class UEA0003 : TConstructionPodUnit +UEA0003 = ClassUnit(TConstructionPodUnit) {} - OnScriptBitSet = function(self, bit) - TConstructionUnit.OnScriptBitSet(self, bit) - if bit == 1 then - self.rebuildDrone = true - end - end, - - OnScriptBitClear = function(self, bit) - TConstructionUnit.OnScriptBitClear(self, bit) - if bit == 1 then - self.rebuildDrone = false - end - end, - - SetParent = function(self, parent, podName) - self.Parent = parent - self.Pod = podName - self:SetScriptBit('RULEUTC_WeaponToggle', true) - end, - - OnKilled = function(self, instigator, type, overkillRatio) - self.Parent:NotifyOfPodDeath(self.Pod, self.rebuildDrone) - self.Parent = nil - TConstructionUnit.OnKilled(self, instigator, type, overkillRatio) - end, - - -- Don't make wreckage - CreateWreckage = function (self, overkillRatio) - overkillRatio = 1.1 - TConstructionUnit.CreateWreckage(self, overkillRatio) - end, -} - -TypeClass = UEA0003 +TypeClass = UEA0003 \ No newline at end of file From 92313edd98f2c65b918621bb736bf125647e244a Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 17:16:47 -0400 Subject: [PATCH 2/6] persistent shoulder drone guard orders --- lua/sim/units/uef/TConstructionPodUnit.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lua/sim/units/uef/TConstructionPodUnit.lua b/lua/sim/units/uef/TConstructionPodUnit.lua index 13d76b5882..d56007e79f 100644 --- a/lua/sim/units/uef/TConstructionPodUnit.lua +++ b/lua/sim/units/uef/TConstructionPodUnit.lua @@ -1,9 +1,17 @@ local TConstructionUnit = import("/lua/terranunits.lua").TConstructionUnit ---@class TConstructionPodUnit : TConstructionUnit +---@field guardDummy Unit TConstructionPodUnit = ClassUnit(TConstructionUnit) { Parent = nil, + OnCreate = function(self) + TConstructionUnit.OnCreate(self) + self.guardDummy = CreateUnitHPR('ZXA0003', self:GetArmy(), 0,0,0,0,0,0) + self.guardDummy:AttachTo(self, -1) + self.Trash:Add(self.guardDummy) + end, + OnScriptBitSet = function(self, bit) TConstructionUnit.OnScriptBitSet(self, bit) if bit == 1 then @@ -18,6 +26,20 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { end end, + OnAttachedToTransport = function(self, transport, bone) + local guards = self:GetGuards() + IssueClearCommands(guards) + IssueGuard(guards, self.guardDummy) + TConstructionUnit.OnAttachedToTransport(self, transport, bone) + end, + + OnDetachedFromTransport = function(self, transport, bone) + TConstructionUnit.OnDetachedFromTransport(self, transport, bone) + local guards = self.guardDummy:GetGuards() + IssueClearCommands(guards) + IssueGuard(guards, self) + end, + SetParent = function(self, parent, podName) self.Parent = parent self.Pod = podName From daf53a1333033bbb79cfc8dbe06a39cca50a95d0 Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 17:17:43 -0400 Subject: [PATCH 3/6] units assisting shoulder pods work properly --- lua/sim/units/uef/TConstructionPodUnit.lua | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/lua/sim/units/uef/TConstructionPodUnit.lua b/lua/sim/units/uef/TConstructionPodUnit.lua index d56007e79f..9c10d4c7dc 100644 --- a/lua/sim/units/uef/TConstructionPodUnit.lua +++ b/lua/sim/units/uef/TConstructionPodUnit.lua @@ -46,6 +46,109 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { self:SetScriptBit('RULEUTC_WeaponToggle', true) end, + OnStartBuild = function(self, unitBeingBuilt, order) + TConstructionUnit.OnStartBuild(self, unitBeingBuilt, order) + self:FocusAssistersOnCurrentTask() + end, + + ---@param self TConstructionPodUnit + ---@param built Unit + ---@param order string + OnStopBuild = function(self, built, order) + TConstructionUnit.OnStopBuild(self, built, order) + -- Check if we finished our build task and clear our cached command if so + if self.guardCache and built:GetFractionComplete() == 1 then + self.guardCache = nil + end + end, + + ---@param self TConstructionPodUnit + ---@param target Unit|Prop + OnStartReclaim = function(self, target) + TConstructionUnit.OnStartReclaim(self, target) + self:FocusAssistersOnCurrentTask() + end, + + ---@param self TConstructionPodUnit + ---@param target Unit|Prop + OnStopReclaim = function(self, target) + TConstructionUnit.OnStopReclaim(self, target) + -- Check if we finished our reclaim task and clear our cached commaand if so + if self.guardCache and table.empty(target) then + self.guardCache = nil + end + end, + + ---@param self TConstructionPodUnit + ---@param unitBeingRepaired Unit + OnStartRepair = function(self, unitBeingRepaired) + TConstructionUnit.OnStartRepair(self, unitBeingRepaired) + self:FocusAssistersOnCurrentTask() + end, + + ---@param self TConstructionPodUnit + FocusAssistersOnCurrentTask = function(self) + + if self.Dead then + return + end + + local engineerGuards = self:GetGuards() + + -- Make sure we've got some assisters to work with + if not next(engineerGuards) then + self.guardCache = nil + return + end + + -- Make sure we're performing an engineering task + if not (self:IsUnitState('Reclaiming') + or self:IsUnitState('Building') + or self:IsUnitState('Repairing')) then + return + end + + local command + if self:IsUnitState('Reclaiming') then + command = IssueReclaim + elseif self:IsUnitState('Repairing') or self:IsUnitState('Building') then + command = IssueRepair + end + + -- We only need to worry about refocusing our guards if we currently have an engineering target + local target = self:GetFocusUnit() or self:GetCommandQueue()[1].target + if target then + IssueClearCommands(engineerGuards) + command(engineerGuards, target) + IssueGuard(engineerGuards, self) + self.guardCache = engineerGuards + self.guardCache.target = target + self.guardCache.command = command + end + end, + + ---Override get guards to pick up our assist cache + GetGuards = function(self) + local guards = oldGetGuards(self) + local count = 0 + if self.guardCache then + local firstCommand, secondCommand + local target = self.guardCache.target + for _, guard in ipairs(self.guardCache) do + firstCommand, secondCommand = unpack(guard:GetCommandQueue()) + if firstCommand.target == target + and secondCommand.target == self then + table.insert(guards, guard) + count = count + 1 + end + end + end + if count > 0 then + print(string.format('Found %d cached guards', count)) + end + return guards + end, + OnKilled = function(self, instigator, type, overkillRatio) self.Parent:NotifyOfPodDeath(self.Pod, self.rebuildDrone) self.Parent = nil From 5e8177f36d3f32cfe0791f580ad48a53031a0b9f Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 17:37:05 -0400 Subject: [PATCH 4/6] add refocus assisters to abort navigation, annotations, tidying up --- changelog/snippets/features.6169.md | 3 ++ lua/sim/Unit.lua | 16 ++++----- lua/sim/commands/abort-navigation.lua | 1 + lua/sim/units/uef/TConstructionPodUnit.lua | 42 ++++++++++++++++++++-- 4 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 changelog/snippets/features.6169.md diff --git a/changelog/snippets/features.6169.md b/changelog/snippets/features.6169.md new file mode 100644 index 0000000000..aa85e0e86e --- /dev/null +++ b/changelog/snippets/features.6169.md @@ -0,0 +1,3 @@ +(#6169) Shoulder pods (ACU drones) now track the focus of their parent unit more closely and will automatically switch to any engineering task their parent starts. Additionally, pods can now be properly assisted by other engineering units, and assist commands targeting them will persist when the pod attaches/detaches from the parent. + +(#6169) The abort pathfinding key action on a lead unit will refocus any assisting engineers on the leader's task. \ No newline at end of file diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index a3f2fd46c6..d8260bb2c4 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -854,14 +854,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) { self:CheckAssistersFocus() self:DoUnitCallbacks('OnStartReclaim', target) - -- Force me to move on to the guard properly when done - local guard = self:GetGuardedUnit() - if guard then - IssueToUnitClearCommands(self) - IssueReclaim({self}, target) - IssueGuard({self}, guard) - end - -- add state to be able to show the amount reclaimed in the UI if target.IsProp then self.OnStartReclaimPropStartTick = GetGameTick() + 2 @@ -2775,6 +2767,14 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) { end end, + ---Called via hotkey to refocus any assisting engineers + ---@param self Unit + RefocusAssisters = function(self) + local engineerGuards = EntityCategoryFilterDown(categories.ENGINEER, self:GetGuards()) + IssueClearCommands(engineerGuards) + IssueGuard(engineerGuards, self) + end, + ---@param self Unit ---@param built Unit ---@param order string diff --git a/lua/sim/commands/abort-navigation.lua b/lua/sim/commands/abort-navigation.lua index fa136d1195..9d136814a9 100644 --- a/lua/sim/commands/abort-navigation.lua +++ b/lua/sim/commands/abort-navigation.lua @@ -43,6 +43,7 @@ function AbortNavigation(units, doPrint) if not IsDestroyed(unit) then local navigator = unit:GetNavigator() navigator:AbortMove() + unit:RefocusAssisters() end end diff --git a/lua/sim/units/uef/TConstructionPodUnit.lua b/lua/sim/units/uef/TConstructionPodUnit.lua index 9c10d4c7dc..f58a18b08f 100644 --- a/lua/sim/units/uef/TConstructionPodUnit.lua +++ b/lua/sim/units/uef/TConstructionPodUnit.lua @@ -1,10 +1,15 @@ local TConstructionUnit = import("/lua/terranunits.lua").TConstructionUnit +local oldGetGuards = TConstructionUnit.GetGuards ---@class TConstructionPodUnit : TConstructionUnit +---@field Pod string +---@field Parent Unit +---@field guardCache table ---@field guardDummy Unit TConstructionPodUnit = ClassUnit(TConstructionUnit) { Parent = nil, + ---@param self TConstructionPodUnit OnCreate = function(self) TConstructionUnit.OnCreate(self) self.guardDummy = CreateUnitHPR('ZXA0003', self:GetArmy(), 0,0,0,0,0,0) @@ -12,6 +17,8 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { self.Trash:Add(self.guardDummy) end, + ---@param self TConstructionPodUnit + ---@param bit number OnScriptBitSet = function(self, bit) TConstructionUnit.OnScriptBitSet(self, bit) if bit == 1 then @@ -19,6 +26,8 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { end end, + ---@param self TConstructionPodUnit + ---@param bit number OnScriptBitClear = function(self, bit) TConstructionUnit.OnScriptBitClear(self, bit) if bit == 1 then @@ -26,6 +35,9 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { end end, + ---@param self TConstructionPodUnit + ---@param transport Unit + ---@param bone number OnAttachedToTransport = function(self, transport, bone) local guards = self:GetGuards() IssueClearCommands(guards) @@ -33,6 +45,9 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { TConstructionUnit.OnAttachedToTransport(self, transport, bone) end, + ---@param self TConstructionPodUnit + ---@param transport Unit + ---@param bone number OnDetachedFromTransport = function(self, transport, bone) TConstructionUnit.OnDetachedFromTransport(self, transport, bone) local guards = self.guardDummy:GetGuards() @@ -40,12 +55,18 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { IssueGuard(guards, self) end, + ---@param self TConstructionPodUnit + ---@param parent Unit + ---@param podName string SetParent = function(self, parent, podName) self.Parent = parent self.Pod = podName self:SetScriptBit('RULEUTC_WeaponToggle', true) end, + ---@param self TConstructionPodUnit + ---@param unitBeingBuilt Unit + ---@param order string OnStartBuild = function(self, unitBeingBuilt, order) TConstructionUnit.OnStartBuild(self, unitBeingBuilt, order) self:FocusAssistersOnCurrentTask() @@ -127,7 +148,20 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { end end, + ---Called via hotkey to refocus assisters on our current task + ---@param self TConstructionPodUnit + RefocusAssisters = function(self) + local engineerGuards = EntityCategoryFilterDown(categories.ENGINEER, self:GetGuards()) + IssueClearCommands(engineerGuards) + if self.guardCache then + LOG('We have a guard cache') + self.guardCache.command(engineerGuards, self.guardCache.target) + end + IssueGuard(engineerGuards, self) + end, + ---Override get guards to pick up our assist cache + ---@param self TConstructionPodUnit GetGuards = function(self) local guards = oldGetGuards(self) local count = 0 @@ -149,15 +183,17 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) { return guards end, + ---@param self TConstructionPodUnit + ---@param instigator Unit + ---@param type string + ---@param overkillRatio number OnKilled = function(self, instigator, type, overkillRatio) self.Parent:NotifyOfPodDeath(self.Pod, self.rebuildDrone) self.Parent = nil TConstructionUnit.OnKilled(self, instigator, type, overkillRatio) end, - -- Don't make wreckage CreateWreckage = function (self, overkillRatio) - overkillRatio = 1.1 - TConstructionUnit.CreateWreckage(self, overkillRatio) + -- Don't make wreckage end, } \ No newline at end of file From e5c143cb7ea7c3250da56873d167494f025ff3c6 Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 18:00:24 -0400 Subject: [PATCH 5/6] add permanent shoulder pod soft focus to UEF SACU and ACU + annotations --- units/UEL0001/UEL0001_script.lua | 51 +++++++++++++++++++++++++++++ units/UEL0301/UEL0301_script.lua | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/units/UEL0001/UEL0001_script.lua b/units/UEL0001/UEL0001_script.lua index 96c4f4b481..0b0379361a 100644 --- a/units/UEL0001/UEL0001_script.lua +++ b/units/UEL0001/UEL0001_script.lua @@ -26,6 +26,8 @@ local EffectUtil = import("/lua/effectutilities.lua") local Buff = import("/lua/sim/buff.lua") ---@class UEL0001 : ACUUnit +---@field LeftPod TConstructionPodUnit +---@field RightPod TConstructionPodUnit UEL0001 = ClassUnit(ACUUnit) { Weapons = { DeathWeapon = ClassWeapon(ACUDeathWeapon) {}, @@ -102,10 +104,12 @@ UEL0001 = ClassUnit(ACUUnit) { }, }, + ---@param self UEL0001 __init = function(self) ACUUnit.__init(self, 'RightZephyr') end, + ---@param self UEL0001 OnCreate = function(self) ACUUnit.OnCreate(self) self:SetCapturable(false) @@ -127,6 +131,9 @@ UEL0001 = ClassUnit(ACUUnit) { end end, + ---@param self UEL0001 + ---@param builder Unit + ---@param layer string OnStopBeingBuilt = function(self, builder, layer) ACUUnit.OnStopBeingBuilt(self, builder, layer) if self:BeenDestroyed() then return end @@ -139,13 +146,34 @@ UEL0001 = ClassUnit(ACUUnit) { self:ForkThread(self.GiveInitialResources) end, + ---@param self UEL0001 + ---@param unitBeingBuilt Unit + ---@param order string OnStartBuild = function(self, unitBeingBuilt, order) ACUUnit.OnStartBuild(self, unitBeingBuilt, order) if self.Animator then self.Animator:SetRate(0) end + self:RefreshPodFocus() end, + ---@param self UEL0001 + ---@param unitBeingRepaired Unit + OnStartRepair = function(self, unitBeingRepaired) + ACUUnit.OnStartRepair(self, unitBeingRepaired) + self:RefreshPodFocus() + end, + + ---@param self UEL0001 + ---@param target Unit|Prop + OnStartReclaim = function(self, target) + ACUUnit.OnStartReclaim(self, target) + self:RefreshPodFocus() + end, + + ---@param self UEL0001 + ---@param unitBeingBuilt Unit + ---@param order string CreateBuildEffects = function(self, unitBeingBuilt, order) -- Different effect if we have building cube if unitBeingBuilt.BuildingCube then @@ -156,6 +184,8 @@ UEL0001 = ClassUnit(ACUUnit) { end end, + ---@param self UEL0001 + ---@param PodNumber integer RebuildPod = function(self, PodNumber) if PodNumber == 1 then -- Force pod rebuilds to queue up @@ -199,6 +229,9 @@ UEL0001 = ClassUnit(ACUUnit) { self:RequestRefreshUI() end, + ---@param self UEL0001 + ---@param pod string + ---@param rebuildDrone boolean NotifyOfPodDeath = function(self, pod, rebuildDrone) if rebuildDrone == true then if pod == 'LeftPod' then @@ -215,6 +248,22 @@ UEL0001 = ClassUnit(ACUUnit) { end end, + ---Calling this function will pull any pods without explicit orders to our current task + ---@param self UEL0001 + RefreshPodFocus = function(self) + for _, pod in self:GetPods() do + if not pod.Dead and pod:GetCommandQueue()[1].commandType == 29 then + IssueToUnitClearCommands(pod) + end + end + end, + + ---@param self UEL0001 + ---@return Unit[]? pods + GetPods = function(self) + return {self.LeftPod, self.RightPod} + end, + ---@param self UEL0001 ---@param bone Bone ---@param attachee Unit @@ -231,6 +280,8 @@ UEL0001 = ClassUnit(ACUUnit) { attachee:SetDoNotTarget(false) end, + ---@param self UEL0001 + ---@param enh string CreateEnhancement = function(self, enh) ACUUnit.CreateEnhancement(self, enh) diff --git a/units/UEL0301/UEL0301_script.lua b/units/UEL0301/UEL0301_script.lua index 2f06740314..49d417c6ff 100644 --- a/units/UEL0301/UEL0301_script.lua +++ b/units/UEL0301/UEL0301_script.lua @@ -29,6 +29,7 @@ UEL0301 = ClassUnit(CommandUnit) { DeathWeapon = ClassWeapon(SCUDeathWeapon) {}, }, + ---@param self UEL0301 OnCreate = function(self) CommandUnit.OnCreate(self) self:SetCapturable(false) @@ -37,16 +38,23 @@ UEL0301 = ClassUnit(CommandUnit) { self:SetupBuildBones() end, + ---@param self UEL0301 __init = function(self) CommandUnit.__init(self, 'RightHeavyPlasmaCannon') end, + ---@param self UEL0301 + ---@param builder Unit + ---@param layer Layer OnStopBeingBuilt = function(self, builder, layer) CommandUnit.OnStopBeingBuilt(self, builder, layer) -- Block Jammer until Enhancement is built self:DisableUnitIntel('Enhancement', 'Jammer') end, + ---@param self UEL0301 + ---@param unitBeingBuilt Unit + ---@param order string CreateBuildEffects = function(self, unitBeingBuilt, order) -- Different effect if we have building cube if unitBeingBuilt.BuildingCube then @@ -56,6 +64,29 @@ UEL0301 = ClassUnit(CommandUnit) { end end, + ---@param self UEL0301 + ---@param unitBeingBuilt Unit + ---@param order string + OnStartBuild = function(self, unitBeingBuilt, order) + CommandUnit.OnStartBuild(self, unitBeingBuilt, order) + self:RefreshPodFocus() + end, + + ---@param self UEL0301 + ---@param unitBeingRepaired Unit + OnStartRepair = function(self, unitBeingRepaired) + CommandUnit.OnStartRepair(self, unitBeingRepaired) + self:RefreshPodFocus() + end, + + ---@param self UEL0301 + ---@param target Unit|Prop + OnStartReclaim = function(self, target) + CommandUnit.OnStartReclaim(self, target) + self:RefreshPodFocus() + end, + + ---@param self UEL0301 RebuildPod = function(self) if self.HasPod == true then self.RebuildingPod = CreateEconomyEvent(self, 1600, 160, 10, self.SetWorkProgress) @@ -73,6 +104,9 @@ UEL0301 = ClassUnit(CommandUnit) { end end, + ---@param self UEL0301 + ---@param pod TConstructionPodUnit + ---@param rebuildDrone boolean NotifyOfPodDeath = function(self, pod, rebuildDrone) if rebuildDrone == true then if self.HasPod == true then @@ -83,6 +117,22 @@ UEL0301 = ClassUnit(CommandUnit) { end end, + ---Calling this function will pull any pods without explicit orders to our current task + ---@param self UEL0301 + RefreshPodFocus = function(self) + for _, pod in self:GetPods() do + if not pod.Dead and pod:GetCommandQueue()[1].commandType == 29 then + IssueToUnitClearCommands(pod) + end + end + end, + + ---@param self UEL0301 + ---@return Unit[]? pods + GetPods = function(self) + return {self.Pod} + end, + ---@param self UEL0301 ---@param bone Bone ---@param attachee Unit @@ -99,6 +149,8 @@ UEL0301 = ClassUnit(CommandUnit) { attachee:SetDoNotTarget(false) end, + ---@param self UEL0301 + ---@param enh string CreateEnhancement = function(self, enh) CommandUnit.CreateEnhancement(self, enh) local bp = self:GetBlueprint().Enhancements[enh] @@ -191,6 +243,8 @@ UEL0301 = ClassUnit(CommandUnit) { end end, + ---@param self UEL0301 + ---@param intel IntelType OnIntelEnabled = function(self, intel) CommandUnit.OnIntelEnabled(self, intel) if self.RadarJammerEnh and self:IsIntelEnabled('Jammer') then @@ -203,6 +257,8 @@ UEL0301 = ClassUnit(CommandUnit) { end end, + ---@param self UEL0301 + ---@param intel IntelType OnIntelDisabled = function(self, intel) CommandUnit.OnIntelDisabled(self, intel) if self.RadarJammerEnh and not self:IsIntelEnabled('Jammer') then From 8016114cf338259ecf697d45f1ce828953bd24dd Mon Sep 17 00:00:00 2001 From: clyf Date: Thu, 23 May 2024 18:15:46 -0400 Subject: [PATCH 6/6] harden shoulder pod parent focus --- units/UEL0001/UEL0001_script.lua | 22 ++++++++++++++++++++++ units/UEL0301/UEL0301_script.lua | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/units/UEL0001/UEL0001_script.lua b/units/UEL0001/UEL0001_script.lua index 0b0379361a..80dfcab0bc 100644 --- a/units/UEL0001/UEL0001_script.lua +++ b/units/UEL0001/UEL0001_script.lua @@ -157,6 +157,14 @@ UEL0001 = ClassUnit(ACUUnit) { self:RefreshPodFocus() end, + ---@param self UEL0001 + ---@param unitBeingBuilt Unit + ---@param order string + OnStopBuild = function(self, unitBeingBuilt, order) + ACUUnit.OnStopBuild(self, unitBeingBuilt, order) + self:RefreshPodFocus() + end, + ---@param self UEL0001 ---@param unitBeingRepaired Unit OnStartRepair = function(self, unitBeingRepaired) @@ -164,6 +172,13 @@ UEL0001 = ClassUnit(ACUUnit) { self:RefreshPodFocus() end, + ---@param self UEL0001 + ---@param unitBeingRepaired Unit + OnStopRepair = function(self, unitBeingRepaired) + ACUUnit.OnStopRepair(self, unitBeingRepaired) + self:RefreshPodFocus() + end, + ---@param self UEL0001 ---@param target Unit|Prop OnStartReclaim = function(self, target) @@ -171,6 +186,13 @@ UEL0001 = ClassUnit(ACUUnit) { self:RefreshPodFocus() end, + ---@param self UEL0001 + ---@param target Unit|Prop + OnStopReclaim = function(self, target) + ACUUnit.OnStopReclaim(self, target) + self:RefreshPodFocus() + end, + ---@param self UEL0001 ---@param unitBeingBuilt Unit ---@param order string diff --git a/units/UEL0301/UEL0301_script.lua b/units/UEL0301/UEL0301_script.lua index 49d417c6ff..6a78aa6eed 100644 --- a/units/UEL0301/UEL0301_script.lua +++ b/units/UEL0301/UEL0301_script.lua @@ -72,6 +72,14 @@ UEL0301 = ClassUnit(CommandUnit) { self:RefreshPodFocus() end, + ---@param self UEL0301 + ---@param unitBeingBuilt Unit + ---@param order string + OnStopBuild = function(self, unitBeingBuilt, order) + CommandUnit.OnStopBuild(self, unitBeingBuilt, order) + self:RefreshPodFocus() + end, + ---@param self UEL0301 ---@param unitBeingRepaired Unit OnStartRepair = function(self, unitBeingRepaired) @@ -79,6 +87,13 @@ UEL0301 = ClassUnit(CommandUnit) { self:RefreshPodFocus() end, + ---@param self UEL0301 + ---@param unitBeingRepaired Unit + OnStopRepair = function(self, unitBeingRepaired) + CommandUnit.OnStopRepair(self, unitBeingRepaired) + self:RefreshPodFocus() + end, + ---@param self UEL0301 ---@param target Unit|Prop OnStartReclaim = function(self, target) @@ -86,6 +101,13 @@ UEL0301 = ClassUnit(CommandUnit) { self:RefreshPodFocus() end, + ---@param self UEL0301 + ---@param target Unit|Prop + OnStopReclaim = function(self, target) + CommandUnit.OnStopReclaim(self, target) + self:RefreshPodFocus() + end, + ---@param self UEL0301 RebuildPod = function(self) if self.HasPod == true then