Conditionals overhaul (#666)

* more general type check

* conditional work + characterInfo

* conditional work + characterInfo

* conditional overhaul WIP

* fix typo with BagLearnedRecipes

* Cursed Eye + Black Candle synergy

* conditional stuff

* Change Brittle wording

* Teleport 2.0 Red Room check

* Changed collectiblesToCheck format, moved some mods to conds

* Add getPlayerName, tweak replaceNameMarkupStrings

* massive conditional overhaul

* AB+ birthright check fix

* oh yeah birthright isn't zero-indexed yet

* update with mirades

* update with mirades

* Move blank card / rune IDs

* move rune IDs, reduce reused code

* Add {{NameOnlyX###}} markup

* more conditionals

* more conditionals

* Update eid_conditionals.lua

* separate icon from name in variablecharge

* keep old localizations working

* split Dead Cat so it doesn't have a variable text

* Blank Card + ? Card

* moving Blank Card + ? Card

* Pretend english detailed doesn't exist

* Oops! No Comma!

* milk override

* Placenta no red hp

* actually no placenta still gives +1 health

* Dark Arts conditional

* Marbles percentage

* Dark Arts conditional
This commit is contained in:
Buurazu authored and GitHub committed 2024-06-09 17:59:56 +02:00
1 parent 68caf34fed
commit ac2aecae92
30 files changed
+614 -358

No files matched your search

+28 -154
View File
@@ -7,38 +7,37 @@ EID.inModifierPreview = false
EID.TabDescThisFrame = false
-- List of collectible IDs for us to check if a player owns them; feel free to add to this in mods that add description modifiers!
EID.collectiblesToCheck = { CollectibleType.COLLECTIBLE_VOID, CollectibleType.COLLECTIBLE_CAR_BATTERY, CollectibleType.COLLECTIBLE_BFFS }
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_VOID] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_BFFS] = true
local maxSlot = 1
-- Repentance modifiers
if EID.isRepentance then
maxSlot = 3
--include the AB+ collectiblesToCheck in this table! (wish there was an easy way to merge two tables)
EID.collectiblesToCheck = { CollectibleType.COLLECTIBLE_VOID,
CollectibleType.COLLECTIBLE_BINGE_EATER, CollectibleType.COLLECTIBLE_BOOK_OF_VIRTUES, CollectibleType.COLLECTIBLE_SPINDOWN_DICE,
CollectibleType.COLLECTIBLE_TAROT_CLOTH, CollectibleType.COLLECTIBLE_MOMS_BOX, 59, --Birthright Belial
CollectibleType.COLLECTIBLE_BLANK_CARD, CollectibleType.COLLECTIBLE_CLEAR_RUNE, CollectibleType.COLLECTIBLE_PLACEBO,
CollectibleType.COLLECTIBLE_FALSE_PHD, CollectibleType.COLLECTIBLE_ABYSS, CollectibleType.COLLECTIBLE_FLIP, CollectibleType.COLLECTIBLE_CAR_BATTERY,
CollectibleType.COLLECTIBLE_GLOWING_HOUR_GLASS, CollectibleType.COLLECTIBLE_BFFS
}
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_BOOK_OF_VIRTUES] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_SPINDOWN_DICE] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_MOMS_BOX] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_BLANK_CARD] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_CLEAR_RUNE] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_PLACEBO] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_FALSE_PHD] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_FLIP] = true
EID.collectiblesToCheck[CollectibleType.COLLECTIBLE_GLOWING_HOUR_GLASS] = true
end
EID.collectiblesOwned = {}
EID.collectiblesAbsorbed = {}
EID.blackRuneOwned = false
EID.blankCardHidden = {[32]=true,[33]=true,[34]=true,[35]=true,[36]=true,[37]=true,[38]=true,[39]=true,[40]=true,[41]=true,[49]=true,[50]=true,[55]=true,[78]=true,[81]=true,[82]=true,[83]=true,[84]=true,[85]=true,[86]=true,[87]=true,[88]=true,[89]=true,[90]=true,[91]=true,[92]=true,[93]=true,[94]=true,[95]=true,[96]=true,[97]=true,}
EID.runeIDs = {[32]=true,[33]=true,[34]=true,[35]=true,[36]=true,[37]=true,[38]=true,[39]=true,[40]=true,[41]=true,[55]=true,[81]=true,[82]=true,[83]=true,[84]=true,[85]=true,[86]=true,[87]=true,[88]=true,[89]=true,[90]=true,[91]=true,[92]=true,[93]=true,[94]=true,[95]=true,[96]=true,[97]=true,}
EID.blackFeatherItems = {[215]=true,[216]=true,[230]=true,[260]=true,[262]=true,[339]=true,[344]=true,[654]=true,}
EID.blackFeatherTrinkets = {[17]=true,[22]=true}
local lastCheck = 0
EID.LastCollectibleCheck = 0
function EID:CheckPlayersCollectibles()
-- recheck the players' owned collectibles periodically, not every frame
-- (has to be checked regularly due to mechanics like D4 / Tainted Eden)
if EID.GameUpdateCount >= lastCheck + 15 then
lastCheck = EID.GameUpdateCount
if EID.GameUpdateCount >= EID.LastCollectibleCheck + 15 then
EID.LastCollectibleCheck = EID.GameUpdateCount
local numPlayers = game:GetNumPlayers()
local players = {}; for i = 0, numPlayers - 1 do players[i] = Isaac.GetPlayer(i) end
for _,v in ipairs(EID.collectiblesToCheck) do
for v,_ in pairs(EID.collectiblesToCheck) do
EID.collectiblesOwned[v] = false
EID.collectiblesAbsorbed[v] = false
for i = 0, numPlayers - 1 do
@@ -230,45 +229,6 @@ local function SacrificeRoomCallback(descObj)
return descObj
end
-- Handle Car Battery description addition
local function CarBatteryCallback(descObj)
local carBatteryBuff = EID:getDescriptionEntry("carBattery", descObj.ObjSubType)
if carBatteryBuff ~= nil then
-- String = append
if type(carBatteryBuff) == "string" then
local iconStr = "#{{Collectible356}} "
EID:appendToDescription(descObj, iconStr..carBatteryBuff:gsub("#",iconStr))
-- Table with 1 entry = replace
elseif #carBatteryBuff == 1 then
descObj.Description = carBatteryBuff[1]
-- Table with 2+ entries = find and replace
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
else
local pos = 1
while pos < #carBatteryBuff do
local toFind = carBatteryBuff[pos]
local replaceWith = carBatteryBuff[pos+1]
--"%d*%.?%d+" will grab every number group (1, 10, 0.5), this will allow us to not replace the "1" in "10" erroneously
if (type(toFind) == "number") then
local count = 0
descObj.Description = string.gsub(descObj.Description, "%d*%.?%d+", function(s)
if (s == tostring(toFind) and count == 0) then
count = count + 1
return "{{BlinkYellowGreen}}" .. replaceWith .. "{{CR}}"
end
end)
-- Basic find+replace for non-numbers
else
descObj.Description = string.gsub(descObj.Description, tostring(toFind), "{{BlinkYellowGreen}}" .. replaceWith .. "{{CR}}", 1)
end
pos = pos + 2
end
end
end
return descObj
end
local function BlackFeatherCallback(descObj)
local itemCounter = 0
for itemID, _ in pairs(EID.blackFeatherItems) do
@@ -339,27 +299,6 @@ if EID.isRepentance then
return descObj
end
-- Handle Bingeeater description addition
local function BingeEaterCallback(descObj)
local bingeBuff = EID:getDescriptionEntry("bingeEaterBuffs", descObj.ObjSubType)
if bingeBuff ~= nil then
local iconStr = "#{{Collectible664}} "
EID:appendToDescription(descObj, iconStr..bingeBuff:gsub("#",iconStr))
end
return descObj
end
-- Handle Book of Belial description for Judas' Birthright addition
local function BookOfBelialCallback(descObj)
local belialBuff = EID:getDescriptionEntry("bookOfBelialBuffs", descObj.ObjSubType)
if belialBuff ~= nil then
local iconStr = "#{{Collectible34}} "
EID:appendToDescription(descObj, iconStr..belialBuff:gsub("#",iconStr))
end
return descObj
end
-- Handle Book of Virtues description addition
local function BookOfVirtuesCallback(descObj)
-- Display players' current active item's wisp effect when looking at a Book of Virtues pedestal
@@ -515,45 +454,6 @@ if EID.isRepentance then
return descObj
end
-- Handle Tarot Cloth description addition
local function TarotClothCallback(descObj)
local clothBuff = EID:getDescriptionEntry("tarotClothBuffs", descObj.ObjSubType)
if clothBuff ~= nil then
-- String = append
if type(clothBuff) == "string" then
local iconStr = "#{{Collectible451}} "
EID:appendToDescription(descObj, iconStr..clothBuff:gsub("#",iconStr))
-- Table with 1 entry = replace
elseif #clothBuff == 1 then
descObj.Description = clothBuff[1]
-- Table with 2+ entries = find and replace
-- Entry 1 is replaced with entry 2, entry 3 is replaced with entry 4, etc.
else
local pos = 1
while pos < #clothBuff do
local toFind = clothBuff[pos]
local replaceWith = clothBuff[pos+1]
--"%d*%.?%d+" will grab every number group (1, 10, 0.5), this will allow us to not replace the "1" in "10" erroneously
if (type(toFind) == "number") then
local count = 0
descObj.Description = string.gsub(descObj.Description, "%d*%.?%d+", function(s)
if (s == tostring(toFind) and count == 0) then
count = count + 1
return "{{ColorShinyPurple}}" .. replaceWith .. "{{CR}}"
end
end)
-- Basic find+replace for non-numbers
else
descObj.Description = string.gsub(descObj.Description, tostring(toFind), "{{ColorShinyPurple}}" .. replaceWith .. "{{CR}}", 1)
end
pos = pos + 2
end
end
end
return EID:applyConditionals(descObj,"Tarot")
end
local hasBox = false
local isGolden = false
@@ -640,48 +540,37 @@ if EID.isRepentance then
local hasTarot = false
local function VariableCharge(descObj, metadata, collID, chargeText)
local text = EID:getDescriptionEntry(chargeText or "VariableCharge")
if text ~= nil and metadata ~= nil and metadata.mimiccharge and metadata.mimiccharge ~= -1 then
text = EID:ReplaceVariableStr(text, 1, "{{NameOnlyC" .. collID .. "}}")
EID:appendToDescription(descObj, "#{{ColorSilver}}{{Collectible" .. collID .. "}} " .. text .. " {{"..metadata.mimiccharge.."}}{{Battery}}")
end
end
-- Handle Blank Card description addition
local function BlankCardCallback(descObj)
local text = EID:getDescriptionEntry("BlankCardCharge")
local charge = EID.cardMetadata[descObj.ObjSubType]
local iconStr = "#{{Collectible286}} {{ColorSilver}}"
if text ~= nil and charge ~= nil and charge.mimiccharge and charge.mimiccharge ~= -1 then
if descObj.ObjSubType == 48 then -- ? card
text = EID:getDescriptionEntry("BlankCardQCard")
EID:appendToDescription(descObj, iconStr..text:gsub("#",iconStr))
else
EID:appendToDescription(descObj, iconStr..text.." {{"..charge.mimiccharge.."}}{{Battery}}")
end
end
VariableCharge(descObj, EID.cardMetadata[descObj.ObjSubType], 286, "BlankCardCharge")
-- If the player has Tarot Cloth and Blank Card, display additional text
if hasTarot then
text = EID:getDescriptionEntry("BlankCardEffect")
local buffText = EID:getDescriptionEntry("tarotClothBlankCardBuffs", descObj.ObjSubType)
if buffText then EID:appendToDescription(descObj, iconStr .. text .. " " .. buffText) end
if buffText then EID:appendToDescription(descObj, "#{{ColorSilver}}{{Collectible286}} " .. text .. " " .. buffText) end
end
return descObj
end
-- Handle Clear Rune description addition
local function ClearRuneCallback(descObj)
local text = EID:getDescriptionEntry("ClearRuneCharge")
local charge = EID.cardMetadata[descObj.ObjSubType]
if text ~= nil and charge ~= nil and charge.mimiccharge and charge.mimiccharge ~= -1 then
local iconStr = "#{{Collectible263}} {{ColorSilver}}"
EID:appendToDescription(descObj, iconStr..text.." {{"..charge.mimiccharge.."}}{{Battery}}")
end
VariableCharge(descObj, EID.cardMetadata[descObj.ObjSubType], 263, "ClearRuneCharge")
return descObj
end
-- Handle Placebo description addition
local function PlaceboCallback(descObj)
local text = EID:getDescriptionEntry("PlaceboCharge")
local adjustedID = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType)
local charge = EID.pillMetadata[adjustedID-1]
if text ~= nil and charge ~= nil and charge.mimiccharge and charge.mimiccharge ~= -1 then
local iconStr = "#{{Collectible348}} {{ColorSilver}}"
EID:appendToDescription(descObj, iconStr..text.." {{"..charge.mimiccharge.."}}{{Battery}}")
end
VariableCharge(descObj, EID.pillMetadata[adjustedID-1], 348, "PlaceboCharge")
return descObj
end
@@ -811,16 +700,6 @@ if EID.isRepentance then
return descObj
end
-- Handle Abyss description addition
local function AbyssCallback(descObj)
local text = EID:getDescriptionEntry("abyssSynergies", descObj.ObjSubType)
if text ~= nil then
local iconStr = "#{{Collectible706}} {{ColorRed}}"
EID:appendToDescription(descObj, iconStr..text)
end
return descObj
end
-- Handle Flip description addition
local function FlipCallback(descObj)
local flipItemID = EID:getEntityData(descObj.Entity, "EID_FlipItemID")
@@ -866,10 +745,7 @@ if EID.isRepentance then
if REPENTOGON and descObj.ObjSubType == 422 then table.insert(callbacks, GlowingHourglassCallback) end
if descObj.ObjSubType == 644 then table.insert(callbacks, ConsolationPrizeCallback) end
if EID.collectiblesOwned[664] then table.insert(callbacks, BingeEaterCallback) end
if EID.collectiblesOwned[59] then table.insert(callbacks, BookOfBelialCallback) end
if EID.collectiblesOwned[584] or descObj.ObjSubType == 584 then table.insert(callbacks, BookOfVirtuesCallback) end
if EID.collectiblesOwned[706] or EID.collectiblesAbsorbed[706] then table.insert(callbacks, AbyssCallback) end
if EID.collectiblesOwned[711] and EID:getEntityData(descObj.Entity, "EID_FlipItemID") then table.insert(callbacks, FlipCallback) end
if EID.Config["SpindownDiceResults"] > 0 and (EID.collectiblesOwned[723] or EID.collectiblesAbsorbed[723]) and descObj.ObjSubType ~= 668 then table.insert(callbacks, SpindownDiceCallback) end
@@ -877,7 +753,6 @@ if EID.isRepentance then
-- Card / Rune Callbacks
elseif descObj.ObjVariant == PickupVariant.PICKUP_TAROTCARD then
hasTarot = EID.collectiblesOwned[451]
if hasTarot then table.insert(callbacks, TarotClothCallback) end
if EID.collectiblesOwned[286] and not EID.blankCardHidden[descObj.ObjSubType] and EID.cardMetadata[descObj.ObjSubType] then table.insert(callbacks, BlankCardCallback) end
if EID.collectiblesOwned[263] and EID.runeIDs[descObj.ObjSubType] and EID.cardMetadata[descObj.ObjSubType] then table.insert(callbacks, ClearRuneCallback) end
@@ -926,7 +801,6 @@ local function EIDConditionsAB(descObj)
if EID.collectiblesOwned[477] then table.insert(callbacks, VoidCallback) end
if EID.blackRuneOwned then table.insert(callbacks, BlackRuneCallback) end
end
if EID.collectiblesOwned[356] then table.insert(callbacks, CarBatteryCallback) end
-- BFF Synergy check
if EID.collectiblesOwned[247] then