From da0bb81337a85f9c3dfe33cc0af7b659d3416532 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:56:36 -0700 Subject: [PATCH 1/6] Update shield.lua annotations --- lua/shield.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/shield.lua b/lua/shield.lua index 84fd60bc46..4d51882ecc 100644 --- a/lua/shield.lua +++ b/lua/shield.lua @@ -356,7 +356,7 @@ Shield = ClassShield(moho.shield_methods, Entity) { --- Retrieves allied shields that overlap with this shield, caches the results per tick -- @param self A shield that we're computing the overlapping shields for - -- @param tick Optional parameter, represents the game tick. Used to determine if we need to refresh the cash + -- @param tick Optional parameter, represents the game tick. Used to determine if we need to refresh the cache GetOverlappingShields = function(self, tick) -- allow the game tick to be send to us, saves cycles @@ -458,7 +458,7 @@ Shield = ClassShield(moho.shield_methods, Entity) { ---@param instigator Unit ---@param amount number ---@param type DamageType - ---@return number damageAbsorbed If not all damage is absorbed, the remainder passes to targets under the shield. + ---@return number? damageAbsorbed If not all damage is absorbed, the remainder passes to targets under the shield. OnGetDamageAbsorption = function(self, instigator, amount, type) if type == "TreeForce" or type == "TreeFire" then return @@ -678,8 +678,8 @@ Shield = ClassShield(moho.shield_methods, Entity) { end, --- Called when a shield collides with a projectile to check if the collision is valid - -- @param self The shield we're checking the collision for - -- @param other The projectile we're checking the collision with + ---@param self Shield The shield we're checking the collision for + ---@param other Projectile The projectile we're checking the collision with OnCollisionCheck = function(self, other) -- special logic when it is a projectile to simulate air crashes From 9c941aa679e8532412d783721233828d22289983 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:06:29 -0700 Subject: [PATCH 2/6] Force guards to repair shields upon being damaged --- lua/shield.lua | 24 +++++++++++++++++++++++- lua/sim/Unit.lua | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/shield.lua b/lua/shield.lua index 4d51882ecc..bdc832281c 100644 --- a/lua/shield.lua +++ b/lua/shield.lua @@ -563,7 +563,29 @@ Shield = ClassShield(moho.shield_methods, Entity) { local absorbed = self:OnGetDamageAbsorption(instigator, amount, dmgType) -- take some damage - EntityAdjustHealth(self, instigator, -absorbed) + if absorbed then + EntityAdjustHealth(self, instigator, -absorbed) + + -- force guards to start repairing in 1 tick instead of waiting for them to react 7-11 ticks + if tick > self.Owner.tickIssuedShieldRepair then + self.Owner.tickIssuedShieldRepair = tick + local owner = self.Owner + local guards = owner:GetGuards() + if not table.empty(guards) then + for k, guard in guards do + -- do not clear queues for units order to do something after assisting the shield + if table.getn(guard:GetCommandQueue()) == 1 then + IssueToUnitClearCommands(guard) + else + guards[k] = nil + end + end + IssueRepair(guards, owner) + -- Queue a guard order so that units start guarding again after the repair is done + IssueGuard(guards, owner) + end + end + end -- check to spawn impact effect local r = Random(1, self.Size) diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index 2e07017a23..bafd755365 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -146,6 +146,7 @@ local cUnitGetBuildRate = cUnit.GetBuildRate ---@field ReclaimTimeMultiplier? number ---@field CaptureTimeMultiplier? number ---@field PlatoonHandle? Platoon +---@field tickIssuedShieldRepair number? # Used by shields to keep track of when this unit's guards were ordered to start shield repair instantly Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUnitComponent) { IsUnit = true, From 44628e67b1d949efed62b2465836ef6318528d14 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:08:03 -0700 Subject: [PATCH 3/6] Upvalue `self.Owner` --- lua/shield.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/shield.lua b/lua/shield.lua index bdc832281c..cffc8be4d9 100644 --- a/lua/shield.lua +++ b/lua/shield.lua @@ -559,7 +559,8 @@ Shield = ClassShield(moho.shield_methods, Entity) { -- do damage logic for shield - if self.Owner ~= instigator then + local owner = self.Owner + if owner ~= instigator then local absorbed = self:OnGetDamageAbsorption(instigator, amount, dmgType) -- take some damage @@ -567,9 +568,8 @@ Shield = ClassShield(moho.shield_methods, Entity) { EntityAdjustHealth(self, instigator, -absorbed) -- force guards to start repairing in 1 tick instead of waiting for them to react 7-11 ticks - if tick > self.Owner.tickIssuedShieldRepair then - self.Owner.tickIssuedShieldRepair = tick - local owner = self.Owner + if tick > owner.tickIssuedShieldRepair then + owner.tickIssuedShieldRepair = tick local guards = owner:GetGuards() if not table.empty(guards) then for k, guard in guards do From 78afac15afecf38a86aafc6bf16451cacfa2e92e Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:17:45 -0700 Subject: [PATCH 4/6] Debug setup --- lua/shield.lua | 2 +- lua/sim/Unit.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/shield.lua b/lua/shield.lua index cffc8be4d9..d53c684ad9 100644 --- a/lua/shield.lua +++ b/lua/shield.lua @@ -566,7 +566,7 @@ Shield = ClassShield(moho.shield_methods, Entity) { -- take some damage if absorbed then EntityAdjustHealth(self, instigator, -absorbed) - + LOG('Shield damaged: ', GetGameTick()) -- force guards to start repairing in 1 tick instead of waiting for them to react 7-11 ticks if tick > owner.tickIssuedShieldRepair then owner.tickIssuedShieldRepair = tick diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index bafd755365..e51113e496 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -2768,6 +2768,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni ---@param order string ---@return boolean OnStartBuild = function(self, built, order) + LOG('OnStartBuild', GetGameTick()) self.BuildEffectsBag = self.BuildEffectsBag or TrashBag() -- Prevent UI mods from violating game/scenario restrictions From bd7ae6afef972406f48836adc7d895278b77c3fa Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:18:03 -0700 Subject: [PATCH 5/6] Revert "Debug setup" This reverts commit 78afac15afecf38a86aafc6bf16451cacfa2e92e. --- lua/shield.lua | 2 +- lua/sim/Unit.lua | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/shield.lua b/lua/shield.lua index d53c684ad9..cffc8be4d9 100644 --- a/lua/shield.lua +++ b/lua/shield.lua @@ -566,7 +566,7 @@ Shield = ClassShield(moho.shield_methods, Entity) { -- take some damage if absorbed then EntityAdjustHealth(self, instigator, -absorbed) - LOG('Shield damaged: ', GetGameTick()) + -- force guards to start repairing in 1 tick instead of waiting for them to react 7-11 ticks if tick > owner.tickIssuedShieldRepair then owner.tickIssuedShieldRepair = tick diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index e51113e496..bafd755365 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -2768,7 +2768,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni ---@param order string ---@return boolean OnStartBuild = function(self, built, order) - LOG('OnStartBuild', GetGameTick()) self.BuildEffectsBag = self.BuildEffectsBag or TrashBag() -- Prevent UI mods from violating game/scenario restrictions From b957a6a22645ee518e672ab863312af562f8704d Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:50:59 -0700 Subject: [PATCH 6/6] Create balance.6464.md --- changelog/snippets/balance.6464.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/snippets/balance.6464.md diff --git a/changelog/snippets/balance.6464.md b/changelog/snippets/balance.6464.md new file mode 100644 index 0000000000..a9abc12adb --- /dev/null +++ b/changelog/snippets/balance.6464.md @@ -0,0 +1 @@ +- (#6464) Make engineers assisting a shield start repairing the shield in 0.1 seconds instead of 0.7 to 1.1 seconds.