@@ -151,7 +151,7 @@ local CompareTabClass = newClass("CompareTab", "ControlHost", "Control", functio
151151
152152 -- Compare power report state
153153 self .comparePowerStat = nil -- selected data.powerStatList entry
154- self .comparePowerCategories = { treeNodes = true , items = true , gems = true , config = true }
154+ self .comparePowerCategories = { treeNodes = true , items = true , skillGems = true , supportGems = true , config = true }
155155 self .comparePowerResults = nil -- sorted list of result entries
156156 self .comparePowerCoroutine = nil -- active coroutine
157157 self .comparePowerProgress = 0 -- 0-100
@@ -735,13 +735,20 @@ function CompareTabClass:InitControls()
735735 self .controls .comparePowerItemsCheck .shown = powerReportShown
736736 self .controls .comparePowerItemsCheck .state = true
737737
738- self .controls .comparePowerGemsCheck = new (" CheckBoxControl" , nil , {0 , 0 , 18 }, " Gems :" , function (state )
739- self .comparePowerCategories .gems = state
738+ self .controls .comparePowerGemsCheck = new (" CheckBoxControl" , nil , {0 , 0 , 18 }, " Skill gems :" , function (state )
739+ self .comparePowerCategories .skillGems = state
740740 self .comparePowerDirty = true
741- end , " Include skill gem groups from compared build" )
741+ end , " Include skill gem groups unique to compared build" )
742742 self .controls .comparePowerGemsCheck .shown = powerReportShown
743743 self .controls .comparePowerGemsCheck .state = true
744744
745+ self .controls .comparePowerSupportGemsCheck = new (" CheckBoxControl" , nil , {0 , 0 , 18 }, " Support gems:" , function (state )
746+ self .comparePowerCategories .supportGems = state
747+ self .comparePowerDirty = true
748+ end , " Include support gems from compared build's active skill" )
749+ self .controls .comparePowerSupportGemsCheck .shown = powerReportShown
750+ self .controls .comparePowerSupportGemsCheck .state = true
751+
745752 self .controls .comparePowerConfigCheck = new (" CheckBoxControl" , nil , {0 , 0 , 18 }, " Config:" , function (state )
746753 self .comparePowerCategories .config = state
747754 self .comparePowerDirty = true
@@ -2317,6 +2324,14 @@ function CompareTabClass:CalculatePowerStat(selection, output, calcBase)
23172324 return withValue - baseValue
23182325end
23192326
2327+ -- Resolve the granted effect for a gem instance
2328+ function CompareTabClass :GetGemGrantedEffect (gem )
2329+ if gem .gemData and gem .gemData .grantedEffect then
2330+ return gem .gemData .grantedEffect
2331+ end
2332+ return gem .grantedEffect
2333+ end
2334+
23202335-- Build a signature string for a socket group (sorted gem names)
23212336function CompareTabClass :GetSocketGroupSignature (group )
23222337 local names = {}
@@ -2414,10 +2429,34 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
24142429 end
24152430 end
24162431 end
2417- if categories .gems then
2432+ if categories .skillGems then
24182433 local cGroups = compareEntry .skillsTab and compareEntry .skillsTab .socketGroupList or {}
24192434 total = total + # cGroups
24202435 end
2436+ if categories .supportGems then
2437+ local cMainGroup = compareEntry .skillsTab and compareEntry .skillsTab .socketGroupList [compareEntry .mainSocketGroup ]
2438+ local pMainGroup = self .primaryBuild .skillsTab and self .primaryBuild .skillsTab .socketGroupList [self .primaryBuild .mainSocketGroup ]
2439+ if cMainGroup and pMainGroup then
2440+ -- Count support gems in compared build's main group not in primary's main group
2441+ local pSupportNames = {}
2442+ for _ , gem in ipairs (pMainGroup .gemList or {}) do
2443+ local ge = self :GetGemGrantedEffect (gem )
2444+ if ge and ge .support then
2445+ local name = ge .name or gem .nameSpec
2446+ if name then pSupportNames [name ] = true end
2447+ end
2448+ end
2449+ for _ , gem in ipairs (cMainGroup .gemList or {}) do
2450+ local ge = self :GetGemGrantedEffect (gem )
2451+ if ge and ge .support then
2452+ local name = ge .name or gem .nameSpec
2453+ if name and not pSupportNames [name ] then
2454+ total = total + 1
2455+ end
2456+ end
2457+ end
2458+ end
2459+ end
24212460 if categories .config then
24222461 local pInput = self .primaryBuild .configTab .input or {}
24232462 local cInput = compareEntry .configTab .input or {}
@@ -2660,7 +2699,7 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26602699 -- ==========================================
26612700 -- Skill Gems (socket groups)
26622701 -- ==========================================
2663- if categories .gems then
2702+ if categories .skillGems then
26642703 local cGroups = compareEntry .skillsTab and compareEntry .skillsTab .socketGroupList or {}
26652704 local pGroups = self .primaryBuild .skillsTab and self .primaryBuild .skillsTab .socketGroupList or {}
26662705
@@ -2678,7 +2717,9 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26782717 self .primaryBuild .buildFlag = true
26792718
26802719 -- Get a fresh calculator with the added group (pcall to guarantee cleanup)
2681- local ok , gemCalcFunc , gemCalcBase = pcall (self .calcs .getMiscCalculator , self .calcs , self .primaryBuild )
2720+ local ok , gemCalcFunc , gemCalcBase = pcall (function ()
2721+ return self .calcs .getMiscCalculator (self .primaryBuild )
2722+ end )
26822723
26832724 -- Always remove the temporarily added group
26842725 t_remove (pGroups )
@@ -2693,7 +2734,7 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26932734 local label = self :GetSocketGroupLabel (cGroup )
26942735
26952736 t_insert (results , {
2696- category = " Gem " ,
2737+ category = " Skill gem " ,
26972738 categoryColor = colorCodes .GEM ,
26982739 nameColor = colorCodes .GEM ,
26992740 name = label ,
@@ -2716,6 +2757,87 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
27162757 end
27172758 end
27182759
2760+ -- ==========================================
2761+ -- Support Gems (from compared build's active skill)
2762+ -- ==========================================
2763+ if categories .supportGems then
2764+ local cMainGroup = compareEntry .skillsTab and compareEntry .skillsTab .socketGroupList [compareEntry .mainSocketGroup ]
2765+ local pMainGroup = self .primaryBuild .skillsTab and self .primaryBuild .skillsTab .socketGroupList [self .primaryBuild .mainSocketGroup ]
2766+
2767+ if cMainGroup and pMainGroup then
2768+ -- Collect support gem names already in primary build's main group
2769+ local pSupportNames = {}
2770+ for _ , gem in ipairs (pMainGroup .gemList or {}) do
2771+ local ge = self :GetGemGrantedEffect (gem )
2772+ if ge and ge .support then
2773+ local name = ge .name or gem .nameSpec
2774+ if name then pSupportNames [name ] = true end
2775+ end
2776+ end
2777+
2778+ for _ , cGem in ipairs (cMainGroup .gemList or {}) do
2779+ local cGrantedEffect = self :GetGemGrantedEffect (cGem )
2780+ if cGrantedEffect and cGrantedEffect .support then
2781+ local name = cGrantedEffect .name or cGem .nameSpec
2782+ if name and not pSupportNames [name ] then
2783+ -- Create a temporary copy of this support gem
2784+ local tempGem = {
2785+ nameSpec = cGem .nameSpec ,
2786+ level = cGem .level ,
2787+ quality = cGem .quality ,
2788+ qualityId = cGem .qualityId ,
2789+ enabled = cGem .enabled ,
2790+ grantedEffect = cGem .grantedEffect ,
2791+ gemData = cGem .gemData ,
2792+ count = cGem .count ,
2793+ enableGlobal1 = cGem .enableGlobal1 ,
2794+ enableGlobal2 = cGem .enableGlobal2 ,
2795+ }
2796+
2797+ -- Temporarily add to primary build's main socket group
2798+ t_insert (pMainGroup .gemList , tempGem )
2799+ self .primaryBuild .buildFlag = true
2800+
2801+ local ok , sgCalcFunc , sgCalcBase = pcall (function ()
2802+ return self .calcs .getMiscCalculator (self .primaryBuild )
2803+ end )
2804+
2805+ -- Always remove the temporarily added gem
2806+ t_remove (pMainGroup .gemList )
2807+ self .primaryBuild .buildFlag = true
2808+
2809+ if not ok then
2810+ ConPrintf (" Compare power (support gem): %s" , tostring (sgCalcFunc ))
2811+ else
2812+ local impact = self :CalculatePowerStat (powerStat , sgCalcBase , calcBase )
2813+ local impactStr , impactVal , combinedImpactStr , impactPercent = formatImpact (impact )
2814+
2815+ t_insert (results , {
2816+ category = " Support gem" ,
2817+ categoryColor = colorCodes .GEM ,
2818+ nameColor = colorCodes .GEM ,
2819+ name = name ,
2820+ impact = impactVal ,
2821+ impactStr = impactStr ,
2822+ impactPercent = impactPercent ,
2823+ combinedImpactStr = combinedImpactStr ,
2824+ pathDist = nil ,
2825+ perPoint = nil ,
2826+ perPointStr = nil ,
2827+ })
2828+ end
2829+ processed = processed + 1
2830+ if coroutine.running () and GetTime () - start > 100 then
2831+ self .comparePowerProgress = m_floor (processed / total * 100 )
2832+ coroutine.yield ()
2833+ start = GetTime ()
2834+ end
2835+ end
2836+ end
2837+ end
2838+ end
2839+ end
2840+
27192841 -- ==========================================
27202842 -- Config Options
27212843 -- ==========================================
@@ -2926,6 +3048,10 @@ function CompareTabClass:DrawSummary(vp, compareEntry)
29263048 self .controls .comparePowerGemsCheck .y = controlY
29273049 checkX = checkX + self .controls .comparePowerGemsCheck .labelWidth + 26
29283050
3051+ self .controls .comparePowerSupportGemsCheck .x = checkX + self .controls .comparePowerSupportGemsCheck .labelWidth
3052+ self .controls .comparePowerSupportGemsCheck .y = controlY
3053+ checkX = checkX + self .controls .comparePowerSupportGemsCheck .labelWidth + 26
3054+
29293055 self .controls .comparePowerConfigCheck .x = checkX + self .controls .comparePowerConfigCheck .labelWidth
29303056 self .controls .comparePowerConfigCheck .y = controlY
29313057
0 commit comments