UnitBuff

From Wowpedia
Jump to: navigation, search

Retrieve info about a certain buff on a certain unit.

name, icon, count, debuffType, duration, expirationTime, source, isStealable, 
  nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, castByPlayer, nameplateShowAll, timeMod, ...
= UnitBuff("unit", index[, "filter"])

Arguments

unit 
String (unitId) - unit whose buffs to query.
index 
Number or String - index (from 1 to 40)
filter 
String (optional) - list of filters, separated by spaces or pipes ("|"). "HELPFUL" by default. The following filters are available:
HELPFUL - buffs.
HARMFUL - debuffs.
PLAYER - buffs that were applied by the player.
RAID - buffs that can be applied by the player.
CANCELABLE - buffs that can be removed (such as by right-clicking or using the /cancelaura command)
NOT_CANCELABLE - buffs that cannot be removed

Returns

see Aura Type

1. name 
String - The localized name of the buff, or nil if no buff was found at the specified index. This is the name shown in yellow when you mouse over the buff's icon.
2. icon 
Number (fileDataID) - Identifier of the buff's icon for use with SetTexture()
3. count 
Number - The number of stacks, or 0 for a non-stackable buff
4. debuffType 
String - The magic type of the buff
5. duration 
Number - The full duration of the buff in seconds
6. expirationTime 
Number - Time the buff expires (compare to GetTime())
7. source 
String - The unit that cast the buff
8. isStealable 
Boolean - true if it the buff may be stolen (see [Spellsteal])
9. nameplateShowPersonal 
Boolean - true if the buff should be shown on the player/pet/vehicle nameplate
10. spellId 
Number - unique ID of the buff for use with the spell API such as GetSpellInfo()
11. canApplyAura 
Boolean - true if the player can apply the buff (not necessarily that the player did apply it, just that the player can).
12. isBossDebuff 
Boolean - true if the buff was cast by a boss.
13. castByPlayer 
Boolean - true if the buff was applied by a player.
14. nameplateShowAll 
Boolean - true if the buff should be shown on nameplates
15. timeMod 
Number - scaling factor used for displaying time left
16 and subsequent. ... 
Additional values, documented as up to 11 but possibly more, based on the specifics of the buff in question.

Example

The following snippet prints the name, icon, and time left for each buff on the player:

for i=1,40 do
  local name, icon, _, _, _, etime = UnitBuff("player",i)
  if name then
    print(("%d=%s, %s, %.2f minutes left."):format(i,name,icon,(etime-GetTime())/60))
  end
end

Details

  • This essentially an alias of UnitAura with the "HELPFUL" filter.

Patch changes

See also