Skip to content

Commit 91a5571

Browse files
LocalIdentityLocalIdentity
andauthored
Fix calculation when using Unexciting Runegraft (#9251)
I implemented the Unexciting mod incorrectly in the past making it negate any lucky or unlucky mod instead of applying the correct formula Unexciting rolls three times and keeps the median result -> 3p^2 - 2p^3 This affects Block Chance, Suppress chance and crit chance Also changed the sidebar for Block and Suppress chance to use 3 and 2 significant figures as when using azadi's crest for double lucky the block chance values can easily get to 99 and require more precision Made sure so add a new handler that trims off 0 after the decimal so regular block builds don't show 75.000% block Co-authored-by: LocalIdentity <[email protected]>
1 parent 12da634 commit 91a5571

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

src/Modules/Build.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,10 @@ function buildMode:FormatStat(statData, statVal, overCapStatVal, colorOverride)
15351535
end
15361536

15371537
local valStr = s_format("%"..statData.fmt, val)
1538+
local number, suffix = valStr:match("^([%+%-]?%d+%.%d+)(%D*)$")
1539+
if number then
1540+
valStr = number:gsub("0+$", ""):gsub("%.$", "") .. suffix
1541+
end
15381542
valStr:gsub("%.", main.decimalSeparator)
15391543
valStr = color .. formatNumSep(valStr)
15401544

src/Modules/BuildDisplayStats.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ local displayStats = {
159159
{ stat = "Spec:ArmourInc", label = "%Inc Armour from Tree", fmt = "d%%" },
160160
{ stat = "PhysicalDamageReduction", label = "Phys. Damage Reduction", fmt = "d%%", condFunc = function() return true end },
161161
{ },
162-
{ stat = "EffectiveBlockChance", label = "Block Chance", fmt = "d%%", overCapStat = "BlockChanceOverCap" },
163-
{ stat = "EffectiveSpellBlockChance", label = "Spell Block Chance", fmt = "d%%", overCapStat = "SpellBlockChanceOverCap" },
162+
{ stat = "EffectiveBlockChance", label = "Block Chance", fmt = ".3f%%", overCapStat = "BlockChanceOverCap" },
163+
{ stat = "EffectiveSpellBlockChance", label = "Spell Block Chance", fmt = ".3f%%", overCapStat = "SpellBlockChanceOverCap" },
164164
{ stat = "AttackDodgeChance", label = "Attack Dodge Chance", fmt = "d%%", overCapStat = "AttackDodgeChanceOverCap" },
165165
{ stat = "SpellDodgeChance", label = "Spell Dodge Chance", fmt = "d%%", overCapStat = "SpellDodgeChanceOverCap" },
166-
{ stat = "EffectiveSpellSuppressionChance", label = "Spell Suppression Chance", fmt = "d%%", overCapStat = "SpellSuppressionChanceOverCap" },
166+
{ stat = "EffectiveSpellSuppressionChance", label = "Spell Suppression Chance", fmt = ".2f%%", overCapStat = "SpellSuppressionChanceOverCap" },
167167
{ },
168168
{ stat = "FireResist", label = "Fire Resistance", fmt = "d%%", color = colorCodes.FIRE, condFunc = function() return true end, overCapStat = "FireResistOverCap"},
169169
{ stat = "FireResistOverCap", label = "Fire Res. Over Max", fmt = "d%%", hideStat = true },

src/Modules/CalcDefence.lua

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -720,19 +720,20 @@ function calcs.defence(env, actor)
720720
if modDB:Flag(nil, "ExtremeLuck") then
721721
blockRolls = blockRolls * 2
722722
end
723-
if modDB:Flag(nil, "Unexciting") then
724-
blockRolls = 0
725-
end
726723
end
727724
-- unlucky config to lower the value of block, dodge, evade etc for ehp
728725
if env.configInput.EHPUnluckyWorstOf and env.configInput.EHPUnluckyWorstOf ~= 1 then
729726
blockRolls = -env.configInput.EHPUnluckyWorstOf / 2
730727
end
731728
if blockRolls ~= 0 then
732-
if blockRolls > 0 then
733-
output["Effective"..blockType] = (1 - (1 - output["Effective"..blockType] / 100) ^ (blockRolls + 1)) * 100
729+
local blockChance = output["Effective"..blockType] / 100
730+
if modDB:Flag(nil, "Unexciting") then
731+
-- Unexciting rolls three times and keeps the median result -> 3p^2 - 2p^3
732+
output["Effective"..blockType] = (3 * blockChance ^ 2 - 2 * blockChance ^ 3) * 100
733+
elseif blockRolls > 0 then
734+
output["Effective"..blockType] = (1 - (1 - blockChance) ^ (blockRolls + 1)) * 100
734735
else
735-
output["Effective"..blockType] = (output["Effective"..blockType] / 100) ^ m_abs(blockRolls) * output["Effective"..blockType]
736+
output["Effective"..blockType] = blockChance ^ m_abs(blockRolls) * output["Effective"..blockType]
736737
end
737738
end
738739
end
@@ -1096,19 +1097,20 @@ function calcs.defence(env, actor)
10961097
if modDB:Flag(nil, "ExtremeLuck") then
10971098
suppressRolls = suppressRolls * 2
10981099
end
1099-
if modDB:Flag(nil, "Unexciting") then
1100-
suppressRolls = 0
1101-
end
11021100
end
11031101
-- unlucky config to lower the value of block, dodge, evade etc for ehp
11041102
if env.configInput.EHPUnluckyWorstOf and env.configInput.EHPUnluckyWorstOf ~= 1 then
11051103
suppressRolls = -env.configInput.EHPUnluckyWorstOf / 2
11061104
end
11071105
if suppressRolls ~= 0 then
1108-
if suppressRolls > 0 then
1109-
output.EffectiveSpellSuppressionChance = (1 - (1 - output.EffectiveSpellSuppressionChance / 100) ^ (suppressRolls + 1)) * 100
1106+
local suppressChance = output.EffectiveSpellSuppressionChance / 100
1107+
if modDB:Flag(nil, "Unexciting") then
1108+
-- Unexciting rolls three times and keeps the median result -> 3p^2 - 2p^3
1109+
output.EffectiveSpellSuppressionChance = (3 * suppressChance ^ 2 - 2 * suppressChance ^ 3) * 100
1110+
elseif suppressRolls > 0 then
1111+
output.EffectiveSpellSuppressionChance = (1 - (1 - suppressChance) ^ (suppressRolls + 1)) * 100
11101112
else
1111-
output.EffectiveSpellSuppressionChance = (output.EffectiveSpellSuppressionChance / 100) ^ m_abs(suppressRolls) * output.EffectiveSpellSuppressionChance
1113+
output.EffectiveSpellSuppressionChance = suppressChance ^ m_abs(suppressRolls) * output.EffectiveSpellSuppressionChance
11121114
end
11131115
end
11141116

src/Modules/CalcOffence.lua

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,11 +2882,13 @@ function calcs.offence(env, actor, activeSkill)
28822882
if skillModList:Flag(skillCfg, "ExtremeLuck") then
28832883
critRolls = critRolls * 2
28842884
end
2885-
if skillModList:Flag(skillCfg, "Unexciting") then
2886-
critRolls = 0
2887-
end
28882885
if critRolls ~= 0 then
2889-
output.CritChance = (1 - (1 - output.CritChance / 100) ^ (critRolls + 1)) * 100
2886+
if modDB:Flag(nil, "Unexciting") then
2887+
-- Unexciting rolls three times and keeps the median result -> 3p^2 - 2p^3
2888+
output.CritChance = (3 * (output.CritChance / 100) ^ 2 - 2 * (output.CritChance / 100) ^ 3) * 100
2889+
else
2890+
output.CritChance = (1 - (1 - output.CritChance / 100) ^ (critRolls + 1)) * 100
2891+
end
28902892
end
28912893
local preHitCheckCritChance = output.CritChance
28922894
local preSkillUseCritChance= output.CritChance
@@ -2921,8 +2923,13 @@ function calcs.offence(env, actor, activeSkill)
29212923
end
29222924
if env.mode_effective and (critRolls ~= 0 or skillModList:Flag(skillCfg, "Every3UseCrit") or skillModList:Flag(skillCfg, "Every5UseCrit")) then
29232925
if critRolls ~= 0 then
2924-
t_insert(breakdown.CritChance, "Crit Chance is Lucky:")
2925-
t_insert(breakdown.CritChance, s_format("1 - (1 - %.4f)^ %d", preLuckyCritChance / 100, critRolls + 1))
2926+
if skillModList:Flag(skillCfg, "Unexciting") then
2927+
t_insert(breakdown.CritChance, "Crit Chance is Unexciting:")
2928+
t_insert(breakdown.CritChance, s_format("(3 x %.4f^ 2) - (2 x %.4f^ 3)", preLuckyCritChance / 100, preLuckyCritChance / 100))
2929+
else
2930+
t_insert(breakdown.CritChance, "Crit Chance is Lucky:")
2931+
t_insert(breakdown.CritChance, s_format("1 - (1 - %.4f)^ %d", preLuckyCritChance / 100, critRolls + 1))
2932+
end
29262933
end
29272934
if skillModList:Flag(skillCfg, "Every3UseCrit") then
29282935
t_insert(breakdown.CritChance, s_format("+ %.2f%% ^8(crit every 3rd use)", (2 * preSkillUseCritChance + 100) / 3 - preSkillUseCritChance))
@@ -3154,7 +3161,7 @@ function calcs.offence(env, actor, activeSkill)
31543161
damageTypeHitAvgUnlucky = ((rolls - 1) * damageTypeHitMin / rolls + damageTypeHitMax / rolls)
31553162
if damageTypeLuckyChance >= 0 then
31563163
damageTypeHitAvg = damageTypeHitAvgNotLucky * (1 - damageTypeLuckyChance) + damageTypeHitAvgLucky * damageTypeLuckyChance
3157-
else
3164+
else
31583165
damageTypeHitAvg = damageTypeHitAvgNotLucky * (1 - m_abs(damageTypeLuckyChance)) + damageTypeHitAvgUnlucky * m_abs(damageTypeLuckyChance)
31593166
end
31603167
if (damageTypeHitMin ~= 0 or damageTypeHitMax ~= 0) and env.mode_effective then

src/Modules/CalcSections.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ return {
16001600
{ label = "Avoid Chaos Chance", haveOutput = "AvoidChaosDamageChance", { format = "{0:output:AvoidChaosDamageChance}%", { modName = "AvoidChaosDamageChance" }, }, },
16011601
{ label = "Avoid Proj Ch.", haveOutput = "AvoidProjectilesChance", { format = "{0:output:AvoidProjectilesChance}%", { modName = "AvoidProjectilesChance" }, }, },
16021602
} }, { defaultCollapsed = false, label = "Block", data = {
1603-
extra = "{0:output:EffectiveBlockChance}%/{0:output:EffectiveSpellBlockChance}%",
1603+
extra = "{3:output:EffectiveBlockChance}%/{3:output:EffectiveSpellBlockChance}%",
16041604
{ label = "Block Chance", { format = "{0:output:BlockChance}% (+{0:output:BlockChanceOverCap}%)",
16051605
{ breakdown = "BlockChance" },
16061606
{ modName = { "BlockChance", "ReplaceShieldBlock" } },
@@ -1629,7 +1629,7 @@ return {
16291629
}, },
16301630
} },
16311631
{ defaultCollapsed = false, label = "Spell Suppression", data = {
1632-
extra = "{0:output:SpellSuppressionChance}%",
1632+
extra = "{2:output:EffectiveSpellSuppressionChance}%",
16331633
{ label = "Suppression Ch.", { format = "{0:output:SpellSuppressionChance}% (+{0:output:SpellSuppressionChanceOverCap}%)", { modName = "SpellSuppressionChance" }, }, },
16341634
{ label = "Suppression Effect", { format = "{0:output:SpellSuppressionEffect}%", { modName = "SpellSuppressionEffect" }, }, },
16351635
{ label = "Life on Suppression", haveOutput = "LifeOnSuppress", { format = "{0:output:LifeOnSuppress}", { modName = "LifeOnSuppress" }, }, },

0 commit comments

Comments
 (0)