WoW:API UnitBuff: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (→‎Returns: English: casted -> cast)
(unindent definition lists)
Line 1: Line 1:
{{wowapi}} __NOTOC__
{{wowapi}} __NOTOC__
Retrieve info about a certain buff on a certain unit. This essentially an alias of [[API_UnitAura|UnitAura]] with the "HELPFUL" filter.
Retrieve info about a certain buff on a certain unit. This essentially an alias of [[API_UnitAura|UnitAura]] with the "HELPFUL" filter.
  name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitBuff(unit, index or name [, castable])
  name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable  
  = UnitBuff(unit, index or name [, castable])


== Parameters ==
== Arguments ==
=== Arguments ===
;unitId : String - The [[unitId|unit]] to query information for
;index or name : Number or string - The index or name of the buff to retrieve information for. Indices start at 1 and go up indefinitely until there are no more buffs on target.
;castable : Boolean - If present and true (1), then only player-castable buffs will be returned; buffIndex still starts at 1.


:;unitId : String - The [[unitId|unit]] to query information for
== Returns ==
:;index or name : Number or string - The index or name of the buff to retrieve information for. Indices start at 1 and go up indefinitely until there are no more buffs on target.
;name : String - The name of the spell or effect of the buff, or nil if no buff was found with the specified name or at the specified index. This is the name shown in yellow when you mouse over the icon.
:;castable : Boolean - If present and true (1), then only player-castable buffs will be returned; buffIndex still starts at 1.
;rank : String - The rank of the spell or effect that caused the buff. Returns "" if there is no rank.
 
;iconTexture : String - The identifier of (path and filename to) the indicated buff.
=== Returns ===
;count : Number - The number of times the buff has been applied to the target.
:;name : String - The name of the spell or effect of the buff, or nil if no buff was found with the specified name or at the specified index. This is the name shown in yellow when you mouse over the icon.
;debuffType : String - The magic type of the buff
:;rank : String - The rank of the spell or effect that caused the buff. Returns "" if there is no rank.
;duration : Number - The full duration of the buff in seconds
:;iconTexture : String - The identifier of (path and filename to) the indicated buff.
;expirationTime : Number - Time the buff will expire in seconds
:;count : Number - The number of times the buff has been applied to the target.
;isMine : String - The [[unitId|unit]] that cast the buff
:;debuffType : String - The magic type of the buff
;isStealable : Boolean - 1 if it is stealable otherwise nil
:;duration : Number - The full duration of the buff in seconds
:;expirationTime : Number - Time the buff will expire in seconds
:;isMine : String - The [[unitId|unit]] that cast the buff
:;isStealable : Boolean - 1 if it is stealable otherwise nil


== Example ==
== Example ==

Revision as of 13:08, 28 May 2009

WoW API < UnitBuff

Retrieve info about a certain buff on a certain unit. This essentially an alias of UnitAura with the "HELPFUL" filter.

name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable 
 = UnitBuff(unit, index or name [, castable])

Arguments

unitId
String - The unit to query information for
index or name
Number or string - The index or name of the buff to retrieve information for. Indices start at 1 and go up indefinitely until there are no more buffs on target.
castable
Boolean - If present and true (1), then only player-castable buffs will be returned; buffIndex still starts at 1.

Returns

name
String - The name of the spell or effect of the buff, or nil if no buff was found with the specified name or at the specified index. 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 buff. Returns "" if there is no rank.
iconTexture
String - The identifier of (path and filename to) the indicated buff.
count
Number - The number of times the buff has been applied to the target.
debuffType
String - The magic type of the buff
duration
Number - The full duration of the buff in seconds
expirationTime
Number - Time the buff will expire in seconds
isMine
String - The unit that cast the buff
isStealable
Boolean - 1 if it is stealable otherwise nil

Example

local buffs, i = { }, 1;
local buff = UnitBuff("player", i);
while buff do
  buffs[#buffs + 1] = buff;
  i = i + 1;
  buff = UnitBuff("player", i);
end;
if #buffs < 1 then
  buffs = "You have no buffs";
else
  buffs[1] = "You're buffed with: "..buffs[1];
  buffs = table.concat(buffs, ", ");
end;
DEFAULT_CHAT_FRAME:AddMessage(buffs);
Macro Options:

1. Prints the names of all buffs on the current target:

/run for i=1,40 do local B=UnitBuff("target",i); if B then print(i.."="..B) end end

2. Prints the name, icon texture, and time left for all buffs on the player.

/run for i=1,40 do local n,_,icon,_,_,dur,x,_,_=UnitBuff("player",i);if n then print(i.."="..n..", "..icon..", "..format("%.2f",-1*(GetTime()-x)/60).." minutes left.")end end

History

  • Patch 1.9 added castable to the list of parameters.
  • Patch 2.0 added name and rank return values.
  • Patch 2.1 added duration and timeLeft return values.
  • Patch 2.3.2 changed behaviour of castable parameter - spells cast by other players are no longer shown at all when castable is used. Bug or intented change?
  • Patch 2.4 (PTR 8089-enGB) changed (again) behaviour of castable parameter - spells cast by other classes are no longer shown at all when castable is used. Tested with druid and priest spells, MacOSX client. Needs to be confirmed.
  • Patch 2.4 (Live) has corrected the bug introduced in 2.3.2. The castable parameter correctly filters non-castable buffs once again.
  • Patch 3.0 updated the return values.
  • Patch 3.1 updated the return value:isMine

See also

UnitDebuff
HOWTO: Identify Buffs Using Textures
List of known buff and debuff effects that can be queried