mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 05:50:50 +00:00
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:
+18
-47
@@ -910,45 +910,26 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cat, stealth
|
local cat, stealth
|
||||||
local inCatForm = nil -- cached from buff scan
|
local inCatForm = nil
|
||||||
local prowlActive = nil -- tracks if prowl is active
|
local prowlActive = nil
|
||||||
|
|
||||||
-- 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
|
|
||||||
|
|
||||||
if strfind(texture, "Ability_Druid_CatForm") then
|
-- Cat Form's icon path is stable across locales and ranks, so we match on
|
||||||
foundCat = true
|
-- the texture rather than spellID (which differs between cast spellID and
|
||||||
end
|
-- the resulting buff's spellID in the descriptor).
|
||||||
|
local function HasCatForm()
|
||||||
if strfind(texture, "Ability_Ambush") then
|
for _, a in ipairs(C_UnitAuras.GetUnitAuras("player", "HELPFUL")) do
|
||||||
foundStealth = true
|
if strfind(a.icon, "Ability_Druid_CatForm") then return true end
|
||||||
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
|
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
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
|
-- pagemaster / meta page switch
|
||||||
if pfUI.expansion == "vanilla" then
|
if pfUI.expansion == "vanilla" then
|
||||||
local prowl, shift, ctrl, alt, default = 8, 6, 5, 3, 1
|
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
|
-- PLAYER_AURAS_CHANGED: smart scanning
|
||||||
if event == "PLAYER_AURAS_CHANGED" then
|
if event == "PLAYER_AURAS_CHANGED" then
|
||||||
if prowlActive then
|
if prowlActive then
|
||||||
-- We were prowling, check if still prowling
|
if IsStealthed() then
|
||||||
if HasProwlBuff() then
|
|
||||||
prowling = true
|
prowling = true
|
||||||
else
|
else
|
||||||
-- Prowl ended
|
-- Prowl ended; recheck cat form (we might have shifted out entirely)
|
||||||
prowlActive = nil
|
prowlActive = nil
|
||||||
prowling = nil
|
prowling = nil
|
||||||
-- Also check if still in cat form
|
inCatForm = HasCatForm()
|
||||||
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
|
|
||||||
end
|
end
|
||||||
elseif not inCatForm then
|
elseif not inCatForm then
|
||||||
-- Not in cat form, do a full scan (might have just shifted)
|
-- Not in cat form, do a full scan (might have just shifted)
|
||||||
|
|||||||
Reference in New Issue
Block a user