Skip to content

Commit 872d4e2

Browse files
authored
Jugg armour applies to ele damage (#4673)
* Add support for % of armour applies to elemental damage * add mod parser change * cap percent of armour * fix merge conflict * add breakdown and fix phys not apply * add to main breakdown
1 parent 6507425 commit 872d4e2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/Modules/CalcDefence.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function calcs.defence(env, actor)
6262
output.DamageReductionMax = modDB:Override(nil, "DamageReductionMax") or data.misc.DamageReductionCap
6363
output.PhysicalDamageReduction = m_min(m_max(0, modDB:Sum("BASE", nil, "PhysicalDamageReduction")), output.DamageReductionMax)
6464
output.PhysicalDamageReductionwhenHit = m_min(m_max(0, output.PhysicalDamageReduction + modDB:Sum("BASE", nil, "PhysicalDamageReductionWhenHit")), output.DamageReductionMax)
65-
modDB:NewMod("ArmourAppliesToPhysicalDamageTaken", "FLAG", true)
65+
modDB:NewMod("ArmourAppliesToPhysicalDamageTaken", "BASE", 100)
6666
output["PhysicalResist"] = 0
6767

6868
-- Highest Maximum Elemental Resistance for Melding of the Flesh
@@ -1129,15 +1129,16 @@ function calcs.defence(env, actor)
11291129
local takenFlat = modDB:Sum("BASE", nil, "DamageTaken", damageType.."DamageTaken", "DamageTakenWhenHit", damageType.."DamageTakenWhenHit")
11301130
local damage = output[damageType.."TakenDamage"]
11311131
local armourReduct = 0
1132+
local percentOfArmourApplies = m_min((not modDB:Flag(nil, "ArmourDoesNotApplyTo"..damageType.."DamageTaken") and modDB:Sum("BASE", nil, "ArmourAppliesTo"..damageType.."DamageTaken") or 0), 100)
11321133
local resMult = 1 - (resist - enemyPen) / 100
11331134
local reductMult = 1
11341135
if damageCategoryConfig == "Melee" or damageCategoryConfig == "Projectile" then
11351136
takenFlat = takenFlat + modDB:Sum("BASE", nil, "DamageTakenFromAttacks", damageType.."DamageTakenFromAttacks")
11361137
elseif damageCategoryConfig == "Average" then
11371138
takenFlat = takenFlat + modDB:Sum("BASE", nil, "DamageTakenFromAttacks", damageType.."DamageTakenFromAttacks") / 2
11381139
end
1139-
if (modDB:Flag(nil, "ArmourAppliesTo"..damageType.."DamageTaken")) and not modDB:Flag(nil, "ArmourDoesNotApplyTo"..damageType.."DamageTaken") then
1140-
armourReduct = calcs.armourReduction(output.Armour * (1 + output.ArmourDefense), damage * resMult)
1140+
if percentOfArmourApplies > 0 then
1141+
armourReduct = calcs.armourReduction((output.Armour * percentOfArmourApplies / 100) * (1 + output.ArmourDefense), damage * resMult)
11411142
armourReduct = m_min(output.DamageReductionMax, armourReduct)
11421143
end
11431144
reductMult = (1 - m_max(m_min(output.DamageReductionMax, armourReduct + reduction - enemyOverwhelm), 0) / 100)
@@ -1150,6 +1151,9 @@ function calcs.defence(env, actor)
11501151
else
11511152
t_insert(breakdown[damageType.."DamageReduction"], s_format("Enemy Hit Damage: %d ^8(total incoming damage)", damage))
11521153
end
1154+
if percentOfArmourApplies ~= 100 then
1155+
t_insert(breakdown[damageType.."DamageReduction"], s_format("%d%% percent of armour applies", percentOfArmourApplies))
1156+
end
11531157
t_insert(breakdown[damageType.."DamageReduction"], s_format("Reduction from Armour: %d%%", armourReduct))
11541158
end
11551159
if reduction ~= 0 then
@@ -1200,6 +1204,9 @@ function calcs.defence(env, actor)
12001204
else
12011205
t_insert(breakdown[damageType.."TakenHitMult"], s_format("Enemy Hit Damage: %d ^8(total incoming damage)", damage))
12021206
end
1207+
if percentOfArmourApplies ~= 100 then
1208+
t_insert(breakdown[damageType.."TakenHitMult"], s_format("%d%% percent of armour applies", percentOfArmourApplies))
1209+
end
12031210
t_insert(breakdown[damageType.."TakenHitMult"], s_format("Reduction from Armour: %.2f", 1 - armourReduct / 100))
12041211
end
12051212
if enemyOverwhelm ~= 0 then

src/Modules/ModParser.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,17 @@ local specialModList = {
16481648
mod("LifeRecovery", "BASE", 1, { type = "PercentStat", stat = "Mana", percent = num }, { type = "Condition", var = "FullLife", neg = true })
16491649
} end,
16501650
["you are blind"] = { flag("Condition:Blinded") },
1651-
["armour applies to fire, cold and lightning damage taken from hits instead of physical damage"] = { flag("ArmourAppliesToFireDamageTaken"), flag("ArmourAppliesToColdDamageTaken"), flag("ArmourAppliesToLightningDamageTaken"), flag("ArmourDoesNotApplyToPhysicalDamageTaken") },
1651+
["armour applies to fire, cold and lightning damage taken from hits instead of physical damage"] = {
1652+
mod("ArmourAppliesToFireDamageTaken", "BASE", 100),
1653+
mod("ArmourAppliesToColdDamageTaken", "BASE", 100),
1654+
mod("ArmourAppliesToLightningDamageTaken", "BASE", 100),
1655+
flag("ArmourDoesNotApplyToPhysicalDamageTaken")
1656+
},
1657+
["(%d+)%% armour applies to fire, cold and lightning damage taken from hits"] = function(num) return {
1658+
mod("ArmourAppliesToFireDamageTaken", "BASE", num),
1659+
mod("ArmourAppliesToColdDamageTaken", "BASE", num),
1660+
mod("ArmourAppliesToLightningDamageTaken", "BASE", num),
1661+
} end,
16521662
["maximum damage reduction for any damage type is (%d+)%%"] = function(num) return { mod("DamageReductionMax", "OVERRIDE", num) } end,
16531663
["(%d+)%% of maximum mana is converted to twice that much armour"] = function(num) return {
16541664
mod("ManaConvertToArmour", "BASE", num),
@@ -3041,7 +3051,7 @@ local specialModList = {
30413051
["immune to curses while you have at least (%d+) rage"] = function(num) return { mod("AvoidCurse", "BASE", 100, { type = "MultiplierThreshold", var = "Rage", threshold = num }) } end,
30423052
["the effect of chill on you is reversed"] = { flag("SelfChillEffectIsReversed") },
30433053
["your movement speed is (%d+)%% of its base value"] = function(num) return { mod("MovementSpeed", "OVERRIDE", num / 100) } end,
3044-
["armour also applies to lightning damage taken from hits"] = { flag("ArmourAppliesToLightningDamageTaken") },
3054+
["armour also applies to lightning damage taken from hits"] = { mod("ArmourAppliesToLightningDamageTaken", "BASE", 100), },
30453055
["lightning resistance does not affect lightning damage taken"] = { flag("SelfIgnoreLightningResistance") },
30463056
["(%d+)%% increased maximum life and reduced fire resistance"] = function(num) return {
30473057
mod("Life", "INC", num),

0 commit comments

Comments
 (0)