Misc item reminder updates (#695)

* Change wisp checking

* Change selected item var

* Trinket and wisp checks

* add a simple room counter

* various changes

* update my todo list

* Gulped trinket support

* Reset selected items better

* update todo list

* add poop nuggets to pickup names

* add glyph of balance

* add a helper function for xml names

* overhaul special description modifiers

* Pandora's Box greed

* Pandora's Box tweak

* Pandora's Box overview desc

* let Card Reading Boss portal get modified

* move Strange Key to conditionals

* Update eid_conditionals.lua

* misc helper functions

* whitelists

* small text pos modifier tweaks

* wild card + glowing hourglass + void ab+

* move vurp, add wild card

* move SimpleRound

* add wild card, move simpleround, fix pill icon stuff

* Echo Chamber color

* update todo list

* starting work on The Stars? preview

* remove collectible count check; bad for tainted eden

* Tainted Laz overhaul

* fix 4.5 volt with timed pocket actives

* fix pocket active check functions

* Tainted Laz overhaul + The Stars?

* more conditionals

* Battery and bean synergies
This commit is contained in:
Buurazu authored and GitHub committed 2024-07-14 22:07:10 +02:00
1 parent 24a6a808ba
commit 9703626b71
12 files changed
+985 -383

No files matched your search

+141 -66
View File
@@ -51,6 +51,8 @@ EID.holdTabPlayer = 0
EID.holdTabCounter = 0
EID.DInfinityState = {}
local forgottenDropTimer = 0
EID.roomCount = 0
local preHourglassStatus = {}
EID.GameUpdateCount = 0
EID.GameRenderCount = 0
@@ -375,7 +377,8 @@ end
-- Watch for a Void absorbing active items
function EID:CheckVoidAbsorbs(_, _, player)
local playerID = EID:getPlayerID(player)
player = player or EID.player
local playerID = EID:getPlayerID(player, true)
EID.absorbedItems[tostring(playerID)] = EID.absorbedItems[tostring(playerID)] or {}
for _,v in ipairs(EID:VoidRoomCheck()) do
EID.absorbedItems[tostring(playerID)][tostring(v)] = true
@@ -672,7 +675,7 @@ function EID:printDescription(desc, cachedID)
if #EID.coopAllPlayers > 1 then
transformationName = transformationName .. EID:GetPlayerIcon(playerType)
end
local numCollected = EID.TransformationProgress[EID:getPlayerID(player)] and EID.TransformationProgress[EID:getPlayerID(player)][transform] or 0
local numCollected = EID.TransformationProgress[EID:getPlayerID(player, true)] and EID.TransformationProgress[EID:getPlayerID(player, true)][transform] or 0
local numMax = EID.TransformationData[transform] and EID.TransformationData[transform].NumNeeded or 3
transformationName = transformationName.."("..numCollected.."/"..numMax..") "
end
@@ -776,6 +779,18 @@ end
function EID:onNewRoom()
EID:CheckCurrentRoomGridEntities()
EID.roomCount = EID.roomCount + 1
-- Store values here to be rewound after using Glowing Hour Glass
preHourglassStatus = {}
preHourglassStatus.absorbedItems = EID:CopyTable(EID.absorbedItems)
preHourglassStatus.PlayerItemInteractions = EID:CopyTable(EID.PlayerItemInteractions)
if EID.isRepentance then
preHourglassStatus.WildCardEffects = EID:CopyTable(EID.WildCardEffects)
preHourglassStatus.WildCardPillColor = EID:CopyTable(EID.WildCardPillColor)
preHourglassStatus.DInfinityState = EID:CopyTable(EID.DInfinityState)
preHourglassStatus.BagItems = EID:CopyTable(EID.BoC.BagItems)
preHourglassStatus.RoomQueries = EID:CopyTable(EID.BoC.RoomQueries)
end
end
EID:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, EID.onNewRoom)
@@ -1063,31 +1078,32 @@ function EID:onGameUpdate()
EID.RecheckVoid = true
end
if EID.isRepentance and EID.GameUpdateCount % 10 == 0 then
-- Check wisp for adding reminder when using lemegeton
if EID.ShouldCheckWisp then
for _, wisp in ipairs(Isaac.FindByType(3, 237, -1, true, false)) do
if wisp.FrameCount < 10 then
local player = wisp:ToFamiliar() and wisp:ToFamiliar().Player
if player then
local playerID = EID:getPlayerID(player)
EID:InitItemInteractionIfAbsent(playerID)
table.insert(EID.RecentlyTouchedItems[playerID], wisp.SubType)
end
end
-- Check player items for starting items
if EID.ShouldCheckStartingItems then
EID:UpdateAllPlayerPassiveItems()
EID:SetOldestItemIndex()
EID.ShouldCheckStartingItems = false
end
if EID.isRepentance then
EID:UpdateWildCardEffects()
if EID.GameUpdateCount % 10 == 0 then
-- Check wisp for adding reminder when using lemegeton
if EID.ShouldCheckWisp then
EID:UpdateAllPlayerLemegetonWisps()
EID.ShouldCheckWisp = false
end
EID.ShouldCheckWisp = false
end
-- Remove Crane Game item data if it's giving the prize out
for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do
if EID.CraneItemType[tostring(crane.InitSeed)] then
if crane:GetSprite():IsPlaying("Prize") then
EID.CraneItemType[tostring(crane.InitSeed)] = nil
-- Pair the Crane Game's new drop seed with the latest collectible ID it's gotten
-- (fixes Glowing Hour Glass rewinds)
elseif EID.CraneItemType[crane.InitSeed.."Drop"..crane.DropSeed] == nil then
EID.CraneItemType[crane.InitSeed.."Drop"..crane.DropSeed] = EID.CraneItemType[tostring(crane.InitSeed)]
-- Remove Crane Game item data if it's giving the prize out
for _, crane in ipairs(Isaac.FindByType(6, 16, -1, true, false)) do
if EID.CraneItemType[tostring(crane.InitSeed)] then
if crane:GetSprite():IsPlaying("Prize") then
EID.CraneItemType[tostring(crane.InitSeed)] = nil
-- Pair the Crane Game's new drop seed with the latest collectible ID it's gotten
-- (fixes Glowing Hour Glass rewinds)
elseif EID.CraneItemType[crane.InitSeed.."Drop"..crane.DropSeed] == nil then
EID.CraneItemType[crane.InitSeed.."Drop"..crane.DropSeed] = EID.CraneItemType[tostring(crane.InitSeed)]
end
end
end
end
@@ -1185,20 +1201,20 @@ function EID:CheckPosModifiers()
else
-- Tainted Isaac and Tainted ??? unique HUD adjustment
if EID.player:GetPlayerType() == 21 or EID.player:GetPlayerType() == 25 then
EID:addTextPosModifier("Tainted HUD", Vector(0,30))
EID:addTextPosModifier("Tainted HUD", Vector(0,26))
else
EID:removeTextPosModifier("Tainted HUD")
end
-- Jacob and Esau card/pill adjustment
if EID.player:GetPlayerType() == 19 then
EID:addTextPosModifier("J&E HUD", Vector(0,15))
EID:addTextPosModifier("J&E HUD", Vector(0,16))
else
EID:removeTextPosModifier("J&E HUD")
end
-- Magdalene Birthright, Keeper & Tainted Keeper third/fourth row of hearts adjustment
if EID.player:GetEffectiveMaxHearts() + EID.player:GetSoulHearts() + (EID.player:GetBrokenHearts() * 2) >= 37 then
EID:removeTextPosModifier("18 Heart HUD")
EID:addTextPosModifier("24 Heart HUD", Vector(0,22))
EID:addTextPosModifier("24 Heart HUD", Vector(0,20))
elseif EID.player:GetEffectiveMaxHearts() + EID.player:GetSoulHearts() + (EID.player:GetBrokenHearts() * 2) >= 25 then
EID:removeTextPosModifier("24 Heart HUD")
EID:addTextPosModifier("18 Heart HUD", Vector(0,10))
@@ -1298,7 +1314,7 @@ function EID:OnRender()
local dropTriggered, playerNumPressingDrop = EID:PlayersActionPressed(ButtonAction.ACTION_DROP, Input.IsActionTriggered)
if dropTriggered then
local playerPressingDrop = EID.coopMainPlayers[playerNumPressingDrop]
local playerID = EID:getPlayerID(playerPressingDrop)
local playerID = EID:getPlayerID(playerPressingDrop, true)
local playerType = playerPressingDrop:GetPlayerType()
-- Forgotten's drop requires a double tap to actually count for this
if (playerType == 16 or playerType == 17) then
@@ -1465,10 +1481,10 @@ function EID:OnRender()
elseif closest.Type == 1000 and closest.Variant == 161 and closest.SubType <= 2 then
local subtypeToCard = {18, 5, 19}
-- Reuse the descriptions of The Emperor/Stars/Moon, so no localization needed
local descriptionObj = EID:getDescriptionObj(5, 300, subtypeToCard[closest.SubType+1], closest, false)
local descriptionObj = EID:getDescriptionObj(5, 300, subtypeToCard[closest.SubType+1], closest)
-- Card Reading's name
descriptionObj.Name = EID:getObjectName(5, 100, 660)
-- Only keep the first line of the description
-- Only keep the first line of the description (to avoid Tarot Cloth effects or Planetarium mention on The Stars)
descriptionObj.Description = string.sub(descriptionObj.Description, 1, string.find(descriptionObj.Description, "#"))
EID:addDescriptionToPrint(descriptionObj)
-- Handle Crane Game
@@ -1596,13 +1612,9 @@ EID:AddCallback(ModCallbacks.MC_POST_RENDER, EID.OnRender)
local function AddActiveItemProgress(player, isD4)
EID.ForceRefreshCache = true
local playerID = EID:getPlayerID(player)
local playerID = EID:getPlayerID(player, true)
EID:InitItemInteractionIfAbsent(playerID)
-- Dead Tainted Lazarus exceptions
local activesTable = EID.PlayerItemInteractions[playerID].actives
if player:GetPlayerType() == 38 then
activesTable = EID.PlayerItemInteractions[playerID].altActives or activesTable
end
-- don't check pocket items after D4, they don't reroll and would get counted twice
local maxSlot = 3
if isD4 then maxSlot = 1 end
@@ -1629,22 +1641,61 @@ local function OnGameStartGeneral(_,isSave)
EID:GetTransformationsOfModdedItems()
EID:buildTransformationTables()
EID.RecentlyTouchedItems = {}
EID.GulpedTrinkets = {}
EID.OldestItemIndex = {}
if not isSave then
EID.PlayerItemInteractions = {}
EID.DInfinityState = {}
end
EID.ShouldCheckWisp = true
EID.WildCardEffects = {}
EID.roomCount = 0
end
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStartGeneral)
local function OnPostPlayerInit()
EID.ShouldCheckStartingItems = true -- for The Stars? tracking
end
EID:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, OnPostPlayerInit)
-- Add currently held active items after D4 was used. Used for Transformation Progress
local function OnUseD4(_, _, _, player)
-- in AB+, USE_ITEM doesn't provide a player
AddActiveItemProgress(player or EID.player, true)
-- repentance fixed needing to blacklist your new items from counting (and AB+ counts everything)
--EID:CollectRerolledItemsOfPlayer(player or EID.player)
if EID.isRepentance then
local playerNum = EID:getPlayerID(player, true)
EID.OldestItemIndex[playerNum] = -1 -- D4 makes it impossible for us to know what the oldest item is for The Stars?
end
end
EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D4)
-- Watch for smelting trinkets; includes Gulp and Marbles
local function OnUseSmelter(_, _, _, player)
player = player or EID.player
local playerNum = EID:getPlayerID(player, true)
EID.GulpedTrinkets[playerNum] = EID.GulpedTrinkets[playerNum] or {}
for i=0,1 do
local trinket = player:GetTrinket(i)
if trinket > 0 then table.insert(EID.GulpedTrinkets[playerNum], trinket) end
end
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, OnUseSmelter, CollectibleType.COLLECTIBLE_SMELTER)
-- Watch for Glowing Hourglass to revert certain variables
local function OnUseGlowingHourglass(_, _, _, _)
EID.absorbedItems = EID:CopyTable(preHourglassStatus.absorbedItems)
EID.PlayerItemInteractions = EID:CopyTable(preHourglassStatus.PlayerItemInteractions)
if EID.isRepentance then
EID.WildCardEffects = EID:CopyTable(preHourglassStatus.WildCardEffects)
EID.WildCardPillColor = EID:CopyTable(preHourglassStatus.WildCardPillColor)
EID.DInfinityState = EID:CopyTable(preHourglassStatus.DInfinityState)
EID.BoC.BagItems = EID:CopyTable(preHourglassStatus.BagItems)
EID.BoC.RoomQueries = EID:CopyTable(preHourglassStatus.RoomQueries)
end
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, OnUseGlowingHourglass, CollectibleType.COLLECTIBLE_GLOWING_HOUR_GLASS)
-- Re-init transformation progress and item interactions after using Genesis
if EID.isRepentance then
local function OnUseGenesis(_, _, _, _)
@@ -1658,6 +1709,14 @@ if EID.isRepentance then
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, OnUseLemegeton, CollectibleType.COLLECTIBLE_LEMEGETON)
-- Watch for any active item usage for Wild Card
local function OnUseGeneral(_, collectibleType, _, player, useFlags, activeSlot)
-- add the active to Wild Card tracking if it was a real active usage
if useFlags & UseFlag.USE_OWNED > 0 and activeSlot >= 0 then
EID:TrackWildCardEffects("5.100." .. collectibleType, player)
end
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, OnUseGeneral)
end
function EID:OnUsePill(pillEffectID, player, useFlags)
@@ -1666,9 +1725,11 @@ function EID:OnUsePill(pillEffectID, player, useFlags)
local pillColor = EID.PlayerHeldPill[EID:getPlayerID(player)]
-- add the pill used to our history for Echo Chamber / Vurp! / transformation progress
EID:AddPickupToHistory("pill", pillEffectID+1, player, useFlags, pillColor)
-- add the pill to Wild Card tracking, unless it's a Temperance? pill
if EID.isRepentance and useFlags ~= UseFlag.USE_NOANNOUNCER then EID:TrackWildCardEffects("5.70." .. (pillEffectID+1), player, pillColor) end
EID.ForceRefreshCache = true -- for transformation progress update
-- for tracking used pills, ignore gold pills and noannouncer flag pills
-- for tracking used pills, ignore gold pills and noannouncer flag pills (Temperance?)
-- (not using a bitmask, because Placebo is mimic+noannouncer, and we want to count those)
if EID.isRepentance and (pillColor % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD or useFlags == UseFlag.USE_NOANNOUNCER) then return end
EID.UsedPillColors[tostring(pillColor)] = true
@@ -1678,6 +1739,8 @@ EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)
function EID:OnUseCard(cardID, player, useFlags)
player = player or EID.player --AB+ doesn't receive player in callback arguments!
EID:AddPickupToHistory("card", cardID, player, useFlags)
-- add the card to Wild Card tracking unless it's Wild Card
if EID.isRepentance and cardID ~= 80 then EID:TrackWildCardEffects("5.300." .. cardID, player) end
end
EID:AddCallback(ModCallbacks.MC_USE_CARD, EID.OnUseCard)
@@ -1693,16 +1756,34 @@ local configIgnoreList = {
["PlayerItemInteractions"] = true,
["UsedPillColors"] = true,
["RecentlyTouchedItems"] = true,
["GulpedTrinkets"] = true,
["WildCardEffects"] = true,
["DInfinityState"] = true,
["OldestItemIndex"] = true,
}
--------------------------------
--------Handle Savadata---------
--------Handle Savedata---------
--------------------------------
function EID:OnGameStart(isSave)
--Loading Moddata--
if EID:HasData() then
local savedEIDConfig = json.decode(Isaac.LoadModData(EID))
-- JSON saves integer table keys as strings. we need to transform them back... used in OnGameStart
local function ConvertSavedTable(tableName)
for playerID, data in pairs(savedEIDConfig[tableName] or {}) do
local convertedData = {}
if type(data) == "table" then
for key, value in pairs(data) do
convertedData[tonumber(key) or key] = value
end
else
convertedData = data
end
EID[tableName][tonumber(playerID)] = convertedData
end
end
-- collection progress
EID.CollectedItems = savedEIDConfig["CollectedItems"] or {}
if EID.SaveGame and savedEIDConfig["SaveGameNumber"] > 0 then
@@ -1713,44 +1794,35 @@ function EID:OnGameStart(isSave)
EID.PlayerItemInteractions = {}
if isSave then
-- JSON saves integer table keys as strings. we need to transform them back...
for playerID, data in pairs(savedEIDConfig["PlayerItemInteractions"] or {}) do
local convertedData = {}
for key, value in pairs(data) do
convertedData[tonumber(key) or key] = value
end
EID.PlayerItemInteractions[tonumber(playerID)] = convertedData
end
for playerID, data in pairs(savedEIDConfig["RecentlyTouchedItems"] or {}) do
local convertedData = {}
for key, value in pairs(data) do
convertedData[tonumber(key) or key] = value
end
EID.RecentlyTouchedItems[tonumber(playerID)] = convertedData
end
ConvertSavedTable("PlayerItemInteractions")
ConvertSavedTable("RecentlyTouchedItems")
ConvertSavedTable("GulpedTrinkets")
ConvertSavedTable("WildCardEffects")
ConvertSavedTable("DInfinityState")
ConvertSavedTable("OldestItemIndex")
else
-- check for the players' starting active items
CheckAllActiveItemProgress()
end
EID.UsedPillColors = {}
EID.absorbedItems = {}
if isSave then
EID.UsedPillColors = savedEIDConfig["UsedPillColors"] or {}
EID.absorbedItems = savedEIDConfig["AbsorbedItems"] or {}
end
if EID.isRepentance then
EID.BoC.BagItems = {}
EID.BoC.LearnedRecipes = {}
EID.CraneItemType = {}
EID.flipItemPositions = {}
EID.absorbedItems = {}
if isSave then
EID.BoC.BagItems = savedEIDConfig["BagContent"] or {}
EID.BoC.LearnedRecipes = savedEIDConfig["BagLearnedRecipes"] or {}
EID.BoC.RoomQueries = savedEIDConfig["BagFloorContent"] or {}
EID.CraneItemType = savedEIDConfig["CraneItemType"] or {}
EID.absorbedItems = savedEIDConfig["AbsorbedItems"] or {}
-- turn list back into dict because json cant save dict indices.
local flipItemTable = {}
for _, v in ipairs(savedEIDConfig["FlipItemPositions"]) do
@@ -1794,7 +1866,7 @@ function EID:OnGameStart(isSave)
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.Scale = EID.Config["Size"]
EID.ItemReminderSelectedCategory = EID.Config["ItemReminderDisplayMode"] == "NoOverview" and 1 or 0
EID:fixDefinedFont()
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
end
@@ -1808,8 +1880,8 @@ function EID:OnGameExit()
EID.Config["BagLearnedRecipes"] = EID.BoC.LearnedRecipes or {}
EID.Config["BagFloorContent"] = EID.BoC.RoomQueries or {}
EID.Config["CraneItemType"] = EID.CraneItemType or {}
EID.Config["AbsorbedItems"] = EID.absorbedItems or {}
EID.Config["WildCardEffects"] = EID.WildCardEffects or {}
EID.Config["DInfinityState"] = EID.DInfinityState or {}
-- turn dictionary into list because json cant save dict indices.
local flipItemTable = {}
for k, v in pairs(EID.flipItemPositions) do
@@ -1824,7 +1896,10 @@ function EID:OnGameExit()
EID.Config["CollectedItems"] = EID.CollectedItems
EID.Config["PlayerItemInteractions"] = EID.PlayerItemInteractions or {}
EID.Config["RecentlyTouchedItems"] = EID.RecentlyTouchedItems or {}
EID.Config["GulpedTrinkets"] = EID.GulpedTrinkets or {}
EID.Config["UsedPillColors"] = EID.UsedPillColors
EID.Config["AbsorbedItems"] = EID.absorbedItems or {}
EID.Config["OldestItemIndex"] = EID.OldestItemIndex or {}
EID.SaveData(EID, json.encode(EID.Config))
EID:hidePermanentText()