diff --git a/Modules/QuestieLearner.lua b/Modules/QuestieLearner.lua index 25fbb1a..b1dc848 100644 --- a/Modules/QuestieLearner.lua +++ b/Modules/QuestieLearner.lua @@ -1406,6 +1406,8 @@ function QuestieLearner:LearnNPC(npcId, name, level, subName, npcFlags, factionS CrossLinkAfterNPC(npcId) end _Learner:BroadcastIfCommsAvailable("NPC", npcId, existing) + + return isNew end ------------------------------------------------------------------------ @@ -3728,9 +3730,14 @@ function QuestieLearner:OnCombatLogEvent(timestamp, eventType, srcGUID, srcName, -- Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Kill cached for correlation:", npcId, dstName, "@", tostring(px), tostring(py), "zone", tostring(zoneId)) end - -- Unconditionally map the spawn position for Ascension DB building + -- Unconditionally map the spawn position for Ascension DB building. + -- Only announce the first time we learn a unique NPC ID; repeated kills + -- still update evidence but should not spam "learned" debug output. + local npcWasKnown = Questie.dbLearner.global.npcs[npcId] ~= nil self:LearnNPC(npcId, name, nil, nil, nil, nil, px, py, zoneId) - Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Combat-log learned NPC:", eventType, npcId, name or "?") + if not npcWasKnown then + Questie:Debug(Questie.DEBUG_LEARNER, "[QuestieLearner] Combat-log learned NPC:", eventType, npcId, name or "?") + end -- Phase 2: store per-GUID spawn evidence for weighted merge self:_StoreGuidSpawnEvidence(npcId, dstGUID, zoneId, px, py) diff --git a/Tests/QuestieLearner_performance_spec.lua b/Tests/QuestieLearner_performance_spec.lua index f68a25d..8279e70 100644 --- a/Tests/QuestieLearner_performance_spec.lua +++ b/Tests/QuestieLearner_performance_spec.lua @@ -215,6 +215,47 @@ describe("QuestieLearner kill-path batching", function() assert.equals(2, table.getn(queuedTimers)) end) + it("only announces combat-log learning once per unique NPC id", function() + local debugMessages = {} + local originalDebug = Questie.Debug + Questie.Debug = function(self, level, ...) + local parts = { ... } + for i = 1, table.getn(parts) do + if parts[i] == "[QuestieLearner] Combat-log learned NPC:" then + debugMessages[table.getn(debugMessages) + 1] = level + break + end + end + end + + QuestieLearner:OnCombatLogEvent( + 1234, + "PARTY_KILL", + UnitGUID("player"), + UnitName("player"), + nil, + "Creature-0-0-0-0-7010-0000000001", + "Unique Boar", + nil + ) + + QuestieLearner:OnCombatLogEvent( + 1235, + "PARTY_KILL", + UnitGUID("player"), + UnitName("player"), + nil, + "Creature-0-0-0-0-7010-0000000002", + "Unique Boar", + nil + ) + + assert.is_table(Questie.dbLearner.global.npcs[7010]) + assert.equals(1, table.getn(debugMessages)) + + Questie.Debug = originalDebug + end) + it("still learns credited UNIT_DIED combat-log events when PARTY_KILL is absent", function() QuestieLearner:OnCombatLogEvent( 1234,