Skip to content

Commit e8d107e

Browse files
committed
Fix distance with too many digits crashing build
1 parent 0a9265e commit e8d107e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/Modules/CalcOffence.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,8 +2644,8 @@ function calcs.offence(env, actor, activeSkill)
26442644
local hitChances = {}
26452645
hitChances[1] = {distance = enemyDistance}
26462646
local buffers = {
2647-
dist = {" ", " ", " ", ""}, -- these define the number of required spaces based on string length to have the numbers aligned (it's not a simple length * x due to linting that happens later)
2648-
chance = {" ", " ", ""}
2647+
dist = { " ", " ", " " }, -- these define the number of required spaces based on string length to have the numbers aligned (it's not a simple length * x due to linting that happens later)
2648+
chance = { " ", " " }
26492649
}
26502650
for _, distance in ipairs(distances) do -- put distance values in order, incl. config value
26512651
if distance < hitChances[#hitChances].distance then
@@ -2659,9 +2659,12 @@ function calcs.offence(env, actor, activeSkill)
26592659
entry.capped = ((entry.distance == enemyDistance) and output.AccuracyHitChance) or (cannotBeEvaded and 100) or m_max(calcs.hitChance(enemyEvasion, entry.adjustedAccuracy) * hitChanceMod)
26602660
entry.uncapped = exceedsHitChance and m_max(calcs.hitChance(enemyEvasion, entry.adjustedAccuracy, true) * hitChanceMod, entry.capped) -- compare to capped to account for cannotBeEvaded
26612661
entry.excess = exceedsHitChance and entry.uncapped > 100 and entry.uncapped - entry.capped
2662-
entry.distBuffer = buffers.dist[string.len(entry.distance)] -- buffer defines the number of spaces needed to align the output numbers
2663-
entry.cappedBuffer = buffers.chance[string.len(entry.capped)]
2664-
entry.excessText = entry.excess and " ^8(+" .. buffers.chance[string.len(entry.excess)+1] .. entry.excess .. "%)" or ""
2662+
-- buffer defines the number of spaces needed to align the output numbers
2663+
entry.distBuffer = buffers.dist[string.len(entry.distance)] or
2664+
""
2665+
entry.cappedBuffer = buffers.chance[string.len(entry.capped)] or ""
2666+
entry.excessText = entry.excess and
2667+
" ^8(+" .. (buffers.chance[string.len(entry.excess) + 1] or "") .. entry.excess .. "%)" or ""
26652668
entry.config = (entry.distance == enemyDistance) and " ^8(current config)" or ""
26662669
t_insert(breakdown.AccuracyHitChance, entry.distBuffer .. entry.distance .. "m: " .. entry.cappedBuffer .. entry.capped .. "%" .. entry.excessText .. entry.config)
26672670
end

0 commit comments

Comments
 (0)