API UnitDebuff

From Turtle WoW Wiki

Retrieve info about a certain debuff on a certain unit.

debuffTexture, debuffApplications, debuffDispelType = UnitDebuff( unitID, debuffIndex [, showDispellable] );

Arguments

UnitName

The unit id you want debuff information for

DebuffIndex

Number - The index of the debuff to retrieve info for. Starts at 1.

The maximum numbers used by the turtle code are 16 for party/pet/target debuffs.

ShowDispellable

Boolean - (optional) - Can be 0, 1, or nil. If present and 1, then only debuffs will be returned which are dispellable by the player. Index is still starting with 1 and counting up.

Returns

DebuffTexture

String - The identifier of (path and filename to) the indicated debuff, or nil if no debuff

DebuffApplications

Number - The number of times the debuff has been applied to the target. Returns 0 for any debuff which doesn't stack.

DebuffDispelType

String - The debuff dispel type. Can be "Magic", "Curse", "Poison", "Disease" or nil if not dispellable. These strings are constant across localizations.

Example 1

Retrieve the debuff texture of the player's pet's debuff with the index i.

debuff = UnitDebuff("pet", i);

Example 2

This macro will apply debuffs when needed. There are some drawbacks to this as it can’t distinguish between your own debuffs and fellow warlocks. Still, its quite useful for grinding or when you’re the lone warlock in group. Another limitation is the length of the macro. In order to fit the 255 character limit the debuff names have to be shortened, this could cause conflicts in case a debuff with a similar name is already applied.

Curse of Agony = Spell_Shadow_CurseOfSargeras

Corruption = Spell_Shadow_AbominationExplosion

Siphon Life = Spell_Shadow_Requiem

/run c=CastSpellByName function b(k)for i=1,16 do if strfind(tostring(UnitDebuff("target",i)),k)then return 1 end end end if not b("ionExp")then c("Corruption(Rank 6)")elseif not b("eOfSar")then c("Curse of Agony(Rank 6)")else c("Siphon Life(Rank 4)")end

Example 3

This prints the texture names of any buffs and debuffs on the target

/run function m(s) DEFAULT_CHAT_FRAME:AddMessage(s); end for i=1,16 do s=UnitBuff("target", i); if(s) then m("B "..i..": "..s); end s=UnitDebuff("target", i); if(s) then m("D "..i..": "..s); end end