Skip to content

Commit 84092f6

Browse files
committed
Add crafted item modifiers as unscaled lines
1 parent 1622fcd commit 84092f6

3 files changed

Lines changed: 67 additions & 12 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,56 @@ describe("TestAdvancedItemParse #item", function()
589589
assert.are.equals(19, item.catalystQuality)
590590
end)
591591

592+
it("scales suffix (Dextral) catalyst", function()
593+
local item = new("Item", raw([[
594+
Quality (Suffix Modifiers): +20% (augmented)
595+
{ Suffix Modifier — Attribute }
596+
+90(80-100) to all Attributes
597+
(Attributes are Strength, Dexterity, and Intelligence)
598+
]], "Onyx Amulet"))
599+
assert.are.equals(3, item.catalyst)
600+
assert.are.equals(20, item.catalystQuality)
601+
assert.are.equals(108, item.baseModList[1].value)
602+
end)
603+
604+
it("scales prefix (Sinistral) catalyst when crafted on simplex", function()
605+
build.itemsTab:CreateDisplayItemFromRaw(main.rareDB.list["Amulet, Simplex Amulet"].raw)
606+
local item = build.itemsTab.displayItem
607+
-- 26% spell damage
608+
item.prefixes[1] = { modId = "SpellDamage5", range = 1 }
609+
item:Craft()
610+
assert.are.equals(52, item.baseModList[1].value)
611+
build.itemsTab:UpdateAffixControls()
612+
-- dextral is id 9, but selector has a "None" in position 1
613+
build.itemsTab.controls.displayItemCatalyst:SetSel(10)
614+
assert.are.equals(57, item.baseModList[1].value)
615+
assert.are.equals(9, item.catalyst)
616+
assert.are.equals(20, item.catalystQuality)
617+
end)
618+
619+
it("scales prefix (Sinistral) catalyst", function()
620+
local item = new("Item", raw([[
621+
Quality (Prefix Modifiers): +20% (augmented)
622+
{ Prefix Modifier — Attribute }
623+
+90(80-100) to all Attributes
624+
(Attributes are Strength, Dexterity, and Intelligence)
625+
]], "Onyx Amulet"))
626+
assert.are.equals(9, item.catalyst)
627+
assert.are.equals(20, item.catalystQuality)
628+
assert.are.equals(108, item.baseModList[1].value)
629+
end)
630+
631+
it("suffix catalyst does not scale prefix mods", function()
632+
local item = new("Item", raw([[
633+
Quality (Suffix Modifiers): +20% (augmented)
634+
{ Prefix Modifier — Attribute }
635+
+90(80-100) to all Attributes
636+
(Attributes are Strength, Dexterity, and Intelligence)
637+
]], "Onyx Amulet"))
638+
assert.are.equals(3, item.catalyst)
639+
assert.are.equals(20, item.catalystQuality)
640+
assert.are.equals(90, item.baseModList[1].value)
641+
end)
592642
it("doesn't scale unscalable", function()
593643
local item = new("Item", raw([[
594644
Quality (Life and Mana Modifiers): +20% (augmented)

src/Classes/Item.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,13 +1711,13 @@ function ItemClass:Craft()
17111711
if mod then
17121712
if mod.type == "Prefix" then
17131713
self.namePrefix = mod.affix .. " " .. self.namePrefix
1714+
mod.prefix = true
17141715
elseif mod.type == "Suffix" then
17151716
self.nameSuffix = self.nameSuffix .. " " .. mod.affix
1717+
mod.suffix = true
17161718
end
17171719
self.requirements.level = m_max(self.requirements.level or 0, m_floor(mod.level * 0.8))
1718-
local rangeScalar = getCatalystScalar(self.catalyst, mod, self.catalystQuality)
17191720
for i, line in ipairs(mod) do
1720-
line = itemLib.applyRange(line, affix.range or 0.5, rangeScalar)
17211721
local order = mod.statOrder[i]
17221722
if statOrder[order] then
17231723
-- Combine stats
@@ -1728,12 +1728,7 @@ function ItemClass:Craft()
17281728
return tonumber(num) + tonumber(other)
17291729
end)
17301730
else
1731-
local modLine = { line = line, order = order, type = mod.type }
1732-
if mod.type == "Prefix" then
1733-
modLine.prefix = true
1734-
elseif mod.type == "Suffix" then
1735-
modLine.suffix = true
1736-
end
1731+
local modLine = { line = line, order = order, type = mod.type, prefix = mod.prefix, suffix = mod.suffix, modTags = mod.modTags, range = affix.range }
17371732
for l = 1, #self.explicitModLines + 1 do
17381733
if not self.explicitModLines[l] or self.explicitModLines[l].order > order then
17391734
t_insert(self.explicitModLines, l, modLine)
@@ -2147,18 +2142,23 @@ function ItemClass:BuildModList()
21472142
end
21482143
end
21492144
end
2150-
local function processModLine(modLine)
2145+
local function processModLine(modLine, isExplicitMod)
21512146
if self:CheckModLineVariant(modLine) then
21522147
-- special section for variant over-ride of pre-modifier item parameters
21532148
if modLine.line:find("Requires Class") then
21542149
self.classRestriction = modLine.line:gsub("{variant:([%d,]+)}", ""):match("Requires Class (.+)")
21552150
end
21562151
-- handle understood modifier variable properties
21572152
local rangedModList = not modLine.extra and getRangedModList(self, modLine)
2153+
local isRare = (self.rarity ~= "UNIQUE") and (self.rarity ~= "RELIC")
21582154
if rangedModList then
21592155
modLine.modList = rangedModList
2160-
modLine.showSlider = true
2161-
t_insert(self.rangeLineList, modLine)
2156+
-- rare explicit mods are supposed to be controlled via the crafting
2157+
-- affix selectors, and are skipped here
2158+
if not (isRare and isExplicitMod) then
2159+
modLine.showSlider = true
2160+
t_insert(self.rangeLineList, modLine)
2161+
end
21622162
elseif modLine.modId and modLine.newModId then
21632163
-- mutated mod transformation available
21642164
t_insert(self.rangeLineList, modLine)
@@ -2187,7 +2187,7 @@ function ItemClass:BuildModList()
21872187
processModLine(modLine)
21882188
end
21892189
for _, modLine in ipairs(self.explicitModLines) do
2190-
processModLine(modLine)
2190+
processModLine(modLine, true)
21912191
end
21922192
for _, modLine in ipairs(self.crucibleModLines) do
21932193
processModLine(modLine)

src/Classes/ItemsTab.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,11 @@ holding Shift will put it in the second.]])
959959
end})
960960
local foulbornIcon = NewImageHandle()
961961
foulbornIcon:Load("Assets/breachicon.png")
962+
-- single affix selector. this is intended for editing a single unique affix
963+
-- and for controlling the implicit modifiers of rares.
964+
-- TODO: remove this. it doesn't make much sense to keep it as it duplicates a
965+
-- lot of code from the "show all item affixes sliders" UI, which is enabled
966+
-- by default. this also provides no advantages whatsoever over that UI
962967
self.controls.displayItemRangeLine = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionRange,"TOPLEFT"}, {0, 0, 350, 18}, nil, function(index, value)
963968
self.controls.displayItemRangeSlider.val = self.displayItem.rangeLineList[index].range
964969
end)

0 commit comments

Comments
 (0)