Skip to content

Commit

Permalink
Reduce table operations
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 committed Apr 7, 2024
1 parent 4110861 commit 7f60bec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ end
---@field PassOverkillDamage boolean
---@field ImpactMeshBp string
---@field SkipAttachmentCheck boolean
---@field AbsorptionType AbsorptionType
---@field AbsorptionTypeDamageTypeToMulti table<DamageType, number>
Shield = ClassShield(moho.shield_methods, Entity) {

RemainEnabledWhenAttached = false,
Expand Down Expand Up @@ -223,8 +223,8 @@ Shield = ClassShield(moho.shield_methods, Entity) {
self.CommandShield = true
end

-- lookup our damage absorption type
self.AbsorptionType = ownerBp.Defense.Shield.AbsorptionType or "Default"
-- lookup our damage absorption type's table
self.AbsorptionTypeDamageTypeToMulti = shieldAbsorptionValues[ownerBp.Defense.Shield.AbsorptionType or "Default"]

-- use trashbag of the unit that owns us
self.Trash = self.Owner.Trash
Expand Down Expand Up @@ -455,7 +455,7 @@ Shield = ClassShield(moho.shield_methods, Entity) {
---@return number damageAbsorbed If not all damage is absorbed, the remainder passes to targets under the shield.
OnGetDamageAbsorption = function(self, instigator, amount, type)
-- Allow decoupling the shield from the owner's armor multiplier
local absorptionMulti = shieldAbsorptionValues[self.AbsorptionType][type] or self.Owner:GetArmorMult(type)
local absorptionMulti = self.AbsorptionTypeDamageTypeToMulti[type] or self.Owner:GetArmorMult(type)

-- Like armor damage, first multiply by armor reduction, then apply handicap
-- See SimDamage.cpp (DealDamage function) for how this should work
Expand Down

0 comments on commit 7f60bec

Please sign in to comment.