From a5db589b61c2bdaf7ddd2adb7f87b6417e73ae8c Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Sun, 22 Feb 2026 01:23:04 +0100 Subject: [PATCH] allowed /focus name to even accept just a part of the name to attempt to target the right name --- modules/focus.lua | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/focus.lua b/modules/focus.lua index d2c9f47f..979dbedc 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -51,9 +51,37 @@ function SlashCmdList.PFFOCUS(msg) if msg ~= "" then -- Try to resolve GUID via short target swap if UnitExists then + local _, prevGUID = UnitExists("target") + local prevPlayer = UnitIsUnit("target", "player") + + -- Suppress "Unknown unit" errors during targeting attempts (fired async) + UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE") + + -- Try exact match first, then prefix match via /tar TargetByName(msg, true) local _, guid = UnitExists("target") - TargetLastTarget() + + if not guid or guid == "0x0000000000000000" then + -- Fallback: prefix match (like /tar storm -> Stormwind Guard) + SlashCmdList.TARGET(msg) + _, guid = UnitExists("target") + end + + -- Re-enable errors next frame (errors are fired async) + local restore = CreateFrame("Frame") + restore:SetScript("OnUpdate", function() + UIErrorsFrame:RegisterEvent("UI_ERROR_MESSAGE") + restore:SetScript("OnUpdate", nil) + end) + + -- Restore previous target + if prevGUID and prevGUID ~= "0x0000000000000000" then + TargetUnit(prevGUID) + elseif prevPlayer then + TargetUnit("player") + else + ClearTarget() + end if guid and guid ~= "0x0000000000000000" then SetFocusByGUID(guid)