libunitscan: disable target sounds during scan

This commit is contained in:
shagu
2021-08-01 12:20:23 +02:00
parent 5b815a899b
commit 75d9a2fff3
+11
View File
@@ -140,15 +140,26 @@ end)
-- since TargetByName can only be triggered within vanilla,
-- we can't auto-scan targets on further expansions.
if pfUI.client <= 11200 then
-- setup sound function switches
local SoundOn = PlaySound
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
local name = next(queue)
if name then
-- disable sound
_G.PlaySound = SoundOff
-- try to target the unknown unit
TargetByName(name, true)
ClearTarget()
-- enable sound again
_G.PlaySound = SoundOn
queue[name] = nil
end