GUIDs uniquely identify almost everything the player character can interact with in World of Warcraft -- including players, pets, vehicle, and interactive world objects (think Midsummer bonfires). GUIDs are represented in WoW as a long string of hex numbers separated by hyphens.
GUIDs are intended to provide a unique way to identify units; the following general rules apply:
- A monster has a single GUID from spawn until death (or despawn). When it respawns it gets a new GUID.
- Pets get a new GUID each time they are summoned.
- Monster and pet GUIDs can be recycled after server (or instance) restart.
- Players keep their GUID forever, and are unique even in cross-server battlegrounds.
- However, units that "transform" into other units may not switch GUID immediately.
Prints the currently active companion pet.
/dump C_PetJournal.GetSummonedPetGUID() > "BattlePet-0-00000338F951"
- GUIDs for Battle.net accounts are returned from C_Club.GetMemberInfo() or C_VoiceChat.GetMemberGUID()
local playerAccountGUID = string.format("BNetAccount-0-%012X", (BNGetNumFriends() + 1)); local isBattleNetGUID = C_AccountInfo.IsGUIDBattleNetAccountType(playerAccountGUID); local isLocalPlayerGUID = C_AccountInfo.IsGUIDRelatedToLocalAccount(playerAccountGUID); print(playerAccountGUID, isBattleNetGUID, isLocalPlayerGUID); > "BNetAccount-0-000000000016", true, true
accountID portion of the GUID is, at least for friend accounts, a hexadecimal form of the Battle.net account ID as used by C_BattleNet.GetAccountInfoByID()
- GUIDs for spell casts are obtained from spell cast events or as a return value from UnitCastingInfo()
type parameter has the following known variants.
For local spell casts, the server, instance, and zone ID components will always be zero, and the cast UID will be a locally-incrementing integer.
For all other known spell cast types, the cast UID component is similar to Creature and Vehicle GUIDs; the lowest 23 bits represent the timestamp of the cast measured in seconds since the UNIX epoch as returned by GetServerTime() modulo
2^23, and the higher bits appear to be an incrementing number for spell casts that occur within the same second.
ClientActors are NPCs which are only simulated by the game client instead of the server.
/dump UnitName("target"), UnitGUID("target") > "Unleashed Hatred", "ClientActor-3-5-1340"
"Creature", "Pet", "GameObject", "Vehicle"
/dump UnitName("target"), UnitGUID("target") > "Hogger", "Creature-0-1465-0-2105-448-000043F59F"
local npcID = select(6, strsplit("-", UnitGUID("target"))) print(npcID, tonumber(npcID)) > "448", 448
For Creature and Vehicle GUIDs the
spawnUID component encodes a wrapping spawn time offset of the entity in the low 23 bits of the field, measured in seconds since the UNIX epoch as returned by GetServerTime() modulo
2^23. Higher bits appear to be a unique counter for individual spawns within the same time unit.
local guid = UnitGUID("target") local unitType, _, _, _, _, _, spawnUID = strsplit("-", guid) if unitType == "Creature" or unitType == "Vehicle" then local spawnEpoch = GetServerTime() - (GetServerTime() % 2^23) local spawnEpochOffset = bit.band(tonumber(string.sub(spawnUID, 5), 16), 0x7fffff) local spawnIndex = bit.rshift(bit.band(tonumber(string.sub(spawnUID, 1, 5), 16), 0xffff8), 3) local spawnTime = spawnEpoch + spawnEpochOffset if spawnTime > GetServerTime() then -- This only occurs if the epoch has rolled over since a unit has spawned. spawnTime = spawnTime - ((2^23) - 1) end print(guid) print("Spawned at:", date("%Y-%m-%d %H:%M:%S", spawnTime)) print("Spawn index:", spawnIndex) end > "Creature-0-4170-0-41-68662-00000F4B37" > "Spawned at:", "2021-01-25 22:50:31" > "Spawn index:", 0
For Pet GUIDs the
spawnUID component encodes a unique identifier in the low 32 bits, similar to Player GUIDs, and a wrapping counter in the upper 8 bits representing the number of times the pet has been summoned.
local guid = UnitGUID("target") local unitType, _, _, _, _, _, spawnUID = strsplit("-", guid) if unitType == "Pet" then local petUID = string.sub(spawnUID, 3) local spawnIndex = tonumber(string.sub(spawnUID, 1, 2), 16) print(guid) print("Unique Pet ID:", petUID) print("Spawn index:", spawnIndex) end > "Pet-0-4234-0-6610-165189-0202F859E9" > "Unique Pet ID:", "02F859E9" > "Spawn index:", 2
local followers = C_Garrison.GetFollowers() print(followers.name, followers.followerID) > "Calia Menethil", "0x0000000004CBDB61"
- GUIDs for items are returned from C_Item.GetItemGUID, ItemMixin:GetItemGUID and GetLootSourceInfo. (Not to be confused with ItemIDs)
Prints the GUID of the item in the player's head slot.
local itemLoc = ItemLocation:CreateFromEquipmentSlot(INVSLOT_HEAD) local item = Item:CreateFromItemLocation(itemLoc) print(item:GetItemGUID()) > "Item-1598-0-4000000A369860E1"
/dump UnitGUID("player") > "Player-970-0002FD64"
It should be noted that the act of transferring characters, either server to server, account to account, or even account to account while remaining on the same server will generate a new character GUID, because of how the process works (the character "ceases to exist" for a short period, and is then recreated). This act erases friend and ignore lists. Renaming a character does not trigger a new GUID, as that process is much simpler than a full character move.
"Vignette-0-970-1116-7-0-0017CAE465" -- for rare mob Sulfurious
- Patch 6.0.2 / API (2014-10-14): Changed to a new format, e.g. for players:
- Patch 5.1.0 / API (2012-11-27): Bits shifted. NPCID is now characters 6-9, not 7-10 (counting from 1).
- Patch 4.0.1 / API (2010-10-12): Bits shifted. NPCID is now characters 5-8, not 7-10 (counting from 1).
- Patch 3.3.0 / API (2009-12-08): Bits shifted. NPCID is now characters 7-10, not 6-9 (counting from 1).
- Patch 2.4.0 / API (2008-03-25): Added, an example of the old format is