From 6a85f7caf3423211840e43387258bb3b4890a8e2 Mon Sep 17 00:00:00 2001 From: Xaver-DaRed Date: Sun, 28 Jan 2024 20:46:24 +0100 Subject: [PATCH] Implement AoE damage reduction Only for converted spells. --- scripts/enum/mod.lua | 1 + scripts/globals/spells/damage_spell.lua | 12 ++++++++++++ src/map/modifier.h | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/enum/mod.lua b/scripts/enum/mod.lua index 203396287b0..97ee9f6bc28 100644 --- a/scripts/enum/mod.lua +++ b/scripts/enum/mod.lua @@ -185,6 +185,7 @@ xi.mod = DMGMAGIC = 163, DMGMAGIC_II = 831, -- Magic Damage Taken II % (Aegis) DMGRANGE = 164, + DMG_AOE = 158, -- Damage Taken % when not main target of an AoE action. (Ex: Locus Mobs) UDMGPHYS = 387, UDMGBREATH = 388, UDMGMAGIC = 389, diff --git a/scripts/globals/spells/damage_spell.lua b/scripts/globals/spells/damage_spell.lua index 146b0df585f..f8e7dd1953b 100644 --- a/scripts/globals/spells/damage_spell.lua +++ b/scripts/globals/spells/damage_spell.lua @@ -812,6 +812,16 @@ xi.spells.damage.calculateHelixMeritMultiplier = function(caster, spellId) return helixMeritMultiplier end +xi.spells.damage.calculateAreaOfEffectResistance = function(target, spell) + local areaOfEffectMultiplier = 1 + + if target:getID() ~= spell:getPrimaryTargetID() then + areaOfEffectMultiplier = utils.clamp(areaOfEffectMultiplier + target:getMod(xi.mod.DMG_AOE) / 10000, 0, 2) + end + + return areaOfEffectMultiplier +end + xi.spells.damage.calculateNukeAbsorbOrNullify = function(target, spellElement) local nukeAbsorbOrNullify = 1 @@ -911,6 +921,7 @@ xi.spells.damage.useDamageSpell = function(caster, target, spell) local undeadDivinePenalty = xi.spells.damage.calculateUndeadDivinePenalty(target, skillType) local scarletDeliriumMultiplier = xi.spells.damage.calculateScarletDeliriumMultiplier(caster) local helixMeritMultiplier = xi.spells.damage.calculateHelixMeritMultiplier(caster, spellId) + local areaOfEffectResistance = xi.spells.damage.calculateAreaOfEffectResistance(target, spell) local nukeAbsorbOrNullify = xi.spells.damage.calculateNukeAbsorbOrNullify(target, spellElement) -- Calculate finalDamage. It MUST be floored after EACH multiplication. @@ -933,6 +944,7 @@ xi.spells.damage.useDamageSpell = function(caster, target, spell) finalDamage = math.floor(finalDamage * undeadDivinePenalty) finalDamage = math.floor(finalDamage * scarletDeliriumMultiplier) finalDamage = math.floor(finalDamage * helixMeritMultiplier) + finalDamage = math.floor(finalDamage * areaOfEffectResistance) finalDamage = math.floor(finalDamage * nukeAbsorbOrNullify) -- Handle "Nuke Wall". It must be handled after all previous calculations, but before clamp. diff --git a/src/map/modifier.h b/src/map/modifier.h index 2ed6f5139df..468dd35e81b 100644 --- a/src/map/modifier.h +++ b/src/map/modifier.h @@ -211,6 +211,7 @@ enum class Mod DMGMAGIC = 163, // Magic Damage Taken % DMGMAGIC_II = 831, // Magic Damage Taken II % (Aegis) DMGRANGE = 164, // Range Damage Taken % + DMG_AOE = 158, // Damage Taken % when not main target of an AoE action. (Ex: Locus Mobs) // Uncapped damage - 10000 base, 375 = 3.75% UDMGPHYS = 387, // Uncapped Damage Multipliers @@ -997,7 +998,7 @@ enum class Mod // // SPARE IDs: // 141 to 143 - // 158, 159 + // 159 // 217 to 223 // 271 to 280 //