Skip to content

Commit d815ced

Browse files
TrifallLocalIdentity
andauthored
Fix invalid mod parsing for mods that grant skills (#10174)
* Fix invalid mod parsing on mods that grant skills * add regression test for invalid mod parsing involving grantedExtraSkill * Stop skill granting mods from scaling --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent eef6747 commit d815ced

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎spec/System/TestItemParse_spec.lua‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,5 +1358,44 @@ describe("TestAdvancedItemParse #item", function()
13581358
assert.equal(27, spellCrit())
13591359
assert.equal(8, spellDamage())
13601360
end)
1361+
it("does not scale modifiers that grant skills", function()
1362+
local item = new("Item", [[
1363+
Item Class: Rings
1364+
Rarity: Rare
1365+
Plague Knuckle
1366+
Helical Ring
1367+
--------
1368+
Item Level: 84
1369+
--------
1370+
{ Implicit Modifier }
1371+
50% increased Suffix Modifier magnitudes
1372+
--------
1373+
{ Suffix Modifier "of !!UNPARSEABLE!!" — 50% Increased }
1374+
Grants Level 20 Aspect of !!UNPARSEABLE!! Skill
1375+
{ Suffix Modifier "of the Spider" — 50% Increased }
1376+
Grants Level 20 Aspect of the Spider Skill
1377+
--------
1378+
]])
1379+
assert.truthy(item.base)
1380+
local found = 0
1381+
local foundExtraSkill = false
1382+
for _, modLine in ipairs(item.explicitModLines) do
1383+
if modLine.line:find("Grants Level", 1, true) then
1384+
found = found + 1
1385+
assert.matches("Level 20", itemLib.formatModLine(modLine))
1386+
for _, mod in ipairs(modLine.modList) do
1387+
if mod.name == "ExtraSkill" then
1388+
foundExtraSkill = true
1389+
assert.equals(20, mod.value.level)
1390+
end
1391+
end
1392+
if modLine.line:find("UNPARSEABLE", 1, true) then
1393+
assert.truthy(modLine.extra)
1394+
end
1395+
end
1396+
end
1397+
assert.equals(2, found)
1398+
assert.is_true(foundExtraSkill)
1399+
end)
13611400
end)
13621401
end)

‎src/Classes/Item.lua‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,18 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
13941394
if mod.variantList and (self:GetModLineVariantCount(mod) == 0) then
13951395
goto modMagnitudeContinue
13961396
end
1397+
-- Modifiers that grant skills are not affected by modifier magnitude.
1398+
local grantsSkill = false
1399+
for _, parsedMod in ipairs(mod.modList) do
1400+
if parsedMod.name == "ExtraSkill" then
1401+
grantsSkill = true
1402+
break
1403+
end
1404+
end
1405+
if mod.extra and not grantsSkill then
1406+
local line = mod.line:lower()
1407+
grantsSkill = line:match("^grants level %d+ ") or line:match("^grants %D+$")
1408+
end
13971409
-- Create a fast lookup table for all provided tags
13981410
local tagLookup = {}
13991411
for _, curTag in ipairs(mod.modTags) do
@@ -1414,7 +1426,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
14141426
if modMagnitudeMod.anyTags and not (tagLookup[modMagnitudeMod.anyTags[1]] or tagLookup[modMagnitudeMod.anyTags[2]]) then
14151427
match = false
14161428
end
1417-
if match and not mod.unscalable then
1429+
if match and not mod.unscalable and not grantsSkill then
14181430
if modMagnitudeMod.multiplier then
14191431
mod.valueScalar = (mod.valueScalar or 1) * modMagnitudeMod.multiplier
14201432
else
@@ -1424,9 +1436,11 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
14241436
if mod.valueScalar and mod.valueScalar ~= 1 then
14251437
local rangedLine = itemLib.applyRange(mod.line, mod.range or 1, mod.valueScalar, 1)
14261438
local modList, extra = modLib.parseMod(rangedLine)
1427-
mod.displayValueScalar = 1
1428-
mod.modList = modList
1429-
mod.extra = extra
1439+
if modList then
1440+
mod.displayValueScalar = 1
1441+
mod.modList = modList
1442+
mod.extra = extra
1443+
end
14301444
end
14311445
::modMagnitudeContinue::
14321446
end

0 commit comments

Comments
 (0)