Skip to content

Commit 69defed

Browse files
authored
Add support for Small/Notable Passive mods on all Time-Lost Jewels (#48)
* update ATD processStats logic to apply to all Time-Lost jewels * move weaponset logic lower for time lost jewel to process first
1 parent 323397f commit 69defed

File tree

1 file changed

+38
-40
lines changed

1 file changed

+38
-40
lines changed

src/Modules/CalcSetup.lua

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,35 @@ function calcs.initModDB(env, modDB)
9393
end
9494

9595
-- grab the stat lines from the selected variants on the jewel to add to the nodes
96-
-- e.g. Against the Darkness
96+
-- e.g. Against the Darkness or Time-Lost jewels
9797
local function setRadiusJewelStats(radiusJewel, radiusJewelStats)
98-
local jewel = radiusJewel.item
99-
if jewel.title == "Against the Darkness" then
100-
radiusJewelStats.source = radiusJewel.data.modSource
101-
102-
local variant = jewel.variant or 1
98+
-- ATD has a special case with variant/variantAlt but other jewels have a fairly simple iterative list
99+
local function setStats(jewel, radiusJewelStats, index, alternate)
100+
local variant = (alternate and jewel.variantAlt or jewel.variant) or index
103101
local range = jewel.explicitModLines[variant].range
104102
local value = 0
105103
jewel.explicitModLines[variant].line:gsub("%((%d+)%-(%d+)%)",
106104
function(num1, num2)
107105
value = round(num1 + (num2-num1) * range)
108106
end
109107
)
110-
radiusJewelStats[1] = {
108+
radiusJewelStats[index] = {
111109
isNotable = (jewel.explicitModLines[variant].line:match("^(%S+)") == "Notable"),
112110
sd = jewel.explicitModLines[variant].line:gsub(".*grant ", ""):gsub("%(.-%)", value)
113111
}
114-
115-
local variantAlt = jewel.variantAlt or 2
116-
local rangeAlt = jewel.explicitModLines[variantAlt].range
117-
local valueAlt = 0
118-
jewel.explicitModLines[variantAlt].line:gsub("%((%d+)%-(%d+)%)",
119-
function(num1, num2)
120-
valueAlt = round(num1 + (num2-num1) * rangeAlt)
112+
end
113+
114+
local jewel = radiusJewel.item
115+
if jewel.baseName:find("Time%-Lost") == 1 then
116+
radiusJewelStats.source = radiusJewel.data.modSource
117+
if jewel.title == "Against the Darkness" then
118+
setStats(jewel, radiusJewelStats, 1, false)
119+
setStats(jewel, radiusJewelStats, 2, true)
120+
else
121+
for modIndex, _ in ipairs(jewel.explicitModLines) do
122+
setStats(jewel, radiusJewelStats, modIndex, false)
121123
end
122-
)
123-
radiusJewelStats[2] = {
124-
isNotable = (jewel.explicitModLines[variantAlt].line:match("^(%S+)") == "Notable"),
125-
sd = jewel.explicitModLines[variantAlt].line:gsub(".*grant ", ""):gsub("%(.-%)", valueAlt)
126-
}
124+
end
127125
end
128126
end
129127

@@ -155,11 +153,11 @@ local function addStatsFromJewelToNode(jewel, node, spec)
155153
if itemsTab.activeSocketList then
156154
for _, nodeId in pairs(itemsTab.activeSocketList) do
157155
local _, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
158-
if socketedJewel and socketedJewel.title == "Against the Darkness" then
156+
if socketedJewel and socketedJewel.baseName:find("Time%-Lost") == 1 then
159157
return addStats(jewel, node, spec)
160158
end
161159
end
162-
-- activeSocketList isn't init on Load, need to run once
160+
-- activeSocketList isn't init on Load, need to run once
163161
elseif itemsTab.initSockets then
164162
return addStats(jewel, node, spec)
165163
end
@@ -173,27 +171,10 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
173171
modList:AddList(node.modList)
174172
end
175173

176-
if node.allocMode and node.allocMode ~= 0 then
177-
for i, mod in ipairs(modList) do
178-
local added = false
179-
for j, extra in ipairs(mod) do
180-
-- if type conditional and start with WeaponSet then update the var to the current weapon set
181-
if extra.type == "Condition" and extra.var and extra.var:match("^WeaponSet") then
182-
mod[j].var = "WeaponSet".. node.allocMode
183-
added = true
184-
break
185-
end
186-
end
187-
if not added then
188-
table.insert(mod, { type = "Condition", var = "WeaponSet".. node.allocMode })
189-
end
190-
end
191-
end
192-
193174
-- Run first pass radius jewels
194175
for _, rad in pairs(env.radiusJewelList) do
195176
if rad.type == "Other" and rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" then
196-
if rad.item.title ~= "Against the Darkness" then
177+
if rad.item.baseName:find("Time%-Lost") ~= 1 then
197178
rad.func(node, modList, rad.data)
198179
else
199180
local nodeList = addStatsFromJewelToNode(rad, node, env.build.spec)
@@ -217,7 +198,7 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
217198
-- Run second pass radius jewels
218199
for _, rad in pairs(env.radiusJewelList) do
219200
if rad.nodes[node.id] and rad.nodes[node.id].type ~= "Mastery" and (rad.type == "Threshold" or (rad.type == "Self" and env.allocNodes[node.id]) or (rad.type == "SelfUnalloc" and not env.allocNodes[node.id])) then
220-
if rad.item.title ~= "Against the Darkness" then
201+
if rad.item.baseName:find("Time%-Lost") ~= 1 then
221202
rad.func(node, modList, rad.data)
222203
else
223204
local nodeList = addStatsFromJewelToNode(rad, node, env.build.spec)
@@ -249,6 +230,23 @@ function calcs.buildModListForNode(env, node, incSmallPassiveSkill)
249230
t_insert(env.explodeSources, node)
250231
end
251232

233+
if node.allocMode and node.allocMode ~= 0 then
234+
for i, mod in ipairs(modList) do
235+
local added = false
236+
for j, extra in ipairs(mod) do
237+
-- if type conditional and start with WeaponSet then update the var to the current weapon set
238+
if extra.type == "Condition" and extra.var and extra.var:match("^WeaponSet") then
239+
mod[j].var = "WeaponSet".. node.allocMode
240+
added = true
241+
break
242+
end
243+
end
244+
if not added then
245+
table.insert(mod, { type = "Condition", var = "WeaponSet".. node.allocMode })
246+
end
247+
end
248+
end
249+
252250
-- Apply Inc Node scaling from Hulking Form
253251
if incSmallPassiveSkill > 0 and node.type == "Normal" and not node.isAttribute and not node.ascendancyName then
254252
local scale = 1 + incSmallPassiveSkill / 100

0 commit comments

Comments
 (0)