feat(tooltip): show learner spawn data in NPC tooltips

Adds learned spawn position (most-visited GUID), total distinct spawns
learned, and total kills recorded to both unit hover tooltips and
world-map pin tooltips. Replaces the removed Source: attribution line
with factual learner data that was actually recorded.
This commit is contained in:
Xurkon
2026-06-09 02:48:38 -05:00
parent 53dc151cc0
commit b0152b8a12
3 changed files with 95 additions and 6 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
- **[QuestieLearner - Learner-Only Spawn Isolation]** Fixed learner-only mode showing AscensionDB-curated coords instead of learner data. `GetNPC` now discards `npcDataOverrides` in learner mode (where `_Asc_MergeInto` had written curated coords), returning only the learner record. Three-mode spawn-merge semantics: learner uses learner data exclusively, auto fills gaps with learner while protecting curated spawns, static uses base DB only. Also hardened the object-spawn live-injection path with the same three-mode pattern using a new `AscensionOwnsObjectSpawns()` helper. Removed the `allowSpawnMerge` bypass that was the original hole letting learner coords leak into curated spawns in auto mode.
- **[QuestieLearner - Kill Position Attribution]** Fixed the learner recording the local player's position for other players' kills. `OnCombatLogEvent` now only calls `GetCurrentPlayerPosition()` for credited kills (your own kills or mobs you damaged within 60 seconds). Non-credited party/raid kills still update the NPC's learned name and zone but no longer pollute the spawn map with the wrong coordinates.
- **[QuestieLearner - Area 52 Compat]** Fixed `HasQuestReferences` crashing with `attempt to index local 'entry' (a number value)` on Area 52. Some quest records store `qData[2][3]` as a flat number instead of a table-of-tables; the inner loop now normalizes with a type check before comparing.
- **[Tooltip - Remove Misleading Source Line]** Removed the `Source:` attribution line from both world-map pin tooltips and unit/object hover tooltips. Per-pin provenance tracking across static DB, AscensionDB plugin, learner, and comms would require changing every spawn registration site; until that infrastructure exists the label was misleading.
- **[Tooltip - Learner Spawn Data in Tooltips]** Added learner spawn data to NPC tooltips: learned spawn position (from the most-visited GUID), total distinct spawns learned, and total kills recorded. Shown on both unit hover tooltips (via `Tooltip.lua`) and world-map pin tooltips (via `MapIconTooltip.lua`). The old `Source:` attribution line was removed since per-pin provenance tracking would require changing every spawn registration site; the learner data lines are factual (they show what was recorded) rather than attributing a source.
### Tooltip
+31 -2
View File
@@ -69,7 +69,36 @@ local DEFAULT_WAYPOINT_HOVER_COLOR = { 0.93, 0.46, 0.13, 0.8 }
local lastTooltipShowTimestamp = GetTime()
local function _GetWorldMapTooltipSourceLine()
local function _GetWorldMapTooltipSourceLine(pinData)
-- Show learner spawn data for the hovered map icon when available.
local id = pinData and pinData.Id
if not id then return nil end
local npcId = math.abs(id)
local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner")
if not QuestieLearner or not QuestieLearner.IsEnabled or not QuestieLearner:IsEnabled() then
return nil
end
local learnedNpc = QuestieLearner.data and QuestieLearner.data.npcs and QuestieLearner.data.npcs[npcId]
if not learnedNpc then return nil end
local guidSpawns = learnedNpc[8]
local bestX, bestY, bestCount = nil, nil, 0
if guidSpawns then
for uid, entry in pairs(guidSpawns) do
local c = tonumber(entry.count) or 1
if c > bestCount then
bestCount = c
bestX = entry.x
bestY = entry.y
end
end
end
if bestX and bestY then
return string.format("|cFF808080Learned spawn (%.1f, %.1f) from %d kills|r", bestX, bestY, bestCount)
end
return nil
end
@@ -721,7 +750,7 @@ function MapIconTooltip:Show()
end
end
self:AddLine(_GetWorldMapTooltipSourceLine(), 0.55, 0.55, 0.55)
self:AddLine(_GetWorldMapTooltipSourceLine(self.data), 0.55, 0.55, 0.55)
end
Tooltip:_Rebuild() -- we separate this so things like MODIFIER_STATE_CHANGED can redraw the tooltip
Tooltip:SetFrameStrata("TOOLTIP");
+63 -3
View File
@@ -547,14 +547,74 @@ elseif key:sub(1,2) == "o_" then
end
end
local sourceLine = _GetTooltipSourceLine(key)
if sourceLine then
tinsert(tooltipLines, sourceLine)
-- Append learner spawn data when the learner has recorded this NPC.
local learnerLines = _GetLearnerTooltipLines(key)
if learnerLines then
for _, line in ipairs(learnerLines) do
tinsert(tooltipLines, line)
end
end
return tooltipLines
end
local function _GetLearnerTooltipLines(key)
-- key format: "m_<npcId>" for NPCs, "o_<objectId>" for objects, "i_<itemId>" for items
local prefix = key:sub(1, 2)
local id = tonumber(key:sub(3))
if not id then return nil end
local QuestieLearner = QuestieLoader:ImportModule("QuestieLearner")
if not QuestieLearner or not QuestieLearner.IsEnabled or not QuestieLearner:IsEnabled() then
return nil
end
local learnedNpc = QuestieLearner.data and QuestieLearner.data.npcs and QuestieLearner.data.npcs[id]
if not learnedNpc then return nil end
local lines = {}
local guidSpawns = learnedNpc[8]
local spawnList = learnedNpc[7]
-- Count total distinct spawn points
local totalSpawns = 0
if spawnList then
for _ in pairs(spawnList) do totalSpawns = totalSpawns + 1 end
end
-- Find the most-visited spawn (highest count in guidSpawns)
local bestUID, bestX, bestY, bestCount = nil, nil, nil, 0
if guidSpawns then
for uid, entry in pairs(guidSpawns) do
local c = tonumber(entry.count) or 1
if c > bestCount then
bestCount = c
bestUID = uid
bestX = entry.x
bestY = entry.y
end
end
end
if bestX and bestY then
tinsert(lines, string.format(" |cFF808080Learned spawn|r (|cFFFFFFFF%.1f, %.1f|r) |cFF808080from %d kills|r", bestX, bestY, bestCount))
end
if totalSpawns > 0 then
tinsert(lines, string.format(" |cFF808080Total spawns learned|r |cFFFFFFFF%d|r", totalSpawns))
end
local mc = tonumber(learnedNpc.mc) or 0
if mc > 0 then
tinsert(lines, string.format(" |cFF808080Total kills recorded|r |cFFFFFFFF%d|r", mc))
end
if #lines > 0 then
return lines
end
return nil
end
_InitObjectiveTexts = function(objectivesText, objectiveIndex, playerName)
if (not objectivesText) then
objectivesText = {}