Skip to content

Commit b1bdc19

Browse files
LocalIdentityLocalIdentityWires77
authored
Fix Runegraft of the Bound scaling Facebreaker's incorrectly (#8820)
* Fix Runegraft of the Bound scaling Facebreaker's incorrectly The mod was scaling the more multiplier on the gloves incorrectly by adding another More multiplier mod instead of modifying the existing mod This change also made me realise that we sometime incorrectly handle mods when the are 2 instances of them on an item e.g. T1 Life + crafted hybrid life shows up as 2 mods on the item so we process them in 2 loops which results in the rounding being incorrect Would have to somehow merge all similar mods on an item first then loop though them to fix it I think * Fix split mod rounding issues and move logic with other scaling logic * Hack fix for getting mod data from the tree * Remove old block --------- Co-authored-by: LocalIdentity <[email protected]> Co-authored-by: Wires77 <[email protected]>
1 parent 370a8e6 commit b1bdc19

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

src/Classes/ModDB.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ function ModDBClass:ReplaceModInternal(mod)
4545
local modIndex = -1
4646
for i = 1, #modList do
4747
local curMod = modList[i]
48-
if mod.name == curMod.name and mod.type == curMod.type and mod.flags == curMod.flags and mod.keywordFlags == curMod.keywordFlags and mod.source == curMod.source then
48+
if mod.name == curMod.name and mod.type == curMod.type and mod.flags == curMod.flags and mod.keywordFlags == curMod.keywordFlags and mod.source == curMod.source and not curMod.replaced then
4949
modIndex = i
50+
mod.replaced = true
5051
break;
5152
end
5253
end

src/Classes/ModStore.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ local ModStoreClass = newClass("ModStore", function(self, parent)
3434
self.conditions = { }
3535
end)
3636

37-
function ModStoreClass:ScaleAddMod(mod, scale)
37+
function ModStoreClass:ScaleAddMod(mod, scale, replace)
3838
local unscalable = false
3939
for _, effects in ipairs(mod) do
4040
if effects.unscalable then
@@ -63,7 +63,11 @@ function ModStoreClass:ScaleAddMod(mod, scale)
6363
subMod.value = m_modf(round(subMod.value * scale, 2))
6464
end
6565
end
66-
self:AddMod(scaledMod)
66+
if replace then
67+
self:ReplaceModInternal(scaledMod)
68+
else
69+
self:AddMod(scaledMod)
70+
end
6771
end
6872
end
6973

@@ -73,12 +77,12 @@ function ModStoreClass:CopyList(modList)
7377
end
7478
end
7579

76-
function ModStoreClass:ScaleAddList(modList, scale)
80+
function ModStoreClass:ScaleAddList(modList, scale, replace)
7781
if scale == 1 then
7882
self:AddList(modList)
7983
else
8084
for i = 1, #modList do
81-
self:ScaleAddMod(modList[i], scale)
85+
self:ScaleAddMod(modList[i], scale, replace)
8286
end
8387
end
8488
end

src/Modules/CalcSetup.lua

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ function calcs.initEnv(build, mode, override, specEnv)
638638
nodes = copyTable(env.spec.allocNodes, true)
639639
end
640640
env.allocNodes = nodes
641+
env.initialNodeModDB = calcs.buildModListForNodeList(env, env.allocNodes, true)
641642
end
642643

643644
if allocatedNotableCount and allocatedNotableCount > 0 then
@@ -1051,6 +1052,20 @@ function calcs.initEnv(build, mode, override, specEnv)
10511052
combinedList:MergeMod(mod)
10521053
end
10531054
env.itemModDB:ScaleAddList(combinedList, scale)
1055+
elseif item.type == "Gloves" and calcLib.mod(env.initialNodeModDB, nil, "EffectOfBonusesFromGloves") ~=1 then
1056+
scale = calcLib.mod(env.initialNodeModDB, nil, "EffectOfBonusesFromGloves")
1057+
local combinedList = new("ModList")
1058+
for _, mod in ipairs(srcList) do
1059+
combinedList:MergeMod(mod)
1060+
end
1061+
env.itemModDB:ScaleAddList(combinedList, scale)
1062+
elseif item.type == "Boots" and calcLib.mod(env.initialNodeModDB, nil, "EffectOfBonusesFromBoots") ~= 1 then
1063+
scale = calcLib.mod(env.initialNodeModDB, nil, "EffectOfBonusesFromBoots")
1064+
local combinedList = new("ModList")
1065+
for _, mod in ipairs(srcList) do
1066+
combinedList:MergeMod(mod)
1067+
end
1068+
env.itemModDB:ScaleAddList(combinedList, scale)
10541069
else
10551070
env.itemModDB:ScaleAddList(srcList, scale)
10561071
end
@@ -1188,33 +1203,6 @@ function calcs.initEnv(build, mode, override, specEnv)
11881203
return calcs.initEnv(build, mode, override, specEnv)
11891204
end
11901205
end
1191-
1192-
if env.player.itemList["Gloves"] then
1193-
local gloveEffectMod = env.modDB:Sum("INC", nil, "EffectOfBonusesFromGloves") / 100
1194-
if gloveEffectMod ~= 0 then
1195-
local modList = env.player.itemList["Gloves"].modList
1196-
for _, mod in ipairs(modList) do
1197-
if not (mod.name == "ExtraSupport" or mod.name == "ExtraSkill" or mod.name == "ExtraSupport" or mod.name == "ExtraSkillMod" or (mod[1] and mod[1].type == "SocketedIn")) then
1198-
local modCopy = copyTable(mod)
1199-
modCopy.source = tostring(gloveEffectMod * 100) .. "% Gloves Bonus Effect"
1200-
modDB:ScaleAddMod(modCopy, gloveEffectMod)
1201-
end
1202-
end
1203-
end
1204-
end
1205-
if env.player.itemList["Boots"] then
1206-
local bootEffectMod = env.modDB:Sum("INC", nil, "EffectOfBonusesFromBoots") / 100
1207-
if bootEffectMod ~= 0 then
1208-
local modList = env.player.itemList["Boots"].modList
1209-
for _, mod in ipairs(modList) do
1210-
if not (mod.name == "ExtraSupport" or mod.name == "ExtraSkill" or mod.name == "ExtraSupport" or mod.name == "ExtraSkillMod" or (mod[1] and mod[1].type == "SocketedIn")) then
1211-
local modCopy = copyTable(mod)
1212-
modCopy.source = tostring(bootEffectMod * 100) .. "% Boots Bonus Effect"
1213-
modDB:ScaleAddMod(modCopy, bootEffectMod)
1214-
end
1215-
end
1216-
end
1217-
end
12181206

12191207
-- Find skills granted by tree nodes
12201208
if not accelerate.nodeAlloc then

0 commit comments

Comments
 (0)