Event:UNIT TARGET CHANGED

Triggered when a new target is selected or deselected (either by clicking on a monster or NPC, pressing the alt key or escape to cancel your selection).

Arguments


 * arg1
 * UnitId of the Unit that changed its selection ("player")
 * arg2
 * Unique identifier of the selected target. 0 Essentially means he cancelled his last target and has no current target or that he is targeting himself. If the cancellation is due to distance/visibility change, then the return value can be anything between 0 and X (typically I've seen values between 1 and 3000). MonsterID values are much, much higher than the values of cancellation, so we can use that to determine which it is.
 * arg3
 * Unknown integer (0)
 * arg4
 * Apparently, the name of the last player that spoke.


 * Example:

function Addon_TargetChanged(arg1,arg2) if(arg2 == 0) then --UnitID(arg1) doesn't have any target or is targeting himself. elseif(arg2 < 10000) --value limit needs testing, this is what I would use to be safe from getting mixed into the unique identifier. --UnitID(arg1) doesn't have any target due to target disappearing from view or dying (and thus being deselected). else --UnitID(arg1) changed it's target to a monster with ID (arg2). end end