diff --git a/src/Classes/GemSelectControl.lua b/src/Classes/GemSelectControl.lua index 36028fcc8d..853db7607e 100644 --- a/src/Classes/GemSelectControl.lua +++ b/src/Classes/GemSelectControl.lua @@ -12,8 +12,9 @@ local m_max = math.max local m_floor = math.floor local toolTipText = "Prefix tag searches with a colon and exclude tags with a dash. e.g. :fire:lightning:-cold:area" +local imbuedTooltipText = "\"Socketed in\" item must be set in order to add an imbued support.\nOnly one imbued support is allowed per item." -local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip) +local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip, imbued) self.EditControl(anchor, rect, nil, nil, "^ %a':-") self.controls.scrollBar = new("ScrollBarControl", { "TOPRIGHT", self, "TOPRIGHT" }, {-1, 0, 18, 0}, (self.height - 4) * 4) self.controls.scrollBar.y = function() @@ -50,6 +51,7 @@ local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self lifeReservationFlat = "Life", lifeReservationPercent = "LifePercent", } + self.imbuedSelect = imbued end) function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS) @@ -74,7 +76,7 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS) -- Create gemInstance to represent the hovered gem local gemInstance = gemList[self.index] - gemInstance.level = self.skillsTab:ProcessGemLevel(gemData) + gemInstance.level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect) gemInstance.gemData = gemData gemInstance.displayEffect = nil -- Calculate the impact of using this gem @@ -105,12 +107,19 @@ function GemSelectClass:PopulateGemList() if (self.sortGemsBy and gemData.tags[self.sortGemsBy] == true or not self.sortGemsBy) then local levelRequirement = gemData.grantedEffect.levels[1].levelRequirement or 1 if characterLevel >= levelRequirement or not matchLevel then - if (showExceptional or showAll) and ((gemData.grantedEffect.legacy and gemData.grantedEffect.plusVersionOf) or gemData.tagString:match("Exceptional")) then - if self.skillsTab.showLegacyGems or not gemData.grantedEffect.legacy then + if self.imbuedSelect then + -- Imbued dropdown only allows non-exceptional support gems. + if gemData.grantedEffect.support and not gemData.tagString:match("Exceptional") and not gemData.grantedEffect.plusVersionOf then + self.gems["Default:" .. gemId] = gemData + end + else + if (showExceptional or showAll) and ((gemData.grantedEffect.legacy and gemData.grantedEffect.plusVersionOf) or gemData.tagString:match("Exceptional")) then + if self.skillsTab.showLegacyGems or not gemData.grantedEffect.legacy then + self.gems["Default:" .. gemId] = gemData + end + elseif showNormal or showAll then self.gems["Default:" .. gemId] = gemData end - elseif showNormal or showAll then - self.gems["Default:" .. gemId] = gemData end end end @@ -123,6 +132,11 @@ function GemSelectClass:FilterSupport(gemId, gemData) if gemData.grantedEffect.legacy and not self.skillsTab.showLegacyGems then return false end + + if self.imbuedSelect then + return gemData.grantedEffect.support and not gemData.tagString:match("Exceptional") and self.sortCache.canSupport[gemId] + end + return (not gemData.grantedEffect.support or showSupportTypes == "ALL" or (showSupportTypes == "NORMAL" and not (isLegacyAwakened or gemData.tagString:match("Exceptional"))) @@ -273,7 +287,7 @@ function GemSelectClass:UpdateSortCache() for gemId, gemData in pairs(self.gems) do if gemData.grantedEffect.support then for _, activeSkill in ipairs(self.skillsTab.displayGroup.displaySkillList) do - if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then + if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then sortCache.canSupport[gemId] = true break end @@ -288,7 +302,7 @@ function GemSelectClass:UpdateSortCache() for gemId, gemData in pairs(self.gems) do if gemData.grantedEffect.support then for _, activeSkill in ipairs(group.displaySkillList) do - if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then + if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then sortCache.canSupport[gemId] = true break end @@ -301,7 +315,7 @@ function GemSelectClass:UpdateSortCache() for gemId, gemData in pairs(self.gems) do if gemData.grantedEffect.support then for _, activeSkill in ipairs(group.displaySkillList) do - if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill) then + if calcLib.canGrantedEffectSupportActiveSkill(gemData.grantedEffect, activeSkill, self.imbuedSelect) then sortCache.canSupport[gemId] = true break end @@ -468,7 +482,7 @@ function GemSelectClass:Draw(viewPort, noTooltip) local gemData = self.gems[self.list[self.hoverSel]] local output= self:CalcOutputWithThisGem(calcFunc, gemData, self.skillsTab.sortGemsByDPSField == "FullDPS") local gemInstance = { - level = self.skillsTab:ProcessGemLevel(gemData), + level = self.skillsTab:ProcessGemLevel(gemData, self.imbuedSelect), quality = self.skillsTab.defaultGemQuality or 0, count = 1, enabled = true, @@ -508,41 +522,55 @@ function GemSelectClass:Draw(viewPort, noTooltip) local gemInstance = self.skillsTab.displayGroup.gemList[self.index] local cursorX, cursorY = GetCursorPos() self.tooltip:Clear() + + if hoverControl and hoverControl.imbuedSelect then -- tooltip for imbued + gemInstance = { } + if type(hoverControl.gemId) == "string" then -- on select + gemInstance["gemData"] = hoverControl.gems[hoverControl.gemId] + else -- on load + gemInstance["gemData"] = hoverControl.gemId + end + gemInstance.level = 1 + gemInstance.quality = 0 + end + if gemInstance and gemInstance.gemData then self:AddGemTooltip(gemInstance) else - self.tooltip:AddLine(16, toolTipText) - end + self.tooltip:AddLine(16, self.imbuedSelect and imbuedTooltipText or toolTipText) + end + + if not self.imbuedSelect then + colorS = 0.5 + colorA = 0.5 + if cursorX > (x + width - 18) then + colorS = 1 + self.tooltip:Clear() + self.tooltip:AddLine(16, "Only show Support gems") + elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then + colorA = 1 + self.tooltip:Clear() + self.tooltip:AddLine(16, "Only show Active gems") + end - colorS = 0.5 - colorA = 0.5 - if cursorX > (x + width - 18) then - colorS = 1 - self.tooltip:Clear() - self.tooltip:AddLine(16, "Only show Support gems") - elseif (cursorX > (x + width - 40) and cursorX < (cursorX + width - 20)) then - colorA = 1 - self.tooltip:Clear() - self.tooltip:AddLine(16, "Only show Active gems") - end - - -- support shortcut - sx = x + width - 16 - 2 - SetDrawColor(colorS,colorS,colorS) - DrawImage(nil, sx, y+2, 16, height-4) - SetDrawColor(0,0,0) - DrawImage(nil, sx+1, y+2, 16-2, height-4) - SetDrawColor(colorS,colorS,colorS) - DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "S") - - -- active shortcut - sx = x + width - (16*2) - (2*2) - SetDrawColor(colorA,colorA,colorA) - DrawImage(nil, sx, y+2, 16, height-4) - SetDrawColor(0,0,0) - DrawImage(nil, sx+1, y+2, 16-2, height-4) - SetDrawColor(colorA,colorA,colorA) - DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "A") + -- support shortcut + sx = x + width - 16 - 2 + SetDrawColor(colorS,colorS,colorS) + DrawImage(nil, sx, y+2, 16, height-4) + SetDrawColor(0,0,0) + DrawImage(nil, sx+1, y+2, 16-2, height-4) + SetDrawColor(colorS,colorS,colorS) + DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "S") + + -- active shortcut + sx = x + width - (16*2) - (2*2) + SetDrawColor(colorA,colorA,colorA) + DrawImage(nil, sx, y+2, 16, height-4) + SetDrawColor(0,0,0) + DrawImage(nil, sx+1, y+2, 16-2, height-4) + SetDrawColor(colorA,colorA,colorA) + DrawString(sx + 8, y, "CENTER_X", height - 2, "VAR", "A") + end SetDrawLayer(nil, 10) self.tooltip:Draw(x, y, width, height, viewPort) @@ -738,7 +766,7 @@ function GemSelectClass:OnFocusGained() self:UpdateSortCache() self:BuildList("") for index, gemId in pairs(self.list) do - if self.gems[gemId].name == self.buf then + if self.gems[gemId] and self.gems[gemId].name == self.buf then self.selIndex = index self:ScrollSelIntoView() break @@ -768,7 +796,7 @@ function GemSelectClass:OnKeyDown(key, doubleClick) local width, height = self:GetSize() local cursorX, cursorY = GetCursorPos() -- constrain cursor to the height of the control - if key == "LEFTBUTTON" and (cursorY > y and cursorY < (y + height)) then + if not self.imbuedSelect and key == "LEFTBUTTON" and (cursorY > y and cursorY < (y + height)) then -- no need to constrain right side of the S overlay as that's outside hover if cursorX > (x + width - 18) then self.sortGemsBy = "support" -- only need to change sortBy, code will continue to UpdateSortCache @@ -880,4 +908,4 @@ function GemSelectClass:OnKeyUp(key) end local newSel = self.EditControl:OnKeyUp(key) return newSel == self.EditControl and self or newSel -end \ No newline at end of file +end diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 2c0461200f..9975a98ebc 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -758,6 +758,7 @@ function ImportTabClass:ImportItemsAndSkills(json) end end wipeTable(self.build.skillsTab.socketGroupList) + self.build.skillsTab:RebuildImbuedSupportBySlot() end self.charImportStatus = colorCodes.POSITIVE.."Items and skills successfully imported." --ConPrintTable(charItemData) @@ -1148,6 +1149,10 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName) else t_insert(socketGroup.gemList, gemInstance) end + if socketedItem.builtInSupport then + socketGroup.imbuedSupport = socketedItem.builtInSupport:gsub("Supported by Level 1 ", "") + self.build.skillsTab.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, slotName) + end end end end diff --git a/src/Classes/SkillListControl.lua b/src/Classes/SkillListControl.lua index ff645e2302..dddea6f9a9 100644 --- a/src/Classes/SkillListControl.lua +++ b/src/Classes/SkillListControl.lua @@ -39,6 +39,7 @@ local SkillListClass = newClass("SkillListControl", "ListControl", function(self self.controls.deleteAll = new("ButtonControl", {"RIGHT",self.controls.delete,"LEFT"}, {-4, 0, 70, 18}, "Delete All", function() main:OpenConfirmPopup("Delete All", "Are you sure you want to delete all socket groups in this build?", "Delete", function() wipeTable(self.list) + skillsTab:RebuildImbuedSupportBySlot() skillsTab:SetDisplayGroup() skillsTab:AddUndoState() skillsTab.build.buildFlag = true @@ -165,6 +166,7 @@ function SkillListClass:OnSelDelete(index, socketGroup) main:OpenMessagePopup("Delete Socket Group", "This socket group cannot be deleted as it is created by an equipped item.") elseif not socketGroup.gemList[1] then t_remove(self.list, index) + self.skillsTab:RebuildImbuedSupportBySlot() if self.skillsTab.displayGroup == socketGroup then self.skillsTab.displayGroup = nil end @@ -175,6 +177,7 @@ function SkillListClass:OnSelDelete(index, socketGroup) else main:OpenConfirmPopup("Delete Socket Group", "Are you sure you want to delete '"..socketGroup.displayLabel.."'?", "Delete", function() t_remove(self.list, index) + self.skillsTab:RebuildImbuedSupportBySlot() if self.skillsTab.displayGroup == socketGroup then self.skillsTab:SetDisplayGroup() end diff --git a/src/Classes/SkillsTab.lua b/src/Classes/SkillsTab.lua index 88b5bcbb43..ea65069bc5 100644 --- a/src/Classes/SkillsTab.lua +++ b/src/Classes/SkillsTab.lua @@ -166,6 +166,18 @@ local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Cont end) self.controls.groupSlotLabel = new("LabelControl", { "TOPLEFT", self.anchorGroupDetail, "TOPLEFT" }, { 0, 30, 0, 16 }, "^7Socketed in:") self.controls.groupSlot = new("DropDownControl", { "TOPLEFT", self.anchorGroupDetail, "TOPLEFT" }, { 85, 28, 130, 20 }, groupSlotDropList, function(index, value) + -- maintain imbued support to new slot + if self.imbuedSupportBySlot[self.displayGroup.slot] and self.displayGroup.imbuedSupport then + if value.slotName and not self.imbuedSupportBySlot[value.slotName] then + self.imbuedSupportBySlot[value.slotName] = copyTable(self.imbuedSupportBySlot[self.displayGroup.slot], true) + else + self.controls.imbuedSupport.gemId = nil + self.controls.imbuedSupport:SetText("") + self.displayGroup.imbuedSupport = nil -- reset saved support to None + end + self.imbuedSupportBySlot[self.displayGroup.slot] = nil + end + self.displayGroup.slot = value.slotName self:AddUndoState() self.build.buildFlag = true @@ -198,6 +210,56 @@ local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Cont self:AddUndoState() self.build.buildFlag = true end) + + -- self.imbuedSupportBySlot is used by CalcSetup to add an ExtraSupport mod of the selected gem + -- Each displayGroup has its own "imbuedSupport" and is saved to the xml to load when changing sockets or loading a build + -- "slotName" is used on import, which uses builtInSupport to get the gemData and pass in here + -- buildFlag to true triggers the reload/run the CalcSetup to add on the support + -- the last var in the GemSelectControl init, the true, sets imbuedSelect to true which sets the level to 1 and support filtering + self.imbuedSupportBySlot = { } + self.controls.imbuedSupportLabel = new("LabelControl", { "LEFT", self.controls.groupSlotLabel, "LEFT" }, { 86, 28, 0, 16 }, colorCodes.CRAFTED.."Imbued Support:") + self.controls.imbuedSupport = new("GemSelectControl", { "LEFT", self.controls.imbuedSupportLabel, "RIGHT" }, { 8, 0, 250, 20 }, self, 1, function(gemData, _, _, slotName) -- slotName used on Import + local targetSlot = slotName or (self.displayGroup and self.displayGroup.slot) + if not targetSlot then + return + end + local updateDisplayGroup = self.displayGroup and targetSlot == self.displayGroup.slot + if gemData and (type(gemData) == "string" or gemData.id) then + local gem = data.gems[gemData.id or gemData] + self.imbuedSupportBySlot[targetSlot] = gem.grantedEffect + if updateDisplayGroup then + self.displayGroup.imbuedSupport = gem.name + end + self.controls.imbuedSupport.inactiveCol = data.skillColorMap[gem.grantedEffect.color] + self.build.buildFlag = true + else + self.imbuedSupportBySlot[targetSlot] = nil + if updateDisplayGroup then + self.displayGroup.imbuedSupport = nil + end + end + end, true, true) + local function isImbuedEnabled() -- socketedIn must be set and the displayGroup must have an imbued, otherwise disable the imbued dropdown + return (self.displayGroup and self.displayGroup.slot and ((self.imbuedSupportBySlot[self.displayGroup.slot] and self.displayGroup.imbuedSupport) or not self.imbuedSupportBySlot[self.displayGroup.slot])) + end + self.controls.imbuedSupport.enabled = function() + return isImbuedEnabled() + end + self.controls.imbuedSupportLabel.shown = function() -- don't show imbued for skills from items + return not self.displayGroup.source + end + self.controls.imbuedSupportClear = new("ButtonControl", { "LEFT", self.controls.imbuedSupportLabel, "RIGHT" }, { 260, 0, 20, 20}, "x", function() + self.controls.imbuedSupport.gemId = nil + self.controls.imbuedSupport:SetText("") + self.displayGroup.imbuedSupport = nil + self.imbuedSupportBySlot[self.displayGroup.slot] = nil + self.build.buildFlag = true + end) + self.controls.imbuedSupportClear.enabled = function() + return isImbuedEnabled() + end + self.controls.imbuedSupportClear.tooltipText = "Remove this imbued support." + self.controls.groupCountLabel = new("LabelControl", { "LEFT", self.controls.includeInFullDPS, "RIGHT" }, { 16, 0, 0, 16 }, "Count:") self.controls.groupCountLabel.shown = function() return self.displayGroup.source ~= nil @@ -256,7 +318,7 @@ will automatically apply to the skill.]] self:SetActiveSkillSet(1) -- Skill gem slots - self.anchorGemSlots = new("Control", {"TOPLEFT",self.anchorGroupDetail,"TOPLEFT"}, {0, 28 + 28 + 16, 0, 0}) + self.anchorGemSlots = new("Control", {"TOPLEFT",self.anchorGroupDetail,"TOPLEFT"}, {0, 28 + 28 + 16 + 28, 0, 0}) self.gemSlots = { } self:CreateGemSlot(1) self.controls.gemNameHeader = new("LabelControl", {"BOTTOMLEFT", self.gemSlots[1].nameSpec, "TOPLEFT"}, {0, -2, 0, 16}, "^7Gem name:") @@ -282,6 +344,11 @@ function SkillsTabClass:LoadSkill(node, skillSetId) socketGroup.mainActiveSkill = tonumber(node.attrib.mainActiveSkill) or 1 socketGroup.mainActiveSkillCalcs = tonumber(node.attrib.mainActiveSkillCalcs) or 1 socketGroup.gemList = { } + if node.attrib.imbuedSupport and node.attrib.slot then + socketGroup.imbuedSupport = node.attrib.imbuedSupport + self.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, socketGroup.slot) + end + for _, child in ipairs(node) do local gemInstance = { } gemInstance.nameSpec = sanitiseText(child.attrib.nameSpec or "") @@ -419,6 +486,7 @@ function SkillsTabClass:Save(xml) source = socketGroup.source, mainActiveSkill = tostring(socketGroup.mainActiveSkill), mainActiveSkillCalcs = tostring(socketGroup.mainActiveSkillCalcs), + imbuedSupport = socketGroup.imbuedSupport and tostring(socketGroup.imbuedSupport), } } for _, gemInstance in ipairs(socketGroup.gemList) do t_insert(node, { elem = "Gem", attrib = { @@ -461,7 +529,7 @@ function SkillsTabClass:Draw(viewPort, inputEvents) self.controls.scrollBarH.y = viewPort.y + viewPort.height - 18 do - local maxX = self.controls.gemCountHeader:GetPos() + self.controls.gemCountHeader:GetSize() + 15 + local maxX = self.controls.gemCountHeader:GetPos() + self.controls.gemCountHeader:GetSize() + 350 local contentWidth = maxX - self.x self.controls.scrollBarH:SetContentDimension(contentWidth, viewPort.width) end @@ -562,6 +630,13 @@ function SkillsTabClass:PasteSocketGroup(testInput) end end +-- the imbued support control actively switches to the latest count of the current displayGroup's gemList so we can use the canSupport filtering +local function updateImbuedSupportIndex(control, gemListCount) + if gemListCount > 0 then + control.index = gemListCount + 1 + end +end + -- Create the controls for editing the gem at a given index function SkillsTabClass:CreateGemSlot(index) local slot = { } @@ -581,6 +656,7 @@ function SkillsTabClass:CreateGemSlot(index) self.gemSlots[index2].enableGlobal2.state = gemInstance.enableGlobal2 self.gemSlots[index2].count:SetText(gemInstance.count or 1) end + updateImbuedSupportIndex(self.controls.imbuedSupport, #self.displayGroup.gemList) self:AddUndoState() self.build.buildFlag = true end) @@ -929,10 +1005,12 @@ function SkillsTabClass:FindSkillGem(nameSpec) return "Unrecognised gem name '" .. nameSpec .. "'" end -function SkillsTabClass:ProcessGemLevel(gemData) +function SkillsTabClass:ProcessGemLevel(gemData, imbued) local grantedEffect = gemData.grantedEffect local naturalMaxLevel = gemData.naturalMaxLevel - if self.defaultGemLevel == "awakenedMaximum" then + if imbued or self.defaultGemLevel == "levelOne" then + return 1 + elseif self.defaultGemLevel == "awakenedMaximum" then return naturalMaxLevel + 1 elseif self.defaultGemLevel == "corruptedMaximum" then if grantedEffect.plusVersionOf then @@ -942,8 +1020,6 @@ function SkillsTabClass:ProcessGemLevel(gemData) end elseif self.defaultGemLevel == "normalMaximum" then return naturalMaxLevel - elseif self.defaultGemLevel == "levelOne" then - return 1 else -- self.defaultGemLevel == "characterLevel" local maxGemLevel = naturalMaxLevel if not grantedEffect.levels[maxGemLevel] then @@ -1033,6 +1109,7 @@ function SkillsTabClass:ProcessSocketGroup(socketGroup) end end end + updateImbuedSupportIndex(self.controls.imbuedSupport, #socketGroup.gemList) end -- Set the skill to be displayed/edited @@ -1047,6 +1124,15 @@ function SkillsTabClass:SetDisplayGroup(socketGroup) self.controls.groupEnabled.state = socketGroup.enabled self.controls.includeInFullDPS.state = socketGroup.includeInFullDPS and socketGroup.enabled self.controls.groupCount:SetText(socketGroup.groupCount or 1) + if socketGroup.imbuedSupport then + local gemId = data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]] + self.controls.imbuedSupport.gemId = gemId + self.controls.imbuedSupport:SetText(socketGroup.imbuedSupport) + self.controls.imbuedSupport.inactiveCol = data.skillColorMap[gemId.grantedEffect.color] + else + self.controls.imbuedSupport.gemId = nil + self.controls.imbuedSupport:SetText("") + end -- Update the gem slot controls self:UpdateGemSlots() @@ -1216,6 +1302,19 @@ function SkillsTabClass:NewSkillSet(skillSetId) return skillSet end +function SkillsTabClass:RebuildImbuedSupportBySlot() + wipeTable(self.imbuedSupportBySlot) + for _, socketGroup in ipairs(self.socketGroupList) do + if socketGroup.slot and socketGroup.imbuedSupport then + local gemId = data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"] + local gem = gemId and data.gems[gemId] + if gem and gem.grantedEffect then + self.imbuedSupportBySlot[socketGroup.slot] = gem.grantedEffect + end + end + end +end + -- Changes the active skill set function SkillsTabClass:SetActiveSkillSet(skillSetId) -- Initialize skill sets if needed @@ -1233,6 +1332,7 @@ function SkillsTabClass:SetActiveSkillSet(skillSetId) end self.socketGroupList = self.skillSets[skillSetId].socketGroupList + self:RebuildImbuedSupportBySlot() self.controls.groupList.list = self.socketGroupList self.activeSkillSetId = skillSetId self.build.buildFlag = true diff --git a/src/Modules/CalcSetup.lua b/src/Modules/CalcSetup.lua index a8bc4ff6aa..d06899d7e8 100644 --- a/src/Modules/CalcSetup.lua +++ b/src/Modules/CalcSetup.lua @@ -1482,31 +1482,42 @@ function calcs.initEnv(build, mode, override, specEnv) t_insert(targetListList, supportLists[group]) end + local function addExtraSupports(value, grantedEffect, level) + local grantedEffect = grantedEffect or env.data.skills[value.skillId] + if value and grantedEffect then -- Only item ExtraSupport gems should be flagged as fromItem. Imbued gems do not pass this check + grantedEffect.fromItem = true + end + -- Some skill gems share the same name as support gems, e.g. Barrage. + -- Since a support gem is expected here, if the first lookup returns a skill, then + -- prepending "Support" to the skillId will find the support version of the gem. + if value and grantedEffect and not grantedEffect.support then + grantedEffect = env.data.skills["Support"..value.skillId] + grantedEffect.fromItem = true + end + if grantedEffect then + for _, targetList in ipairs(targetListList) do + t_insert(targetList, { + grantedEffect = grantedEffect, + gemData = env.data.gems[env.data.gemForBaseName[grantedEffect.name:lower()] or env.data.gemForBaseName[(grantedEffect.name .. " Support"):lower()]], + level = level or value.level, + quality = 0, + enabled = true, + }) + end + end + end + -- if not unique item that provides skills if not group.source then -- Add extra supports from the item this group is socketed in for _, value in ipairs(env.modDB:List(groupCfg, "ExtraSupport")) do - local grantedEffect = env.data.skills[value.skillId] - -- Some skill gems share the same name as support gems, e.g. Barrage. - -- Since a support gem is expected here, if the first lookup returns a skill, then - -- prepending "Support" to the skillId will find the support version of the gem. - if grantedEffect and not grantedEffect.support then - grantedEffect = env.data.skills["Support"..value.skillId] - end - grantedEffect.fromItem = true - if grantedEffect then - for _, targetList in ipairs(targetListList) do - t_insert(targetList, { - grantedEffect = grantedEffect, - gemData = env.data.gems[env.data.gemForBaseName[grantedEffect.name:lower()] or env.data.gemForBaseName[(grantedEffect.name .. " Support"):lower()]], - level = value.level, - quality = 0, - enabled = true, - }) - end - end + addExtraSupports(value) end end + -- if the slot has an imbued support, add it as an ExtraSupport + if build.skillsTab.imbuedSupportBySlot and build.skillsTab.imbuedSupportBySlot[slotName] and group.imbuedSupport then + addExtraSupports(nil, build.skillsTab.imbuedSupportBySlot[slotName], 1) + end for gemIndex, gemInstance in ipairs(group.gemList) do -- Add support gems from this group diff --git a/src/Modules/CalcTools.lua b/src/Modules/CalcTools.lua index b694c779f3..48b7506ba3 100644 --- a/src/Modules/CalcTools.lua +++ b/src/Modules/CalcTools.lua @@ -82,7 +82,7 @@ function calcLib.doesTypeExpressionMatch(checkTypes, skillTypes, minionTypes) end -- Check if given support skill can support the given active skill -function calcLib.canGrantedEffectSupportActiveSkill(grantedEffect, activeSkill) +function calcLib.canGrantedEffectSupportActiveSkill(grantedEffect, activeSkill, imbuedSupport) if grantedEffect.unsupported or activeSkill.activeEffect.grantedEffect.cannotBeSupported then return false end @@ -95,8 +95,15 @@ function calcLib.canGrantedEffectSupportActiveSkill(grantedEffect, activeSkill) return false end - local effectiveSkillTypes = activeSkill.summonSkill and activeSkill.summonSkill.skillTypes or activeSkill.skillTypes - local effectiveMinionTypes = not grantedEffect.ignoreMinionTypes and (activeSkill.summonSkill and activeSkill.summonSkill.minionSkillTypes or activeSkill.minionSkillTypes) + local effectiveSkillTypes + local effectiveMinionTypes + if imbuedSupport then -- Use the skillTypes from the gem so it ignores any support added types + effectiveSkillTypes = activeSkill.summonSkill and activeSkill.summonSkill.activeEffect.grantedEffect.skillTypes or activeSkill.activeEffect.grantedEffect.skillTypes + effectiveMinionTypes = not grantedEffect.ignoreMinionTypes and (activeSkill.summonSkill and activeSkill.summonSkill.activeEffect.grantedEffect.minionSkillTypes or activeSkill.activeEffect.grantedEffect.minionSkillTypes) + else + effectiveSkillTypes = activeSkill.summonSkill and activeSkill.summonSkill.skillTypes or activeSkill.skillTypes + effectiveMinionTypes = not grantedEffect.ignoreMinionTypes and (activeSkill.summonSkill and activeSkill.summonSkill.minionSkillTypes or activeSkill.minionSkillTypes) + end -- if the activeSkill is a Minion's skill like "Default Attack", use minion's skillTypes instead for exclusions -- otherwise compare support to activeSkill directly