diff --git a/spec/System/TestTriggers_spec.lua b/spec/System/TestTriggers_spec.lua index 4628749ed50..8cd37a580cf 100644 --- a/spec/System/TestTriggers_spec.lua +++ b/spec/System/TestTriggers_spec.lua @@ -1266,6 +1266,283 @@ describe("TestTriggers", function() assert.True(build.calcsTab.mainOutput.SkillTriggerRate ~= nil) end) + describe("The Monastery Bell", function() + local function equipUnique(category, name, slot) + local items = data.uniques[category] + local index = isValueInArrayPred(items, function(raw) return raw:sub(1, #name + 1) == name .. "\n" end) + assert.is_not_nil(index) + local item = new("Item"):Item(items[index]) + build.itemsTab:AddItem(item, true) + build.itemsTab.slots[slot]:SetSelItemId(item.id) + build.buildFlag = true + runCallback("OnFrame") + end + + local bellNodeId = 26055 + local function selectReliquarian() + local spec = build.spec + spec:SelectClass(spec.tree.classNameMap.Scion) + spec:SelectAscendClass(spec.tree.ascendNameMap.Reliquarian.ascendClassId) + assert.are.equal("The Monastery Bell", spec.nodes[bellNodeId].dn) + build.buildFlag = true + runCallback("OnFrame") + end + + local function allocateBellNode() + build.spec:AllocNode(build.spec.nodes[bellNodeId]) + assert.is_not_nil(build.spec.allocNodes[bellNodeId]) + build.buildFlag = true + runCallback("OnFrame") + end + + local function selectSkill(name, occurrence) + local matches = 0 + runCallback("OnFrame") + for groupIndex, group in ipairs(build.skillsTab.socketGroupList) do + -- A disabled group keeps its last skill list + for skillIndex, skill in ipairs(group.enabled and group.displaySkillList or {}) do + if skill.activeEffect.grantedEffect.name == name then + matches = matches + 1 + if matches == (occurrence or 1) then + build.mainSocketGroup = groupIndex + group.mainActiveSkill = skillIndex + build.buildFlag = true + runCallback("OnFrame") + assert.are.equal(name, build.calcsTab.mainEnv.player.mainSkill.activeEffect.grantedEffect.name) + return build.calcsTab.mainOutput, group + end + end + end + end + error("Missing active skill: " .. name) + end + + local function setCustomMods(text) + build.configTab.input.customMods = text + build.configTab:BuildModList() + build.buildFlag = true + end + + -- The trigger simulation counts a whole number of triggers over 1000 attacks + local function assertRate(expected, actual) + assert.are.near(expected, actual, expected * 0.002) + end + + for _, name in ipairs({ "Festering Resentment", "Svalinn" }) do + it("keeps the usual block assumptions for " .. name .. " without the Bell or a shield attack to block with", function() + local slot, hasShatter + selectReliquarian() + if name == "Svalinn" then + equipUnique("shield", name, "Weapon 2") + slot = "Weapon 2" + else + equipUnique("dagger", name, "Weapon 1") + equipUnique("shield", "Shattershard", "Weapon 2") + slot, hasShatter = "Weapon 1", true + end + setCustomMods("Your Hits can't be Evaded") + build.skillsTab:PasteSocketGroup("Slot: " .. slot .. "\nArc 20/0 1\nArc 20/0 1\n") + build.skillsTab:PasteSocketGroup("Tempest Shield 20/0 1\n") + + local function triggerRates() + local rates = {} + local arc = selectSkill("Arc") + -- Blocks come as often as the trigger's cooldown allows and alternate between both spells + assert.are.near(1 / 0.264, arc.TriggerRateCap, 1e-6) + assert.are.near(arc.TriggerRateCap / 2, arc.SkillTriggerRate, 1e-6) + rates.firstArc, rates.secondArc = arc.SkillTriggerRate, selectSkill("Arc", 2).SkillTriggerRate + local tempestShield = selectSkill("Tempest Shield") + assert.are.equal(tempestShield.TriggerRateCap, tempestShield.SkillTriggerRate) + rates.tempestShield = tempestShield.SkillTriggerRate + if hasShatter then + local shatter = selectSkill("Shield Shatter") + assert.are.near(1 / shatter.Duration, shatter.SkillTriggerRate, 1e-6) + rates.shatter = shatter.SkillTriggerRate + end + return rates + end + + local usual = triggerRates() + build.skillsTab:PasteSocketGroup("Shield Charge 20/0 1\n") + local _, chargeGroup = selectSkill("Shield Charge") + assert.are.same(usual, triggerRates()) + + -- Retaliation skills and attacks that do not use the shield are no source of blocks + chargeGroup.enabled = false + build.skillsTab:PasteSocketGroup("Smite 20/0 1\n") + build.skillsTab:PasteSocketGroup("Shield of Light 20/0 1\n") + allocateBellNode() + assert.are.same(usual, triggerRates()) + end) + end + + it("triggers Shield Shatter with each shield attack that hits", function() + equipUnique("shield", "Shattershard", "Weapon 2") + selectReliquarian() + setCustomMods("Your Hits can't be Evaded") + build.skillsTab:PasteSocketGroup("Shield Charge 20/0 1\n") + local usual = selectSkill("Shield Shatter") + + equipUnique("mace", "The Monastery Bell", "Weapon 1") + local charge = selectSkill("Shield Charge") + local shatter = selectSkill("Shield Shatter") + assert.True(shatter.SkillTriggerRate > 4 * usual.SkillTriggerRate) + assertRate(charge.Speed, shatter.SkillTriggerRate) + assert.are.equal(usual.Duration, shatter.Duration) + + -- Attacking faster blocks proportionally more often + setCustomMods("Your Hits can't be Evaded\n100% increased Attack Speed") + local fasterCharge = selectSkill("Shield Charge") + local fasterShatter = selectSkill("Shield Shatter") + assert.True(fasterCharge.Speed > 1.5 * charge.Speed) + assertRate(shatter.SkillTriggerRate * fasterCharge.Speed / charge.Speed, fasterShatter.SkillTriggerRate) + + -- Attacks that miss do not block + setCustomMods("100% increased Attack Speed") + local evadedCharge = selectSkill("Shield Charge") + assert.True(evadedCharge.HitChance > 0 and evadedCharge.HitChance < 100) + assert.are.equal(fasterCharge.Speed, evadedCharge.Speed) + assertRate(fasterShatter.SkillTriggerRate * evadedCharge.HitChance / 100, selectSkill("Shield Shatter").SkillTriggerRate) + + -- The Reliquarian passive has the same modifier as the mace + setCustomMods("Your Hits can't be Evaded") + build.itemsTab.slots["Weapon 1"]:SetSelItemId(0) + build.buildFlag = true + assert.are.equal(usual.SkillTriggerRate, selectSkill("Shield Shatter").SkillTriggerRate) + local preview = build.calcsTab.calcs.getMiscCalculator(build)({ addNodes = { [build.spec.nodes[bellNodeId]] = true } }) + allocateBellNode() + local passive = selectSkill("Shield Shatter") + assertRate(selectSkill("Shield Charge").Speed, passive.SkillTriggerRate) + assert.are.equal(passive.SkillTriggerRate, preview.SkillTriggerRate) + end) + + it("blocks once per use of a repeating shield attack and uses the attack that blocks most often", function() + equipUnique("mace", "The Monastery Bell", "Weapon 1") + equipUnique("shield", "Shattershard", "Weapon 2") + setCustomMods("Your Hits can't be Evaded") + build.skillsTab:PasteSocketGroup("Shield Crush 20/0 1\n") + local _, crushGroup = selectSkill("Shield Crush") + local single = selectSkill("Shield Shatter").SkillTriggerRate + + -- Multistrike attacks faster, but its two repeats belong to the same use + build.skillsTab:PasteSocketGroup("Shield Crush 20/0 1\nMultistrike 20/0 1\n") + crushGroup.enabled = false + local repeating = selectSkill("Shield Crush") + assert.are.equal(3, repeating.Repeats) + local shatter = selectSkill("Shield Shatter") + assert.True(shatter.SkillTriggerRate < single) + assertRate(repeating.Speed / 3, shatter.SkillTriggerRate) + + crushGroup.enabled = true + build.buildFlag = true + assert.are.equal(single, selectSkill("Shield Shatter").SkillTriggerRate) + end) + + it("adds Bell recovery for the selected shield attack once per use", function() + equipUnique("shield", "Shattershard", "Weapon 2") + setCustomMods("40 Life gained when you Block\n20 Mana gained when you Block\nGain 30 Energy Shield when you Block") + build.configTab.input.enemyEvasion = 3000 + build.configTab:BuildModList() + build.skillsTab:PasteSocketGroup("Shield Crush 20/0 1\nMultistrike 20/0 1\n") + build.skillsTab:PasteSocketGroup("Fireball 20/0 1\n") + + local withoutBell = selectSkill("Shield Crush") + assert.is_nil(withoutBell.LifeOnBlockRate) + assert.is_nil(withoutBell.ManaOnBlockRate) + assert.is_nil(withoutBell.EnergyShieldOnBlockRate) + + equipUnique("mace", "The Monastery Bell", "Weapon 1") + local crush = selectSkill("Shield Crush") + assert.are.equal(3, crush.Repeats) + assert.True(crush.HitChance > 0 and crush.HitChance < 100) + local expectedBlocks = crush.Speed / crush.Repeats * crush.HitChance / 100 + for resource, gain in pairs({ Life = 40, Mana = 20, EnergyShield = 30 }) do + local suffix = resource .. "OnBlockRate" + assert.are.near(gain * expectedBlocks, crush[suffix], 1e-6) + assert.are.near(crush[resource .. "LeechRate"] + crush[resource .. "OnHitRate"] + crush[suffix], + crush[resource .. "LeechGainRate"], 1e-6) + end + assertRate(expectedBlocks, selectSkill("Shield Shatter").SkillTriggerRate) + local fireball = selectSkill("Fireball") + assert.is_nil(fireball.LifeOnBlockRate) + assert.is_nil(fireball.ManaOnBlockRate) + assert.is_nil(fireball.EnergyShieldOnBlockRate) + end) + + it("counts one block per shield throw regardless of the displayed Trarthus skill part", function() + equipUnique("mace", "The Monastery Bell", "Weapon 1") + equipUnique("shield", "Shattershard", "Weapon 2") + setCustomMods("Your Hits can't be Evaded") + local name = "Spectral Shield Throw of Trarthus" + build.skillsTab:PasteSocketGroup(name .. " 20/0 1\n") + local shield, group = selectSkill(name) + local rate = selectSkill("Shield Shatter").SkillTriggerRate + assertRate(shield.Speed, rate) + group.gemList[1].skillPart = 2 + build.buildFlag = true + local shards = selectSkill(name) + assert.are.equal(shield.Speed, shards.Speed) + assert.True(shards.HitSpeed > shards.Speed) + assert.are.equal(rate, selectSkill("Shield Shatter").SkillTriggerRate) + end) + + for _, name in ipairs({ "Festering Resentment", "Svalinn" }) do + it("respects the cooldown and spell rotation of " .. name, function() + local slot + if name == "Svalinn" then + equipUnique("mace", "The Monastery Bell", "Weapon 1") + equipUnique("shield", name, "Weapon 2") + slot = "Weapon 2" + else + equipUnique("dagger", name, "Weapon 1") + equipUnique("shield", "Shattershard", "Weapon 2") + selectReliquarian() + allocateBellNode() + slot = "Weapon 1" + end + setCustomMods("Your Hits can't be Evaded") + build.skillsTab:PasteSocketGroup("Shield Charge 20/0 1\n") + build.skillsTab:PasteSocketGroup("Slot: " .. slot .. "\nArc 20/0 1\n") + local charge = selectSkill("Shield Charge") + local arc, spellGroup = selectSkill("Arc") + -- Each block triggers the spell while blocks are further apart than the cooldown + assert.True(charge.Speed < arc.TriggerRateCap) + assertRate(charge.Speed, arc.SkillTriggerRate) + + -- Blocks during the cooldown are wasted + setCustomMods("Your Hits can't be Evaded\n300% increased Attack Speed") + local fastCharge = selectSkill("Shield Charge") + local fastArc = selectSkill("Arc") + assert.True(fastCharge.Speed > 2 * fastArc.TriggerRateCap) + assert.True(fastArc.SkillTriggerRate > arc.SkillTriggerRate) + assert.True(fastArc.SkillTriggerRate <= fastArc.TriggerRateCap) + + -- Spells in the same item take turns + setCustomMods("Your Hits can't be Evaded") + spellGroup.enabled = false + build.skillsTab:PasteSocketGroup("Slot: " .. slot .. "\nArc 20/0 1\nFireball 20/0 1\n") + assertRate(charge.Speed / 2, selectSkill("Arc").SkillTriggerRate) + assertRate(charge.Speed / 2, selectSkill("Fireball").SkillTriggerRate) + end) + end + + it("discharges Tempest Shield with each block regardless of its activation cooldown", function() + equipUnique("mace", "The Monastery Bell", "Weapon 1") + equipUnique("shield", "Svalinn", "Weapon 2") + setCustomMods("Your Hits can't be Evaded\n300% increased Attack Speed") + build.skillsTab:PasteSocketGroup("Tempest Shield 20/0 1\n") + local usual = selectSkill("Tempest Shield") + assert.True(usual.SkillTriggerRate < 1) + + build.skillsTab:PasteSocketGroup("Shield Charge 20/0 1\n") + local charge = selectSkill("Shield Charge") + local tempestShield = selectSkill("Tempest Shield") + assert.True(charge.Speed > 5) + assertRate(charge.Speed, tempestShield.SkillTriggerRate) + assert.are.equal(usual.Cooldown, tempestShield.Cooldown) + end) + end) + it("Trigger Combust", function() build.skillsTab:PasteSocketGroup("Infernal Cry 20/0 1\n") runCallback("OnFrame") diff --git a/src/Data/ModCache.lua b/src/Data/ModCache.lua index 94ce6007e71..b862881832c 100755 --- a/src/Data/ModCache.lua +++ b/src/Data/ModCache.lua @@ -15164,7 +15164,7 @@ c["Corrupted Blood cannot be inflicted on you"]={{[1]={flags=0,keywordFlags=0,na c["Corrupted Blood cannot be inflicted on you if you have at least 5 Corrupted Blood Debuffs on you"]={nil,"Corrupted Blood cannot be inflicted on you if you have at least 5 Corrupted Blood Debuffs on you "} c["Corrupted Soul"]={{[1]={flags=0,keywordFlags=0,name="Keystone",type="LIST",value="Corrupted Soul"},[2]={flags=0,keywordFlags=0,name="Condition:HaveCorruptedSoul",type="FLAG",value=true}},nil} c["Cost every third time you Pay it"]={nil,"Cost every third time you Pay it "} -c["Count as Blocking Attack Damage from the first target Hit with each Shield Attack"]={nil,"Count as Blocking Attack Damage from the first target Hit with each Shield Attack "} +c["Count as Blocking Attack Damage from the first target Hit with each Shield Attack"]={{[1]={flags=0,keywordFlags=0,name="ShieldAttacksCountAsBlocks",type="FLAG",value=true}},nil} c["Count as having maximum number of Endurance Charges"]={{[1]={flags=0,keywordFlags=0,name="HaveMaximumEnduranceCharges",type="FLAG",value=true}},nil} c["Count as having maximum number of Endurance Charges Count as having maximum number of Frenzy Charges Count as having maximum number of Power Charges"]={nil,"Count as having maximum number of Endurance Charges Count as having maximum number of Frenzy Charges Count as having maximum number of Power Charges "} c["Count as having maximum number of Frenzy Charges"]={{[1]={flags=0,keywordFlags=0,name="HaveMaximumFrenzyCharges",type="FLAG",value=true}},nil} diff --git a/src/Modules/BuildDisplayStats.lua b/src/Modules/BuildDisplayStats.lua index 950c579f09a..2deb9316538 100644 --- a/src/Modules/BuildDisplayStats.lua +++ b/src/Modules/BuildDisplayStats.lua @@ -160,7 +160,7 @@ local displayStats = { { stat = "LifeRegenRecovery", label = "Life Regen", fmt = ".1f", color = colorCodes.LIFE, condFunc = function(v, o) return o.LifeRecovery <= 0 and o.LifeRegenRecovery ~= 0 end, breakdown = "LifeRegenRecovery" }, { stat = "LifeRegenRecovery", label = "Life Recovery", fmt = ".1f", color = colorCodes.LIFE, condFunc = function(v, o) return o.LifeRecovery > 0 and o.LifeRegenRecovery ~= 0 end, breakdown = "LifeRegenRecovery" }, { stat = "LifeRecharge", label = "Life Recharge", fmt = ".1f", color = colorCodes.LIFE, condFunc = function(v,o) return v > 0 end }, - { stat = "LifeLeechGainRate", label = "Life Leech/On Hit Rate", fmt = ".1f", color = colorCodes.LIFE, compPercent = true, breakdown = "LifeLeech" }, + { stat = "LifeLeechGainRate", label = "Life Leech/Gain Rate", fmt = ".1f", color = colorCodes.LIFE, compPercent = true, breakdown = "LifeLeech" }, { stat = "LifeLeechGainPerHit", label = "Life Leech/Gain per Hit", fmt = ".1f", color = colorCodes.LIFE, compPercent = true }, { }, { stat = "Mana", label = "Total Mana", fmt = "d", compactValue = true, color = colorCodes.MANA, compPercent = true, modNames = { "Mana" }, ignoredSections = { "Base from Gear", "Inc. from Tree" } }, @@ -169,7 +169,7 @@ local displayStats = { { stat = "ManaUnreservedPercent", label = "Unreserved Mana", fmt = "d%%", color = colorCodes.MANA, condFunc = function(v, o) return v < 100 end, breakdown = "ManaReserved" }, { stat = "ManaRegenRecovery", label = "Mana Regen", fmt = ".1f", color = colorCodes.MANA, condFunc = function(v,o) return o.ManaRecovery <= 0 and o.ManaRegenRecovery ~= 0 end }, { stat = "ManaRegenRecovery", label = "Mana Recovery", fmt = ".1f", color = colorCodes.MANA, condFunc = function(v,o) return o.ManaRecovery > 0 and o.ManaRegenRecovery ~= 0 end }, - { stat = "ManaLeechGainRate", label = "Mana Leech/On Hit Rate", fmt = ".1f", color = colorCodes.MANA, compPercent = true }, + { stat = "ManaLeechGainRate", label = "Mana Leech/Gain Rate", fmt = ".1f", color = colorCodes.MANA, compPercent = true }, { stat = "ManaLeechGainPerHit", label = "Mana Leech/Gain per Hit", fmt = ".1f", color = colorCodes.MANA, compPercent = true }, { }, -- the breakdown for armour, es and ev doesn't have anything relevant, and @@ -179,7 +179,7 @@ local displayStats = { { stat = "Spec:EnergyShieldInc", label = "%Inc ES from Tree", color = colorCodes.ES, fmt = "d%%" }, { stat = "EnergyShieldRegenRecovery", label = "ES Regen", color = colorCodes.ES, fmt = ".1f", condFunc = function(v,o) return o.EnergyShieldRecovery <= 0 and o.EnergyShieldRegenRecovery ~= 0 end }, { stat = "EnergyShieldRegenRecovery", label = "ES Recovery", color = colorCodes.ES, fmt = ".1f", condFunc = function(v,o) return o.EnergyShieldRecovery > 0 and o.EnergyShieldRegenRecovery ~= 0 end }, - { stat = "EnergyShieldLeechGainRate", label = "ES Leech/On Hit Rate", color = colorCodes.ES, fmt = ".1f", compPercent = true }, + { stat = "EnergyShieldLeechGainRate", label = "ES Leech/Gain Rate", color = colorCodes.ES, fmt = ".1f", compPercent = true }, { stat = "EnergyShieldLeechGainPerHit", label = "ES Leech/Gain per Hit", color = colorCodes.ES, fmt = ".1f", compPercent = true }, { }, { stat = "Ward", label = "Ward", fmt = "d", compactValue = true, color = colorCodes.WARD, compPercent = true, modNames = { "Ward" }, ignoredSections = defenseIgnoredSections }, diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua index fa2291f1e3a..4f2d254894a 100644 --- a/src/Modules/CalcOffence.lua +++ b/src/Modules/CalcOffence.lua @@ -4180,14 +4180,35 @@ function calcs.offence(env, actor, activeSkill) skillFlags.leechLife = output.LifeLeechRate > 0 skillFlags.leechES = output.EnergyShieldLeechRate > 0 skillFlags.leechMana = output.ManaLeechRate > 0 + -- Only the first target hit by each shield attack use counts as a Bell block. + if actor == env.player and skillFlags.shieldAttack and skillModList:Flag(nil, "ShieldAttacksCountAsBlocks") + and not (skillFlags.mine or skillFlags.trap or skillFlags.totem) then + local usesPerSecond = output.Speed / output.Repeats + local blockRate = usesPerSecond * output.HitChance / 100 + for _, resource in ipairs({ "Life", "Mana", "EnergyShield" }) do + local onBlock = output[resource .. "OnBlock"] or 0 + if onBlock > 0 and blockRate > 0 and not skillModList:Flag(skillCfg, "CannotGain" .. resource) then + local rateStat = resource .. "OnBlockRate" + output[rateStat] = onBlock * blockRate + if breakdown then + breakdown[rateStat] = { + s_format("%.1f ^8(gained on block)", onBlock), + s_format("x %.2f ^8(shield attack uses per second)", usesPerSecond), + s_format("x %.2f%% ^8(chance to hit)", output.HitChance), + s_format("= %.1f ^8(per second)", output[rateStat]), + } + end + end + end + end if skillData.showAverage then output.LifeLeechGainPerHit = output.LifeLeechPerHit + output.LifeOnHit output.EnergyShieldLeechGainPerHit = output.EnergyShieldLeechPerHit + output.EnergyShieldOnHit output.ManaLeechGainPerHit = output.ManaLeechPerHit + output.ManaOnHit else - output.LifeLeechGainRate = output.LifeLeechRate + output.LifeOnHitRate - output.EnergyShieldLeechGainRate = output.EnergyShieldLeechRate + output.EnergyShieldOnHitRate - output.ManaLeechGainRate = output.ManaLeechRate + output.ManaOnHitRate + output.LifeLeechGainRate = output.LifeLeechRate + output.LifeOnHitRate + (output.LifeOnBlockRate or 0) + output.EnergyShieldLeechGainRate = output.EnergyShieldLeechRate + output.EnergyShieldOnHitRate + (output.EnergyShieldOnBlockRate or 0) + output.ManaLeechGainRate = output.ManaLeechRate + output.ManaOnHitRate + (output.ManaOnBlockRate or 0) end if breakdown then local hitRate = output.HitChance / 100 * (globalOutput.HitSpeed or globalOutput.Speed) * skillData.dpsMultiplier diff --git a/src/Modules/CalcSections.lua b/src/Modules/CalcSections.lua index b103db1be51..f1e8e5c4328 100644 --- a/src/Modules/CalcSections.lua +++ b/src/Modules/CalcSections.lua @@ -1152,7 +1152,7 @@ return { }, }, } } } }, -{ 1, "LeechGain", 1, colorCodes.OFFENCE, {{ defaultCollapsed = false, label = "Leech & Gain on Hit", data = { +{ 1, "LeechGain", 1, colorCodes.OFFENCE, {{ defaultCollapsed = false, label = "Leech & Gain on Hit/Block", data = { { label = "Life Leech Cap", flag = "leechLife", { format = "{1:output:MaxLifeLeechRate}", { breakdown = "MaxLifeLeechRate" }, { modName = "MaxLifeLeechRate" }, @@ -1185,6 +1185,10 @@ return { { label = "Off Hand", flag = "weapon2Attack", modName = "LifeOnHit", modType = "BASE", cfg = "weapon2" }, { label = "Enemy modifiers", modName = { "SelfLifeOnHit" }, modType = "BASE", cfg = "skill", enemy = true }, }, }, + { label = "Life Gain on Block Rate", haveOutput = "LifeOnBlockRate", { format = "{1:output:LifeOnBlockRate}", + { breakdown = "LifeOnBlockRate" }, + { modName = "LifeOnBlock" }, + }, }, { label = "Life Gain on Kill", haveOutput = "LifeOnKill", { format = "{1:output:LifeOnKill}", {modName = "LifeOnKill"}, }, }, @@ -1220,6 +1224,10 @@ return { { label = "Off Hand", flag = "weapon2Attack", modName = "EnergyShieldOnHit", modType = "BASE", cfg = "weapon2" }, { label = "Enemy modifiers", modName = { "SelfEnergyShieldOnHit" }, modType = "BASE", cfg = "skill", enemy = true }, }, }, + { label = "ES Gain on Block Rate", haveOutput = "EnergyShieldOnBlockRate", { format = "{1:output:EnergyShieldOnBlockRate}", + { breakdown = "EnergyShieldOnBlockRate" }, + { modName = "EnergyShieldOnBlock" }, + }, }, { label = "ES Gain on Kill", haveOutput = "EnergyShieldOnKill", { format = "{1:output:EnergyShieldOnKill}", {modName = "EnergyShieldOnKill"}, }, }, @@ -1253,6 +1261,10 @@ return { { label = "Off Hand", flag = "weapon2Attack", modName = "ManaOnHit", modType = "BASE", cfg = "weapon2" }, { label = "Enemy modifiers", modName = { "SelfManaOnHit" }, modType = "BASE", cfg = "skill", enemy = true }, }, }, + { label = "Mana Gain on Block Rate", haveOutput = "ManaOnBlockRate", { format = "{1:output:ManaOnBlockRate}", + { breakdown = "ManaOnBlockRate" }, + { modName = "ManaOnBlock" }, + }, }, { label = "Mana Gain on Kill", haveOutput = "ManaOnKill", { format = "{1:output:ManaOnKill}", {modName = "ManaOnKill"}, }, }, diff --git a/src/Modules/CalcTriggers.lua b/src/Modules/CalcTriggers.lua index 25a701c352a..c923ffd15e1 100644 --- a/src/Modules/CalcTriggers.lua +++ b/src/Modules/CalcTriggers.lua @@ -100,6 +100,40 @@ local function findTriggerSkill(env, skill, source, triggerRate, comparer, minim return source, triggerRate, source and cacheSkillUUID(source, env) end +-- Config for skills triggered by blocking +-- With "Count as Blocking Attack Damage from the first target Hit with each Shield Attack" the shield attack that +-- blocks most often is the trigger source. Otherwise blocks are assumed to come as often as the skill can trigger +local function onBlockTrigger(env, config) + local mainSkill = env.player.mainSkill + if env.player.modDB:Flag(nil, "ShieldAttacksCountAsBlocks") then + local bestRate + for _, skill in ipairs(env.player.activeSkillList) do + local flags = skill.skillFlags + -- Retaliation attacks need a block before they can be used, so they are not counted as a source of blocks + if flags.shieldAttack and not flags.disable and not skill.skillTypes[SkillType.Retaliation] and not isTriggered(skill) then + local source, _, uuid = findTriggerSkill(env, skill, nil, nil, nil, nil, env.triggerSourceCache) + local cachedData = source and GlobalCache.cachedData[env.mode][uuid] + if cachedData then + -- Only the first target hit by each use blocks, however often the skill hits or repeats + local rate = cachedData.Speed / (1 + skill.skillModList:Sum("BASE", skill.skillCfg, "RepeatCount")) * (cachedData.HitChance or 0) + if not bestRate or rate > bestRate then + bestRate = rate + config.source, config.trigRate, config.sourceUUID = skill, cachedData.Speed, uuid + end + end + end + end + if config.source then + config.ignoreRepeats = true + mainSkill.skillFlags.globalTrigger = false + return config + end + end + mainSkill.skillFlags.globalTrigger = true + config.source = mainSkill + return config +end + -- Calculate the impact other skills and source rate to trigger cooldown alignment have on the trigger rate -- for more details regarding the implementation see comments of #4599 and #5428 function calcMultiSpellRotationImpact(env, skillRotation, sourceRate, triggerCD, chance, actor) @@ -413,7 +447,7 @@ local function defaultTriggerHandler(env, config) local source = config.source local triggeredSkills = config.triggeredSkills or {} local trigRate = config.trigRate - local uuid + local uuid = config.sourceUUID local sourceWeapon = config.sourceWeapon -- Only attacks using the granting weapon can activate source-weapon triggers local sourceWeaponFlag = sourceWeapon and actor.mainSkill.socketGroup.slot and (actor.mainSkill.socketGroup.slot:match("^Weapon 2") and "weapon2Attack" or "weapon1Attack") @@ -580,7 +614,7 @@ local function defaultTriggerHandler(env, config) local cooldownOverride = actor.mainSkill.skillModList:Override(actor.mainSkill.skillCfg, "CooldownRecovery") local triggerCD = actor.mainSkill.triggeredBy and env.player.mainSkill.triggeredBy.grantedEffect.levels[env.player.mainSkill.triggeredBy.level].cooldown triggerCD = triggerCD or source.triggeredBy and source.triggeredBy.grantedEffect.levels[source.triggeredBy.level].cooldown - local triggeredCD = actor.mainSkill.skillData.cooldown + local triggeredCD = not config.ignoreSkillCooldown and actor.mainSkill.skillData.cooldown or nil if actor.mainSkill.skillData.triggeredByBrand then triggerCD = actor.mainSkill.triggeredBy.mainSkill.skillData.repeatFrequency / actor.mainSkill.triggeredBy.activationFreqMore / actor.mainSkill.triggeredBy.activationFreqInc @@ -825,7 +859,12 @@ local function defaultTriggerHandler(env, config) elseif actor.mainSkill.skillFlags.globalTrigger and not config.triggeredSkillCond then -- Trigger does not use source rate breakpoints for one reason or another output.SkillTriggerRate = output.EffectiveSourceRate else -- Triggers like Cast on Crit go through simulation to calculate the trigger rate of each skill in the trigger group - output.SkillTriggerRate, simBreakdown = calcMultiSpellRotationImpact(env, config.triggeredSkillCond and triggeredSkills or {packageSkillDataForSimulation(actor.mainSkill, env)}, output.EffectiveSourceRate, (not actor.mainSkill.skillData.triggeredByBrand and ( triggerCD or triggeredCD ) or 0), triggerChance, actor) + local skillRotation = config.triggeredSkillCond and triggeredSkills or {packageSkillDataForSimulation(actor.mainSkill, env)} + if config.ignoreSkillCooldown then + skillRotation[1].cd = nil + end + local simBreakdown + output.SkillTriggerRate, simBreakdown = calcMultiSpellRotationImpact(env, skillRotation, output.EffectiveSourceRate, (not actor.mainSkill.skillData.triggeredByBrand and ( triggerCD or triggeredCD ) or 0), triggerChance, actor) local triggerBotsEffective = actor.modDB:Flag(nil, "HaveTriggerBots") and actor.mainSkill.skillTypes[SkillType.Spell] if triggerBotsEffective then output.SkillTriggerRate = 2 * output.SkillTriggerRate @@ -1316,11 +1355,17 @@ local configTable = { end} end, ["tempest shield"] = function(env) - env.player.mainSkill.skillFlags.globalTrigger = true - return {source = env.player.mainSkill} + local config = onBlockTrigger(env, {}) + -- Tempest Shield's cooldown limits activating the buff, not how often a block discharges it + config.ignoreSkillCooldown = config.sourceUUID ~= nil + return config end, ["shattershard"] = function(env) - env.player.mainSkill.skillFlags.globalTrigger = true + local config = onBlockTrigger(env, {}) + if config.sourceUUID then + -- Shield Shatter only prevents ordinary blocks for its duration + return config + end local uuid = cacheSkillUUID(env.player.mainSkill, env) if not GlobalCache.cachedData[env.mode][uuid] or env.mode == "CALCULATOR" then calcs.buildActiveSkill(env, env.mode, env.player.mainSkill, uuid, {uuid}) @@ -1333,7 +1378,7 @@ local configTable = { s_format("= %.2f ^8per second", env.player.mainSkill.skillData.triggerRateCapOverride), } end - return {source = env.player.mainSkill} + return config end, ["battlemage's cry"] = function(env) if env.player.mainSkill.activeEffect.grantedEffect.name ~= "Battlemage's Cry" then @@ -1524,18 +1569,16 @@ local configTable = { end end, ["svalinn cast on block"] = function(env) -- Svalinn Girded Tower Shield - env.player.mainSkill.skillFlags.globalTrigger = true - return {source = env.player.mainSkill, + return onBlockTrigger(env, { triggeredSkillCond = function(env, skill) return slotMatch(env, skill) and skill.triggeredBy and calcLib.canGrantedEffectSupportActiveSkill(skill.triggeredBy.grantedEffect, skill) - end} + end}) end, ["festering resentment cast on block"] = function(env) -- Festering Resentment Demon Dagger - env.player.mainSkill.skillFlags.globalTrigger = true - return {source = env.player.mainSkill, + return onBlockTrigger(env, { triggeredSkillCond = function(env, skill) return slotMatch(env, skill) and skill.triggeredBy and calcLib.canGrantedEffectSupportActiveSkill(skill.triggeredBy.grantedEffect, skill) - end} + end}) end, ["hex on trap"] = function(env) -- Hand of the Lords Carnal Mitts return {triggerSkillCond = function(env, skill) diff --git a/src/Modules/ModParser.lua b/src/Modules/ModParser.lua index a7f29d28835..0ef430d6329 100644 --- a/src/Modules/ModParser.lua +++ b/src/Modules/ModParser.lua @@ -4237,6 +4237,7 @@ local specialModList = { ["y?o?u?r? ?chance to block attack damage is lucky"] = { flag("BlockChanceIsLucky"), flag("ProjectileBlockChanceIsLucky") }, ["y?o?u?r? ?chance to block attack damage is unlucky"] = { flag("BlockChanceIsUnlucky"), flag("ProjectileBlockChanceIsUnlucky") }, ["y?o?u?r? ?chance to block is unlucky"] = { flag("BlockChanceIsUnlucky"), flag("ProjectileBlockChanceIsUnlucky"), flag("SpellBlockChanceIsUnlucky"), flag("SpellProjectileBlockChanceIsUnlucky") }, + ["count as blocking attack damage from the first target hit with each shield attack"] = { flag("ShieldAttacksCountAsBlocks") }, ["y?o?u?r? ?chance to block spell damage is lucky"] = { flag("SpellBlockChanceIsLucky"), flag("SpellProjectileBlockChanceIsLucky") }, ["y?o?u?r? ?chance to block spell damage is unlucky"] = { flag("SpellBlockChanceIsUnlucky"), flag("SpellProjectileBlockChanceIsUnlucky") }, ["your lucky or unlucky effects use the best or worst from three rolls instead of two"] = { flag("ExtremeLuck")},