-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for items that disable other item slots #5664
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but the code is a bit messy. Using itemDisabled
to create a stack of dependent items, then setting each of those slot items to nil
if they're all valid seems cleaner to me. For stalemates you'd just have to check if the item you're looking at is already in the stack.
Failing that, I think size
can be removed almost everywhere, just by looking at how you're using it.
--["can't use helmets"] = { mod("CanNotUseHelmet", "Flag", 1, { type = "DisablesItem", slotName = "Helmet" }) }, -- this one does not work due to being on a passive? | ||
["can't use helmet"] = { mod("CanNotUseHelmet", "Flag", 1, { type = "DisablesItem", slotName = "Helmet" }) }, -- this is to allow for custom mod without saying the other is parsed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should include either of these lines if it's not supported. Getting it supported would be nice for the power report, though.
if modDB:Flag(nil, "CanNotUseHelm") then | ||
itemDisabled["Helmet"] = { disabled = true, size = 1 } | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the other comment about helmets, this probably should just be removed.
Co-authored-by: Wires77 <[email protected]>
cleaned up most of it, just still have the helm mods, which I havnt removed because I personaly would use it, but agree it should be properly supported in future |
I noodled on this some more from work and made a PoC on https://www.jdoodle.com/execute-lua-online/ Play with the For this PR we'd just have to build the two tables as you have in the initial loop, then change the numbers to their slots. Finally loop through (Also these are PoC names, so feel free to change them to better suit the items) function prettyPrintTable(tbl, pre, outFile)
pre = pre or ""
local outNames = { }
for name in pairs(tbl) do
table.insert(outNames, name)
end
table.sort(outNames)
for _, name in ipairs(outNames) do
if type(tbl[name]) == "table" then
prettyPrintTable(tbl[name], pre .. name .. ".", outFile)
else
if outFile then
outFile:write(pre .. name .. " = " .. tostring(tbl[name]) .. "\n")
else
print("%s%s = %s", pre, name, tostring(tbl[name]))
end
end
end
end
local disabled = {}
local causers = {}
causers[1] = 2
causers[2] = 3
causers[3] = 4
causers[4] = 1
for num, disable in pairs(causers) do
disabled[disable] = num
end
visited = {}
trueDisabled = {}
for num, disabler in pairs(disabled) do
if not visited[num] then
-- find chain start
curChain = { num = true }
while disabled[num] do
num = disabled[num]
if curChain[num] then break end -- detect cycles
curChain[num] = true
end
repeat
visited[num] = true
num = causers[num]
if not num then break end
visited[num] = true
trueDisabled[num] = true
num = causers[num]
until(not num or visited[num])
end
end
prettyPrintTable(trueDisabled) |
Refactored algorithm for determining disabled items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go, hopefully we can include Dance with Death properly some day
…mmunity#5664) * Initial Implementation of item Disablers * fix spelling * fix spelling * update tooltip * Apply suggestions from code review Co-authored-by: Wires77 <[email protected]> * cleanup merge issues * Refactored algorithm for determining disabled items --------- Co-authored-by: Wires77 <[email protected]>
This adds support for disabling helm/body/rings/5th flask from things like bringer of rain (disables body)
supersedes #1317
"can't use helmets" isnt properly supported due to being on a passive which isnt fully processed by the time items are added, a substitute ("can't use helmet") was added, but must be applied to an item to work atm, may come up with a workaround to it