From 5adb9370d204fd2b7e42d51da929878f4d46cf30 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 17:58:53 -0700 Subject: [PATCH] fix: return caster unit ID from UnitBuff/UnitDebuff/UnitAura The caster field (8th return value) was always nil. Now returns the caster's unit ID ("player", "target", "focus", "pet") or hex GUID string for other units. Enables addons to identify who applied a buff/debuff for filtering and tracking purposes. --- src/addons/lua_engine.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 9bf25ed8..d13b4333 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -392,7 +392,24 @@ static int lua_UnitAura(lua_State* L, bool wantBuff) { } lua_pushnumber(L, aura.maxDurationMs > 0 ? aura.maxDurationMs / 1000.0 : 0); // duration lua_pushnumber(L, 0); // expirationTime (would need absolute time) - lua_pushnil(L); // caster + // caster: return unit ID string if caster is known + if (aura.casterGuid != 0) { + if (aura.casterGuid == gh->getPlayerGuid()) + lua_pushstring(L, "player"); + else if (aura.casterGuid == gh->getTargetGuid()) + lua_pushstring(L, "target"); + else if (aura.casterGuid == gh->getFocusGuid()) + lua_pushstring(L, "focus"); + else if (aura.casterGuid == gh->getPetGuid()) + lua_pushstring(L, "pet"); + else { + char cBuf[32]; + snprintf(cBuf, sizeof(cBuf), "0x%016llX", (unsigned long long)aura.casterGuid); + lua_pushstring(L, cBuf); + } + } else { + lua_pushnil(L); + } lua_pushboolean(L, 0); // isStealable lua_pushboolean(L, 0); // shouldConsolidate lua_pushnumber(L, aura.spellId); // spellId