Skip to content

Commit 666a868

Browse files
authored
Add support for merging mods on nodes in radius of Time-Lost jewels (#474)
* merge mods, some clean up from the itemtooltip flag, call processStats less often * rebase fix * move mod to Other func so we process unalloc nodes in radius for time lost jewels * flag back to be safe * tab
1 parent 903ad1e commit 666a868

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

src/Modules/CalcSetup.lua

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,40 @@ local function setStats(jewel, radiusJewelStats, index, alternate)
107107
radiusJewelStats[index] = {
108108
isNotable = (line:match("^(%S+)") == "Notable"),
109109
toAdd = (line:find("also% grant")~= nil), -- only add mods with the "also grant" text to radiusNodes
110-
sd = line:gsub(".*grant ", ""):gsub("%(.-%)", value)
110+
sdLine = line:gsub(".*grant ", ""):gsub("%(.-%)", value)
111111
}
112112
if line:lower():match("increased effect of small passive skills in radius") then
113113
return tonumber(line:match("%d+"))
114114
end
115115
end
116+
local function mergeStats(node, sd, spec)
117+
-- copy the original tree node so we ignore the mods being added from the jewel
118+
local nodeCopy = copyTable(spec.tree.nodes[node.id], true)
119+
local nodeNumber = 0
120+
local nodeString = ""
121+
local modToAddNumber = 0
122+
local modToAddString = ""
123+
124+
-- loop the original node mods and compare to the jewel mod we want to add
125+
-- if the strings without the numbers are identical, the mods should be identical
126+
-- if so, update the node's version of the mod and do not add the jewel mods to the list
127+
-- otherwise, add the jewel mod because it's unique/new to the node
128+
for index, nodeSd in ipairs(nodeCopy.sd) do
129+
nodeString = nodeSd:gsub("(%d+)", function(number)
130+
nodeNumber = number
131+
return ""
132+
end)
133+
modToAddString = sd:gsub("(%d+)", function(number)
134+
modToAddNumber = number
135+
return ""
136+
end)
137+
if nodeString == modToAddString then
138+
node.sd[index] = node.sd[index]:gsub("(%d+)", (nodeNumber + modToAddNumber))
139+
return
140+
end
141+
end
142+
t_insert(node.sd, sd)
143+
end
116144
-- grab the stat lines from the selected variants on the jewel to add to the nodes
117145
-- e.g. Against the Darkness or Time-Lost jewels
118146
local function setRadiusJewelStats(radiusJewel, radiusJewelStats)
@@ -160,9 +188,9 @@ local function addStats(jewel, node, spec)
160188
incEffect = setRadiusJewelStats(jewel, radiusJewelStats)
161189
for _, stat in ipairs(radiusJewelStats) do
162190
-- the node and stat types match, add sd to node if it's not already there and it's an 'also grant' mod
163-
if not isValueInTable(node.sd, stat.sd) and ((node.type == "Notable" and stat.isNotable) or (node.type == "Normal" and not stat.isNotable))
191+
if not isValueInTable(node.sd, stat.sdLine) and ((node.type == "Notable" and stat.isNotable) or (node.type == "Normal" and not stat.isNotable))
164192
and stat.toAdd then
165-
t_insert(node.sd, stat.sd)
193+
mergeStats(node, stat.sdLine, spec)
166194
end
167195
end
168196
-- if there's an incEffect of Small Passives mod on the jewel and the node is small, scale all numbers
@@ -184,7 +212,7 @@ local function addStatsFromJewelToNode(jewel, node, spec)
184212
-- if the Time-Lost jewel is socketed, add the stat
185213
if itemsTab.activeSocketList then
186214
for _, nodeId in pairs(itemsTab.activeSocketList) do
187-
local socketIndex, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
215+
local _, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
188216
if socketedJewel and socketedJewel.baseName:find("Time%-Lost") == 1 then
189217
addStats(jewel, node, spec)
190218
end
@@ -282,7 +310,7 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
282310
table.insert(mod, { type = "Condition", var = "WeaponSet".. node.allocMode })
283311
end
284312
end
285-
313+
286314
-- Apply Inc Node scaling from Hulking Form
287315
if incSmallPassiveSkill > 0 and node.type == "Normal" and not node.isAttribute and not node.ascendancyName then
288316
local scale = 1 + incSmallPassiveSkill / 100
@@ -329,7 +357,9 @@ function calcs.buildModListForNodeList(env, nodeList, finishJewels)
329357

330358
-- Finalise radius jewels
331359
for _, rad in pairs(env.radiusJewelList) do
332-
rad.func(nil, modList, rad.data)
360+
if rad.item.baseName:find("Time%-Lost") == nil then
361+
rad.func(nil, modList, rad.data)
362+
end
333363
if env.mode == "MAIN" then
334364
if not rad.item.jewelRadiusData then
335365
rad.item.jewelRadiusData = { }

src/Modules/ModParser.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5235,7 +5235,6 @@ local specialModList = {
52355235
["nearby allies have (%d+)%% chance to block attack damage per (%d+) strength you have"] = function(block, _, str) return {
52365236
mod("ExtraAura", "LIST", { onlyAllies = true, mod = mod("BlockChance", "BASE", block) }, { type = "PerStat", stat = "Str", div = tonumber(str) }),
52375237
} end,
5238-
["(%d+)%% increased effect of small passive skills in radius"] = { },
52395238
}
52405239
for _, name in pairs(data.keystones) do
52415240
specialModList[name:lower()] = { mod("Keystone", "LIST", name) }
@@ -5494,6 +5493,7 @@ local jewelOtherFuncs = {
54945493
end
54955494
end
54965495
end,
5496+
["(%d+)%% increased Effect of Small Passive Skills in Radius"] = function(node, out, data) end,
54975497
["50% increased Effect of non-Keystone Passive Skills in Radius"] = function(node, out, data)
54985498
if node and node.type ~= "Keystone" then
54995499
out:NewMod("PassiveSkillEffect", "INC", 50, data.modSource)

0 commit comments

Comments
 (0)