Skip to content

Commit

Permalink
Merge pull request #5037 from Xaver-DaRed/AoE-Damage-Reduction
Browse files Browse the repository at this point in the history
[Magic] Implement AoE damage reduction
  • Loading branch information
TeoTwawki authored Jan 29, 2024
2 parents 0d9eab6 + 6a85f7c commit e5079c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/enum/mod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions scripts/globals/spells/damage_spell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/map/modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -997,7 +998,7 @@ enum class Mod
//
// SPARE IDs:
// 141 to 143
// 158, 159
// 159
// 217 to 223
// 271 to 280
//
Expand Down

0 comments on commit e5079c1

Please sign in to comment.