Skip to content
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

Merged
merged 8 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 87 additions & 1 deletion src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,10 @@ function calcs.initEnv(build, mode, override, specEnv)
modDB:NewMod("Multiplier:AllocatedNotable", "BASE", allocatedNotableCount, "")
modDB:NewMod("Multiplier:AllocatedMastery", "BASE", allocatedMasteryCount, "")
modDB:NewMod("Multiplier:AllocatedMasteryType", "BASE", allocatedMasteryTypeCount, "")

-- Build and merge item modifiers, and create list of radius jewels
if not accelerate.requirementsItems then
local items = {}
for _, slot in pairs(build.itemsTab.orderedSlots) do
local slotName = slot.slotName
local item
Expand Down Expand Up @@ -638,6 +639,91 @@ function calcs.initEnv(build, mode, override, specEnv)
end
end
end
items[slotName] = item
end

if not env.configInput.ignoreItemDisablers then
local itemDisabled = {}
local unhandledItemDisablers = { size = 1}
if modDB:Flag(nil, "CanNotUseHelm") then
itemDisabled["Helmet"] = { disabled = true, size = 1 }
end
Comment on lines +648 to +650
Copy link
Member

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.

for _, slot in pairs(build.itemsTab.orderedSlots) do
local slotName = slot.slotName
if items[slotName] then
local srcList = items[slotName].modList or items[slotName].slotModList[slot.slotNum]
for _, mod in ipairs(srcList) do
-- checks if it disables another slot
for _, tag in ipairs(mod) do
if tag.type == "DisablesItem" then
unhandledItemDisablers[slotName] = unhandledItemDisablers[slotName] and unhandledItemDisablers[slotName] or {}
t_insert(unhandledItemDisablers[slotName], tag.slotName)
unhandledItemDisablers.size = unhandledItemDisablers.size + 1
itemDisabled[tag.slotName] = itemDisabled[tag.slotName] and itemDisabled[tag.slotName] or { size = 0}
itemDisabled[tag.slotName][slotName] = true
itemDisabled[tag.slotName].size = itemDisabled[tag.slotName].size + 1
break
end
end
end
end
end
while unhandledItemDisablers.size > 0 do
local stalemateBreaker = true
for slot, itemData in pairs(unhandledItemDisablers) do
if slot ~= "size" then
if not itemDisabled[slot] then
for _, slot2 in ipairs(unhandledItemDisablers[slot]) do
if unhandledItemDisablers[slot2] then
for _, slot3 in ipairs(unhandledItemDisablers[slot2]) do
itemDisabled[slot3][slot2] = nil
itemDisabled[slot3].size = itemDisabled[slot3].size - 1
if itemDisabled[slot3].size == 0 then
itemDisabled[slot3] = nil
end
end
unhandledItemDisablers[slot2] = nil
unhandledItemDisablers.size = unhandledItemDisablers.size - 1
end
end
unhandledItemDisablers[slot] = nil
unhandledItemDisablers.size = unhandledItemDisablers.size - 1
stalemateBreaker = false
end
end
end
-- if goes through an entire iteration without handling an unhandled Item Disabler, just take the first one
if stalemateBreaker then
for slot, itemData in pairs(unhandledItemDisablers) do
if slot ~= "size" then
for _, slot2 in ipairs(unhandledItemDisablers[slot]) do
if unhandledItemDisablers[slot2] then
for _, slot3 in ipairs(unhandledItemDisablers[slot2]) do
itemDisabled[slot3][slot2] = nil
itemDisabled[slot3].size = itemDisabled[slot3].size - 1
if itemDisabled[slot3].size == 0 then
itemDisabled[slot3] = nil
end
end
unhandledItemDisablers[slot2] = nil
unhandledItemDisablers.size = unhandledItemDisablers.size - 1
end
end
unhandledItemDisablers[slot] = nil
break
end
end
unhandledItemDisablers.size = unhandledItemDisablers.size - 1
end
end
for slot, _ in pairs(itemDisabled) do
items[slot] = nil
end
end

for _, slot in pairs(build.itemsTab.orderedSlots) do
local slotName = slot.slotName
local item = items[slotName]
if item and item.type == "Flask" then
if slot.active then
env.flasks[item] = true
Expand Down
1 change: 1 addition & 0 deletions src/Modules/ConfigOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ return {
{ var = "EVBypass", type = "check", label = "Disable Emperor's Vigilance Bypass", ifCond = "EVBypass", apply = function(val, modList, enemyModList)
modList:NewMod("Condition:EVBypass", "FLAG", true, "Config")
end },
{ var = "ignoreItemDisablers", type = "check", label = "Ignore Item Disablers", tooltip = "Ignore the effects of things which disable items, like bringer of rain" },

-- Section: Skill-specific options
{ section = "Skill Options", col = 2 },
Expand Down
6 changes: 6 additions & 0 deletions src/Modules/ModParser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,12 @@ local specialModList = {
["added small passive skills have (%d+)%% increased effect"] = function(num) return { mod("JewelData", "LIST", { key = "clusterJewelIncEffect", value = num }) } end,
["this jewel's socket has (%d+)%% increased effect per allocated passive skill between it and your class' starting location"] = function(num) return { mod("JewelData", "LIST", { key = "jewelIncEffectFromClassStart", value = num }) } end,
-- Misc
["can't use chest armour"] = { mod("CanNotUseBody", "Flag", 1, { type = "DisablesItem", slotName = "Body Armour" }) },
--["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
Comment on lines +3525 to +3526
Copy link
Member

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.

["can't use other rings"] = { mod("CanNotUseRightRing", "Flag", 1, { type = "DisablesItem", slotName = "Ring 2" }, { type = "SlotNumber", num = 1 }), mod("CanNotUseLeftRing", "Flag", 1, { type = "DisablesItem", slotName = "Ring 1" }, { type = "SlotNumber", num = 2 }) },
["uses both hand slots"] = { mod("CanNotUseRightWeapon", "Flag", 1, { type = "DisablesItem", slotName = "Weapon 2" }, { type = "SlotNumber", num = 1 }), mod("CanNotUseLeftWeapon", "Flag", 1, { type = "DisablesItem", slotName = "Weapon 1" }, { type = "SlotNumber", num = 2 }) },
["can't use flask in fifth slot"] = { mod("CanNotUseFifthFlask", "Flag", 1, { type = "DisablesItem", slotName = "Flask 5" }) },
["boneshatter has (%d+)%% chance to grant %+1 trauma"] = function(num) return { mod("ExtraTrauma", "BASE", num, { type = "SkillName", skillName = "Boneshatter" }) } end,
["your minimum frenzy, endurance and power charges are equal to your maximum while you are stationary"] = {
flag("MinimumFrenzyChargesIsMaximumFrenzyCharges", {type = "Condition", var = "Stationary" }),
Expand Down