Merge pull request #169 from Buurazu/patch-1

Bag of Crafting + Spindown Dice locked items check tweaks
This commit is contained in:
wofsauge authored and GitHub committed 2021-10-20 17:57:36 +02:00
commit 780e0335bd
6 files changed
+174 -70

No files matched your search

+54 -29
View File
@@ -755,14 +755,31 @@ 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 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
return newID
end
function EID:GetMaxCollectibleID()
local id = CollectibleType.NUM_COLLECTIBLES-1
local step = 16
while step > 0 do
if Isaac.GetItemConfig():GetCollectible(id+step) ~= nil then
id = id + step
else
step = step // 2
end
end
return id
end
local maxCollectibleID = nil
function EID:isCollectibleUnlocked(collectibleID, itemPoolOfItem)
local itemPool = Game():GetItemPool()
local itemConfig = Isaac.GetItemConfig()
for i= 1, GetMaxCollectibleID() do
--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
itemPool:AddRoomBlacklist(i)
end
@@ -782,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
@@ -822,20 +847,20 @@ end
-- Converts a given table into a string containing the crafting icons of the table, which are also grouped to reduce render lag
-- Example input: {1,1,1,2,2,3,3,3}
-- Result: "3{{Crafting3}}2{{Crafting2}}3{{Crafting1}}"
local emptyPickupTable = {}
for i=1,25 do emptyPickupTable[i] = 0 end
function EID:tableToCraftingIconsMerged(craftTable)
local sortedList = {table.unpack(craftTable)}
table.sort(sortedList, function(a, b) return a > b end)
local filteredList = {}
local filteredList = {table.unpack(emptyPickupTable)}
for _,nr in ipairs(sortedList) do
if filteredList[nr] == nil then
filteredList[nr] = 1
else
filteredList[nr] = filteredList[nr] +1
end
filteredList[nr] = filteredList[nr] +1
end
local iconString = ""
for nr,count in pairs(filteredList) do
iconString = iconString..count.."{{Crafting"..nr.."}}"
for nr,count in ipairs(filteredList) do
if (count > 0) then
iconString = iconString..count.."{{Crafting"..nr.."}}"
end
end
return iconString
end
+17 -16
View File
@@ -511,24 +511,11 @@ EID.refreshNextTick = false
EID.downHeld = 0
EID.upHeld = 0
local function GetMaxCollectibleID()
local id = CollectibleType.NUM_COLLECTIBLES-1
local step = 16
while step > 0 do
if Isaac.GetItemConfig():GetCollectible(id+step) ~= nil then
id = id + step
else
step = step // 2
end
end
return id
end
local maxItemID = nil
local function detectModdedItems()
if maxItemID == nil then
maxItemID = GetMaxCollectibleID()
maxItemID = EID:GetMaxCollectibleID()
end
if maxItemID > CollectibleType.NUM_COLLECTIBLES then
local customDescObj = EID:getDescriptionObj(5, 100, 710)
@@ -683,7 +670,13 @@ function EID:handleBagOfCraftingRendering()
for k, v in pairs(randResults) do
local resultID = EID:calculateBagOfCrafting(v)
if resultID > 0 then
table.insert(calcResults, {v, resultID})
if (not EID:isCollectibleUnlockedAnyPool(resultID)) then
if (EID.Config["BagOfCraftingDisplayBreakfast"]) then
table.insert(calcResults, {v, resultID, 25})
end
else
table.insert(calcResults, {v, resultID})
end
end
end
randResultCache[queryString] = calcResults
@@ -784,8 +777,13 @@ function EID:handleBagOfCraftingRendering()
for i=EID.bagOfCraftingOffset+1,EID.bagOfCraftingOffset+EID.Config["BagOfCraftingResults"] do
local v = results[i]
if (not v) then break end
if (not EID.Config["BagOfCraftingDisplayNames"]) then
customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} " .. " ="
customDescObj.Description = customDescObj.Description.."# {{Collectible"..v[2].."}} "
--tack on Breakfast image to locked recipes
if (v[3]) then customDescObj.Description = customDescObj.Description.."{{Collectible25}}" end
--color the equals sign with the item quality, so the order of the list can make sense
customDescObj.Description = customDescObj.Description.. qualities[EID.itemWeightsLookup[v[2]]] .. "={{CR}}"
--only display the item name if it's the first occurrence
else
if (prevItem ~= v[2]) then
@@ -795,7 +793,10 @@ function EID:handleBagOfCraftingRendering()
else
customDescObj.Description = customDescObj.Description.."#"
end
--replace recipe bulletpoint with Breakfast on locked recipes
if (v[3]) then customDescObj.Description = customDescObj.Description.." {{Collectible25}} " end
end
customDescObj.Description = customDescObj.Description..EID:tableToCraftingIconsMerged(v[1])
prevItem = v[2]
end
+15 -5
View File
@@ -176,15 +176,19 @@ EID.UserConfig = {
["BagOfCraftingCombinationMax"] = 12,
-- Changes the number of random recipes calculated
-- Higher numbers will cause lag spikes on new pickup sets!
-- Default = 500
["BagOfCraftingRandomResults"] = 500,
-- Default = 400
["BagOfCraftingRandomResults"] = 400,
-- Set the keybinding to toggle the scroll feature of the bag of crafting descriptions
-- look into the AB+ or Repentance documentation for the key names here: https://wofsauge.github.io/IsaacDocs/rep/enums/ButtonAction.html
-- Default = ButtonAction.ACTION_MAP
["BagOfCraftingToggleKey"] = ButtonAction.ACTION_MAP,
-- Display craftable item names, moving the recipe to a new line
-- Default = false
["BagOfCraftingDisplayNames"] = false,
["BagOfCraftingDisplayNames"] = false,
-- Display locked item recipes, which will all turn into Breakfast
-- 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-----------
@@ -202,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,
@@ -282,10 +290,12 @@ EID.DefaultConfig = {
["DisplayBagOfCrafting"] = "always",
["BagOfCraftingResults"] = 7,
["BagOfCraftingCombinationMax"] = 12,
["BagOfCraftingRandomResults"] = 500,
["BagOfCraftingRandomResults"] = 400,
["BagOfCraftingToggleKey"] = ButtonAction.ACTION_MAP,
["BagOfCraftingDisplayNames"] = false,
["BagOfCraftingDisplayNames"] = false,
["BagOfCraftingDisplayBreakfast"] = true,
["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
+67 -20
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?'")
@@ -1031,6 +1056,28 @@ if MCMLoaded then
end,
Info = {"If on, each result takes two lines; lower your displayed results accordingly"}
}
)
-- Bag of Crafting Breakfast recipes
MCM.AddSetting(
"EID",
"Crafting",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["BagOfCraftingDisplayBreakfast"]
end,
Display = function()
local onOff = "False"
if EID.Config["BagOfCraftingDisplayBreakfast"] then
onOff = "True"
end
return "Show Locked Recipes: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["BagOfCraftingDisplayBreakfast"] = currentBool
end,
Info = {"Recipes for locked items turn into Breakfast, cluttering the list; the method to check for unlock status is not perfect, though"}
}
)
MCM.AddSpace("EID", "Crafting")