UnitId

From Warcraft Wiki
Jump to navigation Jump to search
This article is about the World of Warcraft API. For units in Warcraft RTS games, see Unit (RTS).

A unitId (or unit token[1]) identifies a unit by their relationship to the player as a target, party member, pet, or other such role. Several API functions accept unitId as an argument for whom the action applies, though some functions only accept a subset of possible values. UnitIds are case insensitive.

Base Values

"arenaN"
Opposing arena member with index N (1,2,3,4 or 5).
"bossN"
The active bosses of the current encounter if available N (1,2,3...,8).
"focus"
The current player's focus target as selected by the /focus command.
"mouseover"
The unit which the mouse is currently (or was most recently) hovering over.
"none"
A valid unit token that always refers to no unit. UnitName will return "Unknown, nil" for this UnitID. Use to force a macro to not auto self-cast (/cast [target=none] Healing Wave).
"partyN"
The Nth party member excluding the player (1,2,3 or 4).
"partypetN"
The pet of the Nth party member (N is 1,2,3, or 4).
"pet"
The current player's pet.
"player"
The current player.
"raidN"
The raid member with raidIndex N (1,2,3,...,40).
"raidpetN"
The pet of the raid member with raidIndex N (1,2,3,...,40)
"target"
The currently targeted unit. May be overridden in macros by unit specified as a value of respective Secure Button attribute.
"vehicle"
The current player's vehicle.
"nameplateN""
The Nth nameplate (1,2,3,...,40). Cannot be targeted by spells or commands such as /target nameplate1 or /cast [target=nameplate1] Healing Wave.
"spectated<T><N>"
The Nth spectated unit (1,2,3,...,15) for either Team "a" or "b", such as "spectatedb2" for the second unit on team B. Only present in commentator mode.
"spectatedpet<T><N>"
The pet of the Nth spectated unit (1,2,3,...,15) for either Team "a" or "b", such as "spectatedpetb2" for the second units' pet on team B. Only present in commentator mode.

Soft Targeting

Dragonflight This section concerns content related to Dragonflight.

Soft targets are additional units that are automatically selected through an in-world unit scan. These exist separately from the standard "target" unit, which is referred to as a locked target.

"anyenemy"
Resolves to either the "target" unit or "softenemy" target, with "target" being higher priority.
"anyfriend"
Resolves to either the "target" unit or "softfriend" target, with "target" being higher priority.
"anyinteract"
Resolves to either the "target" unit or "softinteract" target, with "target" being higher priority.
"softenemy"
The current soft target that is hostile towards the player.
"softfriend"
The current soft target that is friendly towards the player.
"softinteract"
The current soft target that can be interacted with. This may be an NPC such as a questgiver or merchant, or a game object like a mailbox or a gathering node.

Others

The following units also appear in some very specific places (Vendor interactions, for example) or functions.

"npc"
The NPC with which the player is currently interacting. You must be interacting with the NPC for this to work (e.g. the quest, flight path, merchant, gossip, or bank frame is open).
"questnpc"
The quest giver NPC with which the player is currently interacting. In most cases this will be identical to the "npc" unit.
player name
As returned by UnitName, GetGuildRosterInfo, GetFriendInfo, COMBAT LOG EVENT, etc. This must be spelled exactly and will be invalid if the named player is not a part of your party or raid. As with all other UnitIDs, it is not case sensitive.

Target of unit

Append the suffix target to any UnitId to refer its target (e.g. "pettarget" is the target of your pet). This appending can be repeated indefinitely (e.g. "playertargettarget"), though you will observe an attendant performance hit if you overdo it, as the game engine has to jump from target to target.

If you are using a party or raid member's name as a unit, you need to use hyphens to separate the target chain (e.g. "Cogwheel-target-target").

Examples

"raid7target"
Refers to the 7th raid member's target.
"party1targettarget"
Refers to the first party member (not the player, but the first person in the player's party frames)'s target's target.
"targettargetpettarget"
Refers to the player's target's target's pet's target. Will refer to the player's target if the player's target and the player's pet are both targeting the player.
"mouseoverpettarget"
Refers the unit being moused over's pet's target.
"playertarget"
The same as simply using "target". Using "playertarget" is not as efficient as simply using "target".
"Cogwheel"
Refers to Cogwheel if he is in the player's party/raid.
"Cogwheel-target"
Refers to Cogwheel's target if he is in the player's party/raid.
"Cogwheel-pet-target"
Refers to Cogwheel's pet's target if he is in the player's party/raid.

Details

  • Many of the functions which take a UnitId only provide useful results for a subset of ID's. Other functions will only provide information for friendly targets (or those upon which a power is active).
  • Some functions return different values if the unit is close enough to be 'visible' to your client (not necessarily in line of sight), as can be determined with UnitIsVisible(unit).

Patch changes

  • Dragonflight Patch 10.0.0 (2022-10-25): Added anyenemy, anyfriend, anyinteract, softenemy, softfriend, and softinteract.
  • Legion Patch 7.0.3 (2016-07-19): Added nameplateN.
  • Wrath-Logo-Small.png Patch 3.3.0 (2009-12-08): Added bossN.
  • Bc icon.gif Patch 2.0.1 (2006-12-05): Added focus.
  • WoW Icon update.png Patch 1.5.0 (2005-06-07): Added partypetN and raidpetN.

Used by

Global API

C_Commentator.FindSpectatedUnit(unitToken) : playerIndex, teamIndex, isPet
C_Commentator.GetAdditionalCameraWeightByToken(unitToken) : weight
C_Commentator.GetPlayerAuraInfoByUnit(token, spellID) : startTime, duration, enable
C_Commentator.GetPlayerCooldownInfoByUnit(unitToken, spellID) : startTime, duration, enable
C_Commentator.GetPlayerCrowdControlInfoByUnit(token) : spellID, expiration, duration
C_Commentator.GetPlayerFlagInfoByUnit(unitToken) : hasFlag
C_Commentator.GetPlayerItemCooldownInfoByUnit(unitToken, itemID) : startTime, duration, enable
C_Commentator.GetPlayerSpellChargesByUnit(unitToken, spellID) : charges, maxCharges, startTime, duration
C_Commentator.GetTeamColorByUnit(unitToken) : color
C_Commentator.GetTrackedSpellsByUnit(unitToken, category) : spells
C_Commentator.GetUnitData(unitToken) : data
C_Commentator.HasTrackedAuras(token) : hasOffensiveAura, hasDefensiveAura
C_Commentator.IsTrackedSpellByUnit(unitToken, spellID, category) : isTracked
C_Commentator.SetAdditionalCameraWeightByToken(unitToken, weight)
C_Container.UseContainerItem(containerIndex, slotIndex, unitToken, bankType, reagentBankOpen)
C_DelvesUI.IsEligibleForActiveDelveRewards(unit) : result
C_GuildInfo.GetGuildTabardInfo(unit) : tabardInfo
C_IncomingSummon.HasIncomingSummon(unit) : summon
C_IncomingSummon.IncomingSummonStatus(unit) : status
C_Item.DropItemOnUnit(unitGUID)
C_LossOfControl.GetActiveLossOfControlDataByUnit(unitToken, index) : event
C_LossOfControl.GetActiveLossOfControlDataCountByUnit(unitToken) : count
C_Map.GetBestMapForUnit(unitToken) : uiMapID
C_Map.GetPlayerMapPosition(uiMapID, unitToken) : position
C_PaperDollInfo.GetInspectAzeriteItemEmpoweredChoices(unit, equipmentSlotIndex) : azeritePowerIDs
C_PaperDollInfo.GetInspectItemLevel(unit) : equippedItemLevel
C_PaperDollInfo.GetStaggerPercentage(unit) : stagger, staggerAgainstTarget
C_PlayerInfo.GetContentDifficultyCreatureForPlayer(unitToken) : difficulty
C_PlayerInfo.GetPlayerMythicPlusRatingSummary(playerToken) : ratingSummary
C_PvP.GetArenaCrowdControlInfo(playerToken) : spellID, startTime, duration
C_PvP.RequestCrowdControlSpell(playerToken)
C_QuestItemUse.CanUseQuestItemOnObject(item, unit, checkRange) : canUse
C_QuestLog.IsUnitOnQuest(unit, questID) : isOnQuest
C_QuestLog.UnitIsRelatedToActiveQuest(unit) : isRelatedToActiveQuest
C_SpecializationInfo.GetInspectSelectedPvpTalent(inspectedUnit, talentIndex) : selectedTalentID
C_Spell.IsSpellInRange(spellIdentifier, targetUnit) : inRange
C_SpellBook.IsSpellBookItemInRange(spellBookItemSlotIndex, spellBookItemSpellBank, targetUnit) : inRange
C_TooltipInfo.GetInventoryItem(unit, slot, hideUselessStats) : data
C_TooltipInfo.GetUnit(unit, hideStatus) : data
C_TooltipInfo.GetUnitAura(unitToken, index, filter) : data
C_TooltipInfo.GetUnitBuff(unitToken, index, filter) : data
C_TooltipInfo.GetUnitDebuff(unitToken, index, filter) : data
C_UIWidgetManager.SetProcessingUnit(unit)
C_UnitAuras.GetAuraSlots(unitToken, filter, maxSlots, continuationToken) : outContinuationToken, slots
C_WorldLootObject.GetWorldLootObjectInfo(unitToken) : info
C_WorldLootObject.IsWorldLootObject(unitToken) : isWorldLootObject
C_WorldLootObject.IsWorldLootObjectInRange(unitToken) : isWorldLootObjectInRange
C_WorldLootObject.OnWorldLootObjectClick(unitToken)
CanInspect(targetGUID) : result
CheckInteractDistance(unitGUID, distIndex) : result
GetComboPoints(unit, target) : result
GetUnitChargedPowerPoints(unit) : pointIndices
GetUnitEmpowerHoldAtMaxTime(unit) : holdAtMaxTime
GetUnitEmpowerMinHoldTime(unit) : minHoldTime
GetUnitEmpowerStageDuration(unit, index) : duration
GetUnitHealthModifier(unit) : result
GetUnitMaxHealthModifier(unit) : result
GetUnitPowerBarInfo(unitToken) : info
GetUnitPowerBarStrings(unitToken) : name, tooltip, cost
GetUnitPowerBarTextureInfo(unitToken, textureIndex, timerIndex) : texture, colorR, colorG, colorB, colorA
GetUnitPowerModifier(unit) : result
GetUnitSpeed(unit) : currentSpeed, runSpeed, flightSpeed, swimSpeed
GetUnitTotalModifiedMaxHealthPercent(unit) : result
InitiateTrade(guid)
IsFalling(unit) : result
IsFlying(unit) : result
IsSubmerged(unit) : result
IsSwimming(unit) : result
IsUnitModelReadyForUI(unitToken) : isReady
NotifyInspect(targetGUID)
PlayerIsPVPInactive(unit) : result
ReportPlayerIsPVPAFK(unit)
SetPortraitTexture(textureObject, unitToken, disableMasking)
SetUnitCursorTexture(textureObject, unit, style, includeLowPriority) : hasCursor
ShowBossFrameWhenUninteractable(unit) : result
UnitAffectingCombat(unit) : result
UnitAlliedRaceInfo(unit) : isAlliedRace, hasHeritageArmorUnlocked
UnitArmor(unit) : base, effective, real, bonus
UnitAttackPower(unit) : attackPower, posBuff, negBuff
UnitAttackSpeed(unit) : attackSpeed, offhandAttackSpeed
UnitBattlePetLevel(unit) : result
UnitBattlePetSpeciesID(unit) : result
UnitBattlePetType(unit) : result
UnitCanAssist(unit, target) : result
UnitCanAttack(unit, target) : result
UnitCanCooperate(unit, target) : result
UnitCanPetBattle(unit, target) : result
UnitCastingInfo(unit) : name, displayName, textureID, startTimeMs, endTimeMs, isTradeskill, castID, notInterruptible, castingSpellID
UnitChromieTimeID(unit) : ID
UnitClass(unit) : className, classFilename, classID
UnitClassBase(unit) : classFilename, classID
UnitClassification(unit) : result
UnitControllingVehicle(unit) : result
UnitCreatureFamily(unit) : result
UnitCreatureType(unit) : result
UnitDamage(unit) : minDamage, maxDamage, offhandMinDamage, offhandMaxDamage, posBuff, negBuff, percent
UnitDetailedThreatSituation(unit, mobGUID) : isTanking, status, scaledPercentage, rawPercentage, rawThreat
UnitDistanceSquared(unit) : distance, checkedDistance
UnitExists(unit) : result
UnitGetIncomingHeals(unit, healerGUID) : result
UnitGetTotalAbsorbs(unit) : result
UnitGetTotalHealAbsorbs(unit) : result
UnitGroupRolesAssigned(unit) : result
UnitGroupRolesAssignedEnum(unit) : result
UnitGUID(unit) : result
UnitHasRelicSlot(unit) : result
UnitHasVehiclePlayerFrameUI(unit) : result
UnitHasVehicleUI(unit) : result
UnitHealth(unit, usePredicted) : result
UnitHealthMax(unit) : result
UnitHonor(unit) : result
UnitHonorLevel(unit) : result
UnitHonorMax(unit) : result
UnitHPPerStamina(unit) : result
UnitInAnyGroup(unit, partyIndex) : result
UnitInBattleground(unit, partyIndex) : result
UnitInParty(unit, partyIndex) : result
UnitInPartyIsAI(unit) : result
UnitInPartyShard(unit) : inPartyShard
UnitInRaid(unit, partyIndex) : result
UnitInRange(unit) : inRange, checkedRange
UnitInSubgroup(unit, partyIndex) : result
UnitInVehicle(unit) : result
UnitInVehicleControlSeat(unit) : result
UnitInVehicleHidesPetFrame(unit) : result
UnitIsAFK(unit) : result
UnitIsBattlePet(unit) : result
UnitIsBattlePetCompanion(unit) : result
UnitIsBossMob(unit) : result
UnitIsCharmed(unit) : result
UnitIsConnected(unit) : isConnected
UnitIsControlling(unit) : result
UnitIsCorpse(unit) : result
UnitIsDead(unit) : result
UnitIsDeadOrGhost(unit) : result
UnitIsDND(unit) : result
UnitIsEnemy(unit, target) : result
UnitIsFeignDeath(unit) : result
UnitIsFriend(unit, target) : result
UnitIsGameObject(unit) : result
UnitIsGhost(unit) : result
UnitIsInteractable(unit) : result
UnitIsOtherPlayersBattlePet(unit) : result
UnitIsOtherPlayersPet(unit) : result
UnitIsOwnerOrControllerOfUnit(controllingUnit, controlledUnit) : unitIsOwnerOrControllerOfUnit
UnitIsPlayer(unit, partyIndex) : result
UnitIsPossessed(unit) : result
UnitIsPVP(unit) : result
UnitIsPVPFreeForAll(unit) : result
UnitIsPVPSanctuary(unit) : result
UnitIsQuestBoss(unit) : result
UnitIsRaidOfficer(unit) : result
UnitIsTapDenied(unit) : result
UnitIsTrivial(unit) : result
UnitIsUnconscious(unit) : result
UnitIsVisible(unit) : result
UnitIsWildBattlePet(unit) : result
UnitNameplateShowsWidgetsOnly(unit) : nameplateShowsWidgetsOnly
UnitNumPowerBarTimers(unit) : result
UnitOnTaxi(unit) : result
UnitPartialPower(unitToken, powerType, unmodified) : partialPower
UnitPhaseReason(unit) : reason
UnitPlayerControlled(unit) : result
UnitPlayerOrPetInParty(unit, partyIndex) : result
UnitPlayerOrPetInRaid(unit, partyIndex) : result
UnitPosition(unit) : positionX, positionY, positionZ, mapID
UnitPower(unitToken, powerType, unmodified) : power
UnitPowerBarID(unitToken) : barID
UnitPowerBarTimerInfo(unit, index) : duration, expiration, barID, auraID
UnitPowerMax(unitToken, powerType, unmodified) : maxPower
UnitPowerType(unit, index) : powerType, powerTypeToken, rgbX, rgbY, rgbZ
UnitPvpClassification(unit) : classification
UnitPVPName(unit) : result
UnitQuestTrivialLevelRange(unit) : levelRange
UnitQuestTrivialLevelRangeScaling(unit) : levelRange
UnitRangedAttackPower(unit) : attackPower, posBuff, negBuff
UnitRangedDamage(unit) : speed, minDamage, maxDamage, posBuff, negBuff, percent
UnitReaction(unit, target) : result
UnitRealmRelationship(unit) : realmRelationship
UnitSelectionColor(unit, useExtendedColors) : resultR, resultG, resultB, resultA
UnitSelectionType(unit, useExtendedColors) : result
UnitSetRole(unit, roleStr) : result
UnitSetRoleEnum(unit, role) : result
UnitSex(unit) : sex
UnitShouldDisplayName(unit) : result
UnitSpellHaste(unit) : result
UnitStagger(unit) : result
UnitStat(unit, index) : currentStat, effectiveStat, statPositiveBuff, statNegativeBuff
UnitSwitchToVehicleSeat(unit, virtualSeatIndex)
UnitTargetsVehicleInRaidUI(unit) : result
UnitThreatPercentageOfLead(unit, mobGUID) : result
UnitThreatSituation(unit, mobGUID) : result
UnitTreatAsPlayerForDisplay(unit) : treatAsPlayer
UnitTrialBankedLevels(unit) : bankedLevels, xpIntoCurrentLevel, xpForNextLevel
UnitTrialXP(unit) : result
UnitUsingVehicle(unit) : result
UnitVehicleSeatCount(unit) : result
UnitVehicleSeatInfo(unit, virtualSeatIndex) : controlType, occupantName, serverName, ejectable, canSwitchSeats
UnitVehicleSkin(unit) : result
UnitWeaponAttackPower(unit) : mainHandWeaponAttackPower, offHandWeaponAttackPower, rangedWeaponAttackPower
UnitWidgetSet(unit) : uiWidgetSet
UnitXP(unit) : result
UnitXPMax(unit) : result
WorldLootObjectExists(unit) : result

Widgets

ModelSceneActorBase:SetModelByUnit(unit, sheatheWeapons, autoDress, hideWeapons, usePlayerNativeForm, holdBowString) : success
PlayerModel:CanSetUnit(unit)
PlayerModel:SetUnit(unit, blend, useNativeForm) : success

Events

ARENA_COOLDOWNS_UPDATE: unitTarget
ARENA_CROWD_CONTROL_SPELL_UPDATE: unitTarget, spellID
HONOR_XP_UPDATE: unitTarget
INCOMING_RESURRECT_CHANGED: unitTarget
INCOMING_SUMMON_CHANGED: unitTarget
KNOWN_TITLES_UPDATE: unitTarget
LOSS_OF_CONTROL_ADDED: unitTarget, effectIndex
LOSS_OF_CONTROL_UPDATE: unitTarget
MINIMAP_PING: unitTarget, y, x
PARTY_MEMBER_DISABLE: unitTarget
PARTY_MEMBER_ENABLE: unitTarget
PLAYER_DAMAGE_DONE_MODS: unitTarget
PLAYER_FLAGS_CHANGED: unitTarget
PLAYER_GAINS_VEHICLE_DATA: unitTarget, vehicleUIIndicatorID
PLAYER_GUILD_UPDATE: unitTarget
PLAYER_LOSES_VEHICLE_DATA: unitTarget
PLAYER_PVP_KILLS_CHANGED: unitTarget
PLAYER_PVP_RANK_CHANGED: unitTarget
PLAYER_SPECIALIZATION_CHANGED: unitTarget
PLAYER_TRIAL_XP_UPDATE: unitTarget
PLAYER_XP_UPDATE: unitTarget
PVP_TIMER_UPDATE: unitTarget
READY_CHECK_CONFIRM: unitTarget, isReady
UNIT_ABSORB_AMOUNT_CHANGED: unitTarget
UNIT_AREA_CHANGED: unitTarget
UNIT_ATTACK_POWER: unitTarget
UNIT_ATTACK_SPEED: unitTarget
UNIT_ATTACK: unitTarget
UNIT_AURA: unitTarget, updateInfo
UNIT_CLASSIFICATION_CHANGED: unitTarget
UNIT_COMBAT: unitTarget, event, flagText, amount, schoolMask
UNIT_CONNECTION: unitTarget, isConnected
UNIT_CTR_OPTIONS: unitTarget
UNIT_DAMAGE: unitTarget
UNIT_DEFENSE: unitTarget
UNIT_DISPLAYPOWER: unitTarget
UNIT_DISTANCE_CHECK_UPDATE: unitTarget, isInDistance
UNIT_ENTERED_VEHICLE: unitTarget, showVehicleFrame, isControlSeat, vehicleUIIndicatorID, vehicleGUID, mayChooseExit, hasPitch
UNIT_ENTERING_VEHICLE: unitTarget, showVehicleFrame, isControlSeat, vehicleUIIndicatorID, vehicleGUID, mayChooseExit, hasPitch
UNIT_EXITED_VEHICLE: unitTarget
UNIT_EXITING_VEHICLE: unitTarget
UNIT_FACTION: unitTarget
UNIT_FLAGS: unitTarget
UNIT_FORM_CHANGED: unitTarget
UNIT_HEAL_ABSORB_AMOUNT_CHANGED: unitTarget
UNIT_HEAL_PREDICTION: unitTarget
UNIT_HEALTH: unitTarget
UNIT_IN_RANGE_UPDATE: unitTarget, isInRange
UNIT_INVENTORY_CHANGED: unitTarget
UNIT_LEVEL: unitTarget
UNIT_MANA: unitTarget
UNIT_MAX_HEALTH_MODIFIERS_CHANGED: unitTarget, percentMaxHealthAdjusted
UNIT_MAXHEALTH: unitTarget
UNIT_MAXPOWER: unitTarget, powerType
UNIT_MODEL_CHANGED: unitTarget
UNIT_NAME_UPDATE: unitTarget
UNIT_OTHER_PARTY_CHANGED: unitTarget
UNIT_PET_EXPERIENCE: unitTarget
UNIT_PET: unitTarget
UNIT_PHASE: unitTarget
UNIT_PORTRAIT_UPDATE: unitTarget
UNIT_POWER_BAR_HIDE: unitTarget
UNIT_POWER_BAR_SHOW: unitTarget
UNIT_POWER_BAR_TIMER_UPDATE: unitTarget
UNIT_POWER_FREQUENT: unitTarget, powerType
UNIT_POWER_POINT_CHARGE: unitTarget
UNIT_POWER_UPDATE: unitTarget, powerType
UNIT_QUEST_LOG_CHANGED: unitTarget
UNIT_RANGED_ATTACK_POWER: unitTarget
UNIT_RANGEDDAMAGE: unitTarget
UNIT_RESISTANCES: unitTarget
UNIT_SPELL_HASTE: unitTarget
UNIT_SPELLCAST_CHANNEL_START: unitTarget, castGUID, spellID
UNIT_SPELLCAST_CHANNEL_STOP: unitTarget, castGUID, spellID
UNIT_SPELLCAST_CHANNEL_UPDATE: unitTarget, castGUID, spellID
UNIT_SPELLCAST_DELAYED: unitTarget, castGUID, spellID
UNIT_SPELLCAST_EMPOWER_START: unitTarget, castGUID, spellID
UNIT_SPELLCAST_EMPOWER_STOP: unitTarget, castGUID, spellID, complete
UNIT_SPELLCAST_EMPOWER_UPDATE: unitTarget, castGUID, spellID
UNIT_SPELLCAST_FAILED_QUIET: unitTarget, castGUID, spellID
UNIT_SPELLCAST_FAILED: unitTarget, castGUID, spellID
UNIT_SPELLCAST_INTERRUPTED: unitTarget, castGUID, spellID
UNIT_SPELLCAST_INTERRUPTIBLE: unitTarget
UNIT_SPELLCAST_NOT_INTERRUPTIBLE: unitTarget
UNIT_SPELLCAST_RETICLE_CLEAR: unitTarget, castGUID, spellID
UNIT_SPELLCAST_RETICLE_TARGET: unitTarget, castGUID, spellID
UNIT_SPELLCAST_START: unitTarget, castGUID, spellID
UNIT_SPELLCAST_STOP: unitTarget, castGUID, spellID
UNIT_SPELLCAST_SUCCEEDED: unitTarget, castGUID, spellID
UNIT_STATS: unitTarget
UNIT_TARGET: unitTarget
UNIT_TARGETABLE_CHANGED: unitTarget
UNIT_THREAT_LIST_UPDATE: unitTarget
UNIT_THREAT_SITUATION_UPDATE: unitTarget

Last updated: 11.0.2

References

 
  1. ^ Zootfizzle 2010-07-25. Re: 3.1 API changes (and clarifications). Archived from the original