From 8818d68aea0104bf4d618aaf2ba37d7b9d0591db Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 21 May 2026 03:39:09 -0500 Subject: [PATCH] druid prowl detection via IsStealthed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FullScan/HasProwlBuff stop iterating GetPlayerBuffTexture(0..31) for the prowl buff — that's exactly what ClassicAPI's IsStealthed() returns, locale-independent and zero allocations. Cat-form detection still needs the icon (GetShapeshiftForm's index varies by talents/learned forms) but moves to one C_UnitAuras.GetUnitAuras iteration over populated auras via the new HasCatForm helper. The inline cat-form recheck after a prowl ends collapses to one HasCatForm() call. HasProwlBuff is inlined to IsStealthed() at its single call site. --- modules/actionbar.lua | 65 ++++++++++++------------------------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 8d545eb5..2a9fe0ab 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -910,45 +910,26 @@ pfUI:RegisterModule("actionbar", "vanilla", function () end local cat, stealth - local inCatForm = nil -- cached from buff scan - local prowlActive = nil -- tracks if prowl is active - - -- Full scan for cat form and prowl (only on login/reload) - local function FullScan() - if class ~= "DRUID" then return nil end - - local foundCat, foundStealth = nil, nil - - for i = 0, 31 do - local texture = GetPlayerBuffTexture(i) - if not texture then break end + local inCatForm = nil + local prowlActive = nil - if strfind(texture, "Ability_Druid_CatForm") then - foundCat = true - end - - if strfind(texture, "Ability_Ambush") then - foundStealth = true - end - end - - inCatForm = foundCat - prowlActive = foundCat and foundStealth - return prowlActive - end - - -- Quick scan only for prowl (when we know we're in cat form) - local function HasProwlBuff() - for i = 0, 31 do - local texture = GetPlayerBuffTexture(i) - if not texture then break end - if strfind(texture, "Ability_Ambush") then - return true - end + -- Cat Form's icon path is stable across locales and ranks, so we match on + -- the texture rather than spellID (which differs between cast spellID and + -- the resulting buff's spellID in the descriptor). + local function HasCatForm() + for _, a in ipairs(C_UnitAuras.GetUnitAuras("player", "HELPFUL")) do + if strfind(a.icon, "Ability_Druid_CatForm") then return true end end return nil end + local function FullScan() + if class ~= "DRUID" then return nil end + inCatForm = HasCatForm() + prowlActive = inCatForm and IsStealthed() or nil + return prowlActive + end + -- pagemaster / meta page switch if pfUI.expansion == "vanilla" then local prowl, shift, ctrl, alt, default = 8, 6, 5, 3, 1 @@ -995,23 +976,13 @@ pfUI:RegisterModule("actionbar", "vanilla", function () -- PLAYER_AURAS_CHANGED: smart scanning if event == "PLAYER_AURAS_CHANGED" then if prowlActive then - -- We were prowling, check if still prowling - if HasProwlBuff() then + if IsStealthed() then prowling = true else - -- Prowl ended + -- Prowl ended; recheck cat form (we might have shifted out entirely) prowlActive = nil prowling = nil - -- Also check if still in cat form - inCatForm = nil - for i = 0, 31 do - local texture = GetPlayerBuffTexture(i) - if not texture then break end - if strfind(texture, "Ability_Druid_CatForm") then - inCatForm = true - break - end - end + inCatForm = HasCatForm() end elseif not inCatForm then -- Not in cat form, do a full scan (might have just shifted)