Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
m (Cleanup; Elinks message per WW:BR request AWB)
 
m (→‎Example: Decomposing a GUID: Change from "King Varian Wrynn" to "Mo'arg Weaponsmith")
 
Line 1: Line 1:
  +
{{wowapi}}
−
{{questbox
 
  +
Returns the GUID of the specified unit; works on both players and NPC.
−
| name= The Ancient Leaf
 
  +
guid = UnitGUID("unit")
−
| faction= Neutral
 
−
| level= 60
 
−
| levelreq = 60
 
−
| type= Solo
 
−
| category = Molten Core
 
−
| start = [[Ancient Petrified Leaf]]
 
−
| end = [[Vartrus the Ancient]]
 
−
| rewards =
 
−
| id = 7632
 
−
}}
 
   
−
== Objectives ==
+
==Arguments==
  +
; unit : String - [[unitId|Unit ID]] of the unit to look up.
−
Find the owner of the [[Ancient Petrified Leaf]]. Good luck, <name>; It's a big world.
 
−
*{{item|Ancient Petrified Leaf|icon=}} (Provided)
 
   
−
== Description ==
+
== Returns ==
  +
; guid : String - a string containing the hexadecimal representation of the unit's GUID, or nil if the unit does not exist.
−
The epidermis of the leaf glows a bright green. The surface is extremely rugose, exposing several veins and wrinkles.
 
   
 
== Example ==
−
If you had to take a guess, you would say this leaf came from something ancient and powerful.
 
  +
local name = UnitName("target"); local guid = UnitGUID("target"); ChatFrame1:AddMessage(name.." has the GUID: "..guid);
   
  +
<big>'''Result'''</big>
−
Maybe you should find the original owner of this leaf?
 
  +
Cyan has the GUID: 0x00000000012729FD
   
  +
<big>'''Conversion to decimal?'''</big>
−
== Progress ==
 
−
<Vartrus groans.>
 
   
  +
GUIDs are 64-bit numbers, and are far too long to convert to decimal numbers using lua's libraries as a whole. E.g. running tonumber(guid, 16) will produce erronous results.
−
== Completion ==
 
−
Of course I recognize my own leaves. Look at that! It's in perfect condition.
 
   
−
How good of you to return it, <class>.
 
   
  +
== Notes ==
−
Perhaps you could be of service to us and we to you.
 
  +
GUIDs are represented in WoW as hexadecimal strings beginning with '0x' -- this prefix is not part of the data, but merely signifies that what follows is a hexadecimal number. GUIDs are intended to provide a unique way to identify units; the following general rules apply: [http://forums.worldofwarcraft.com/thread.html?topicId=2968233433&postId=44201363100&sid=1#231]
  +
* 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.
   
  +
A GUID can be thought of as being composed of multiple pieces of data. Consider "'''0xAABCCCDDDDEEEEEE'''", where:
== Gains ==
 
  +
:; AA : unknown.
−
Upon completion of this quest you will gain:
 
  +
:; B : unit type, mask with 0x7 to get: 0 for players, 1 for world objects, 3 for NPCs, 4 for permanent pets, 5 for vehicles. Temporary pets (Treants, Spirit Wolves, Water Elemental, Mirror Images, and Ghouls) are considered NPCs (3), even if talents or glyphs prevent them from expiring.
−
*0 [[XP]]
 
  +
:; CCC : If the unit is a pet, CCCDDDD forms a unique ID for the pet based on creation order; if a world object, CCCDDDD is the object ID; otherwise unknown.
  +
:; DDDD : If the unit is an NPC, this is the hexadecimal representation of the NPC id.
  +
:; EEEEEE : If the unit is a player, this is a unique identifier based on creation order. Otherwise, this is a spawn counter based on spawn order.<br>(For players it can be 7 digits long, so that its DEEEEEE)
   
−
== Epic Quest Strategy ==
 
−
Here are videos and strategies of all the demon fights done by me.
 
   
  +
=== Example: Determining unit type ===
−
I thank rokk and everyone that posted strats, it has helped me and many others.
 
  +
local guid = UnitGUID("target");
  +
local B = tonumber(guid:sub(5,5), 16);
  +
local maskedB = B % 8; -- x % 8 has the same effect as x & 0x7 on numbers <= 0xf
  +
local knownTypes = {[0]="player", [3]="NPC", [4]="pet", [5]="vehicle"};
  +
print("Your target is a " .. (knownTypes[maskedB] or " unknown entity!"));
   
  +
=== Example: Decomposing a GUID ===
−
Many people think that if you can't kill these demons you are a bad hunter, WRONG. Three out of four of these fights show zero hunter skill (Artorius, on the other hand, is 100% skill) and rely mostly on your knowledge of the strategies and coming prepared with consumables. Once you get the EXACT strategy down, these fights are cake.
 
  +
We have a GUID: "0xF530004D2B008852".
   
  +
First of all, let's find out what kind of unit it is. Take the first three digits in the GUID, ie "F53" (or 0xF53 to show it's an hex value) and apply an AND mask of 0x007 to get 0x003. This GUID is for a normal NPC, neither a pet nor a player.
−
However, once you kill these demons, you will probably kite better, and be more able to switch between attacks quicker. Basically, you will be able to judge specific situations faster, and act accordingly
 
   
  +
We can also extract the Unit ID by taking the seventh to tenth digit and converting it to decimal form: "4D2B", or converted to decimal form "19755". A quick visit to wowhead shows that the NPC with that id is "Mo'arg Weaponsmith", [http://www.wowhead.com/?npc=19755]. All "Mo'arg Weaponsmiths" will have that id to identify them.
−
Best of luck!
 
   
  +
The last six digits, "008852" is the spawn counter. There will never be two "Mo'arg Weaponsmith", possible even never two mobs in the outside world, with the same spawn number. This spawn counter, combined with the rest makes it possible to always refer to exactly this "Mo'arg Weaponsmith", and not the one next to it.
−
*{{questlong|neutral|60|The Ancient Leaf}}, starts with the item [[Ancient Petrified Leaf]]
 
−
**{{questlong|neutral|60|Stave of the Ancients}}, Requires you to kill the 4 demons to get the staff / Shaft of the Bow.
 
−
*** [[Quest:Stave of the Ancients/Artorius the Doombringer]]
 
−
*** [[Quest:Stave of the Ancients/Klinfran the Crazed]]
 
−
*** [[Quest:Stave of the Ancients/Simone the Seductress]]
 
−
*** [[Quest:Stave of the Ancients/Solenor the Slayer]]
 
−
**{{questlong|neutral|60|A Proper String}}, Requires you to bring the [[Mature Black Dragon Sinew]] for the Bow's String.
 
−
**{{questlong|neutral|60|Ancient Sinew Wrapped Lamina}}, Requires you to bring the [[Mature Blue Dragon Sinew]] for the Epic Quiver.
 
   
  +
A simple in game script command can be used to get the NPC ID from your target: ''Target NPC ID: 19755''
−
==External links==
 
  +
/run print("Target NPC ID:", tonumber((UnitGUID("target")):sub(-10, -7), 16))
−
<!-- Read http://www.wowwiki.com/WoWWiki:External_links before posting your links here.
 
  +
More informative script: ''NPC ID("Mo'arg Weaponsmith") = 0x4D2B = 19755''
−
Links that do not conform to the rules will be DELETED.
 
  +
/run local a=string.sub(UnitGUID("target"),9,12);print("NPC ID(\""..UnitName("target").."\") = 0x"..a.." = "..tonumber(a,16))
−
Repeat violations may result in a BAN.
 
−
Have a nice day. :) -->
 
−
{{Elinks-quest|7632}}
 
   
  +
=== Cross-server and GUID "uniqueness" ===
−
[[Category:Walkthroughs]]
 
  +
Player GUIDs are local on a per-server basis, making the "global" scope to be bound to the specific server. Every time a character is created, a new GUID is assigned from a simple +1 counter and then given to that character. 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.
−
[[Category:Hunters]]
 
  +
−
[[Category:Quests|The Ancient Leaf]]
 
  +
Uniqueness is guaranteed in cross-realm battlegrounds by masking the player GUID with a server specific unique identifier, when needed.
  +
  +
NPC GUID collisions have also been observed. It is unknown why or when in specific they occur, but differing mob types have had a NPC ID number which corresponded to an entirely different NPC. This is considered a very rare phenomenon.
  +
  +
== {{C-inline}} 4.0 changes to NPC ID ==
  +
  +
With the PTR 4.0.1 build 13131 [http://www.wowwiki.com/Patch_4.0.1], and Cataclysm Beta 4.0.3 build 13117 [http://www.wowwiki.com/Patch_4.0.3], the NPC portion has moved 2 digits to the left, to <font color="#F6ADC6">CC</font><font color="#ADFF2F">DD</font> instead of <font color="#ADFF2F">DDDD</font>.
  +
*Before: (9th to 12th digit)
  +
0xF13000<font color="#ADFF2F">73AB</font>06AE87,"King Varian Wrynn"
  +
*After: (7th to 10th digit)
  +
0xF130<font color="#ADFF2F">73AB</font>00001BB4,"King Varian Wrynn"
  +
  +
The NPC portion of this is 0x73AB in hex, and a NPC ID of 29611 in decimal.

Revision as of 23:38, 4 October 2010

Returns the GUID of the specified unit; works on both players and NPC.

guid = UnitGUID("unit")

Arguments

unit
String - Unit ID of the unit to look up.

Returns

guid
String - a string containing the hexadecimal representation of the unit's GUID, or nil if the unit does not exist.

Example

local name = UnitName("target"); local guid = UnitGUID("target"); ChatFrame1:AddMessage(name.." has the GUID: "..guid);

Result

Cyan has the GUID: 0x00000000012729FD

Conversion to decimal?

GUIDs are 64-bit numbers, and are far too long to convert to decimal numbers using lua's libraries as a whole. E.g. running tonumber(guid, 16) will produce erronous results.


Notes

GUIDs are represented in WoW as hexadecimal strings beginning with '0x' -- this prefix is not part of the data, but merely signifies that what follows is a hexadecimal number. GUIDs are intended to provide a unique way to identify units; the following general rules apply: [1]

  • 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.

A GUID can be thought of as being composed of multiple pieces of data. Consider "0xAABCCCDDDDEEEEEE", where:

AA
unknown.
B
unit type, mask with 0x7 to get: 0 for players, 1 for world objects, 3 for NPCs, 4 for permanent pets, 5 for vehicles. Temporary pets (Treants, Spirit Wolves, Water Elemental, Mirror Images, and Ghouls) are considered NPCs (3), even if talents or glyphs prevent them from expiring.
CCC
If the unit is a pet, CCCDDDD forms a unique ID for the pet based on creation order; if a world object, CCCDDDD is the object ID; otherwise unknown.
DDDD
If the unit is an NPC, this is the hexadecimal representation of the NPC id.
EEEEEE
If the unit is a player, this is a unique identifier based on creation order. Otherwise, this is a spawn counter based on spawn order.
(For players it can be 7 digits long, so that its DEEEEEE)


Example: Determining unit type

local guid = UnitGUID("target");
local B = tonumber(guid:sub(5,5), 16);
local maskedB = B % 8; -- x % 8 has the same effect as x & 0x7 on numbers <= 0xf
local knownTypes = {[0]="player", [3]="NPC", [4]="pet", [5]="vehicle"};
print("Your target is a " .. (knownTypes[maskedB] or " unknown entity!"));

Example: Decomposing a GUID

We have a GUID: "0xF530004D2B008852".

First of all, let's find out what kind of unit it is. Take the first three digits in the GUID, ie "F53" (or 0xF53 to show it's an hex value) and apply an AND mask of 0x007 to get 0x003. This GUID is for a normal NPC, neither a pet nor a player.

We can also extract the Unit ID by taking the seventh to tenth digit and converting it to decimal form: "4D2B", or converted to decimal form "19755". A quick visit to wowhead shows that the NPC with that id is "Mo'arg Weaponsmith", [2]. All "Mo'arg Weaponsmiths" will have that id to identify them.

The last six digits, "008852" is the spawn counter. There will never be two "Mo'arg Weaponsmith", possible even never two mobs in the outside world, with the same spawn number. This spawn counter, combined with the rest makes it possible to always refer to exactly this "Mo'arg Weaponsmith", and not the one next to it.

A simple in game script command can be used to get the NPC ID from your target: Target NPC ID: 19755

/run print("Target NPC ID:", tonumber((UnitGUID("target")):sub(-10, -7), 16))

More informative script: NPC ID("Mo'arg Weaponsmith") = 0x4D2B = 19755

/run local a=string.sub(UnitGUID("target"),9,12);print("NPC ID(\""..UnitName("target").."\") = 0x"..a.." = "..tonumber(a,16))

Cross-server and GUID "uniqueness"

Player GUIDs are local on a per-server basis, making the "global" scope to be bound to the specific server. Every time a character is created, a new GUID is assigned from a simple +1 counter and then given to that character. 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.

Uniqueness is guaranteed in cross-realm battlegrounds by masking the player GUID with a server specific unique identifier, when needed.

NPC GUID collisions have also been observed. It is unknown why or when in specific they occur, but differing mob types have had a NPC ID number which corresponded to an entirely different NPC. This is considered a very rare phenomenon.

Icon Cataclysm 18x18 4.0 changes to NPC ID

With the PTR 4.0.1 build 13131 [3], and Cataclysm Beta 4.0.3 build 13117 [4], the NPC portion has moved 2 digits to the left, to CCDD instead of DDDD.

  • Before: (9th to 12th digit)
0xF1300073AB06AE87,"King Varian Wrynn"
  • After: (7th to 10th digit)
0xF13073AB00001BB4,"King Varian Wrynn"

The NPC portion of this is 0x73AB in hex, and a NPC ID of 29611 in decimal.