Improved colors and code of new item unlock-state functions

This commit is contained in:
Wofsauge committed 2021-10-21 00:58:37 +02:00
1 parent 1766c52648
commit b7a28b8739
3 files changed
+12 -28

No files matched your search

+3 -11
View File
@@ -751,12 +751,11 @@ end
-- Converts a given CollectibleID into the respective Spindown dice result
function EID:getSpindownResult(collectibleID)
local config = Isaac.GetItemConfig()
local newID = collectibleID
repeat
newID = newID - 1
--note: the order of the SkipLocked check statement is important so that the item is checked for being in a pool either way (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
until (EID.itemConfig:GetCollectible(newID) and (EID:isCollectibleUnlockedAnyPool(newID) or not EID.Config["SpindownDiceSkipLocked"]) and not EID.itemConfig:GetCollectible(newID).Hidden) or newID == CollectibleType.COLLECTIBLE_NULL
return newID
end
@@ -764,7 +763,7 @@ function EID:GetMaxCollectibleID()
local id = CollectibleType.NUM_COLLECTIBLES-1
local step = 16
while step > 0 do
if Isaac.GetItemConfig():GetCollectible(id+step) ~= nil then
if EID.itemConfig:GetCollectible(id+step) ~= nil then
id = id + step
else
step = step // 2
@@ -784,7 +783,6 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
itemPool:AddRoomBlacklist(i)
end
end
local room = Game():GetRoom()
local isUnlocked = false
for i = 0,1 do -- some samples to make sure
local collID = itemPool:GetCollectible(itemPoolOfItem, false)
@@ -798,35 +796,29 @@ function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
end
function EID:isCollectibleUnlockedAnyPool(collectibleID)
local itemConfig = Isaac.GetItemConfig()
local item = itemConfig:GetCollectible(collectibleID)
local item = EID.itemConfig:GetCollectible(collectibleID)
if EID.itemUnlockStates[collectibleID] == nil then
--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
--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]
end
end