Thread Tools Display Modes
10-20-18, 02:05 PM   #1
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
In your nameplate addon you will have a unitID associated with every nameplate that you're drawing.

When a nameplate is shown, the NAME_PLATE_UNIT_ADDED event will fire, and provide the unitID as its first argument. This can be passed to C_NamePlate.GetNamePlateForUnit(unitID) to get the frame associated with the nameplate unit. That frame is what your addon is attaching to in order to draw its own nameplate above the unit's head.

The NAME_PLATE_CREATED, NAME_PLATE_UNIT_ADDED, and NAME_PLATE_UNIT_REMOVED events are used to track when to create a new nameplate frame, when to show and hide your addon's frames, and to keep track of which unitIDs belong to which nameplates.

When coloring your nameplates you generally have a series of conditions that need to be checked in a certain order, so "unit is targeting me" which you want to represent with one color might be a higher priority than "unit is a hostile npc" which has a different color, and therefor needs to take precedence over it.

In my personal addon I just do this check OnUpdate because I don't particularly care about efficiency, but how you do this is up to you.

Last edited by semlar : 10-20-18 at 02:08 PM.
 
10-20-18, 04:42 PM   #2
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
Sorry for hijacking your thread, neheri, but I was also been curious about how nameplates work.

Originally Posted by semlar View Post
The NAME_PLATE_CREATED, NAME_PLATE_UNIT_ADDED, and NAME_PLATE_UNIT_REMOVED events are used to track when to create a new nameplate frame, when to show and hide your addon's frames, and to keep track of which unitIDs belong to which nameplates.
So, if I am understanding correctly, NAME_PLATE_CREATED gets fired when the new nameplate frame needs to be made if there is more of them needed than what currently exists (which I am guessing that they are recycled) while NAME_PLATE_UNIT_ADDED and NAME_PLATE_UNIT_REMOVED are fired when the unit is being allocated to/ release from the nameplate frame.

That being said in case if there are five nameplate frames already exist and the game has to display only four units to assign to the nameplate frame the only event being fried would be NAME_PLATE_UNIT_ADDED.

Am I getting it correctly?
 

WoWInterface » Developer Discussions » Lua/XML Help » How to check if Unit target is player


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off