AgentSkillsCN

Wow Api Unit Player

Wow Api Unit Player

SKILL.md
skill
---
name: wow-api-unit-player
description: "Complete reference for WoW Retail Unit and Player APIs — UnitId tokens, GUIDs, health/power/stats, auras, roles, casting, threat, inspection, paper doll, death/resurrection, and player-specific functions. Use when querying unit identity, health, power, auras, stats, combat state, group membership, casting info, threat, or player character details."
---

# Unit & Player API (Retail — Patch 12.0.0)

Comprehensive reference for all Unit, Player, UnitAuras, UnitRole, PaperDollInfo, and PlayerInfo APIs. Covers unit identification (UnitId tokens, GUIDs), health, power, stats, auras, casting, threat, group membership, inspection, and player-specific character functions.

> **Source of truth:** https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#Unit
> **UnitId reference:** https://warcraft.wiki.gg/wiki/UnitId
> **GUID reference:** https://warcraft.wiki.gg/wiki/GUID
> **Current as of:** Patch 12.0.0 (Build 65655) — January 28, 2026
> **Scope:** Retail only. No deprecated or removed functions.

## Scope

This skill covers these API systems:
- **Unit** — Core unit query functions (`UnitName`, `UnitHealth`, `UnitClass`, etc.)
- **UnitAuras** — Aura/buff/debuff system (`C_UnitAuras`)
- **UnitRole** — Group role assignment and queries
- **PlayerInfo** — Player-specific info (`C_PlayerInfo`)
- **PaperDollInfo** — Equipment, stats, inspection (`C_PaperDollInfo`)
- **PlayerScript** — Global player functions (stats, combat ratings, PvP, death, movement)
- **DeathInfo / IncomingSummon** — Death, resurrection, summoning
- **CreatureInfo** — Creature data helpers

## When to Use This Skill

Use this skill when you need to:
- Query unit identity: name, class, race, level, faction, GUID
- Read or display health, power (mana/rage/energy), or stats
- Work with auras (buffs, debuffs, private auras)
- Check unit state: alive, dead, ghost, combat, AFK, stealthed, flying
- Determine group membership, roles, or raid position
- Inspect other players (item level, spec, PvP data)
- Get player character stats: crit, haste, mastery, armor, attack power
- Handle casting info (what a unit is casting/channeling)
- Query threat situation
- Work with UnitId tokens or GUIDs

## Reference Files

| Reference | Contents |
|-----------|----------|
| [UNIT-IDENTITY.md](references/UNIT-IDENTITY.md) | UnitId tokens, GUIDs, name/class/race/level/faction |
| [UNIT-HEALTH-POWER.md](references/UNIT-HEALTH-POWER.md) | Health, power, stats, armor, combat ratings |
| [UNIT-STATE.md](references/UNIT-STATE.md) | Combat, dead/ghost, casting, vehicle, movement, group state |
| [UNIT-AURAS.md](references/UNIT-AURAS.md) | C_UnitAuras — buffs, debuffs, private auras |
| [UNIT-THREAT-COMBAT.md](references/UNIT-THREAT-COMBAT.md) | Threat, targeting, selection, inspection |
| [PLAYER-FUNCTIONS.md](references/PLAYER-FUNCTIONS.md) | Player-specific: XP, money, PvP, death, resurrection, stats |

---

## UnitId Tokens — Quick Reference

A UnitId (unit token) identifies a unit by relationship to the player. Case insensitive.

### Base Tokens

| Token | Description |
|-------|-------------|
| `"player"` | The current player |
| `"target"` | The current player's target |
| `"focus"` | The player's focus target (set by `/focus`) |
| `"pet"` | The player's pet |
| `"vehicle"` | The player's vehicle |
| `"mouseover"` | Unit currently (or most recently) moused over |
| `"none"` | Valid token that always refers to no unit |
| `"npc"` | NPC the player is interacting with (merchant/quest/gossip frame open) |
| `"questnpc"` | Quest giver NPC being interacted with |

### Indexed Tokens

| Pattern | Range | Description |
|---------|-------|-------------|
| `"partyN"` | 1–4 | Nth party member (excluding player) |
| `"raidN"` | 1–40 | Nth raid member |
| `"partypetN"` | 1–4 | Pet of Nth party member |
| `"raidpetN"` | 1–40 | Pet of Nth raid member |
| `"bossN"` | 1–8 | Active boss in current encounter |
| `"arenaN"` | 1–5 | Opposing arena member |
| `"nameplateN"` | 1–40 | Nth nameplate (cannot be targeted) |

### Soft Targeting (Patch 10.0+)

| Token | Description |
|-------|-------------|
| `"softenemy"` | Current soft target that is hostile |
| `"softfriend"` | Current soft target that is friendly |
| `"softinteract"` | Current soft target that can be interacted with |
| `"anyenemy"` | Resolves to `"target"` or `"softenemy"` (target priority) |
| `"anyfriend"` | Resolves to `"target"` or `"softfriend"` (target priority) |
| `"anyinteract"` | Resolves to `"target"` or `"softinteract"` (target priority) |

### Target Chaining

Append `target` to any UnitId to refer to its target. Can be repeated:
- `"targettarget"` — your target's target
- `"raid7target"` — 7th raid member's target
- `"pettarget"` — your pet's target
- `"Cogwheel-target"` — named player's target (if in group)

> **Source:** https://warcraft.wiki.gg/wiki/UnitId

---

## GUID (Globally Unique Identifier) — Quick Reference

GUIDs uniquely identify everything the player can interact with. Returned by `UnitGUID(unit)`.

### GUID Formats

| Type | Format | Example |
|------|--------|---------|
| Player | `Player-[serverID]-[playerUID]` | `Player-970-0002FD64` |
| Creature | `Creature-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Creature-0-1465-0-2105-448-000043F59F` |
| Pet | `Pet-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | `Pet-0-4234-0-6610-165189-0202F859E9` |
| Vehicle | `Vehicle-0-[serverID]-[instanceID]-[zoneUID]-[npcID]-[spawnUID]` | Same format as Creature |
| GameObject | `GameObject-0-[serverID]-[instanceID]-[zoneUID]-[objectID]-[spawnUID]` | Same format as Creature |
| Item | `Item-[serverID]-0-[spawnUID]` | `Item-1598-0-4000000A369860E1` |
| Vignette | `Vignette-0-[serverID]-[instanceID]-[zoneUID]-[vignetteID]-[spawnUID]` | — |
| BattlePet | `BattlePet-0-[ID]` | `BattlePet-0-00000338F951` |
| Cast | `Cast-[type]-[serverID]-[instanceID]-[zoneUID]-[spellID]-[castUID]` | — |

### Extracting NPC ID from GUID

```lua
local npcID = select(6, strsplit("-", UnitGUID("target")))
print(tonumber(npcID)) -- e.g., 448 for Hogger

Key Rules

  • Players keep their GUID forever (unless faction change/transfer)
  • Creatures get a new GUID each spawn cycle
  • Pets get a new GUID each time summoned
  • GUIDs are recycled after server/instance restart

Source: https://warcraft.wiki.gg/wiki/GUID


Core Unit Functions — Overview

Identity

FunctionReturnsDescription
UnitName(unit)unitName, unitServerUnit's name and realm
UnitFullName(unit)unitName, unitServerFull name with server
UnitNameUnmodified(unit)unitName, unitServerName without modifications
UnitNameFromGUID(guid)unitName, unitServerName from GUID
UnitGUID(unit)guidGUID string
UnitTokenFromGUID(guid)unitTokenUnitId from GUID
UnitClass(unit)className, classFilename, classIDClass info
UnitClassBase(unit)classFilename, classIDNon-localized class
UnitClassFromGUID(guid)className, classFilename, classIDClass from GUID
UnitRace(unit)localizedRace, englishRace, raceIDRace info
UnitSex(unit)sexGender (1=unknown, 2=male, 3=female)
UnitLevel(unit)levelUnit level
UnitEffectiveLevel(unit)levelScaled level
UnitFactionGroup(unit [, checkDisplayRace])factionTag, localizedHorde/Alliance
UnitClassification(unit)class"normal", "elite", "worldboss", etc.
UnitCreatureType(unit)name, idBeast, Humanoid, Undead, etc.
UnitCreatureFamily(unit)name, idCreature family (e.g., Crab)
UnitCreatureID(unit)creatureIDNPC ID
UnitPVPName(unit)nameName with title
GetPlayerInfoByGUID(guid)class, engClass, race, engRace, sex, name, realmInfo from GUID

Health

FunctionReturnsNotes
UnitHealth(unit [, usePredicted])healthReturns secret value in 12.0 — pass directly to widgets
UnitHealthMax(unit)maxHealthReturns secret value in 12.0
UnitHealthMissing(unit [, usePredicted])missingHealth deficit
UnitHealthPercent(unit [, usePredicted [, curve]])percentHealth percentage
UnitPercentHealthFromGUID(guid)percentHealth % from GUID
UnitGetIncomingHeals(unit [, healer])amountPredicted heals
UnitGetTotalAbsorbs(unit)amountDamage absorb shield
UnitGetTotalHealAbsorbs(unit)amountHealing absorb shield
GetUnitHealthModifier(unit)modifierHealth modifier
GetUnitMaxHealthModifier(unit)modifierMax health modifier

Power (Mana/Rage/Energy/etc.)

FunctionReturnsNotes
UnitPower(unit [, powerType [, unmodified]])powerCurrent power
UnitPowerMax(unit [, powerType [, unmodified]])maxPowerMaximum power
UnitPowerMissing(unit [, powerType [, unmodified]])missingPower deficit
UnitPowerPercent(unit [, powerType [, ...]])percentPower percentage
UnitPartialPower(unit [, powerType [, unmodified]])partialPowerFractional power
UnitPowerType(unit [, index])powerType, token, r, g, be.g., 0=Mana, 1=Rage
UnitPowerDisplayMod(powerType)modDisplay modifier
GetUnitPowerModifier(unit)modifierPower modifier

Power Types (Enum.PowerType)

ValueTokenDescription
0ManaMana
1RageRage
2FocusFocus (Hunter pets)
3EnergyEnergy (Rogues, Monks, etc.)
4ComboPointsCombo Points
5RunesDeath Knight Runes
6RunicPowerRunic Power
7SoulShardsWarlock Soul Shards
8LunarPowerBalance Druid
9HolyPowerPaladin Holy Power
11MaelstromShaman Maelstrom
12ChiMonk Chi
13InsanityShadow Priest
16ArcaneChargesArcane Mage
17FuryDemon Hunter Fury
18PainVengeance DH (legacy)
19EssenceEvoker Essence

State Checks

FunctionReturnsDescription
UnitExists([unit])boolUnit exists and can be targeted
UnitIsVisible([unit])boolVisible to client (not necessarily line of sight)
UnitIsConnected(unit)boolNot offline
UnitIsDead(unit)boolDead
UnitIsDeadOrGhost(unit)boolDead or ghost form
UnitIsGhost(unit)boolGhost form
UnitAffectingCombat(unit)boolIn combat
UnitIsAFK(unit)boolAFK (friendly only)
UnitIsDND(unit)boolDo Not Disturb
UnitIsPlayer([unit])boolIs a player character
UnitIsEnemy(unit, target)boolUnits are hostile
UnitIsFriend(unit, target)boolUnits are friendly
UnitCanAttack(unit, target)boolFirst can attack second
UnitCanAssist(unit, target)boolFirst can assist second
UnitCanCooperate(unit, target)boolCan cooperate
UnitIsUnit(unit1, unit2)boolSame unit
UnitIsPVP(unit)boolPvP flagged
UnitIsCharmed([unit])boolCharmed / mind controlled
UnitIsFeignDeath(unit)boolFeigning death (group only)
UnitIsTapDenied(unit)boolTap denied (grey health bar)
UnitIsTrivial(unit)boolGrey to player
UnitIsBossMob(unit)boolBoss unit
IsFalling([unit])boolCurrently falling
IsFlying([unit])boolOn flying mount
IsSwimming([unit])boolSwimming
IsStealthed()boolPlayer is stealthed
PlayerIsInCombat()boolPlayer in combat

Group Membership

FunctionReturnsDescription
UnitInParty([unit])boolIn your party
UnitInRaid([unit])indexIn your raid (returns index)
UnitInAnyGroup([unit])boolIn any group
UnitPlayerOrPetInParty([unit])boolPlayer or pet in party
UnitPlayerOrPetInRaid([unit])boolPlayer or pet in raid
UnitInRange(unit)inRange, checkedWithin 40yd (25yd Evoker) #grouponly
UnitIsGroupLeader(unit [, cat])boolIs group leader
UnitIsGroupAssistant(unit)boolIs assist
UnitGroupRolesAssigned([unit])role"TANK", "HEALER", "DAMAGER", "NONE"
UnitIsInMyGuild(unit)boolSame guild

Casting Info

FunctionReturnsDescription
UnitCastingInfo(unit)name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, castID, notInterruptible, castingSpellID, castBarIDCurrent cast info
UnitChannelInfo(unit)name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, notInterruptible, spellID, isEmpowered, numEmpowerStages, castBarIDChannel info
UnitCastingDuration(unit)durationCast duration
UnitChannelDuration(unit)durationChannel duration
UnitEmpoweredChannelDuration(unit [, includeHold])durationEmpower duration

12.0.0 Change: notInterruptible in UnitCastingInfo is now nilable. New castBarID return added.

Threat

FunctionReturnsDescription
UnitThreatSituation(unit [, mob])status0=low, 1=close, 2=unsafe, 3=tanking
UnitDetailedThreatSituation(unit, mob)isTanking, status, scaledPct, rawPct, rawThreatDetailed threat
UnitThreatPercentageOfLead(unit, mob)percent% of lead
UnitThreatLeadSituation(unit, mob)statusLead situation

C_UnitAuras — Aura System

The aura API provides buff/debuff data for units. Returns AuraData tables.

Key Functions

FunctionReturnsDescription
C_UnitAuras.GetAuraDataByIndex(unit, index [, filter])auraAura by index
C_UnitAuras.GetAuraDataByAuraInstanceID(unit, auraInstanceID)auraAura by instance ID
C_UnitAuras.GetAuraDataBySlot(unit, slot)auraAura by slot
C_UnitAuras.GetAuraDataBySpellName(unit, spellName [, filter])auraAura by spell name
C_UnitAuras.GetBuffDataByIndex(unit, index [, filter])auraBuff specifically
C_UnitAuras.GetDebuffDataByIndex(unit, index [, filter])auraDebuff specifically
C_UnitAuras.GetPlayerAuraBySpellID(spellID)auraPlayer aura by spell ID
C_UnitAuras.GetAuraSlots(unit [, filter [, max [, token]]])continuation, slots...Iterate aura slots
C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter [, max [, sort [, dir]]])auraInstanceIDsAll aura instance IDs
C_UnitAuras.GetUnitAuras(unit, filter [, max [, sort [, dir]]])aurasAll aura data
C_UnitAuras.GetAuraDuration(unit, auraInstanceID)durationRemaining duration
C_UnitAuras.GetAuraBaseDuration(unit, auraID [, spellID])durationBase duration
C_UnitAuras.DoesAuraHaveExpirationTime(unit, auraID)boolHas timer
C_UnitAuras.IsAuraFilteredOutByInstanceID(unit, auraID, filter)boolFiltered by current filter
C_UnitAuras.WantsAlteredForm(unit)boolWants altered form

Aura Filter Strings

Filters are space-separated strings passed to aura query functions:

FilterDescription
"HELPFUL"Buffs only
"HARMFUL"Debuffs only
"PLAYER"Only auras cast by the player
"RAID"Only auras relevant to the raid
"CANCELABLE"Only cancelable auras
"NOT_CANCELABLE"Only non-cancelable auras
"INCLUDE_NAME_PLATE_ONLY"Include nameplate-only auras
"MAW"Maw-specific auras

Combine with spaces: "HELPFUL PLAYER" = buffs cast by player.

AuraData Structure

Fields returned in an AuraData table:

FieldTypeDescription
namestringAura name
iconnumberTexture file ID
applicationsnumberStack count
dispelNamestring?Dispel type: "Magic", "Curse", "Disease", "Poison"
durationnumberTotal duration (0 = indefinite)
expirationTimenumberGetTime() when it expires
isFromPlayerOrPlayerPetboolCast by player or player's pet
isHarmfulboolIs a debuff
isHelpfulboolIs a buff
isNameplateOnlyboolOnly shows on nameplates
isRaidboolShows in raid frames
isStealableboolCan be spellstolen
sourceUnitUnitId?Caster
spellIdnumberSpell ID
pointstableAura effect values
auraInstanceIDnumberUnique instance ID for this application
timeModnumberTime modifier
chargesnumberNumber of charges
isBossAuraboolBoss aura
nameplateShowAllboolShow all stacks on nameplate
nameplateShowPersonalboolShow personal on nameplate

Private Auras

Private auras are auras where the spell data is hidden from addons. Used for encounter mechanics.

FunctionDescription
C_UnitAuras.AddPrivateAuraAnchor(args)Anchor a frame to a private aura's display position → anchorID
C_UnitAuras.RemovePrivateAuraAnchor(anchorID)Remove private aura anchor
C_UnitAuras.AddPrivateAuraAppliedSound(sound)Play sound when private aura applied → soundID
C_UnitAuras.RemovePrivateAuraAppliedSound(soundID)Remove private aura sound
C_UnitAuras.AuraIsPrivate(spellID)Check if spell is private
C_UnitAuras.AuraIsBigDefensive(spellID)Check if big defensive CD
C_UnitAuras.SetPrivateWarningTextAnchor(parent [, anchor])Set warning text anchor
C_UnitAuras.TriggerPrivateAuraShowDispelType(show)Toggle dispel type display

Aura Iteration Pattern

lua
-- Modern pattern: iterate by aura instance IDs
local function GetAllAuras(unit, filter)
    local auras = {}
    local ids = C_UnitAuras.GetUnitAuraInstanceIDs(unit, filter)
    for _, id in ipairs(ids) do
        local aura = C_UnitAuras.GetAuraDataByAuraInstanceID(unit, id)
        if aura then
            table.insert(auras, aura)
        end
    end
    return auras
end

-- Get all player debuffs
local debuffs = GetAllAuras("player", "HARMFUL")

UNIT_AURA Event

lua
-- UNIT_AURA fires when any aura changes on a unit
-- Payload: unitTarget, updateInfo
-- updateInfo contains: addedAuras, updatedAuraInstanceIDs, removedAuraInstanceIDs
-- isFullUpdate (bool) — if true, full refresh is needed

local frame = CreateFrame("Frame")
frame:RegisterUnitEvent("UNIT_AURA", "player")
frame:SetScript("OnEvent", function(self, event, unit, updateInfo)
    if updateInfo.isFullUpdate then
        -- re-scan all auras
        return
    end
    if updateInfo.addedAuras then
        for _, aura in ipairs(updateInfo.addedAuras) do
            print("Added:", aura.name, aura.spellId)
        end
    end
    if updateInfo.removedAuraInstanceIDs then
        for _, id in ipairs(updateInfo.removedAuraInstanceIDs) do
            print("Removed aura instance:", id)
        end
    end
end)

C_PlayerInfo — Player Information

FunctionReturnsDescription
C_PlayerInfo.GUIDIsPlayer(guid)boolGUID belongs to a player
C_PlayerInfo.GetClass(playerLocation)className, classFilename, classIDPlayer class
C_PlayerInfo.GetName(playerLocation)namePlayer name
C_PlayerInfo.GetRace(playerLocation)raceIDPlayer race
C_PlayerInfo.GetSex(playerLocation)sexPlayer sex
C_PlayerInfo.GetContentDifficultyCreatureForPlayer(unit)difficultyContent difficulty
C_PlayerInfo.GetPlayerMythicPlusRatingSummary(unit)ratingSummaryM+ rating

Source: https://warcraft.wiki.gg/wiki/World_of_Warcraft_API#PlayerLocationInfo


C_PaperDollInfo — Equipment & Inspection

FunctionReturnsDescription
C_PaperDollInfo.GetInspectItemLevel(unit)itemLevelInspected unit's avg ilvl
C_PaperDollInfo.GetInspectGuildInfo(unit)achPoints, numMembers, guildName, realmGuild info for inspected
C_PaperDollInfo.GetArmorEffectiveness(armor, attackerLvl)effectivenessArmor DR %
C_PaperDollInfo.GetArmorEffectivenessAgainstTarget(armor)effectivenessArmor DR vs target
C_PaperDollInfo.GetStaggerPercentage(unit)stagger, staggerVsTargetMonk stagger %
C_PaperDollInfo.GetMinItemLevel()minItemLevelMinimum ilvl
C_PaperDollInfo.CanAutoEquipCursorItem()boolCan auto-equip
C_PaperDollInfo.CanCursorCanGoInSlot(slot)boolCursor item fits slot
C_PaperDollInfo.IsInventorySlotEnabled(slotName)boolSlot enabled
C_PaperDollInfo.GetInspectRatedBGData()dataInspected rated BG info
C_PaperDollInfo.GetInspectRatedSoloShuffleData()dataInspected solo shuffle info

Inspection Flow

lua
-- 1. Request inspection data
NotifyInspect("target")

-- 2. Wait for INSPECT_READY event
local frame = CreateFrame("Frame")
frame:RegisterEvent("INSPECT_READY")
frame:SetScript("OnEvent", function(self, event, inspecteeGUID)
    local spec = GetInspectSpecialization("target")
    local ilvl = C_PaperDollInfo.GetInspectItemLevel("target")
    print("Spec:", spec, "iLvl:", ilvl)
    ClearInspectPlayer() -- Clean up
    self:UnregisterEvent("INSPECT_READY")
end)

UnitRole — Group Roles

FunctionReturnsDescription
UnitGroupRolesAssigned([unit])"TANK"/"HEALER"/"DAMAGER"/"NONE"Assigned role
UnitGroupRolesAssignedEnum([unit])enumRole as enum value
UnitGetAvailableRoles(unit)tank, healer, dpsAvailable roles (booleans)
UnitSetRole(unit [, roleStr])successSet role
UnitSetRoleEnum(unit [, role])successSet role by enum
CanShowSetRoleButton()boolRole button available
InitiateRolePoll()successStart role poll
AreClassRolesSoftSuggestions()boolRoles are soft suggestions

Player Character Stats

These global functions query the player's character stats.

Combat Ratings & Stats

FunctionReturnsDescription
GetCritChance()percentMelee crit %
GetRangedCritChance()percentRanged crit %
GetHaste()percentHaste %
GetMeleeHaste()percentMelee haste %
GetRangedHaste()percentRanged haste %
UnitSpellHaste(unit)percentSpell haste %
GetMastery()percentBase mastery %
GetMasteryEffect()effect, coefficientEffective mastery
GetDodgeChance()percentDodge %
GetParryChance()percentParry %
GetBlockChance()percentBlock %
GetLifesteal()percentLeech %
GetAvoidance()percentAvoidance %
GetCombatRating(ratingIndex)ratingRaw combat rating value
GetCombatRatingBonus(ratingIndex)bonusBonus % from rating
UnitStat(unit, index)cur, eff, posBuff, negBuffPrimary stat (1=Str, 2=Agi, 3=Sta, 4=Int)
UnitArmor(unit)base, effective, real, bonusArmor values
UnitAttackPower(unit)ap, posBuff, negBuffMelee attack power
UnitAttackSpeed(unit)mainhand, offhandAttack speed
UnitDamage(unit)min, max, ohMin, ohMax, posBuff, negBuff, pctDamage range
UnitRangedAttackPower(unit)ap, posBuff, negBuffRanged AP
UnitRangedDamage(unit)speed, min, max, posBuff, negBuff, pctRanged damage
GetManaRegen()base, castingMana regen/sec
GetPowerRegen()base, castingPower regen/sec

Player XP & Level

FunctionReturnsDescription
UnitXP("player")xpCurrent XP
UnitXPMax("player")maxXPXP to next level
GetMaxPlayerLevel()levelLevel cap
GetRestState()exhaustionID, name, factorRested state
IsXPUserDisabled()boolXP frozen

Money & Economy

FunctionReturnsDescription
GetMoney()copperTotal money in copper

Movement

FunctionReturnsDescription
GetUnitSpeed(unit)current, run, flight, swimMovement speeds
GetPlayerFacing()radiansDirection facing #noinstance
UnitPosition(unit)x, y, z, mapIDWorld position #noinstance
UnitDistanceSquared(unit)distSq, checkedSquared distance #noinstance
UnitOnTaxi(unit)boolOn flight path

Death & Resurrection

FunctionReturnsDescription
RepopMe()Release spirit
RetrieveCorpse()Resurrect at corpse
AcceptResurrect()Accept rez offer
DeclineResurrect()Decline rez offer
ResurrectGetOfferer()nameWho is offering rez
ResurrectHasSickness()boolRez will give sickness
ResurrectHasTimer()boolMust wait before accepting
GetCorpseRecoveryDelay()secondsDelay before rez
GetReleaseTimeRemaining()secondsTime until forced release
C_IncomingSummon.HasIncomingSummon(unit)boolHas pending summon
C_IncomingSummon.IncomingSummonStatus(unit)statusSummon status
UnitHasIncomingResurrection(unit)boolBeing resurrected

Secret Values — 12.0.0 Impact on Unit APIs

Many unit functions now return secret values under certain conditions. See the wow-api-important instructions for full details.

Functions Returning Secrets

FunctionWhen Secret
UnitHealth(unit)When health is restricted
UnitHealthMax(unit)When health is restricted
UnitName(unit)When unit identity restricted in combat (non-player units in instances)
UnitClass(unit)First return conditionally secret
UnitPower(unit)When power is restricted

Safe Pattern: Display Health

lua
-- CORRECT: Pass secret values directly to widgets
local hp = UnitHealth("target")
local maxHp = UnitHealthMax("target")
myStatusBar:SetMinMaxValues(0, maxHp) -- accepts secrets
myStatusBar:SetValue(hp)              -- accepts secrets

-- WRONG: Do NOT compare or do math
-- if hp < maxHp * 0.3 then -- ERROR: cannot compare secrets

Checking Restrictions

lua
-- Check if unit identity is restricted
local isSecret = C_Secrets.ShouldUnitIdentityBeSecret("target")
local isHealthSecret = C_Secrets.ShouldUnitHealthMaxBeSecret("target")
local isPowerSecret = C_Secrets.ShouldUnitPowerBeSecret("target")

Common Patterns

Unit Frame Health Bar

lua
local frame = CreateFrame("Frame", nil, UIParent)
local healthBar = CreateFrame("StatusBar", nil, frame)
healthBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
healthBar:SetMinMaxValues(0, 1)

local function UpdateHealth(unit)
    local hp = UnitHealth(unit)
    local maxHp = UnitHealthMax(unit)
    healthBar:SetMinMaxValues(0, maxHp)
    healthBar:SetValue(hp)
end

frame:RegisterUnitEvent("UNIT_HEALTH", "target")
frame:RegisterUnitEvent("UNIT_MAXHEALTH", "target")
frame:SetScript("OnEvent", function(self, event, unit)
    UpdateHealth(unit)
end)

Check if Unit is a Healable Friendly

lua
local function IsHealableUnit(unit)
    return UnitExists(unit)
        and UnitCanAssist("player", unit)
        and not UnitIsDeadOrGhost(unit)
        and UnitIsConnected(unit)
end

Get NPC ID from Target

lua
local function GetNPCID(unit)
    local guid = UnitGUID(unit)
    if not guid then return nil end
    local unitType, _, _, _, _, npcID = strsplit("-", guid)
    if unitType == "Creature" or unitType == "Vehicle" then
        return tonumber(npcID)
    end
end

Related Events

EventPayloadDescription
UNIT_HEALTHunitTargetHealth changed
UNIT_MAXHEALTHunitTargetMax health changed
UNIT_POWER_UPDATEunitTarget, powerTypePower changed
UNIT_POWER_FREQUENTunitTarget, powerTypePower changed (frequent)
UNIT_MAXPOWERunitTarget, powerTypeMax power changed
UNIT_AURAunitTarget, updateInfoAuras changed
UNIT_TARGETunitTargetTarget changed
UNIT_LEVELunitTargetLevel changed
UNIT_NAME_UPDATEunitTargetName updated
UNIT_FACTIONunitTargetFaction changed
UNIT_FLAGSunitTargetFlags changed (PvP, AFK, etc.)
UNIT_SPELLCAST_STARTunitTarget, castGUID, spellIDCast started
UNIT_SPELLCAST_STOPunitTarget, castGUID, spellIDCast stopped
UNIT_SPELLCAST_SUCCEEDEDunitTarget, castGUID, spellIDCast succeeded
UNIT_SPELLCAST_CHANNEL_STARTunitTarget, castGUID, spellIDChannel started
UNIT_SPELLCAST_CHANNEL_STOPunitTarget, castGUID, spellIDChannel stopped
UNIT_SPELLCAST_EMPOWER_STARTunitTarget, castGUID, spellIDEmpower started
UNIT_SPELLCAST_EMPOWER_STOPunitTarget, castGUID, spellID, completeEmpower stopped
UNIT_THREAT_SITUATION_UPDATEunitTargetThreat changed
UNIT_THREAT_LIST_UPDATEunitTargetThreat list changed
UNIT_CONNECTIONunitTarget, isConnectedOnline/offline
UNIT_STATSunitTargetStats changed
UNIT_ATTACK_POWERunitTargetAP changed
UNIT_SPELL_HASTEunitTargetSpell haste changed
UNIT_COMBATunitTarget, event, flagText, amount, schoolMaskCombat text event
UNIT_INVENTORY_CHANGEDunitTargetEquipped items changed
PLAYER_TARGET_CHANGEDPlayer target changed
PLAYER_FOCUS_CHANGEDFocus target changed
PLAYER_ENTERING_WORLDisInitialLogin, isReloadingUiZone/instance load
PLAYER_DEADPlayer died
PLAYER_ALIVEPlayer alive (accept rez)
PLAYER_UNGHOSTPlayer no longer ghost
PLAYER_REGEN_ENABLEDLeft combat
PLAYER_REGEN_DISABLEDEntered combat
INSPECT_READYinspecteeGUIDInspection data available
GROUP_ROSTER_UPDATEGroup composition changed
ROLE_CHANGED_INFORMchangedName, from, oldRole, newRoleRole changed

Restrictions & Gotchas

RestrictionDetails
#noinstanceUnitPosition, UnitDistanceSquared, GetPlayerFacing blocked in instances
#grouponlyUnitInRange only works for group members
#nocombatCheckInteractDistance blocked in combat
Secret values (12.0)Health, name, power may be secret — cannot compare/branch, only pass to widgets
NotifyInspect throttleInspecting too fast will be throttled by the server
UnitIsPlayerCharmed players may return false for some APIs

Sources:

code