Add golden trinket additive modifier

This commit is contained in:
Wofsauge committed 2025-05-13 00:40:25 +02:00
1 parent 46f9790ef4
commit acdcdcdd08
2 files changed
+33 -1

No files matched your search

+26
View File
@@ -93,6 +93,7 @@ local dynamicSpriteCache = {} -- used to store sprite objects of collectible ico
---@field findReplace boolean? @If true, the text is replaced ---@field findReplace boolean? @If true, the text is replaced
---@field fullReplace boolean? @If true, description is fully replaced ---@field fullReplace boolean? @If true, description is fully replaced
---@field goldenOnly boolean? @If true, the description is modified only when the trinket is golden ---@field goldenOnly boolean? @If true, the description is modified only when the trinket is golden
---@field additions number? @Add a value to the number in the text, similar to multiplier. Expects a table of 3 values, 1: double, 2: triple, 3: quadruple effect
---@class EID_Icon ---@class EID_Icon
---@field [1] string @Animation name ---@field [1] string @Animation name
@@ -209,6 +210,31 @@ function EID:addGoldenTrinketMetadata(id, appendText, numbersToMultiply, maxMult
EID.descriptions[language].goldenTrinketEffects[id] = { appendText[1], appendText[1], appendText[2] or appendText[1] } EID.descriptions[language].goldenTrinketEffects[id] = { appendText[1], appendText[1], appendText[2] or appendText[1] }
end end
end end
---Adds information about appending text and adding to numbers in a modded trinket's Golden/Mom's Box description. All three variables are optional, set to ""/0 or nil to not include them
---@param appendText? string | string[] @Text to be appended onto the description. Can be one string, or a table of two strings; one for doubling and one for tripling
---@param numbersToChange? number | number[] @The number inside the text that gets added towards. can be one number, or a table of numbers
---@param additiveValues? number @Table of values that should be added to the number, if its doubled, tripled, or quadrupled
-- Example: My modded trinket gives +5 range and when tripled, adds homing instead of tripling the range boost:
--- ```lua
--- EID:addGoldenTrinketMetadataAdditive(Isaac.GetTrinketIdByName("Cool Trinket"), {"", "Homing tears"}, 5, {1,2,3})
--- ```
function EID:addGoldenTrinketMetadataAdditive(id, appendText, numbersToChange, additiveValues, language)
language = language or "en_us"
if appendText == "" then appendText = nil
elseif type(appendText) == "string" then appendText = {appendText} end
if numbersToChange == 0 then numbersToChange = nil
elseif type(numbersToChange) == "number" then numbersToChange = {numbersToChange} end
additiveValues = type(additiveValues) == "number" and {additiveValues, additiveValues, additiveValues} or additiveValues or {1, 2, 3}
EID.GoldenTrinketData[id] = {t = numbersToChange, additions = additiveValues, mults = {1,1,1}, append = appendText and true}
if appendText then
EID:CreateDescriptionTableIfMissing("goldenTrinketEffects", language)
EID.descriptions[language].goldenTrinketEffects[id] = { appendText[1], appendText[1], appendText[2] or appendText[1] }
end
end
---@see EID_GoldenTrinketData ---@see EID_GoldenTrinketData
---Add a fully custom data table to the table of Golden Trinket effects. ---Add a fully custom data table to the table of Golden Trinket effects.
+7 -1
View File
@@ -580,6 +580,12 @@ if EID.isRepentance then
else multiplier = data.mults[1] end else multiplier = data.mults[1] end
elseif data.mult and ((isGolden and hasBox) or data.mult < 2) then multiplier = data.mult end elseif data.mult and ((isGolden and hasBox) or data.mult < 2) then multiplier = data.mult end
--custom additions table (manually defined)
local addition = 0
if data.additions then
addition = data.additions[textChoice]
end
--replacing numeric text based on our multiplier --replacing numeric text based on our multiplier
if (data.t) then if (data.t) then
for _,v in ipairs(data.t) do for _,v in ipairs(data.t) do
@@ -592,7 +598,7 @@ if EID.isRepentance then
if multiplier == 2 then v = 16.5 if multiplier == 2 then v = 16.5
elseif multiplier == 3 then v = (1/6)*100 end -- convert 17% to 33% or 50% elseif multiplier == 3 then v = (1/6)*100 end -- convert 17% to 33% or 50%
elseif v == 33 and (multiplier == 1.5 or multiplier == 3) then v = (1/3)*100 end -- convert 33% to 50% or 100% elseif v == 33 and (multiplier == 1.5 or multiplier == 3) then v = (1/3)*100 end -- convert 33% to 50% or 100%
return "{{ColorGold}}" .. string.format("%.4g",v*multiplier) .. "{{CR}}" return "{{ColorGold}}" .. string.format("%.4g",v * multiplier + addition) .. "{{CR}}"
end end
end) end)
end end