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
+104 -43

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
+8 -2
View File
@@ -186,8 +186,9 @@ EID.UserConfig = {
-- Default = false
["BagOfCraftingDisplayNames"] = false,
-- Display locked item recipes, which will all turn into Breakfast
-- Default = false
["BagOfCraftingDisplayBreakfast"] = false,
-- However, there are false positives with this, as the current state of item pools is checked to determine an item's locked status
-- Default = true
["BagOfCraftingDisplayBreakfast"] = true,
---------Mouse Controls-----------
@@ -205,6 +206,10 @@ EID.UserConfig = {
-- Default = 3
["SpindownDiceResults"] = 3,
-- Spindown dice preview can skip over locked items, however the method for determining an item's locked status is not perfect
-- Default = false
["SpindownDiceSkipLocked"] = false,
-- Show ID of described object in the format "Type.Variant.SubType" next to the name
-- Default = false
["ShowObjectID"] = false,
@@ -290,6 +295,7 @@ EID.DefaultConfig = {
["BagOfCraftingDisplayNames"] = false,
["BagOfCraftingDisplayBreakfast"] = false,
["SpindownDiceResults"] = 3,
["SpindownDiceSkipLocked"] = false,
["EnableMouseControls"] = false,
["ShowCursor"] = false,
["ErrorMessage"] = "[Effect not defined]",
+20
View File
@@ -364,3 +364,23 @@ EID.InlineColors = {
return color
end,
}
--[[
A list of all the item pools that an item is in
generated from itempools in bagOfCrafting.lua:
local items = {}
for i=1,800 do items[i] = {} end
for k,v in ipairs(itempools) do
for k2,v2 in ipairs(v) do
local item = v2[1]
table.insert(items[item],k-1)
end
end
for k,v in ipairs(items) do
print("{" .. table.concat(v,",") .. "},")
end
]]
EID.CollectiblesPools = {
{0,16,23,24}, {0,16}, {0,16,23}, {0,16,23}, {0,16,23}, {0,16}, {0,4,16,21,29}, {0,3,16,28}, {7}, {0,13,16,28}, {5,18}, {0,16,17}, {0,11,16}, {0,2,11,17}, {0,17}, {5,17}, {0,5}, {}, {0}, {5}, {1,10,23}, {2,10,17}, {2,10,17}, {2,10,17}, {2,10,17}, {2,10,17,30}, {2,17,29}, {2,8,17}, {2,8,15,17,27}, {2,15,17,27}, {2,15,17,27}, {2,8,17,23}, {1,4,6}, {3,6,16,20}, {3,5,6,16,20}, {0,7}, {0,16,25}, {16,23}, {0,15,27}, {0}, {0,15,27}, {0,16,30}, {}, {0,23}, {0,16}, {0,10,18,23}, {0,16,23}, {0,16,23}, {0,23}, {16}, {2,3,11,12,20,23}, {0,16}, {0}, {1,10}, {0,15,16,27}, {0,16}, {0,13,16,28}, {0,6}, {}, {1,29}, {}, {0,16}, {1,14,18,23}, {1,16}, {0,6,16}, {0,23}, {0,3,16,20,28}, {0,16,20,23}, {0,16}, {2,11,17}, {0,17}, {0,4,21}, {16,17,18,19,20,21,22,28}, {3,8,20}, {0,1,18}, {0,18}, {0,16,23}, {0,6,16,21}, {3,11,12,20}, {3,11,12,20}, {3,9,12,19,20}, {3,11,20}, {3,11,20}, {3,5,18}, {0,1,16,23}, {0}, {0,11,16}, {0,16,28}, {0,16,23}, {23}, {0,18,23}, {0,2}, {0,16,23}, {0,16}, {0,16,23,28}, {0,16,28}, {0,3,6,16,20}, {0,4,16}, {0,16,28}, {0,16,28}, {0,4,16,17}, {0,1,10,11,15,16,23,27}, {0,16}, {0,16}, {0,18,23}, {0,16,25}, {0,16}, {0,4,16}, {0,3,20}, {0,15,16,27}, {0,10,16}, {4,21,28}, {0,3,20,28}, {0,3,15,16,20,27}, {0,3,16,20}, {1,14,18,23}, {0,16,20,28}, {3,20}, {}, {0,5,16,17}, {0,5}, {3,11,20}, {0,3,6,20}, {0,4,16}, {0,16,25}, {3,11}, {0,3,5,11}, {0,13,16,28}, {0}, {}, {0,16}, {16,17,20}, {3,9,12,19,20}, {3,9,12,19,20}, {}, {0,23}, {0,1,16,23,25}, {0,16,21,29}, {1,15,18,27}, {0,9,16,25,30}, {2}, {0,4,16}, {0,2,11,17}, {0,10,28}, {3,9,12,19,20}, {0,4,16}, {1,23}, {0,16}, {0,16}, {0,16}, {0,16}, {0,16,23}, {0,16,23}, {0,16}, {0,16,28}, {1,4,18}, {0,3,16,20}, {}, {3,11,20}, {0}, {0,16}, {0,4,16,21}, {0,3,16,28}, {1}, {2}, {0,18,23}, {0,16,28}, {5}, {0,16}, {0,16,28}, {0}, {0,3,16,20,28}, {0,4,21}, {0,16,28}, {0,13,16,27}, {0,2,17}, {1,10}, {0,4,21}, {8}, {0,10}, {}, {4,21}, {2,17,29}, {4,21}, {4,21}, {0,16}, {3,20}, {0,16,28}, {0,16,23}, {0,5,25}, {0,16}, {0,6,16}, {2,17}, {2,8,17,23}, {1,2,10,11,15,17,27}, {2,8,17,23}, {2,17,21}, {2,10,17}, {1,13,15,17,27}, {0,15,16,27}, {0,16}, {0}, {1}, {1,10,18}, {1,14}, {0,16}, {28}, {1,18,23}, {0,7,16,25}, {0,16}, {0}, {3,9,12,19,20,23}, {0,5,16}, {0,16}, {3,12}, {3,11,12,20}, {0,15,16,27}, {2}, {2}, {0,16,25}, {0,16}, {0,16}, {0,16}, {0,16}, {0,3,11,12,20}, {5,16}, {0,1,23}, {0,15,16,27}, {0,16}, {3,11,20}, {0,16}, {1,23}, {0,16}, {0,16}, {}, {0,16}, {0,3,16,20}, {}, {}, {0,2,11,17}, {3,11,12}, {0,5,16}, {4,21}, {0,16,23}, {0,16}, {1,10,18}, {1,18}, {1,18}, {1}, {1}, {1,18,23}, {1,18}, {2,17}, {2,16,17}, {2,8,17,23}, {0,16,25}, {0,16}, {5,16}, {3,11,20}, {1,12,18}, {0,16}, {3,5,11}, {5,23}, {0,13,16,28}, {0,16,28}, {0,16,28}, {0,16,23,28}, {0,3,16,20,28,30}, {0,3,16,20,28}, {0,20,28}, {0,5,10,16}, {0,13,28}, {0,16,28,30}, {0,16,28}, {0,3,28}, {0}, {0,16,28}, {0,3,11,28}, {0,13,16,28}, {0,16,28}, {0,16,28}, {0,6}, {0,18,23}, {0,18,23}, {0,18,23}, {1,5,18}, {0,5,6}, {0,16}, {1,18}, {1}, {0,16}, {0,3,6,20}, {}, {0,10}, {0,1}, {1}, {1,9,18}, {0}, {0,16}, {0,16}, {0,16}, {0,16}, {0,16}, {0}, {0,16}, {0,16}, {0,16}, {0,16}, {0,16}, {0,16}, {3,20}, {0,16}, {0,4,21}, {0,17}, {0,16}, {0,5,9,16}, {0,16}, {0,16}, {0,16}, {0,13,16,28}, {0,5,16}, {0,16,28}, {0}, {0}, {0,16}, {4}, {}, {}, {0,16}, {0,16}, {4,21}, {0,4,16}, {0,4,16,21}, {0,4,16,21}, {0,4,16,21}, {0,16,30}, {1,23}, {1,23}, {2,17}, {2,11,17}, {2,8,17,27}, {2,17}, {2,8,13,17}, {2,8,17}, {2,11,17}, {2,17}, {1}, {1,5,18}, {1,16,29}, {0}, {0,16}, {0,16,23}, {0,16,25}, {2,8,17}, {2,8,15,17,27}, {1,14,18}, {1,16,23}, {0,16}, {0,16}, {3,20,28}, {0,28}, {0,10,16,23,29}, {4,21,28}, {0,13,16,28}, {0,13,16,28}, {0,16,25}, {0,16,25}, {0,16}, {0,16}, {2,8,17,23}, {0,9,12,16}, {1,14,18,28}, {0,16}, {0,4,16}, {0,16}, {1,10}, {0,16}, {0,7,16}, {0,16}, {1,16,18}, {0}, {0,16,23}, {1,16,23}, {0,16,28}, {0,10,28}, {0,18,23}, {4,21}, {0,5,13,28}, {0,5,16}, {0,4,21,28}, {0,3,16,20}, {0,16}, {0,16}, {0,16}, {0,16,23}, {1}, {0,16,23}, {0,16}, {3,20}, {4,21}, {0,16}, {1,5,18}, {1,18,23,28}, {0,28}, {0,5,18}, {0,18,23}, {0,16,21}, {3,12,20}, {3,11,20}, {0,16}, {0,3,16,20}, {3,20}, {4,21}, {1}, {4,21}, {1,16,18}, {3,28}, {0}, {0,23}, {3,11,20}, {0,16}, {0,1,23}, {4,21}, {1,5}, {1,16,23}, {0,13,16,28}, {0,23}, {2,8,17}, {}, {0,13,16,28}, {0,3,16,20}, {0,16,25}, {3,20}, {1,16,18}, {0,28}, {0,16}, {0,23}, {2,8,17,23}, {1,15,18,23,27,29}, {0,16}, {3,20}, {3,12,20}, {0,16}, {0,8,16,23}, {0,16}, {0,16}, {0,10,16}, {0,16}, {0,16}, {5,16}, {1,12,18,20,23}, {0,16}, {0,16}, {0,16}, {2,8,10,17,27}, {2,8,10,17}, {0,16}, {0,16}, {0,16}, {0,16}, {0,16}, {3,20}, {0,16}, {4,21}, {0,16,23}, {0,16}, {0,16}, {3,12,20,28}, {0,16}, {0,16,28}, {0,16,28}, {1,18,28}, {0,16,28}, {}, {1,3,9,11,12,18}, {0,18,23}, {3,4,18}, {0,18,23}, {1}, {1,30}, {0,18}, {0,18}, {1,18,25}, {}, {0,1,10,18}, {1,18}, {1,11,18}, {0,18,23,29}, {5,18}, {4,21}, {0,28}, {0,13,28}, {0,11,16}, {0,14,16,23}, {0,16}, {0,11,12,16}, {0,16}, {3,4}, {4,21}, {5,18}, {5}, {0,16}, {11,12,16,20}, {0,7,16}, {1,18,23}, {0,16}Line truncated
+1
View File
@@ -80,6 +80,7 @@ local game = Game()
refID = spinnedID
if refID > 0 and refID < 4294960000 then
EID:appendToDescription(descObj, "{{Collectible"..refID.."}}")
if EID.itemUnlockStates[refID] == false then EID:appendToDescription(descObj, "?") end
if i ~= EID.Config["SpindownDiceResults"] then
EID:appendToDescription(descObj, " ->")
end
+46 -21
View File
@@ -491,6 +491,51 @@ if MCMLoaded then
}
)
-- Spindown Dice results
local diceSteps = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
MCM.AddSetting(
"EID",
"Display",
{
Type = ModConfigMenu.OptionType.SCROLL,
CurrentSetting = function()
return AnIndexOf(diceSteps, EID.Config["SpindownDiceResults"]) - 1
end,
Display = function()
return "Spindown Dice: $scroll" ..
AnIndexOf(diceSteps, EID.Config["SpindownDiceResults"]) - 1 .. " " .. EID.Config["SpindownDiceResults"] .. " Items"
end,
OnChange = function(currentNum)
EID.Config["SpindownDiceResults"] = diceSteps[currentNum%#diceSteps + 1]
end,
Info = {"Preview of Items resulting when using the Spindown dice X times"}
}
)
--
-- Spindown Dice skip locked items
MCM.AddSetting(
"EID",
"Display",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["SpindownDiceSkipLocked"]
end,
Display = function()
local onOff = "False"
if EID.Config["SpindownDiceSkipLocked"] then
onOff = "True"
end
return "Skip Locked Items: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["SpindownDiceSkipLocked"] = currentBool
end,
Info = {"Skip locked items in the preview just as the dice will; the method to check for unlock status is not perfect, though"}
}
)
--------Obstruction---------
MCM.AddSpace("EID", "Display")
MCM.AddText("EID", "Display", "Display Infos when obstructed")
@@ -647,26 +692,6 @@ if MCMLoaded then
}
)
-- Spindown Dice results
local diceSteps = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
MCM.AddSetting(
"EID",
"Display",
{
Type = ModConfigMenu.OptionType.SCROLL,
CurrentSetting = function()
return AnIndexOf(diceSteps, EID.Config["SpindownDiceResults"]) - 1
end,
Display = function()
return "Spindown Dice: $scroll" ..
AnIndexOf(diceSteps, EID.Config["SpindownDiceResults"]) - 1 .. " " .. EID.Config["SpindownDiceResults"] .. " Items"
end,
OnChange = function(currentNum)
EID.Config["SpindownDiceResults"] = diceSteps[currentNum%#diceSteps + 1]
end,
Info = {"Preview of Items resulting when using the Spindown dice X times"}
}
)
MCM.AddSpace("EID", "Display")
MCM.AddText("EID", "Display", "Interaction with 'Options?'")
@@ -1051,7 +1076,7 @@ if MCMLoaded then
OnChange = function(currentBool)
EID.Config["BagOfCraftingDisplayBreakfast"] = currentBool
end,
Info = {"Recipes for locked items turn into Breakfast, filling the list with essentially useless recipes"}
Info = {"Recipes for locked items turn into Breakfast, cluttering the list; the method to check for unlock status is not perfect, though"}
}
)