diff --git a/spec/System/TestAttacks_spec.lua b/spec/System/TestAttacks_spec.lua index d7671bb009..4009d2616f 100644 --- a/spec/System/TestAttacks_spec.lua +++ b/spec/System/TestAttacks_spec.lua @@ -150,6 +150,61 @@ describe("TestAttacks", function() assert.is_nil(player.weaponData2.asThoughUsing) end) + local function useSkill(skill, hollowPalm) + build.skillsTab:PasteSocketGroup(skill) + build.mainSocketGroup = 1 + if hollowPalm then + build.configTab.input.customMods = "Hollow Palm Technique" + build.configTab:BuildModList() + end + runCallback("OnFrame") + build.calcsTab:BuildOutput() + runCallback("OnFrame") + return build.calcsTab.mainEnv.player.mainSkill + end + + it("prevents using skills that can be used Unarmed but not with a Claw", function() + -- Smite can be used Unarmed, but not with a Claw + local mainSkill = useSkill("Smite 20/0 1") + assert.is_falsy(mainSkill.skillFlags.disable) + + newBuild() + equipHide() + mainSkill = useSkill("Smite 20/0 1") + assert.is_true(mainSkill.skillFlags.disable) + end) + + it("dual wields Claw skills with Hollow Palm Technique", function() + equipHide() + local mainSkill = useSkill("Cobra Lash 20/0 1", true) + assert.is_falsy(mainSkill.skillFlags.disable) + assert.is_true(mainSkill.skillFlags.bothWeaponAttack) + assert.is_true(bit.band(mainSkill.weapon2Flags, ModFlag.Unarmed) > 0) + assert.is_true(build.calcsTab.mainOutput.OffHand.AverageHit > 0) + end) + + it("dual wields Spectral Throw with Hollow Palm Technique", function() + -- Spectral Throw can be used with a Claw, but not Unarmed (#10516) + equipHide() + local mainSkill = useSkill("Spectral Throw 20/0 1", true) + assert.is_falsy(mainSkill.skillFlags.disable) + assert.is_true(mainSkill.skillFlags.bothWeaponAttack) + assert.is_true(build.calcsTab.mainOutput.OffHand.AverageHit > 0) + end) + + it("still attacks with both hands using skills that can be used Unarmed with Hollow Palm Technique", function() + equipHide() + local mainSkill = useSkill("Cyclone 20/0 1", true) + assert.is_falsy(mainSkill.skillFlags.disable) + assert.is_true(mainSkill.skillFlags.bothWeaponAttack) + end) + + it("does not allow dual wield only skills with Hollow Palm Technique", function() + equipHide() + local mainSkill = useSkill("Dual Strike 20/0 1", true) + assert.is_true(mainSkill.skillFlags.disable) + end) + it("gains attack speed if you've used a movement skill recently", function() equipHide("20% increased Attack Speed if you've used an Attack Movement Skill Recently") useFrostBlades() diff --git a/spec/System/TestDancingDervish_spec.lua b/spec/System/TestDancingDervish_spec.lua new file mode 100644 index 0000000000..2538b8e03d --- /dev/null +++ b/spec/System/TestDancingDervish_spec.lua @@ -0,0 +1,319 @@ +describe("TestDancingDervish", function() + local dancingDervish = [[ + Rarity: UNIQUE + The Dancing Dervish + Reaver Sword + Implicits: 1 + 60% increased Global Accuracy Rating + 150% increased Physical Damage + 25% increased Attack Speed + 5% increased Movement Speed + Triggers Level 15 Manifest Dancing Dervishes on Rampage + Manifested Dancing Dervishes disables both weapon slots + Manifested Dancing Dervishes die when Rampage ends + Melee Hits count as Rampage Kills + Rampage + ]] + + before_each(function() + newBuild() + end) + + teardown(function() + -- newBuild() takes care of resetting everything in setup() + end) + + local function rebuild() + build.buildFlag = true + runCallback("OnFrame") + build.calcsTab:BuildOutput() + runCallback("OnFrame") + end + + local function equip(raw, slotName) + build.itemsTab:CreateDisplayItemFromRaw(raw) + local item = build.itemsTab.displayItem + build.itemsTab:AddDisplayItem() + if slotName then + build.itemsTab.slots[slotName]:SetSelItemId(item.id) + build.buildFlag = true + end + runCallback("OnFrame") + end + + local function setCustomMods(mods) + build.configTab.input.customMods = mods + build.configTab:BuildModList() + rebuild() + end + + local function findManifestGroup() + for _, group in ipairs(build.skillsTab.socketGroupList) do + if group.source and group.gemList[1] and group.gemList[1].skillId == "ManifestDancingDervishes" then + return group + end + end + end + + -- Equips The Dancing Dervish and uses the given skill as the main skill + -- Returns the socket group of the granted Manifest Dancing Dervishes skill + local function setup(skill) + build.skillsTab:PasteSocketGroup(skill) + runCallback("OnFrame") + equip(dancingDervish) + build.mainSocketGroup = 1 + rebuild() + return findManifestGroup() + end + + local function setManifested(dervishGroup, manifested) + dervishGroup.enabled = manifested + rebuild() + end + + local function player() + return build.calcsTab.mainEnv.player + end + + it("does not apply the weapon's modifiers while the Dancing Dervishes are manifested", function() + local dervishGroup = setup("Cyclone 20/0 1") + assert.is_true(player().weaponsDisabled) + assert.are.equals(0, player().modDB:Sum("INC", nil, "Accuracy")) + -- Only Onslaught's Movement Speed applies + assert.are.equals(20, player().modDB:Sum("INC", nil, "MovementSpeed")) + + setManifested(dervishGroup, false) + assert.is_false(player().weaponsDisabled) + assert.are.equals(60, player().modDB:Sum("INC", nil, "Accuracy")) + assert.are.equals(5, player().modDB:Sum("INC", nil, "MovementSpeed")) + end) + + it("lets the Dancing Dervishes use the weapon while it's disabled for the player", function() + local dervishGroup = setup("Cyclone 20/0 1") + for index, group in ipairs(build.skillsTab.socketGroupList) do + if group == dervishGroup then + build.mainSocketGroup = index + end + end + rebuild() + local env = build.calcsTab.mainEnv + assert.is_true(player().weaponsDisabled) + assert.are.equals("None", player().weaponData1.type) + assert.is_nil(player().itemList["Weapon 1"]) + assert.are.equals(player().disabledItemList["Weapon 1"].weaponData[1], env.minion.weaponData1) + assert.are.equals("Two Handed Sword", env.minion.weaponData1.type) + assert.is_true(build.calcsTab.mainOutput.Minion.TotalDPS > 0) + end) + + it("disables skills socketed in the weapon while the Dancing Dervishes are manifested, but not its supports", function() + local dervishGroup = setup("Cyclone 20/0 1") + build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nHatred 20/0 1\nMinion Damage 20/0 1") + -- Frost Blades can't be used unarmed, so the weapon checks would disable it as well + build.skillsTab:PasteSocketGroup("Slot: Weapon 1\nFrost Blades 20/0 1") + rebuild() + assert.is_true(player().mainSkill.activeEffect.grantedEffect.name == "Cyclone") + local hatred, frostBlades, dervishes + for _, activeSkill in ipairs(player().activeSkillList) do + if activeSkill.activeEffect.grantedEffect.name == "Hatred" then + hatred = activeSkill + elseif activeSkill.activeEffect.grantedEffect.name == "Frost Blades" then + frostBlades = activeSkill + elseif activeSkill.activeEffect.grantedEffect.id == "ManifestDancingDervishes" then + dervishes = activeSkill + end + end + assert.is_true(hatred.skillFlags.disable) + assert.are.equals("This skill is socketed in a disabled weapon", hatred.disableReason) + assert.is_true(frostBlades.skillFlags.disable) + assert.are.equals("This skill is socketed in a disabled weapon", frostBlades.disableReason) + assert.is_nil(player().modDB.conditions["AffectedByHatred"]) + assert.is_falsy(dervishes.skillFlags.disable) + local supportedByMinionDamage = false + for _, effect in ipairs(dervishes.effectList) do + if effect.grantedEffect.name == "Minion Damage" then + supportedByMinionDamage = true + end + end + assert.is_true(supportedByMinionDamage) + + setManifested(dervishGroup, false) + assert.is_true(player().modDB.conditions["AffectedByHatred"]) + end) + + it("keeps Rampage while the Dancing Dervishes are manifested", function() + setup("Cyclone 20/0 1") + assert.is_true(player().weaponsDisabled) + assert.is_true(player().modDB:Flag(nil, "Condition:Rampage")) + end) + + it("makes attacks unarmed while the Dancing Dervishes are manifested", function() + local dervishGroup = setup("Cyclone 20/0 1") + local mainSkill = player().mainSkill + local conditions = player().modDB.conditions + assert.are.equals("None", player().weaponData1.type) + assert.is_true(bit.band(mainSkill.weapon1Flags, ModFlag.Unarmed) > 0) + assert.are.equals(0, bit.band(mainSkill.weapon1Flags, bit.bor(ModFlag.Sword, ModFlag.Weapon))) + assert.is_true(conditions["Unarmed"]) + assert.is_true(conditions["Unencumbered"]) + assert.is_nil(conditions["UsingSword"]) + assert.is_nil(conditions["UsingTwoHandedWeapon"]) + assert.is_nil(conditions["UsingMeleeWeapon"]) + + setManifested(dervishGroup, false) + mainSkill = player().mainSkill + conditions = player().modDB.conditions + assert.are.equals("Two Handed Sword", player().weaponData1.type) + assert.are.equals(0, bit.band(mainSkill.weapon1Flags, ModFlag.Unarmed)) + assert.is_true(bit.band(mainSkill.weapon1Flags, ModFlag.Sword) > 0) + assert.is_nil(conditions["Unarmed"]) + assert.is_true(conditions["UsingSword"]) + assert.is_true(conditions["UsingTwoHandedWeapon"]) + end) + + it("dual wields unarmed with Hollow Palm Technique while the Dancing Dervishes are manifested", function() + local dervishGroup = setup("Cyclone 20/0 1") + setCustomMods("Hollow Palm Technique") + assert.are.equals("None", player().weaponData2.type) + assert.is_true(player().modDB.conditions["DualWielding"]) + assert.is_true(bit.band(player().mainSkill.weapon2Flags, ModFlag.Unarmed) > 0) + assert.is_not_nil(build.calcsTab.mainOutput.OffHand) + + setManifested(dervishGroup, false) + assert.is_nil(player().weaponData2.type) + assert.is_nil(player().modDB.conditions["DualWielding"]) + end) + + it("only applies main hand modifiers to the main hand with Hollow Palm Technique", function() + setup("Cyclone 20/0 1") + setCustomMods("Hollow Palm Technique") + local mainHandHit = build.calcsTab.mainOutput.MainHand.AverageHit + local offHandHit = build.calcsTab.mainOutput.OffHand.AverageHit + assert.is_true(offHandHit > 0) + + -- Ambidexterity + setCustomMods("Hollow Palm Technique\n60% increased Attack Damage with Main Hand while Dual Wielding") + assert.is_true(build.calcsTab.mainOutput.MainHand.AverageHit > mainHandHit) + assert.are.equals(offHandHit, build.calcsTab.mainOutput.OffHand.AverageHit) + end) + + it("lets Hide of the Vendigo attack as though using a Claw while the Dancing Dervishes are manifested", function() + -- Frost Blades requires a Claw, Dagger or One Handed Sword + local dervishGroup = setup("Frost Blades 20/0 1") + assert.is_true(player().mainSkill.skillFlags.disable) + + equip([[ + Rarity: UNIQUE + Test Subject + Exquisite Leather + Can Attack as though using a Claw while main hand is empty + ]]) + rebuild() + assert.is_true(player().weaponData1.asThoughUsing["Claw"]) + assert.is_falsy(player().mainSkill.skillFlags.disable) + assert.is_true(bit.band(player().mainSkill.weapon1Flags, ModFlag.Unarmed) > 0) + + -- The main hand isn't empty while the Dancing Dervishes aren't manifested + setManifested(dervishGroup, false) + assert.is_nil(player().weaponData1.asThoughUsing) + assert.is_true(bit.band(player().mainSkill.weapon1Flags, ModFlag.Sword) > 0) + end) + + it("does not let Battlemage use the disabled weapon's damage", function() + build.skillsTab:PasteSocketGroup("Fireball 20/0 1") + runCallback("OnFrame") + setCustomMods("Battlemage") + local unarmedHit = build.calcsTab.mainOutput.AverageHit + + equip(dancingDervish) + build.mainSocketGroup = 1 + rebuild() + assert.is_true(player().weaponsDisabled) + assert.are.equals(unarmedHit, build.calcsTab.mainOutput.AverageHit) + end) + + it("does not let Spellblade use the disabled weapon's damage", function() + build.skillsTab:PasteSocketGroup("Fireball 20/0 1\nSpellblade 20/0 1") + runCallback("OnFrame") + rebuild() + local unarmedHit = build.calcsTab.mainOutput.AverageHit + + equip(dancingDervish) + build.mainSocketGroup = 1 + rebuild() + assert.is_true(player().weaponsDisabled) + assert.are.equals(unarmedHit, build.calcsTab.mainOutput.AverageHit) + end) + + it("disables the weapon slots as soon as The Dancing Dervish is equipped", function() + build.skillsTab:PasteSocketGroup("Cyclone 20/0 1") + runCallback("OnFrame") + -- The socket group of the granted skill doesn't exist yet when the items are processed + equip(dancingDervish) + assert.is_true(player().weaponsDisabled) + assert.is_nil(player().itemList["Weapon 1"]) + assert.are.equals("None", player().weaponData1.type) + end) + + it("does not disable a weapon that's compared against The Dancing Dervish", function() + setup("Cyclone 20/0 1") + local sword = new("Item"):Item("Rarity: RARE\nTest Sword\nRusted Sword\nImplicits: 0\n10% increased Fire Damage") + local env = build.calcsTab.calcs.initEnv(build, "CALCULATOR", { repSlotName = "Weapon 1", repItem = sword }) + assert.is_false(env.player.weaponsDisabled) + assert.are.equals(sword, env.player.itemList["Weapon 1"]) + assert.are.equals(10, env.modDB:Sum("INC", nil, "FireDamage")) + end) + + it("keeps the requirements of the disabled weapon", function() + setup("Cyclone 20/0 1") + assert.is_true(player().weaponsDisabled) + local weaponRequirement + for _, requirement in ipairs(build.calcsTab.mainEnv.requirementsTable) do + if requirement.sourceSlot == "Weapon 1" then + weaponRequirement = requirement + end + end + assert.are.equals(player().disabledItemList["Weapon 1"], weaponRequirement.sourceItem) + assert.is_true(weaponRequirement.Str > 0) + end) + + it("does not let Energy Blade replace the disabled weapons", function() + local dervishGroup = setup("Cyclone 20/0 1") + build.skillsTab:PasteSocketGroup("Energy Blade 20/0 1") + rebuild() + assert.is_true(player().weaponsDisabled) + assert.is_nil(player().itemList["Weapon 1"]) + assert.are.equals("None", player().weaponData1.type) + assert.is_true(bit.band(player().mainSkill.weapon1Flags, ModFlag.Unarmed) > 0) + + setManifested(dervishGroup, false) + assert.are.equals("Energy Blade Two Handed", player().itemList["Weapon 1"].baseName) + assert.are.equals(0, bit.band(player().mainSkill.weapon1Flags, ModFlag.Unarmed)) + end) + + it("only disables the weapon slots while The Dancing Dervish is in the active weapon set", function() + build.skillsTab:PasteSocketGroup("Cyclone 20/0 1") + runCallback("OnFrame") + equip([[ + Rarity: RARE + Test Sword + Rusted Sword + Implicits: 0 + 10% increased Fire Damage + ]], "Weapon 1") + equip(dancingDervish, "Weapon 1 Swap") + build.mainSocketGroup = 1 + rebuild() + assert.is_false(player().weaponsDisabled) + assert.are.equals("Test Sword", player().itemList["Weapon 1"].title) + assert.are.equals(10, player().modDB:Sum("INC", nil, "FireDamage")) + assert.are.equals(0, player().modDB:Sum("INC", nil, "Accuracy")) + + build.itemsTab.activeItemSet.useSecondWeaponSet = true + rebuild() + assert.is_true(player().weaponsDisabled) + assert.is_nil(player().itemList["Weapon 1"]) + assert.are.equals("The Dancing Dervish", player().disabledItemList["Weapon 1"].title) + assert.are.equals(0, player().modDB:Sum("INC", nil, "FireDamage")) + assert.are.equals(0, player().modDB:Sum("INC", nil, "Accuracy")) + end) +end) diff --git a/src/Modules/CalcActiveSkill.lua b/src/Modules/CalcActiveSkill.lua index aa84385487..8584256930 100644 --- a/src/Modules/CalcActiveSkill.lua +++ b/src/Modules/CalcActiveSkill.lua @@ -216,9 +216,14 @@ local function getWeaponFlags(env, weaponData, weaponTypes) end if weaponTypes then for _, types in ipairs(weaponTypes) do - if not types[weaponData.type] and - (not weaponData.countsAsAll1H or not (types["Claw"] or types["Dagger"] or types["One Handed Axe"] or types["One Handed Mace"] or types["One Handed Sword"])) - and not checkAsThoughWeaponTypes(weaponData, types) then + if weaponData.asThoughUsing then + -- Only the weapon types it attacks as though using determine which skills can be used + -- e.g. Hide of the Vendigo allows Claw skills, but not skills that can only be used Unarmed + if not checkAsThoughWeaponTypes(weaponData, types) then + return nil, info + end + elseif not types[weaponData.type] and + (not weaponData.countsAsAll1H or not (types["Claw"] or types["Dagger"] or types["One Handed Axe"] or types["One Handed Mace"] or types["One Handed Sword"])) then return nil, info end end @@ -342,6 +347,11 @@ function calcs.buildActiveSkillModList(env, activeSkill) end if not skillFlags.forceMainHand then local weapon2Flags, weapon2Info = getWeaponFlags(env, activeSkill.actor.weaponData2, weaponTypes) + if not weapon2Flags and weapon1Flags and activeSkill.actor.weaponData1.asThoughUsing and activeSkill.actor.weaponData2.type == "None" and not skillTypes[SkillType.DualWieldOnly] then + -- Hide of the Vendigo only affects which skills can be used, which depends on the main hand alone + -- Once a skill can be used, the unarmed off hand from Hollow Palm Technique attacks with it as well + weapon2Flags, weapon2Info = getWeaponFlags(env, activeSkill.actor.weaponData2) + end if weapon2Flags then if skillTypes[SkillType.DualWieldRequiresDifferentTypes] and (activeSkill.actor.weaponData1.type == activeSkill.actor.weaponData2.type) and not (activeSkill.actor.weaponData2.countsAsAll1H or activeSkill.actor.weaponData1.countsAsAll1H) then -- Skill requires a different compatible off hand weapon to main hand weapon @@ -365,6 +375,18 @@ function calcs.buildActiveSkillModList(env, activeSkill) end end + -- Checked after the weapon flags so the reason isn't overwritten by the weapon checks + local socketGroup = activeSkill.socketGroup + if activeSkill.actor.weaponsDisabled and socketGroup and socketGroup.slot and socketGroup.slotEnabled and not calcs.grantedEffectDisablesWeapons(activeGrantedEffect) then + local slotName = socketGroup.slot:gsub(" Swap", "") + if slotName == "Weapon 1" or slotName == "Weapon 2" then + -- Skills socketed in or granted by weapons disabled by Manifested Dancing Dervishes can't be used + -- Supports socketed in them still support the skill that disables them + skillFlags.disable = true + activeSkill.disableReason = socketGroup.source and "This skill is granted by a disabled weapon" or "This skill is socketed in a disabled weapon" + end + end + -- Apply stat-map flagged skill flags. for stat, statValue in pairs(calcLib.buildSkillInstanceStats(activeEffect, activeGrantedEffect)) do local map = activeGrantedEffect.statMap[stat] @@ -789,6 +811,9 @@ function calcs.buildActiveSkillModList(env, activeSkill) if item and item.weaponData then minion.weaponData1 = item.weaponData[1] end + elseif env.player.disabledItemList["Weapon 1"] and env.player.disabledItemList["Weapon 1"].weaponData then + -- The player's weapon slots are disabled while the weapon is a minion (e.g. Manifested Dancing Dervishes) + minion.weaponData1 = env.player.disabledItemList["Weapon 1"].weaponData[1] else minion.weaponData1 = env.player.weaponData1 end @@ -799,6 +824,8 @@ function calcs.buildActiveSkillModList(env, activeSkill) if item and item.weaponData then minion.weaponData2 = item.weaponData[2] end + elseif env.player.disabledItemList["Weapon 2"] and env.player.disabledItemList["Weapon 2"].weaponData then + minion.weaponData2 = env.player.disabledItemList["Weapon 2"].weaponData[2] else minion.weaponData2 = env.player.weaponData2 end diff --git a/src/Modules/CalcPerform.lua b/src/Modules/CalcPerform.lua index 9fe4527156..5a937acc59 100644 --- a/src/Modules/CalcPerform.lua +++ b/src/Modules/CalcPerform.lua @@ -1230,7 +1230,7 @@ local function initMinionModDB(env, activeSkill, output) minion.modDB:AddList(env.player.itemList["Gloves"].modList) end end - if activeSkill.skillData.minionUseMainHandWeapon then + if activeSkill.skillData.minionUseMainHandWeapon and env.player.itemList["Weapon 1"] then minion.modDB:AddList(env.player.itemList["Weapon 1"].slotModList[1]) end if minion.itemSet or minion.uses then @@ -1243,7 +1243,8 @@ local function initMinionModDB(env, activeSkill, output) end item = env.build.itemsTab.items[minion.itemSet[slotName].selItemId] else - item = env.player.itemList[slotName] + -- Minions can still use weapons disabled by Manifested Dancing Dervishes + item = env.player.itemList[slotName] or env.player.disabledItemList[slotName] end if item then minion.itemList[slotName] = item @@ -3524,17 +3525,6 @@ function calcs.perform(env, skipEHP) -- Merge keystones again to catch any that were added by buffs modLib.mergeKeystones(env, env.modDB) - -- Special handling for Dancing Dervish - if modDB:Flag(nil, "DisableWeapons") then - env.player.weaponData1 = copyTable(env.data.unarmedWeaponData[env.classId]) - modDB.conditions["Unarmed"] = true - if not env.player.Gloves or env.player.Gloves == "None" then - modDB.conditions["Unencumbered"] = true - end - elseif env.weaponModList1 then - modDB:AddList(env.weaponModList1) - end - -- Process prerequisites for conditionals calcs.defenceForConditionals(env, env.player) if env.minion then diff --git a/src/Modules/CalcSetup.lua b/src/Modules/CalcSetup.lua index aebfb4756d..00abdc21bd 100644 --- a/src/Modules/CalcSetup.lua +++ b/src/Modules/CalcSetup.lua @@ -17,7 +17,8 @@ local tempTable1 = { } local gemSocketColours = { "R", "G", "B" } local function getMatchingSocketQuality(env, groupCfg, gemInstance, socketIndex) - local item = groupCfg.slotName and env.player.itemList[groupCfg.slotName] + -- Supports socketed in weapons disabled by Manifested Dancing Dervishes still support the skill that disables them + local item = groupCfg.slotName and (env.player.itemList[groupCfg.slotName] or env.player.disabledItemList[groupCfg.slotName]) local sockets = item and item.sockets if not sockets then return 0 @@ -371,9 +372,8 @@ function wipeEnv(env, accelerate) if env.theIronMass then wipeTable(env.theIronMass) end - if env.weaponModList1 then - wipeTable(env.weaponModList1) - end + -- Weapons disabled by Manifested Dancing Dervishes + wipeTable(env.player.disabledItemList) -- Requirements from Items (Str, Dex, Int) wipeTable(env.requirementsTableItems) @@ -394,6 +394,62 @@ function wipeEnv(env, accelerate) end end +local function itemGrantsSkill(item, skillId) + for _, grantedSkill in ipairs(item.grantedSkills or { }) do + if grantedSkill.skillId == skillId then + return true + end + end + return false +end + +-- Check if a skill's buff disables the weapon slots (e.g. Manifest Dancing Dervishes) +function calcs.grantedEffectDisablesWeapons(grantedEffect) + for _, mod in ipairs(grantedEffect.baseMods or { }) do + if mod.name == "DisableWeapons" then + return true + end + end + return false +end + +local function setMainSocketGroup(env, build) + if env.mode == "CALCS" then + env.calcsInput.skill_number = m_min(m_max(#build.skillsTab.socketGroupList, 1), env.calcsInput.skill_number or 1) + env.mainSocketGroup = env.calcsInput.skill_number + else + build.mainSocketGroup = m_min(m_max(#build.skillsTab.socketGroupList, 1), build.mainSocketGroup or 1) + env.mainSocketGroup = build.mainSocketGroup + end +end + +-- Check if an active socket group has a skill whose buff disables the weapon slots +-- This mirrors the checks used when creating the active skills, as it's needed before the items are processed +local function socketGroupsDisableWeapons(env, build, override) + if not env.mode_buffs then + return false + end + for index, group in ipairs(build.skillsTab.socketGroupList) do + local slot = group.slot and build.itemsTab.slots[group.slot] + local slotEnabled = not slot or not slot.weaponSet or slot.weaponSet == (build.itemsTab.activeItemSet.useSecondWeaponSet and 2 or 1) + -- Ignore skills granted by an item that's being replaced, e.g. when comparing weapons with The Dancing Dervish equipped + local sourceReplaced = group.sourceItem and group.slot == override.repSlotName and group.sourceItem ~= override.repItem + if not sourceReplaced and (index == env.mainSocketGroup or (group.enabled and slotEnabled)) then + for _, gemInstance in ipairs(group.gemList) do + if gemInstance.enabled then + local grantedEffectList = gemInstance.gemData and gemInstance.gemData.grantedEffectList or { gemInstance.grantedEffect } + for effectIndex, grantedEffect in ipairs(grantedEffectList) do + if not grantedEffect.support and not grantedEffect.unsupported and (not grantedEffect.hasGlobalEffect or gemInstance["enableGlobal"..effectIndex]) and calcs.grantedEffectDisablesWeapons(grantedEffect) then + return true + end + end + end + end + end + end + return false +end + local function applyGemMods(effect, modList) for _, mod in ipairs(modList) do local match = true @@ -546,6 +602,7 @@ function calcs.initEnv(build, mode, override, specEnv) env.radiusJewelList = wipeTable(env.radiusJewelList) env.extraRadiusNodeList = wipeTable(env.extraRadiusNodeList) env.player.itemList = { } + env.player.disabledItemList = { } env.grantedSkills = { } env.grantedSkillsNodes = { } env.grantedSkillsItems = { } @@ -810,6 +867,11 @@ function calcs.initEnv(build, mode, override, specEnv) -- Build and merge item modifiers, and create list of radius jewels if not accelerate.requirementsItems then + -- Manifested Dancing Dervishes disable both weapon slots while their buff is active + -- This is checked before the items are processed, so the disabled weapons can be left out + setMainSocketGroup(env, build) + env.player.weaponsDisabled = socketGroupsDisableWeapons(env, build, override) + local items = {} local jewelLimits = {} for _, slot in ipairs(build.itemsTab.orderedSlots) do @@ -1081,6 +1143,29 @@ function calcs.initEnv(build, mode, override, specEnv) end item = nil end + if item and env.player.weaponsDisabled and (slotName == "Weapon 1" or slotName == "Weapon 2") then + -- Weapons disabled by Manifested Dancing Dervishes count as unequipped, but their requirements still need to be met + env.player.disabledItemList[slotName] = item + if item.requirements then + t_insert(env.requirementsTableItems, { + source = "Item", + sourceItem = item, + sourceSlot = slotName, + Str = item.requirements.strMod, + Dex = item.requirements.dexMod, + Int = item.requirements.intMod, + }) + end + if itemGrantsSkill(item, "ManifestDancingDervishes") then + -- Rampage is kept as the Dancing Dervishes die when it ends + for _, mod in ipairs(item.modList or (item.slotModList and item.slotModList[slot.slotNum]) or { }) do + if mod.name == "Condition:Rampage" then + env.itemModDB:AddMod(mod) + end + end + end + item = nil + end local scale = 1 if item and item.type == "Jewel" and item.base.subType == "Abyss" and slot.parentSlot then -- Check if the item in the parent slot has enough Abyssal Sockets @@ -1201,24 +1286,6 @@ function calcs.initEnv(build, mode, override, specEnv) -- Add all the stats to player as well env.itemModDB:ScaleAddMod(mod, scale) end - elseif slotName == "Weapon 1" and item.grantedSkills[1] and item.grantedSkills[1].skillId == "UniqueAnimateWeapon" then - -- Special handling for The Dancing Dervish - env.weaponModList1 = new("ModList"):ModList() - for _, mod in ipairs(srcList) do - -- Filter out mods that apply to socketed gems, or which add supports - local add = true - for _, tag in ipairs(mod) do - if tag.type == "SocketedIn" then - add = false - break - end - end - if add then - env.weaponModList1:ScaleAddMod(mod, scale) - else - env.itemModDB:ScaleAddMod(mod, scale) - end - end elseif item.name:match("Kalandra's Touch") then local otherRing = items[(slotName == "Ring 1" and "Ring 2") or (slotName == "Ring 2" and "Ring 1")] if otherRing and not otherRing.name:match("Kalandra's Touch") then @@ -1619,6 +1686,17 @@ function calcs.initEnv(build, mode, override, specEnv) end end + -- Determine main skill group + setMainSocketGroup(env, build) + + -- The weapon slots were handled before the item-granted skill groups above were updated + -- Recalculate if that changed whether they're disabled, e.g. when The Dancing Dervish was just equipped + if not accelerate.requirementsItems and not override.weaponsDisabledRechecked and socketGroupsDisableWeapons(env, build, override) ~= env.player.weaponsDisabled then + override = copyTable(override, true) + override.weaponsDisabledRechecked = true + return calcs.initEnv(build, mode, override, specEnv) + end + -- Get the weapon data tables for the equipped weapons env.player.weaponData1 = env.player.itemList["Weapon 1"] and env.player.itemList["Weapon 1"].weaponData and env.player.itemList["Weapon 1"].weaponData[1] or copyTable(env.data.unarmedWeaponData[env.classId]) -- Hide of the Vendigo: Can Attack as though using a Claw while main hand is empty @@ -1642,15 +1720,6 @@ function calcs.initEnv(build, mode, override, specEnv) env.player.weaponData2 = env.player.itemList["Weapon 2"].weaponData and env.player.itemList["Weapon 2"].weaponData[2] or { } end - -- Determine main skill group - if env.mode == "CALCS" then - env.calcsInput.skill_number = m_min(m_max(#build.skillsTab.socketGroupList, 1), env.calcsInput.skill_number or 1) - env.mainSocketGroup = env.calcsInput.skill_number - else - build.mainSocketGroup = m_min(m_max(#build.skillsTab.socketGroupList, 1), build.mainSocketGroup or 1) - env.mainSocketGroup = build.mainSocketGroup - end - -- Process supports and put them into the correct buckets env.crossLinkedSupportGroups = {} for _, mod in ipairs(env.modDB:Tabulate("LIST", nil, "LinkedSupport")) do