Skip to content
Merged
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
13 changes: 10 additions & 3 deletions src/Modules/CalcDefence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function calcs.defence(env, actor)
output.DamageReductionMax = modDB:Override(nil, "DamageReductionMax") or data.misc.DamageReductionCap
output.PhysicalDamageReduction = m_min(m_max(0, modDB:Sum("BASE", nil, "PhysicalDamageReduction")), output.DamageReductionMax)
output.PhysicalDamageReductionwhenHit = m_min(m_max(0, output.PhysicalDamageReduction + modDB:Sum("BASE", nil, "PhysicalDamageReductionWhenHit")), output.DamageReductionMax)
modDB:NewMod("ArmourAppliesToPhysicalDamageTaken", "FLAG", true)
modDB:NewMod("ArmourAppliesToPhysicalDamageTaken", "BASE", 100)
output["PhysicalResist"] = 0

-- Highest Maximum Elemental Resistance for Melding of the Flesh
Expand Down Expand Up @@ -1069,15 +1069,16 @@ function calcs.defence(env, actor)
local takenFlat = modDB:Sum("BASE", nil, "DamageTaken", damageType.."DamageTaken", "DamageTakenWhenHit", damageType.."DamageTakenWhenHit")
local damage = output[damageType.."TakenDamage"]
local armourReduct = 0
local percentOfArmourApplies = m_min((not modDB:Flag(nil, "ArmourDoesNotApplyTo"..damageType.."DamageTaken") and modDB:Sum("BASE", nil, "ArmourAppliesTo"..damageType.."DamageTaken") or 0), 100)
local resMult = 1 - (resist - enemyPen) / 100
local reductMult = 1
if damageCategoryConfig == "Melee" or damageCategoryConfig == "Projectile" then
takenFlat = takenFlat + modDB:Sum("BASE", nil, "DamageTakenFromAttacks", damageType.."DamageTakenFromAttacks")
elseif damageCategoryConfig == "Average" then
takenFlat = takenFlat + modDB:Sum("BASE", nil, "DamageTakenFromAttacks", damageType.."DamageTakenFromAttacks") / 2
end
if (modDB:Flag(nil, "ArmourAppliesTo"..damageType.."DamageTaken")) and not modDB:Flag(nil, "ArmourDoesNotApplyTo"..damageType.."DamageTaken") then
armourReduct = calcs.armourReduction(output.Armour * (1 + output.ArmourDefense), damage * resMult)
if percentOfArmourApplies > 0 then
armourReduct = calcs.armourReduction((output.Armour * percentOfArmourApplies / 100) * (1 + output.ArmourDefense), damage * resMult)
armourReduct = m_min(output.DamageReductionMax, armourReduct)
end
reductMult = (1 - m_max(m_min(output.DamageReductionMax, armourReduct + reduction - enemyOverwhelm), 0) / 100)
Expand All @@ -1090,6 +1091,9 @@ function calcs.defence(env, actor)
else
t_insert(breakdown[damageType.."DamageReduction"], s_format("Enemy Hit Damage: %d ^8(total incoming damage)", damage))
end
if percentOfArmourApplies ~= 100 then
t_insert(breakdown[damageType.."DamageReduction"], s_format("%d%% percent of armour applies", percentOfArmourApplies))
end
t_insert(breakdown[damageType.."DamageReduction"], s_format("Reduction from Armour: %d%%", armourReduct))
end
if reduction ~= 0 then
Expand Down Expand Up @@ -1140,6 +1144,9 @@ function calcs.defence(env, actor)
else
t_insert(breakdown[damageType.."TakenHitMult"], s_format("Enemy Hit Damage: %d ^8(total incoming damage)", damage))
end
if percentOfArmourApplies ~= 100 then
t_insert(breakdown[damageType.."TakenHitMult"], s_format("%d%% percent of armour applies", percentOfArmourApplies))
end
t_insert(breakdown[damageType.."TakenHitMult"], s_format("Reduction from Armour: %.2f", 1 - armourReduct / 100))
end
if enemyOverwhelm ~= 0 then
Expand Down
14 changes: 12 additions & 2 deletions src/Modules/ModParser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,17 @@ local specialModList = {
mod("LifeRecovery", "BASE", 1, { type = "PercentStat", stat = "Mana", percent = num }, { type = "Condition", var = "FullLife", neg = true })
} end,
["you are blind"] = { flag("Condition:Blinded") },
["armour applies to fire, cold and lightning damage taken from hits instead of physical damage"] = { flag("ArmourAppliesToFireDamageTaken"), flag("ArmourAppliesToColdDamageTaken"), flag("ArmourAppliesToLightningDamageTaken"), flag("ArmourDoesNotApplyToPhysicalDamageTaken") },
["armour applies to fire, cold and lightning damage taken from hits instead of physical damage"] = {
mod("ArmourAppliesToFireDamageTaken", "BASE", 100),
mod("ArmourAppliesToColdDamageTaken", "BASE", 100),
mod("ArmourAppliesToLightningDamageTaken", "BASE", 100),
flag("ArmourDoesNotApplyToPhysicalDamageTaken")
},
["(%d+)%% armour applies to fire, cold and lightning damage taken from hits"] = function(num) return {
mod("ArmourAppliesToFireDamageTaken", "BASE", num),
mod("ArmourAppliesToColdDamageTaken", "BASE", num),
mod("ArmourAppliesToLightningDamageTaken", "BASE", num),
} end,
["maximum damage reduction for any damage type is (%d+)%%"] = function(num) return { mod("DamageReductionMax", "OVERRIDE", num) } end,
["(%d+)%% of maximum mana is converted to twice that much armour"] = function(num) return {
mod("ManaConvertToArmour", "BASE", num),
Expand Down Expand Up @@ -2994,7 +3004,7 @@ local specialModList = {
["immune to curses while you have at least (%d+) rage"] = function(num) return { mod("AvoidCurse", "BASE", 100, { type = "MultiplierThreshold", var = "Rage", threshold = num }) } end,
["the effect of chill on you is reversed"] = { flag("SelfChillEffectIsReversed") },
["your movement speed is (%d+)%% of its base value"] = function(num) return { mod("MovementSpeed", "OVERRIDE", num / 100) } end,
["armour also applies to lightning damage taken from hits"] = { flag("ArmourAppliesToLightningDamageTaken") },
["armour also applies to lightning damage taken from hits"] = { mod("ArmourAppliesToLightningDamageTaken", "BASE", 100), },
["lightning resistance does not affect lightning damage taken"] = { flag("SelfIgnoreLightningResistance") },
["(%d+)%% increased maximum life and reduced fire resistance"] = function(num) return {
mod("Life", "INC", num),
Expand Down