From 62f4c575586d4214e6b4a78d6476bba4f735c735 Mon Sep 17 00:00:00 2001 From: Lucas Karsten Date: Thu, 19 Nov 2026 14:53:39 -0300 Subject: [PATCH] Fix 100% or more reduced attack speed giving negative speed and inflated ailments With 100% or more reduced speed, the increased/more multiplier was used as is, so the skill speed and hit DPS went negative. Ailments then took the "skill with no attack time" path, which assumes a single use and no longer scales stacks by speed, so bleed jumped from 0.04 at 99% reduced to 0.21 at 100% reduced. Floor the speed at 0 when the multiplier is 0 or lower, and give bleed, poison and ignite no stacks in that case instead of the single use fallback. --- spec/System/TestAttackSpeedFloor_spec.lua | 49 +++++++++++++++++++++++ src/Modules/CalcOffence.lua | 17 +++++++- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 spec/System/TestAttackSpeedFloor_spec.lua diff --git a/spec/System/TestAttackSpeedFloor_spec.lua b/spec/System/TestAttackSpeedFloor_spec.lua new file mode 100644 index 0000000000..893b7429a7 --- /dev/null +++ b/spec/System/TestAttackSpeedFloor_spec.lua @@ -0,0 +1,49 @@ +describe("TestAttackSpeedFloor", function() + local function cyclone(mods, skill) + newBuild() + if skill then + build.itemsTab:CreateDisplayItemFromRaw("Rarity: NORMAL\nCorroded Blade") + build.itemsTab:AddDisplayItem() + runCallback("OnFrame") + end + build.skillsTab:PasteSocketGroup((skill or "Cyclone").." 20/0 1\n") + build.configTab.input.customMods = mods + build.configTab:BuildModList() + runCallback("OnFrame") + return build.calcsTab.mainOutput + end + + local ailments = "100% chance to cause Bleeding on Hit\n100% chance to Poison on Hit\n100% chance to Ignite\nAdds 10 to 20 Fire Damage to Attacks\n" + + it("still scales ailments with attack speed above 100% reduced", function() + local output = cyclone(ailments.."99% reduced Attack Speed") + assert.is_true(output.Speed > 0) + assert.is_true(output.BleedDPS > 0) + assert.is_true(output.TotalPoisonDPS > 0) + assert.is_true(output.IgniteDPS > 0) + end) + + for _, reduced in ipairs({ 100, 104, 150 }) do + it("does not hit or inflict ailments with "..reduced.."% reduced attack speed", function() + local output = cyclone(ailments..reduced.."% reduced Attack Speed") + assert.are.equals(0, output.Speed) + assert.are.equals(0, output.TotalDPS) + assert.are.equals(0, output.BleedDPS) + assert.are.equals(0, output.TotalPoisonDPS) + assert.are.equals(0, output.IgniteDPS) + assert.are.equals(0, output.CombinedDPS) + end) + end + + it("does not ignite with a cooldown attack at 100% reduced attack speed", function() + local output = cyclone(ailments.."99% reduced Attack Speed", "Vigilant Strike") + assert.is_not_nil(output.Cooldown) + assert.is_true(output.BleedDPS > 0) + assert.is_true(output.IgniteDPS > 0) + output = cyclone(ailments.."100% reduced Attack Speed", "Vigilant Strike") + assert.are.equals(0, output.Speed) + assert.are.equals(0, output.BleedDPS) + assert.are.equals(0, output.IgniteDPS) + assert.are.equals(0, output.CombinedDPS) + end) +end) diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua index bea7d97e17..8c944b56c7 100644 --- a/src/Modules/CalcOffence.lua +++ b/src/Modules/CalcOffence.lua @@ -2433,7 +2433,14 @@ function calcs.offence(env, actor, activeSkill) if skillFlags.warcry then output.Speed = 1 / output.WarcryCastTime else - output.Speed = 1 / (baseTime / round((1 + inc/100) * more, 2) + skillModList:Sum("BASE", cfg, "TotalAttackTime") + skillModList:Sum("BASE", cfg, "TotalCastTime")) + local speedMult = round((1 + inc/100) * more, 2) + if speedMult <= 0 then + -- 100% or more reduced speed: the skill is never used, so it can't hit or inflict ailments + output.Speed = 0 + globalOutput.SpeedReducedToZero = true + else + output.Speed = 1 / (baseTime / speedMult + skillModList:Sum("BASE", cfg, "TotalAttackTime") + skillModList:Sum("BASE", cfg, "TotalCastTime")) + end end output.CastRate = output.Speed @@ -4497,6 +4504,8 @@ function calcs.offence(env, actor, activeSkill) if (globalOutput.HitSpeed or globalOutput.Speed) > 0 then --assume skills with no cast, attack, or cooldown time are single cast bleedStacks = bleedStacks * globalOutput.BleedDuration * (globalOutput.HitSpeed or globalOutput.Speed) + elseif globalOutput.SpeedReducedToZero then + bleedStacks = 0 end local activeTotems = env.modDB:Override(nil, "TotemsSummoned") or skillModList:Sum("BASE", skillCfg, "ActiveTotemLimit", "ActiveBallistaLimit") if skillFlags.totem then @@ -4790,6 +4799,8 @@ function calcs.offence(env, actor, activeSkill) uncappedPoisonStacks = m_max(PoisonStacks, maxPoisonStacks) PoisonStacks = m_min(PoisonStacks, maxPoisonStacks) end + elseif globalOutput.SpeedReducedToZero then + PoisonStacks = 0 end if PoisonStacks < additionalPoisonStacks and (env.configInput.multiplierPoisonOnEnemy or 0) == 0 then skillModList:NewMod("Condition:NonPoisonedOnly", "FLAG", true, "Calculation") @@ -5081,7 +5092,9 @@ function calcs.offence(env, actor, activeSkill) -- The average number of ignites that will be active on the enemy at once local igniteStacks = output.HitChance / 100 * igniteChance * skillData.dpsMultiplier if not skillData.triggeredOnDeath then - if output.Cooldown then + if globalOutput.SpeedReducedToZero then + igniteStacks = 0 + elseif output.Cooldown then igniteStacks = igniteStacks * globalOutput.IgniteDuration / m_max(output.Cooldown, (output.HitTime or output.Time)) elseif (globalOutput.HitSpeed or globalOutput.Speed) > 0 then --assume skills with no cast, attack, or cooldown time are single cast