druid prowl detection via IsStealthed

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.
This commit is contained in:
Brues
2026-05-21 03:39:09 -05:00
parent 8ad932b529
commit 8818d68aea
+18 -47
View File
@@ -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)