From 9c85a615ac9cfef415434adab1b5cd07cf2899aa Mon Sep 17 00:00:00 2001 From: Meow <30401521+me0wg4ming@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:02:56 +0100 Subject: [PATCH] pet/player handling pet/player handling now uses always GetUnitField, only for npc`s it will use blizzards fallback... --- api/unitframes.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index cb20f82d..255c404e 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -257,8 +257,13 @@ function pfUI.api.GetUnitStats(unitstr, trackStats) local hp, maxHp, power, maxPower, powerType local usedNampower = false - -- For NPCs/Mobs/Pets (everything that's NOT a player): Skip Nampower, use Blizzard API only - if unitstr and UnitExists(unitstr) and not UnitIsPlayer(unitstr) then + + -- For NPCs/Mobs (everything that's NOT a player AND NOT a pet): Skip Nampower, use Blizzard API only + -- Pets should use Nampower for better accuracy (power3=focus, power5=happiness) + -- Proper pet check: UnitPlayerControlled = true for pets and players, UnitIsPlayer = false for pets + local isPet = UnitPlayerControlled(unitstr) and not UnitIsPlayer(unitstr) + + if unitstr and UnitExists(unitstr) and not UnitIsPlayer(unitstr) and not isPet then hp = UnitHealth(unitstr) or 0 maxHp = UnitHealthMax(unitstr) or 1 powerType = UnitPowerType(unitstr) or 0 @@ -285,13 +290,14 @@ function pfUI.api.GetUnitStats(unitstr, trackStats) return hp, maxHp, power, maxPower, powerType end - -- Try Nampower first if available (ONLY for players now) + -- Try Nampower first if available (for players AND pets now) if GetUnitField then -- Use the standard check first, then get guid separately local exists = _G.UnitExists(unitstr) if exists then -- Get guid via the extended UnitExists for Nampower local _, guid = _G.UnitExists(unitstr) + if guid then hp = GetUnitField(guid, "health") maxHp = GetUnitField(guid, "maxHealth") @@ -316,6 +322,12 @@ function pfUI.api.GetUnitStats(unitstr, trackStats) power = GetUnitField(guid, "power4") or UnitMana(unitstr) if power then power = math.floor(power) end maxPower = GetUnitField(guid, "maxPower4") or UnitManaMax(unitstr) + elseif powerType == 2 then + -- Focus (Hunter pets use power3) + power = GetUnitField(guid, "power3") or UnitMana(unitstr) + if power then power = math.floor(power) end + maxPower = GetUnitField(guid, "maxPower3") or UnitManaMax(unitstr) + else -- Mana (default) power = GetUnitField(guid, "power1") or UnitMana(unitstr)