collectible lock check tweaks

This commit is contained in:
Buurazu authored and GitHub committed 2021-10-20 05:25:38 -04:00
1 parent 39fb48fd60
commit 598019686b
5 files changed
+127 -66

No files matched your search

+29 -20
View File
@@ -755,7 +755,8 @@ function EID:getSpindownResult(collectibleID)
local newID = collectibleID
repeat
newID = newID - 1
until (config:GetCollectible(newID) and EID:isCollectibleUnlockedAnyPool(newID) and not config:GetCollectible(newID).Hidden) or newID == CollectibleType.COLLECTIBLE_NULL
--note: the order of this statement is important so that the item is checked for being in a pool (to display a ? if it isn't)
until (config:GetCollectible(newID) and (EID:isCollectibleUnlockedAnyPool(newID) or not EID.Config["SpindownDiceSkipLocked"]) and not config:GetCollectible(newID).Hidden) or newID == CollectibleType.COLLECTIBLE_NULL
return newID
end
@@ -776,7 +777,7 @@ end
local maxCollectibleID = nil
function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
local itemPool = Game():GetItemPool()
local itemConfig = Isaac.GetItemConfig()
--local itemConfig = Isaac.GetItemConfig()
if (not maxCollectibleID) then maxCollectibleID = EID:GetMaxCollectibleID() end
for i= 1, maxCollectibleID do
if ItemConfig.Config.IsValidCollectible(i) and i ~= collectibleID then
@@ -798,27 +799,35 @@ end
function EID:isCollectibleUnlockedAnyPool(collectibleID)
local itemConfig = Isaac.GetItemConfig()
local item = itemConfig:GetCollectible(collectibleID)
if EID.itemUnlockStates[collectibleID] == nil then
local itemPoolNum = 0
while EID:isCollectibleUnlocked(collectibleID, itemPoolNum) == false do
if itemPoolNum == ItemPoolType.NUM_ITEMPOOLS - 1 then
if itemConfig:GetCollectible(collectibleID).Tags & ItemConfig.TAG_QUEST == ItemConfig.TAG_QUEST then
--print("item " .. tostring(collectibleID) .. " is tagged as quest!")
EID.itemUnlockStates[collectibleID] = true
return true
end
--print("couldn't find item " .. tostring(collectibleID) .. " in any item pools")
EID.itemUnlockStates[collectibleID] = false
return false
end
itemPoolNum = itemPoolNum + 1
--whitelist all quest items and items with no associated achievement
if (item.AchievementID == -1 or item.Tags & ItemConfig.TAG_QUEST == ItemConfig.TAG_QUEST) then
--print("item " .. tostring(collectibleID) .. " is tagged as quest or has no achievement ID!")
EID.itemUnlockStates[collectibleID] = true
return true
end
--print("found item " .. tostring(collectibleID) .. " unlocked in pool " .. tostring(itemPoolNum))
EID.itemUnlockStates[collectibleID] = true
return true
--blacklist all hidden items
if (item.Hidden) then
--print("item " .. tostring(collectibleID) .. " is tagged as hidden!")
EID.itemUnlockStates[collectibleID] = false
return false
end
--iterate through the pools this item can be in
for k,v in ipairs(EID.CollectiblesPools[collectibleID]) do
if (EID:isCollectibleUnlocked(collectibleID, v)) then
--print("found item " .. tostring(collectibleID) .. " unlocked in pool " .. tostring(v))
EID.itemUnlockStates[collectibleID] = true
return true
end
end
--note: some items will still be missed by this, if they've been taken out of their pools (especially when in Greed Mode)
--print("couldn't find item " .. tostring(collectibleID) .. " in any item pools")
EID.itemUnlockStates[collectibleID] = false
return false
else
--print("item " .. tostring(collectibleID) .. " was already cached: " .. tostring(EID.itemUnlockStates[collectibleID]))
return EID.itemUnlockStates[collectibleID]
--print("item " .. tostring(collectibleID) .. " was already cached: " .. tostring(EID.itemUnlockStates[collectibleID]))
return EID.itemUnlockStates[collectibleID]
end
end