Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make shield assist start repairing the shield instantly #6464

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/balance.6464.md
Original file line number Diff line number Diff line change
@@ -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.
34 changes: 28 additions & 6 deletions lua/shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -559,11 +559,33 @@ 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
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 > owner.tickIssuedShieldRepair then
owner.tickIssuedShieldRepair = tick
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)
Expand Down Expand Up @@ -678,8 +700,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
Expand Down
1 change: 1 addition & 0 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading