Skip to content

Commit baee98d

Browse files
Use offset mods for Cryogenesis redirect, label source
Replaced ConvertMod approach with sum-and-offset: for each non-target damage type, add a negative mod to cancel the original and a positive mod on the target type. Both labeled "Cryogenesis Conversion" so the breakdown popup shows where the redirected damage comes from. Removed ConvertMod/ConvertModInternal from ModStore/ModList/ModDB since nothing uses them anymore.
1 parent b1766ee commit baee98d

4 files changed

Lines changed: 8 additions & 76 deletions

File tree

src/Classes/ModDB.lua

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,44 +66,6 @@ function ModDBClass:ReplaceModInternal(mod)
6666
return false
6767
end
6868

69-
---ConvertModInternal
70-
--- Converts an existing mod with oldName to a new mod with a different name.
71-
--- Moves the mod from the old name's bucket to the new name's bucket.
72-
--- If no matching mod exists, then the function returns false
73-
---@param oldName string @The name of the existing mod to find
74-
---@param mod table @The new mod to replace it with
75-
---@return boolean @Whether any mod was converted
76-
function ModDBClass:ConvertModInternal(oldName, mod)
77-
if not self.mods[oldName] then
78-
if self.parent then
79-
return self.parent:ConvertModInternal(oldName, mod)
80-
end
81-
return false
82-
end
83-
84-
local oldList = self.mods[oldName]
85-
for i = 1, #oldList do
86-
local curMod = oldList[i]
87-
if oldName == 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.converted then
88-
-- Remove from old name's bucket
89-
t_remove(oldList, i)
90-
-- Add to new name's bucket
91-
local newName = mod.name
92-
if not self.mods[newName] then
93-
self.mods[newName] = { }
94-
end
95-
mod.converted = true
96-
t_insert(self.mods[newName], mod)
97-
return true
98-
end
99-
end
100-
101-
if self.parent then
102-
return self.parent:ConvertModInternal(oldName, mod)
103-
end
104-
105-
return false
106-
end
10769

10870
function ModDBClass:AddList(modList)
10971
local mods = self.mods

src/Classes/ModList.lua

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ function ModListClass:ReplaceModInternal(mod)
4545
return false
4646
end
4747

48-
---ConvertModInternal
49-
--- Converts an existing mod with oldName to a new mod with a different name.
50-
--- If no matching mod exists, then the function returns false
51-
---@param oldName string @The name of the existing mod to find
52-
---@param mod table @The new mod to replace it with
53-
---@return boolean @Whether any mod was converted
54-
function ModListClass:ConvertModInternal(oldName, mod)
55-
for i, curMod in ipairs(self) do
56-
if oldName == curMod.name and mod.type == curMod.type and mod.flags == curMod.flags and mod.keywordFlags == curMod.keywordFlags and mod.source == curMod.source then
57-
self[i] = mod
58-
return true
59-
end
60-
end
61-
62-
if self.parent then
63-
return self.parent:ConvertModInternal(oldName, mod)
64-
end
65-
66-
return false
67-
end
6848

6949
function ModListClass:MergeMod(mod, skipNonAdditive)
7050
if mod.type == "BASE" or mod.type == "INC" or mod.type == "MORE" then

src/Classes/ModStore.lua

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,6 @@ function ModStoreClass:ReplaceMod(...)
110110
end
111111
end
112112

113-
---ConvertMod
114-
--- Converts an existing mod to a new name, replacing it in the store.
115-
--- Finds a mod matching oldName with the same type, flags, keywordFlags, and source as the new mod.
116-
--- If no matching mod exists, the new mod is added instead.
117-
---@param oldName string @The name of the existing mod to convert
118-
---@param ... any @Parameters to be passed along to the modLib.createMod function (new name, type, value, source, ...)
119-
function ModStoreClass:ConvertMod(oldName, ...)
120-
local mod = mod_createMod(...)
121-
if not self:ConvertModInternal(oldName, mod) then
122-
self:AddMod(mod)
123-
end
124-
end
125113

126114
function ModStoreClass:Combine(modType, cfg, ...)
127115
if modType == "MORE" then

src/Modules/CalcOffence.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3063,13 +3063,15 @@ function calcs.offence(env, actor, activeSkill)
30633063
if not skipRedirect then
30643064
for _, damageType in ipairs(dmgTypeList) do
30653065
if damageType ~= addedDamageRedirectType then
3066-
for _, value in ipairs(skillModList:Tabulate("BASE", cfg, damageType.."Min")) do
3067-
local mod = value.mod
3068-
skillModList:ConvertMod(damageType.."Min", addedDamageRedirectType.."Min", "BASE", mod.value, mod.source, mod.flags, mod.keywordFlags, unpack(mod))
3066+
local addedMin = skillModList:Sum("BASE", cfg, damageType.."Min")
3067+
local addedMax = skillModList:Sum("BASE", cfg, damageType.."Max")
3068+
if addedMin ~= 0 then
3069+
skillModList:NewMod(damageType.."Min", "BASE", -addedMin, "Cryogenesis Conversion")
3070+
skillModList:NewMod(addedDamageRedirectType.."Min", "BASE", addedMin, "Cryogenesis Conversion")
30693071
end
3070-
for _, value in ipairs(skillModList:Tabulate("BASE", cfg, damageType.."Max")) do
3071-
local mod = value.mod
3072-
skillModList:ConvertMod(damageType.."Max", addedDamageRedirectType.."Max", "BASE", mod.value, mod.source, mod.flags, mod.keywordFlags, unpack(mod))
3072+
if addedMax ~= 0 then
3073+
skillModList:NewMod(damageType.."Max", "BASE", -addedMax, "Cryogenesis Conversion")
3074+
skillModList:NewMod(addedDamageRedirectType.."Max", "BASE", addedMax, "Cryogenesis Conversion")
30733075
end
30743076
end
30753077
end

0 commit comments

Comments
 (0)