Skip to content

Commit e543733

Browse files
author
LocalIdentity
committed
Fix item paste from game for scaled rune mods
1 parent f026305 commit e543733

2 files changed

Lines changed: 89 additions & 4 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,65 @@ describe("TestItemParse", function()
539539
assert.are.equals(210, spellDamage)
540540
end)
541541

542+
it("infers pasted game rune lines with socketed rune effect", function()
543+
local item = new("Item", [[
544+
Item Class: Wands
545+
Rarity: Unique
546+
Runeseeker's Call
547+
Runic Fork
548+
--------
549+
Quality: +20% (augmented)
550+
--------
551+
Requires: Level 90 (unmet)
552+
--------
553+
Sockets: S S S S S
554+
--------
555+
Item Level: 86
556+
--------
557+
Gain 120% of Damage as Extra Lightning Damage (rune)
558+
Remnants you create have 75% reduced effect (rune)
559+
Remnants can be collected from 150% further away (rune)
560+
--------
561+
Grants Skill: Level 20 The Stars Answer
562+
--------
563+
{ Unique Modifier }
564+
Only Runes can be Socketed in this item — Unscalable Value
565+
{ Unique Modifier }
566+
200% increased effect of Socketed Runes — Unscalable Value
567+
--------
568+
Smithed from ancient metal
569+
wrought from the very stars.
570+
It is a means to call upon them,
571+
for one capable of wielding it.
572+
--------
573+
Corrupted
574+
]])
575+
576+
local damageGainAsLightning = 0
577+
for _, mod in ipairs(item.slotModList[1]) do
578+
if mod.name == "DamageGainAsLightning" and mod.type == "BASE" then
579+
damageGainAsLightning = damageGainAsLightning + mod.value
580+
end
581+
end
582+
assert.are.equals(120, damageGainAsLightning)
583+
584+
item:BuildAndParseRaw()
585+
586+
assert.are.equals(5, item.itemSocketCount)
587+
assert.are.equals(5, #item.runes)
588+
for _, rune in ipairs(item.runes) do
589+
assert.are_not.equals("None", rune)
590+
end
591+
592+
damageGainAsLightning = 0
593+
for _, mod in ipairs(item.slotModList[1]) do
594+
if mod.name == "DamageGainAsLightning" and mod.type == "BASE" then
595+
damageGainAsLightning = damageGainAsLightning + mod.value
596+
end
597+
end
598+
assert.are.equals(120, damageGainAsLightning)
599+
end)
600+
542601
it("multi-line rune mod", function()
543602
-- Thruldana is Bow-only as well
544603
local item = new("Item", [[

src/Classes/Item.lua

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
850850
gameModeStage = "IMPLICIT"
851851
end
852852
local catalystScalar = 1
853-
if line:match(" %- Unscalable Value$") then
854-
line = line:gsub(" %- Unscalable Value$", "")
853+
if line:match(" %- Unscalable Value$") or line:match(" — Unscalable Value$") then
854+
line = line:gsub(" %- Unscalable Value$", ""):gsub(" — Unscalable Value$", "")
855855
modLine.unscalable = true
856856
else
857857
catalystScalar = getCatalystScalar(self.catalyst, modLine, self.catalystQuality)
@@ -1138,19 +1138,45 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
11381138
table.sort(runes, function(a, b) return compareRuneValueSets(a.values, b.values) end)
11391139
end
11401140

1141+
local gameSocketedRuneEffectModifier = 0
1142+
if mode == "GAME" and shouldFixRunesOnItem then
1143+
for _, modLines in ipairs({ self.enchantModLines, self.implicitModLines, self.explicitModLines }) do
1144+
for _, effectModLine in ipairs(modLines) do
1145+
for _, mod in ipairs(effectModLine.modList or { }) do
1146+
if mod.name == "SocketedRuneEffect" and mod.type == "INC" then
1147+
gameSocketedRuneEffectModifier = gameSocketedRuneEffectModifier + mod.value / 100
1148+
end
1149+
end
1150+
end
1151+
end
1152+
end
1153+
11411154
local remainingRunes = self.itemSocketCount
11421155
for i, modLine in ipairs(self.runeModLines) do
11431156
local strippedModLine, targetValues = getRuneLineParts(modLine.line)
11441157
local groupedRunes = statGroupedRunes[strippedModLine]
11451158
if groupedRunes and not modLine.bonded then -- found the rune category with the relevant stat.
1146-
local result, numRunes = findRuneCombination(groupedRunes, targetValues, remainingRunes)
1159+
local result, numRunes
1160+
local socketedRuneEffectAlreadyApplied
1161+
if gameSocketedRuneEffectModifier ~= 0 then
1162+
local unscaledTargetValues = { }
1163+
for valueIndex, value in ipairs(targetValues) do
1164+
unscaledTargetValues[valueIndex] = value / (1 + gameSocketedRuneEffectModifier)
1165+
end
1166+
result, numRunes = findRuneCombination(groupedRunes, unscaledTargetValues, remainingRunes)
1167+
socketedRuneEffectAlreadyApplied = result ~= nil
1168+
end
1169+
if not result then
1170+
result, numRunes = findRuneCombination(groupedRunes, targetValues, remainingRunes)
1171+
end
11471172

11481173
if result then -- we have found a valid combo for that rune category
11491174
remainingRunes = remainingRunes - numRunes
11501175
-- this code should probably be refactored to based off stored self.runes rather than the recomputed amounts off the runeModLines this
11511176
-- is too avoid having to run the relatively expensive recomputation every time the item is parsed even if we know the runes on the item already.
11521177
modLine.augmentType = groupedRunes[1].type
11531178
modLine.runeCount = numRunes
1179+
modLine.socketedRuneEffectAlreadyApplied = socketedRuneEffectAlreadyApplied
11541180

11551181
if shouldFixRunesOnItem then
11561182
for index, rune in ipairs(groupedRunes) do
@@ -2041,7 +2067,7 @@ function ItemClass:BuildModList()
20412067
for _, modLine in ipairs(self.runeModLines) do
20422068
local effectModifier = modLine.augmentType == "SoulCore" and self.socketedSoulCoreEffectModifier
20432069
or modLine.augmentType == "Rune" and self.socketedRuneEffectModifier
2044-
if effectModifier and effectModifier ~= 0 and self:CheckModLineVariant(modLine) and not modLine.extra then
2070+
if effectModifier and effectModifier ~= 0 and self:CheckModLineVariant(modLine) and not modLine.extra and not modLine.socketedRuneEffectAlreadyApplied then
20452071
for _, mod in ipairs(modLine.modList) do
20462072
baseList:ScaleAddMod(mod, effectModifier)
20472073
end

0 commit comments

Comments
 (0)