Skip to content

Commit

Permalink
fix totems not being affected by auras (PathOfBuildingCommunity#4636)
Browse files Browse the repository at this point in the history
* FEAT: Add support for auras affecting totems

* FIX: Fix mods from extra auras not applying correctly. Add breakdown to totem es. Some refactoring.

* FIX: Blacklist some mods coming from ExtraAuras to avoid moDB pollution. Display more stats for breakdown.

* Update CalcSections.lua

Co-authored-by: LocalIdentity <31035929+LocalIdentity@users.noreply.github.com>
  • Loading branch information
Paliak and LocalIdentity authored Sep 14, 2022
1 parent cb6a2a9 commit bf8c31b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Data/Skills/act_int.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4380,7 +4380,7 @@ skills["ForbiddenRite"] = {
local chaosFlat = floor(round(basetakenFlat * chaosDamageTaken), 0)
if activeSkill.skillFlags.totem then
life = output.TotemLife
energyShield = 0
energyShield = output.TotemEnergyShield
chaosResistance = output.TotemChaosResist
else
life = output.Life
Expand Down Expand Up @@ -8342,7 +8342,7 @@ skills["RighteousFire"] = {
castTime = 0,
preDamageFunc = function(activeSkill, output)
if activeSkill.skillFlags.totem then
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.TotemLife * activeSkill.skillData.RFLifeMultiplier
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.TotemLife * activeSkill.skillData.RFLifeMultiplier + output.TotemEnergyShield * activeSkill.skillData.RFESMultiplier
else
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.Life * activeSkill.skillData.RFLifeMultiplier + output.EnergyShield * activeSkill.skillData.RFESMultiplier
end
Expand Down
4 changes: 2 additions & 2 deletions src/Export/Skills/act_int.txt
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ local skills, mod, flag, skill = ...
local chaosFlat = floor(round(basetakenFlat * chaosDamageTaken), 0)
if activeSkill.skillFlags.totem then
life = output.TotemLife
energyShield = 0
energyShield = output.TotemEnergyShield
chaosResistance = output.TotemChaosResist
else
life = output.Life
Expand Down Expand Up @@ -1727,7 +1727,7 @@ local skills, mod, flag, skill = ...
#flags spell area
preDamageFunc = function(activeSkill, output)
if activeSkill.skillFlags.totem then
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.TotemLife * activeSkill.skillData.RFLifeMultiplier
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.TotemLife * activeSkill.skillData.RFLifeMultiplier + output.TotemEnergyShield * activeSkill.skillData.RFESMultiplier
else
activeSkill.skillData.FireDot = activeSkill.skillData.FireDot + output.Life * activeSkill.skillData.RFLifeMultiplier + output.EnergyShield * activeSkill.skillData.RFESMultiplier
end
Expand Down
15 changes: 14 additions & 1 deletion src/Modules/CalcOffence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ function calcs.offence(env, actor, activeSkill)
end
output.TotemLifeMod = calcLib.mod(skillModList, skillCfg, "TotemLife")
output.TotemLife = round(m_floor(env.data.monsterAllyLifeTable[skillData.totemLevel] * env.data.totemLifeMult[activeSkill.skillTotemId]) * output.TotemLifeMod)
output.TotemEnergyShield = skillModList:Sum("BASE", skillCfg, "TotemEnergyShield")
output.TotemBlockChance = skillModList:Sum("BASE", skillCfg, "TotemBlockChance")
output.TotemArmour = skillModList:Sum("BASE", skillCfg, "TotemArmour")
if breakdown then
breakdown.TotemLifeMod = breakdown.mod(skillModList, skillCfg, "TotemLife")
breakdown.TotemLife = {
Expand All @@ -1018,6 +1021,9 @@ function calcs.offence(env, actor, activeSkill)
"x "..output.TotemLifeMod.." ^8(totem life modifier)",
"= "..output.TotemLife,
}
breakdown.TotemEnergyShield = breakdown.mod(skillModList, skillCfg, "TotemEnergyShield")
breakdown.TotemBlockChance = breakdown.mod(skillModList, skillCfg, "TotemBlockChance")
breakdown.TotemArmour = breakdown.mod(skillModList, skillCfg, "TotemArmour")
end
end
if skillFlags.brand then
Expand Down Expand Up @@ -1602,6 +1608,13 @@ function calcs.offence(env, actor, activeSkill)
output.Speed = output.Speed * globalOutput.ActionSpeedMod
output.CastRate = output.Speed
end
if skillFlags.totem then
-- Totem skill. Apply action speed
local totemActionSpeed = 1 + (modDB:Sum("INC", nil, "TotemActionSpeed") / 100)
output.TotemActionSpeed = totemActionSpeed
output.Speed = output.Speed * totemActionSpeed
output.CastRate = output.Speed
end
if output.Cooldown then
output.Speed = m_min(output.Speed, 1 / output.Cooldown * output.Repeats)
end
Expand All @@ -1624,7 +1637,7 @@ function calcs.offence(env, actor, activeSkill)
base = s_format("%.2f ^8(base)", 1 / baseTime),
{ "%.2f ^8(increased/reduced)", 1 + inc/100 },
{ "%.2f ^8(more/less)", more },
{ "%.2f ^8(action speed modifier)", skillFlags.selfCast and globalOutput.ActionSpeedMod or 1 },
{ "%.2f ^8(action speed modifier)", (skillFlags.totem and output.TotemActionSpeed) or (skillFlags.selfCast and globalOutput.ActionSpeedMod) or 1 },
total = s_format("= %.2f ^8casts per second", output.CastRate)
})
if output.Cooldown and (1 / output.Cooldown) < output.CastRate then
Expand Down
43 changes: 43 additions & 0 deletions src/Modules/CalcPerform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,9 @@ local function doActorMisc(env, actor)
local effect = m_floor(8 * (1 + modDB:Sum("INC", nil, "TailwindEffectOnSelf", "BuffEffectOnSelf") / 100))
modDB:NewMod("ActionSpeed", "INC", effect, "Tailwind")
end
if modDB:Flag(nil, "Condition:TotemTailwind") then
modDB:NewMod("TotemActionSpeed", "INC", 8, "Tailwind")
end
if modDB:Flag(nil, "Adrenaline") then
local effectMod = 1 + modDB:Sum("INC", nil, "BuffEffectOnSelf") / 100
modDB:NewMod("Damage", "INC", m_floor(100 * effectMod), "Adrenaline")
Expand Down Expand Up @@ -1876,6 +1879,36 @@ function calcs.perform(env, avoidCache)
srcList:ScaleAddList(extraAuraModList, mult)
mergeBuff(srcList, minionBuffs, buff.name)
end
if env.player.mainSkill.skillFlags.totem and not (modDB:Flag(nil, "SelfAurasCannotAffectAllies") or modDB:Flag(nil, "SelfAuraSkillsCannotAffectAllies")) then
activeSkill.totemBuffSkill = true
affectedByAura[env.player.mainSkill] = true
env.player.mainSkill.skillModList.conditions["AffectedBy"..buff.name:gsub(" ","")] = true

local srcList = new("ModList")
local inc = skillModList:Sum("INC", skillCfg, "AuraEffect", "BuffEffect", "AuraBuffEffect")
local more = skillModList:More(skillCfg, "AuraEffect", "BuffEffect", "AuraBuffEffect")
local lists = {extraAuraModList, buff.modList}
local scale = (1 + inc / 100) * more
scale = m_max(scale, 0)

for _, modList in ipairs(lists) do
for _, mod in ipairs(modList) do
if mod.name == "EnergyShield" or mod.name == "Armour" or mod.name == "Evasion" or mod.name:match("Resist?M?a?x?$") then
local totemMod = copyTable(mod)
totemMod.name = "Totem"..totemMod.name
if scale ~= 1 then
if type(totemMod.value) == "number" then
totemMod.value = (m_floor(totemMod.value) == totemMod.value) and m_modf(round(totemMod.value * scale, 2)) or totemMod.value * scale
elseif type(totemMod.value) == "table" and totemMod.value.mod then
totemMod.value.mod.value = (m_floor(totemMod.value.mod.value) == totemMod.value.mod.value) and m_modf(round(totemMod.value.mod.value * scale, 2)) or totemMod.value.mod.value * scale
end
end
srcList:AddMod(totemMod)
end
end
end
mergeBuff(srcList, buffs, "Totem "..buff.name)
end
end
elseif buff.type == "Debuff" or buff.type == "AuraDebuff" then
local stackCount
Expand Down Expand Up @@ -3080,6 +3113,16 @@ function calcs.perform(env, avoidCache)
local more = env.minion.modDB:More(nil, "BuffEffectOnSelf", "AuraEffectOnSelf")
env.minion.modDB:ScaleAddList(modList, (1 + inc / 100) * more)
end
local totemModBlacklist = value.mod.name and (value.mod.name == "Speed" or value.mod.name == "CritMultiplier" or value.mod.name == "CritChance")
if env.player.mainSkill.skillFlags.totem and not modDB:Flag(nil, "SelfAurasCannotAffectAllies") and not totemModBlacklist then
local totemMod = copyTable(value.mod)
local totemModName, matches = totemMod.name:gsub("Condition:", "Condition:Totem")
if matches < 1 then
totemModName = "Totem" .. totemMod.name
end
totemMod.name = totemModName
modDB:AddMod(totemMod)
end
end

-- Check for modifiers to apply to actors affected by player auras or curses
Expand Down
18 changes: 15 additions & 3 deletions src/Modules/CalcSections.lua
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ return {
{ label = "Aura Duration", haveOutput = "AuraDuration", { format = "{3:output:AuraDuration}s", { breakdown = "AuraDuration" }, }, },
{ label = "Reserve Duration", haveOutput = "ReserveDuration", { format = "{3:output:ReserveDuration}s", { breakdown = "ReserveDuration" }, }, },
{ label = "Projectile Count", flag = "projectile", { format = "{output:ProjectileCount}", { modName = { "NoAdditionalProjectiles" , "ProjectileCount" }, cfg = "skill" }, }, },
{ label = "Pierce Count", flag = "projectile", { format = "{output:PierceCountString}", { modName = { "CannotPierce", "PierceCount", "PierceAllTargets" }, cfg = "skill" }, }, },
{ label = "Fork Count", flag = "projectile", { format = "{output:ForkCountString}", { modName = { "CannotFork", "ForkCountMax" }, cfg = "skill" }, }, },
{ label = "Max Chain Count", flag = "chaining", { format = "{output:ChainMaxString}", { modName = { "CannotChain", "ChainCountMax" }, cfg = "skill" }, }, },
{ label = "Pierce Count", haveOutput = "PierceCount", { format = "{output:PierceCountString}", { modName = { "CannotPierce", "PierceCount", "PierceAllTargets" }, cfg = "skill" }, }, },
{ label = "Fork Count", haveOutput = "ForkCountMax", { format = "{output:ForkCountString}", { modName = { "CannotFork", "ForkCountMax" }, cfg = "skill" }, }, },
{ label = "Max Chain Count", haveOutput = "ChainCountMax", { format = "{output:ChainMaxString}", { modName = { "CannotChain", "ChainCountMax" }, cfg = "skill" }, }, },
{ label = "Proj. Speed Mod", flag = "projectile", { format = "x {2:output:ProjectileSpeedMod}",
{ breakdown = "ProjectileSpeedMod" },
{ modName = "ProjectileSpeed", cfg = "skill" },
Expand Down Expand Up @@ -695,6 +695,18 @@ return {
{ modName = "TotemLife", cfg = "skill" },
}, },
{ label = "Totem Life", flag = "totem", { format = "{0:output:TotemLife}", { breakdown = "TotemLife" }, }, },
{ label = "Totem ES", haveOutput = "TotemEnergyShield", { format = "{0:output:TotemEnergyShield}",
{ breakdown = "TotemEnergyShield" },
{ modName = "TotemEnergyShield", cfg = "skill" },
}, },
{ label = "Totem Block Chance", haveOutput = "TotemBlockChance", { format = "{0:output:TotemBlockChance}%",
{ breakdown = "TotemBlockChance" },
{ modName = "TotemBlockChance", cfg = "skill" },
}, },
{ label = "Totem Armour", haveOutput = "TotemArmour", { format = "{0:output:TotemArmour}",
{ breakdown = "TotemArmour" },
{ modName = "TotemArmour", cfg = "skill" },
}, },
{ label = "Active Brand Limit", flag = "brand", { format = "{0:output:ActiveBrandLimit}", { modName = "ActiveBrandLimit", cfg = "skill" }, }, },
{ label = "Totem Fire Res", flag = "totem", { format = "{0:output:TotemFireResist}% (+{0:output:TotemFireResistOverCap}%)",
{ breakdown = "TotemFireResist" },
Expand Down

0 comments on commit bf8c31b

Please sign in to comment.