WoW:API UnitAura: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (→‎History: English: casted -> cast)
m (wrap signature; remove Parameters header; unindent lists)
Line 3: Line 3:
This function was introduced in Patch 3.0. It will serve as an all-in-one solution for querying unit buffs and debuffs. [[API UnitBuff|UnitBuff]] and [[API UnitDebuff|UnitDebuff]] will serve as aliases with built-in harmful/helpful filters.
This function was introduced in Patch 3.0. It will serve as an all-in-one solution for querying unit buffs and debuffs. [[API UnitBuff|UnitBuff]] and [[API UnitDebuff|UnitDebuff]] will serve as aliases with built-in harmful/helpful filters.
Usage:
Usage:
  name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura("unit", index or ["name", "rank"][, "filter"])  
  name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable  
  = UnitAura("unit", index or ["name", "rank"][, "filter"])  


== Parameters ==
== Arguments ==
=== Arguments ===
;unit : String - The [[API TYPE UnitId|unit]] you want debuff information for.
:;unit : String - The [[API TYPE UnitId|unit]] you want debuff information for.
;index : Number - The index of the debuff to retrieve info for. Starts at 1, maximum 40.
:;index : Number - The index of the debuff to retrieve info for. Starts at 1, maximum 40.
;filter : This parameter can be any of "HELPFUL", "HARMFUL", "PLAYER", "RAID", "CANCELABLE", "NOT_CANCELABLE". You can also specify several filters separated by a | or space character to chain multiple filters together (e.g. "HELPFUL|RAID" or "HELPFUL RAID" == helpful buffs that you can cast on your raid). By default UnitAura has "HELPFUL" as an implicit filter - you cannot get back BOTH helpful and harmful at the same time. Neither "HELPFUL" or "HARMFUL" have meaning for UnitBuff/UnitDebuff, and will be ignored.
:;filter : This parameter can be any of "HELPFUL", "HARMFUL", "PLAYER", "RAID", "CANCELABLE", "NOT_CANCELABLE". You can also specify several filters separated by a | or space character to chain multiple filters together (e.g. "HELPFUL|RAID" or "HELPFUL RAID" == helpful buffs that you can cast on your raid). By default UnitAura has "HELPFUL" as an implicit filter - you cannot get back BOTH helpful and harmful at the same time. Neither "HELPFUL" or "HARMFUL" have meaning for UnitBuff/UnitDebuff, and will be ignored.


=== Returns ===
== Returns ==
:;name : String - The name of the spell or effect of the debuff. This is the name shown in yellow when you mouse over the icon.
;name : String - The name of the spell or effect of the debuff. This is the name shown in yellow when you mouse over the icon.
:;rank : String - The rank of the spell or effect that caused the debuff. Returns "" if there is no rank.
;rank : String - The rank of the spell or effect that caused the debuff. Returns "" if there is no rank.
:;icon  
;icon  
:;count : Number - The number of times the debuff has been applied to the target.  Returns 0 for any debuff which doesn't stack. ( Changed in 1.11 ).
;count : Number - The number of times the debuff has been applied to the target.  Returns 0 for any debuff which doesn't stack. ( Changed in 1.11 ).
:;debuffType : String - The type of the debuff: Magic, Disease, Poison, Curse, or nothing for those with out a type.
;debuffType : String - The type of the debuff: Magic, Disease, Poison, Curse, or nothing for those with out a type.
:; duration : Number - The full duration of the debuff in seconds; nil if the debuff was not cast by the player.
; duration : Number - The full duration of the debuff in seconds; nil if the debuff was not cast by the player.
:; expirationTime : Number - Time in seconds when the aura will expire.
; expirationTime : Number - Time in seconds when the aura will expire.
:; unitCaster : String - [[unitId]] reference to the unit that casted the buff/debuff.
; unitCaster : String - [[unitId]] reference to the unit that casted the buff/debuff.
:; isStealable : Boolean - 1 or nil depending on if the aura can be spellstolen.
; isStealable : Boolean - 1 or nil depending on if the aura can be spellstolen.





Revision as of 13:10, 28 May 2009

WoW API < UnitAura

This function was introduced in Patch 3.0. It will serve as an all-in-one solution for querying unit buffs and debuffs. UnitBuff and UnitDebuff will serve as aliases with built-in harmful/helpful filters. Usage:

name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable 
 = UnitAura("unit", index or ["name", "rank"][, "filter"]) 

Arguments

unit
String - The unit you want debuff information for.
index
Number - The index of the debuff to retrieve info for. Starts at 1, maximum 40.
filter
This parameter can be any of "HELPFUL", "HARMFUL", "PLAYER", "RAID", "CANCELABLE", "NOT_CANCELABLE". You can also specify several filters separated by a | or space character to chain multiple filters together (e.g. "HELPFUL|RAID" or "HELPFUL RAID" == helpful buffs that you can cast on your raid). By default UnitAura has "HELPFUL" as an implicit filter - you cannot get back BOTH helpful and harmful at the same time. Neither "HELPFUL" or "HARMFUL" have meaning for UnitBuff/UnitDebuff, and will be ignored.

Returns

name
String - The name of the spell or effect of the debuff. This is the name shown in yellow when you mouse over the icon.
rank
String - The rank of the spell or effect that caused the debuff. Returns "" if there is no rank.
icon
count
Number - The number of times the debuff has been applied to the target. Returns 0 for any debuff which doesn't stack. ( Changed in 1.11 ).
debuffType
String - The type of the debuff: Magic, Disease, Poison, Curse, or nothing for those with out a type.
duration
Number - The full duration of the debuff in seconds; nil if the debuff was not cast by the player.
expirationTime
Number - Time in seconds when the aura will expire.
unitCaster
String - unitId reference to the unit that casted the buff/debuff.
isStealable
Boolean - 1 or nil depending on if the aura can be spellstolen.


Macro Options:

1. Prints the name of any stealable buffs on the current target, or a notice if nothing is stealable:

/run local y=0;for i=1,40 do local n,_,_,_,_,_,_,_,isStealable=UnitAura("target",i);if isStealable==1 then print(n.." on target, steal it!")y=1;end end if y~=1 then print("No stealable buffs.")end


History

  • Patch 3.0 combined UnitDebuff and UnitBuff into this command.
  • Patch 3.1 changed "isMine" to "unitCaster". It is now possible for addons to retrieve the unitId that cast the buff/debuff.

See Also

UnitBuff
UnitDebuff
List of known buff and debuff effects that can be queried
Upcoming 3.0 Changes - Concise List