From d3a4f70e913074c0abaa7e30e5c461b3ab6f60dd Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 25 Aug 2026 22:30:26 +0200 Subject: [PATCH] Sleep legacy unit scanner while target is occupied --- libs/libunitscan.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/libunitscan.lua b/libs/libunitscan.lua index d8accef..9313a63 100644 --- a/libs/libunitscan.lua +++ b/libs/libunitscan.lua @@ -263,6 +263,13 @@ libunitscan:SetScript("OnEvent", function() AddData("mobs", name, class, level, elite) end end + + -- Active legacy scans sleep while the player has a target. Wake the scanner + -- only when that target disappears and queued work is actually waiting. + if event == "PLAYER_TARGET_CHANGED" and next(queue) and + not UnitExists("target") and not UnitName("target") then + libunitscan:Show() + end end) -- since TargetByName can only be triggered within vanilla, @@ -273,8 +280,13 @@ if GetExpansion() == "vanilla" then local SoundOff = function() return end libunitscan:SetScript("OnUpdate", function() - -- don't scan when another unit is in target - if UnitExists("target") or UnitName("target") then return end + -- A queued legacy scan cannot do useful work while the player already has + -- a target. Hide completely instead of polling this condition every frame; + -- PLAYER_TARGET_CHANGED above wakes us when the target is cleared. + if UnitExists("target") or UnitName("target") then + this:Hide() + return + end local name = next(queue) if name then