Skip to content
11 changes: 9 additions & 2 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,8 @@ function ItemsTabClass:FormatItemSource(text)
:gsub("prophecy{([^}]+)}",colorCodes.PROPHECY.."%1"..colorCodes.SOURCE)
end

function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, forceSlotOnlyTooltips, compareSlotName)
local slotOnlyTooltips = forceSlotOnlyTooltips ~= nil and forceSlotOnlyTooltips or main.slotOnlyTooltips
local fontSizeSmall = main.showFlavourText and 16 or 14
local fontSizeBig = main.showFlavourText and 18 or 16
local fontSizeTitle = main.showFlavourText and 22 or 20
Expand Down Expand Up @@ -3386,7 +3387,13 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)

-- Add comparisons for each slot
for _, compareSlot in pairs(compareSlots) do
if not main.slotOnlyTooltips or (slot and (slot.nodeId == compareSlot.nodeId or slot.slotName == compareSlot.slotName)) or not slot or slot == compareSlot then
local slotMatches = false
if compareSlotName then
slotMatches = compareSlot.slotName == compareSlotName
elseif slot then
slotMatches = (slot.nodeId and slot.nodeId == compareSlot.nodeId) or (slot.slotName and slot.slotName == compareSlot.slotName) or slot == compareSlot
end
if not slotOnlyTooltips or slotMatches or not slot then
local selItem = self.items[compareSlot.selItemId]
local output = calcFunc({ repSlotName = compareSlot.slotName, repItem = item ~= selItem and item or nil})
local header
Expand Down
28 changes: 26 additions & 2 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -959,12 +959,31 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
self.itemIndexTbl[row_idx] = self.sortedResultTbl[row_idx][index].index
self:SetFetchResultReturn(row_idx, self.itemIndexTbl[row_idx])
end)
local function getResultWeightedScore(result_index)
local sum = 0
for _, eval in ipairs(self:GetResultEvaluation(row_idx, result_index) or {}) do
sum = sum + (eval.weight or 0)
end
return sum
end
local function addStatWeightScoreBreakdownLines(tooltip, result_index)
local evaluation = self:GetResultEvaluation(row_idx, result_index)
if not (evaluation and evaluation[1] and evaluation[1].output and self.statSortSelectionList) then
return
end
local calcFunc, baseOutput = self.itemsTab.build.calcsTab:GetMiscCalculator()
for _, statWeight in ipairs(self.statSortSelectionList) do
local perStatScore = self.tradeQueryGenerator.WeightedRatioOutputs(baseOutput, evaluation[1].output, { statWeight }) * 1000
tooltip:AddLine(16, string.format("^7%s Score: %.0f", statWeight.label, perStatScore))
end
end
local function addCompareTooltip(tooltip, result_index, dbMode)
local result = self.resultTbl[row_idx][result_index]
local item = new("Item", result.item_string)
self.itemsTab:AddItemTooltip(tooltip, item, slotTbl, dbMode)
local targetSlot = slotTbl.nodeId and self.itemsTab.sockets[slotTbl.nodeId] or self.itemsTab.slots[slotTbl.slotName]
self.itemsTab:AddItemTooltip(tooltip, item, targetSlot, dbMode, true, targetSlot and targetSlot.slotName or nil)
if main.slotOnlyTooltips and slotTbl.slotName == "Megalomaniac" then
local evaluation = self.resultTbl[row_idx][result_index].evaluation
local evaluation = self:GetResultEvaluation(row_idx, result_index)
self.itemsTab.build:AddStatComparesToTooltip(tooltip, self.onlyWeightedBaseOutput[row_idx][result_index], evaluation[1].output, "^7Equipping this item will give you:")
end
end
Expand All @@ -974,6 +993,8 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
local result = self.resultTbl[row_idx][result_index]
addCompareTooltip(tooltip, result_index)
tooltip:AddSeparator(10)
tooltip:AddLine(16, string.format("^7Stat Weight Score: %.0f", getResultWeightedScore(result_index) * 1000))
addStatWeightScoreBreakdownLines(tooltip, result_index)
tooltip:AddLine(16, string.format("^7Price: %s %s", result.amount, result.currency))
end
controls["importButton"..row_idx] = new("ButtonControl", { "TOPLEFT", controls["resultDropdown"..row_idx], "TOPRIGHT"}, {8, 0, 100, row_height}, "Import Item", function()
Expand All @@ -995,6 +1016,9 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
local selected_result_index = self.itemIndexTbl[row_idx]
if selected_result_index then
addCompareTooltip(tooltip, selected_result_index, true)
tooltip:AddSeparator(10)
tooltip:AddLine(16, string.format("^7Stat Weight Score: %.0f", getResultWeightedScore(selected_result_index) * 1000))
addStatWeightScoreBreakdownLines(tooltip, selected_result_index)
end
end
controls["importButton"..row_idx].enabled = function()
Expand Down
75 changes: 46 additions & 29 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2068,39 +2068,56 @@ end

function buildMode:CompareStatList(tooltip, statList, actor, baseOutput, compareOutput, header, nodeCount)
local count = 0
for _, statData in ipairs(statList) do
if statData.stat and (not statData.flag or actor.mainSkill.activeEffect.statSet.skillFlags[statData.flag]) and not statData.childStat and statData.stat ~= "SkillDPS" then
local statVal1 = compareOutput[statData.stat] or 0
local statVal2 = baseOutput[statData.stat] or 0
local diff = statVal1 - statVal2
if statData.stat == "FullDPS" and not compareOutput[statData.stat] then
diff = 0
local function addStatCompareLine(statData)
if not (statData.stat and (not statData.flag or actor.mainSkill.activeEffect.statSet.skillFlags[statData.flag]) and not statData.childStat and statData.stat ~= "SkillDPS") then
return
end
local statVal1 = compareOutput[statData.stat] or 0
local statVal2 = baseOutput[statData.stat] or 0
local diff = statVal1 - statVal2
if statData.stat == "FullDPS" and not compareOutput[statData.stat] then
diff = 0
end
if (diff > 0.001 or diff < -0.001) and (not statData.condFunc or statData.condFunc(statVal1,compareOutput) or statData.condFunc(statVal2,baseOutput)) then
if count == 0 then
tooltip:AddLine(14, header)
end
if (diff > 0.001 or diff < -0.001) and (not statData.condFunc or statData.condFunc(statVal1,compareOutput) or statData.condFunc(statVal2,baseOutput)) then
if count == 0 then
tooltip:AddLine(14, header)
end
local color = ((statData.lowerIsBetter and diff < 0) or (not statData.lowerIsBetter and diff > 0)) and colorCodes.POSITIVE or colorCodes.NEGATIVE
local val = diff * ((statData.pc or statData.mod) and 100 or 1)
local valStr = s_format("%+"..statData.fmt, val) -- Can't use self:FormatStat, because it doesn't have %+. Adding that would have complicated a simple function

valStr = formatNumSep(valStr)

local line = s_format("%s%s %s", color, valStr, statData.label)
local pcPerPt = ""
if statData.compPercent and statVal1 ~= 0 and statVal2 ~= 0 then
local pc = statVal1 / statVal2 * 100 - 100
line = line .. s_format(" (%+.1f%%)", pc)
if nodeCount then
pcPerPt = s_format(" (%+.1f%%)", pc / nodeCount)
end
end
local color = ((statData.lowerIsBetter and diff < 0) or (not statData.lowerIsBetter and diff > 0)) and colorCodes.POSITIVE or colorCodes.NEGATIVE
local val = diff * ((statData.pc or statData.mod) and 100 or 1)
local valStr = s_format("%+"..statData.fmt, val) -- Can't use self:FormatStat, because it doesn't have %+. Adding that would have complicated a simple function

valStr = formatNumSep(valStr)

local line = s_format("%s%s %s", color, valStr, statData.label)
local pcPerPt = ""
if statData.compPercent and statVal1 ~= 0 and statVal2 ~= 0 then
local pc = statVal1 / statVal2 * 100 - 100
line = line .. s_format(" (%+.1f%%)", pc)
if nodeCount then
line = line .. s_format(" ^8[%+"..statData.fmt.."%s per point]", diff * ((statData.pc or statData.mod) and 100 or 1) / nodeCount, pcPerPt)
pcPerPt = s_format(" (%+.1f%%)", pc / nodeCount)
end
tooltip:AddLine(14, line)
count = count + 1
end
if nodeCount then
line = line .. s_format(" ^8[%+"..statData.fmt.."%s per point]", diff * ((statData.pc or statData.mod) and 100 or 1) / nodeCount, pcPerPt)
end
tooltip:AddLine(14, line)
count = count + 1
end
end

local prioritized = { FullDPS = true, TotalEHP = true, EffectiveLootRarityMod = true }
for _, priorityStat in ipairs({ "FullDPS", "TotalEHP", "EffectiveLootRarityMod" }) do
for _, statData in ipairs(statList) do
if statData.stat == priorityStat then
addStatCompareLine(statData)
break
end
end
end

for _, statData in ipairs(statList) do
if not prioritized[statData.stat] then
addStatCompareLine(statData)
end
end
return count
Expand Down
1 change: 1 addition & 0 deletions src/Modules/BuildDisplayStats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ local displayStats = {
{ stat = "MovementSpeedWhileUsingSkill", label = "Skill Movement Speed", fmt = "+.1f%%", mod = true, condFunc = function() return true end },
{ },
{ stat = "PresenceRadiusMetres", label = "Presence Radius", fmt = ".1fm", compPercent = true },
{ stat = "EffectiveLootRarityMod", label = "Increased Rarity of Items found", fmt = ".0f%%", mod = true },
--[[ potentially useful mods
{ stat = "QuantityMultiplier", label = "Quantity Multiplier", fmt = "+d%%" },
{ stat = "StoredUses", label = "Stored Uses", fmt = "d" },
Expand Down