Misc. fixes

This commit is contained in:
Buurazu authored and GitHub committed 2022-01-17 13:01:06 -05:00
1 parent 0f90afd1db
commit bf932356b1
1 file changed
+32 -7
+32 -7
View File
@@ -28,6 +28,7 @@ EID.sacrificeCounter = {}
EID.itemConfig = Isaac.GetItemConfig() EID.itemConfig = Isaac.GetItemConfig()
EID.itemUnlockStates = {} EID.itemUnlockStates = {}
EID.CraneItemType = {} EID.CraneItemType = {}
EID.absorbedSpindown = false
-- Sprite inits -- Sprite inits
EID.IconSprite = Sprite() EID.IconSprite = Sprite()
@@ -186,7 +187,7 @@ questionMarkSprite:LoadGraphics()
function EID:IsAltChoice(pickup) function EID:IsAltChoice(pickup)
-- do not run this while Curse of the Blind is active, since this function is really just a "is collectible pedestal a red question mark" check -- do not run this while Curse of the Blind is active, since this function is really just a "is collectible pedestal a red question mark" check
if game:GetLevel():GetCurses() & LevelCurse.CURSE_OF_BLIND == LevelCurse.CURSE_OF_BLIND then if EID:hasCurseBlind() then
return false return false
end end
if pickup:GetData() == nil then if pickup:GetData() == nil then
@@ -246,6 +247,7 @@ if REPENTANCE then
EID.flipItemPositions = {} EID.flipItemPositions = {}
local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed local lastGetItemResult = {nil, nil, nil, nil} -- itemID, Frame, gridIndex, InitSeed
local lastFrameGridChecked = 0
function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed) function EID:postGetCollectible(selectedCollectible, itemPoolType, decrease, seed)
-- Handle Crane Game -- Handle Crane Game
@@ -301,8 +303,8 @@ if REPENTANCE then
-- Update a Flip item's init seed after D6 rerolls or using Flip (aka Grid Index didn't change, Init Seed did) -- Update a Flip item's init seed after D6 rerolls or using Flip (aka Grid Index didn't change, Init Seed did)
if EID.flipItemPositions[curRoomIndex] and not EID.flipItemPositions[curRoomIndex][entity.InitSeed] then if EID.flipItemPositions[curRoomIndex] and not EID.flipItemPositions[curRoomIndex][entity.InitSeed] then
-- Fix pedestal grid indexes (fixes bugs with restock shops, hopefully it isn't laggy) -- Check if any Flip pedestals have changed grid indexes (fixes bugs with restock shops)
EID:CheckFlipGridIndexes() if lastFrameGridChecked ~= Isaac.GetFrameCount() then EID:CheckFlipGridIndexes() end
for k,v in pairs(EID.flipItemPositions[curRoomIndex]) do for k,v in pairs(EID.flipItemPositions[curRoomIndex]) do
if v[2] == gridPos then if v[2] == gridPos then
EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v EID.flipItemPositions[curRoomIndex][entity.InitSeed] = v
@@ -321,6 +323,7 @@ if REPENTANCE then
-- Before using Flip, swap all flippable pedestal's current item with the flip one (also, fix grid index if needed) -- Before using Flip, swap all flippable pedestal's current item with the flip one (also, fix grid index if needed)
function EID:CheckFlipGridIndexes(collectibleType) function EID:CheckFlipGridIndexes(collectibleType)
lastFrameGridChecked = Isaac.GetFrameCount()
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() local curRoomIndex = game:GetLevel():GetCurrentRoomIndex()
if EID.flipItemPositions[curRoomIndex] then if EID.flipItemPositions[curRoomIndex] then
local pedestals = Isaac.FindByType(5, 100, -1, true, false) local pedestals = Isaac.FindByType(5, 100, -1, true, false)
@@ -339,6 +342,18 @@ if REPENTANCE then
end end
end end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes, CollectibleType.COLLECTIBLE_FLIP) EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckFlipGridIndexes, CollectibleType.COLLECTIBLE_FLIP)
-- Watch for a Void absorbing a Spindown Dice
function EID:CheckVoidAbsorbs(collectibleType)
local pedestals = Isaac.FindByType(5, 100, -1, true, false)
for _, pedestal in ipairs(pedestals) do
if pedestal.SubType == CollectibleType.COLLECTIBLE_SPINDOWN_DICE then
EID.absorbedSpindown = true
return
end
end
end
EID:AddCallback(ModCallbacks.MC_PRE_USE_ITEM, EID.CheckVoidAbsorbs, CollectibleType.COLLECTIBLE_VOID)
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -507,12 +522,17 @@ function EID:printBulletPoints(description, renderPos)
end end
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
---------------------------Handle New Room-------------------------------- ----------------------------Handle New Room--------------------------------
local isMirrorRoom = false local isMirrorRoom = false
local isDeathCertRoom = false
if REPENTANCE then if REPENTANCE then
function EID:onNewRoom() function EID:onNewRoom()
isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld() isMirrorRoom = game:GetLevel():GetCurrentRoom():IsMirrorWorld()
local level = game:GetLevel()
local id = level:GetCurrentRoomIndex()
isDeathCertRoom = (id >=0 and GetPtrHash(level:GetRoomByIdx(id)) == GetPtrHash(level:GetRoomByIdx(id, 2)))
-- Handle Flip Item -- Handle Flip Item
initialItemNext = false initialItemNext = false
flipItemNext = false flipItemNext = false
@@ -995,7 +1015,7 @@ local function onRender(t)
elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then
--Handle Collectibles --Handle Collectibles
if EID:getEntityData(closest, "EID_DontHide") ~= true then if EID:getEntityData(closest, "EID_DontHide") ~= true then
if (EID:hasCurseBlind() and not closest:ToPickup().Touched and EID.Config["DisableOnCurse"]) or (EID.Config["DisableOnAltPath"] and not closest:ToPickup().Touched and EID:IsAltChoice(closest)) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then if (EID:hasCurseBlind() and not closest:ToPickup().Touched and EID.Config["DisableOnCurse"] and not isDeathCertRoom) or (EID.Config["DisableOnAltPath"] and not closest:ToPickup().Touched and EID:IsAltChoice(closest)) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then
EID:renderQuestionMark() EID:renderQuestionMark()
return return
end end
@@ -1083,16 +1103,22 @@ if EID.MCMLoaded or REPENTANCE then
["BagFloorContent"] = true, ["BagFloorContent"] = true,
["CraneItemType"] = true, ["CraneItemType"] = true,
["FlipItemPositions"] = true, ["FlipItemPositions"] = true,
["AbsorbedSpindownDice"] = true,
} }
if EID:HasData() then if EID:HasData() then
local savedEIDConfig = json.decode(Isaac.LoadModData(EID)) local savedEIDConfig = json.decode(Isaac.LoadModData(EID))
if REPENTANCE then if REPENTANCE then
EID.BagItems = {}
EID.CraneItemType = {}
EID.flipItemPositions = {} EID.flipItemPositions = {}
EID.absorbedSpindown = false
if isSave then if isSave then
EID.BagItems = savedEIDConfig["BagContent"] EID.BagItems = savedEIDConfig["BagContent"]
EID.bagOfCraftingRoomQueries = savedEIDConfig["BagFloorContent"] EID.bagOfCraftingRoomQueries = savedEIDConfig["BagFloorContent"]
EID.CraneItemType = savedEIDConfig["CraneItemType"] EID.CraneItemType = savedEIDConfig["CraneItemType"]
EID.absorbedSpindown = savedEIDConfig["AbsorbedSpindownDice"]
-- turn list back into dict because json cant save dict indices. -- turn list back into dict because json cant save dict indices.
local flipItemTable = {} local flipItemTable = {}
@@ -1109,8 +1135,6 @@ if EID.MCMLoaded or REPENTANCE then
savedEIDConfig[k] = nil savedEIDConfig[k] = nil
end end
end end
else
EID.BagItems = {}
end end
-- Only copy Saved config entries that exist in the save -- Only copy Saved config entries that exist in the save
@@ -1156,6 +1180,7 @@ if EID.MCMLoaded or REPENTANCE then
EID.Config["BagContent"] = EID.BagItems or {} EID.Config["BagContent"] = EID.BagItems or {}
EID.Config["BagFloorContent"] = EID.bagOfCraftingRoomQueries or {} EID.Config["BagFloorContent"] = EID.bagOfCraftingRoomQueries or {}
EID.Config["CraneItemType"] = EID.CraneItemType or {} EID.Config["CraneItemType"] = EID.CraneItemType or {}
EID.Config["AbsorbedSpindownDice"] = EID.absorbedSpindown or false
-- turn dictionary into list because json cant save dict indices. -- turn dictionary into list because json cant save dict indices.
local flipItemTable = {} local flipItemTable = {}