From cca7d649e10be8440b0494f28c08e7799fe6ffa9 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 21 May 2026 16:57:06 -0500 Subject: [PATCH] innervatecall: ResolveTargetName via UnitTokenFromGUID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 30-line GUID → name resolver (manually checking player, target, then walking raid1..40 / party1..4 for a matching UnitGUID) collapses to calling UnitTokenFromGUID and then UnitName on the returned token. ClassicAPI's UnitTokenFromGUID walks the same engine unit-token table internally — same correctness, less Lua. GetPlayerGuid stays (still used by the AURA_CAST event filter). --- modules/innervatecall.lua | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/modules/innervatecall.lua b/modules/innervatecall.lua index 907dd851..b54f0d8c 100644 --- a/modules/innervatecall.lua +++ b/modules/innervatecall.lua @@ -22,36 +22,14 @@ pfUI:RegisterModule("innervatecall", "vanilla", function () return playerGuid end - -- GUID → name resolution for the target + -- GUID → name resolution for the target. UnitTokenFromGUID walks the + -- engine's known unit tokens (player, party, raid, target, ...) and + -- returns the first one currently bound to the GUID, so we don't have + -- to manually iterate party/raid here. local function ResolveTargetName(targetGuid) - if not targetGuid or not UnitGUID then return nil end - - -- Check player self-cast - if GetPlayerGuid() == targetGuid then - return UnitName("player") - end - - -- Check current target (most common case for other-cast) - local curGuid = UnitGUID("target") - if curGuid == targetGuid then - return UnitName("target") - end - - -- Scan raid/party for GUID match - for i = 1, GetNumRaidMembers() do - local unit = "raid" .. i - if UnitGUID(unit) == targetGuid then - return UnitName(unit) - end - end - for i = 1, GetNumPartyMembers() do - local unit = "party" .. i - if UnitGUID(unit) == targetGuid then - return UnitName(unit) - end - end - - return nil + if not targetGuid then return nil end + local token = UnitTokenFromGUID(targetGuid) + return token and UnitName(token) or nil end -- Determine chat channel based on group context