Skip to content

Commit 4c619ef

Browse files
committed
Port Volatile Vaal Orb support
1 parent 92bc0df commit 4c619ef

10 files changed

Lines changed: 15685 additions & 246 deletions

File tree

src/Classes/Control.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ local rect = {
3535
local ControlClass = newClass("Control", function(self, anchor, rect)
3636
self.rectStart = rect or {0, 0, 0, 0}
3737
self.x, self.y, self.width, self.height = unpack(self.rectStart)
38+
---@type (fun(): boolean) | boolean
3839
self.shown = true
3940
self.enabled = true
4041
self.anchor = { }

src/Classes/Item.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
697697
end
698698
elseif k == "range" then
699699
modLine.range = tonumber(val)
700+
elseif k == "corruptedRange" then
701+
modLine.corruptedRange = tonumber(val)
700702
elseif lineFlags[k] then
701703
modLine[k] = true
702704
end
@@ -888,13 +890,13 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
888890
modLine.range = bestPrecisionRange
889891
end
890892
end
891-
local rangedLine = itemLib.applyRange(line, 1, catalystScalar)
893+
local rangedLine = itemLib.applyRange(line, 1, catalystScalar, modLine.corruptedRange)
892894
local modList, extra = modLib.parseMod(rangedLine)
893895
if (not modList or extra) and self.rawLines[l+1] then
894896
-- Try to combine it with the next line
895897
local nextLine = self.rawLines[l+1]:gsub("%b{}", ""):gsub(" ?%(%l+%)","")
896898
local combLine = line.." "..nextLine
897-
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar)
899+
rangedLine = itemLib.applyRange(combLine, 1, catalystScalar, modLine.corruptedRange)
898900
modList, extra = modLib.parseMod(rangedLine, true)
899901
if modList and not extra then
900902
line = line.."\n"..nextLine
@@ -1262,6 +1264,9 @@ function ItemClass:BuildRaw()
12621264
if modLine.range and line:match("%(%-?[%d%.]+%-%-?[%d%.]+%)") then
12631265
line = "{range:" .. round(modLine.range, 3) .. "}" .. line
12641266
end
1267+
if modLine.corruptedRange then
1268+
line = "{corruptedRange:" .. round(modLine.corruptedRange, 2) .. "}" .. line
1269+
end
12651270
if modLine.crafted then
12661271
line = "{crafted}" .. line
12671272
end
@@ -1863,7 +1868,7 @@ function ItemClass:BuildModList()
18631868
local strippedModeLine = modLine.line:gsub("\n"," ")
18641869
local catalystScalar = getCatalystScalar(self.catalyst, modLine, self.catalystQuality)
18651870
-- Put the modified value into the string
1866-
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar)
1871+
local line = itemLib.applyRange(strippedModeLine, modLine.range, catalystScalar, modLine.corruptedRange)
18671872
-- Check if we can parse it before adding the mods
18681873
local list, extra = modLib.parseMod(line)
18691874
if list and not extra then

src/Classes/ItemsTab.lua

Lines changed: 214 additions & 137 deletions
Large diffs are not rendered by default.

src/Data/ModCache.lua

Lines changed: 34 additions & 59 deletions
Large diffs are not rendered by default.

src/Data/ModScalability.lua

Lines changed: 15021 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
if not loadStatFile then
2+
dofile("statdesc.lua")
3+
end
4+
loadStatFile("stat_descriptions.txt")
5+
6+
local out = io.open("../Data/ModScalability.lua", "w")
7+
out:write('-- This file is automatically generated, do not edit!\n')
8+
out:write('-- Item data (c) Grinding Gear Games\n\nreturn {\n')
9+
local scalabilityLines = describeScalability("stat_descriptions.txt")
10+
local lines = {}
11+
for line, _ in pairs(scalabilityLines) do
12+
table.insert(lines, line)
13+
end
14+
table.sort(lines)
15+
for _, line in ipairs(lines) do
16+
local scalability = scalabilityLines[line]
17+
out:write('\t["', line, '"] = { ')
18+
for i, scalable in ipairs(scalability) do
19+
out:write("{ isScalable = " .. tostring(scalable.isScalable))
20+
if scalable.formats then
21+
out:write(', formats = { ')
22+
for j, format in ipairs(scalable.formats) do
23+
out:write('"' .. format .. '"')
24+
if j < #scalable.formats then out:write(", ") end
25+
end
26+
out:write(" }")
27+
end
28+
out:write(" }")
29+
if i < #scalability then out:write(", ") end
30+
end
31+
out:write(" },\n")
32+
end
33+
34+
out:write('}')
35+
out:close()
36+
37+
print("Stat mod scalability exported.")

src/Export/statdesc.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,45 @@ function describeMod(mod)
443443
out.modTags = describeModTags(mod.ImplicitTags)
444444
return out, orders
445445
end
446+
447+
function describeScalability(fileName)
448+
local out = {}
449+
local stats = dat("stats")
450+
for stat, statDescription in pairsSortByKey(statDescriptors[fileName]) do
451+
local scalability = {}
452+
if statDescription.stats then
453+
for i, stat in ipairs(statDescription.stats) do
454+
table.insert(scalability, stats:GetRow("Id", stat).IsScalable)
455+
end
456+
for _, wordings in ipairs(statDescription[1]) do
457+
local wordingFormats = {}
458+
local inOrderScalability = {}
459+
for _, format in ipairs(wordings) do
460+
if type(format.v) == "number" then
461+
if wordingFormats[tonumber(format.v)] then
462+
table.insert(wordingFormats[tonumber(format.v)], format.k)
463+
else
464+
wordingFormats[tonumber(format.v)] = { format.k }
465+
end
466+
end
467+
end
468+
local strippedLine = wordings.text:gsub("[%+%-]?(%b{})", function(num)
469+
local statNum = (num:match("%d") or 0) + 1
470+
table.insert(inOrderScalability,
471+
{ isScalable = scalability[statNum], formats = wordingFormats[statNum] })
472+
return "#"
473+
end)
474+
if out[strippedLine] then -- we want to use the format with the least oddities in it. If their are less formats then that will be used instead.
475+
for j, priorScalability in ipairs(out[strippedLine]) do
476+
if (priorScalability.formats and #priorScalability.formats or 0) > (wordingFormats[j] and #wordingFormats[j] or 0) then
477+
out[strippedLine][j] = inOrderScalability[j]
478+
end
479+
end
480+
else -- no present
481+
out[strippedLine] = inOrderScalability
482+
end
483+
end
484+
end
485+
end
486+
return out
487+
end

src/Modules/Common.lua

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ function naturalSortCompare(a, b)
642642
end
643643

644644
-- Rounds a number to the nearest <dec> decimal places
645+
---@param val number
646+
---@param dec? number
645647
function round(val, dec)
646648
if dec then
647649
return m_floor(val * 10 ^ dec + 0.5) / 10 ^ dec
@@ -652,7 +654,7 @@ end
652654

653655
--- Rounds down a number to the nearest <dec> decimal places
654656
---@param val number
655-
---@param dec number
657+
---@param dec? number
656658
---@return number
657659
function floor(val, dec)
658660
if dec then
@@ -663,6 +665,70 @@ function floor(val, dec)
663665
end
664666
end
665667

668+
---@param val number
669+
---@param dec? integer decimal places
670+
-- Symmetric round with precision: Rounds towards zero to <dec> decimal places.
671+
function roundSymmetric(val, dec)
672+
if dec then
673+
local factor = 10 ^ dec
674+
if val >= 0 then
675+
return m_floor(val * factor + 0.5) / factor
676+
else
677+
return m_ceil(val * factor - 0.5) / factor
678+
end
679+
else
680+
if val >= 0 then
681+
return m_floor(val + 0.5)
682+
else
683+
return m_ceil(val - 0.5)
684+
end
685+
end
686+
end
687+
688+
---@param val number
689+
---@param dec? integer decimal places
690+
-- Use rounding formula for positive numbers always used in corrupted unique roll ranges this is an incorrect way to round numbers.
691+
function alwaysPositiveRound(val, dec)
692+
if dec then
693+
local factor = 10 ^ dec
694+
return floorSymmetric(val * factor + 0.5) / factor
695+
else
696+
return floorSymmetric(val + 0.5)
697+
end
698+
end
699+
700+
---@param val number
701+
---@param dec? integer decimal places
702+
---@return number
703+
-- Symmetric floor with precision: Rounds down towards zero to <dec> decimal places.
704+
function floorSymmetric(val, dec)
705+
if dec then
706+
local factor = 10 ^ dec
707+
return select(1, math.modf(val * factor)) / factor
708+
else
709+
return select(1, math.modf(val))
710+
end
711+
end
712+
713+
---@param val number
714+
---@param dec? integer decimal places
715+
-- Symmetric ceil with precision: Rounds up away from zero to <dec> decimal places.
716+
function ceilSymmetric(val, dec)
717+
if dec then
718+
local factor = 10 ^ dec
719+
if val >= 0 then
720+
return m_ceil(val * factor) / factor
721+
else
722+
return m_floor(val * factor) / factor
723+
end
724+
else
725+
if val >= 0 then
726+
return m_ceil(val)
727+
else
728+
return m_floor(val)
729+
end
730+
end
731+
end
666732
---@param n number
667733
---@return number
668734
function triangular(n)

src/Modules/Data.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ data.nonDamagingAilment = {
356356

357357
-- Used in ModStoreClass:ScaleAddMod(...) to identify high precision modifiers
358358
data.defaultHighPrecision = 1
359+
data.modScalability = LoadModule("Data/ModScalability")
359360
data.highPrecisionMods = {
360361
["CritChance"] = {
361362
["BASE"] = 2,

0 commit comments

Comments
 (0)