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

Small bug fixes for shields #6445

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
5 changes: 5 additions & 0 deletions changelog/snippets/fix.6445.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- (#6445) Fix overcharge dealing half damage to static and ACU shields.

- (#6445) Shields now block damage from knocking down/setting fire to trees.

- (#6445) Fix normal damage being applied before anti-shield damage, which didn't let the normal damage overkill under a shield.
18 changes: 12 additions & 6 deletions lua/shield.lua
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,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)
if type == "TreeForce" or type == "TreeFire" then
return
return amount
end
-- Allow decoupling the shield from the owner's armor multiplier
local absorptionMulti = self.AbsorptionTypeDamageTypeToMulti[type] or self.Owner:GetArmorMult(type)
Expand Down Expand Up @@ -516,13 +516,19 @@ Shield = ClassShield(moho.shield_methods, Entity) {
local tick = GetGameTick()

-- damage correction for overcharge
-- These preset damages deal `2 * dmg * absorbMult or armorMult`, currently absorption multiplier is 1x so we need to divide by 2

-- If the absorption multiplier is less than 1, then the shield will get hit by two instances of area damage, the absorbed amount and the remainder.
-- This means that the following code then requires a multiplier to correct the total damage amount since both instances will be overriden.
-- For example with 0.25 absorption we would have a 0.25 damage and 0.75 damage instance hitting the shield. Both get set to 800 OC structure damage,
-- but then 0.25x armor is applied again (second OnGetDamageAbsorption call), reducing it to 2x200 damage, which requires a 2x multiplication to bring it to the expected 800.
-- Currently the absorption multiplier is 1, so we don't need a multiplier on the damage to balance it out.

if dmgType == 'Overcharge' then
local wep = instigator:GetWeaponByLabel('OverCharge')
if self.StaticShield then -- fixed damage for static shields
amount = wep:GetBlueprint().Overcharge.structureDamage / 2
elseif self.CommandShield then -- fixed damage for UEF bubble shield
amount = wep:GetBlueprint().Overcharge.commandDamage / 2
if self.StaticShield then
amount = wep:GetBlueprint().Overcharge.structureDamage
elseif self.CommandShield then
amount = wep:GetBlueprint().Overcharge.commandDamage
end
end

Expand Down
23 changes: 12 additions & 11 deletions lua/sim/Projectile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,7 @@ Projectile = ClassProjectile(ProjectileMethods, DebugProjectileComponent) {
local DoTTime = DamageData.DoTTime
if DoTTime <= 0 then
-- no damage over time, do radius-based damage
DamageArea(
instigator,
cachedPosition,
radius,
damage,
damageType,
damageFriendly,
damageSelf
)

-- anti-shield damage first so that the remaining damage can overkill under the shield
local damageToShields = DamageData.DamageToShields
if damageToShields then
DamageArea(
Expand All @@ -675,6 +666,16 @@ Projectile = ClassProjectile(ProjectileMethods, DebugProjectileComponent) {
damageSelf
)
end

DamageArea(
instigator,
cachedPosition,
radius,
damage,
damageType,
damageFriendly,
damageSelf
)
else
-- check for initial damage
local initialDmg = DamageData.InitialDamageAmount
Expand Down Expand Up @@ -708,7 +709,7 @@ Projectile = ClassProjectile(ProjectileMethods, DebugProjectileComponent) {
-- damage a single entity
elseif targetEntity then
local damageType = DamageData.DamageType

-- anti-shield damage first so remainder can overkill under the shield
local damageToShields = DamageData.DamageToShields
if damageToShields then
Damage(
Expand Down
Loading