Thread Tools Display Modes
12-21-08, 12:32 AM   #1
BokTheGolem
A Defias Bandit
 
BokTheGolem's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 2
listening for when player gains/losses a buff?

I just started writing addons and i need to look for when i gain/lose a specific buff. I looked around and found the event COMBAT_LOG_EVENT but after looking over its lengthy documentation it all seems gibberish to me. Could someone explain to me how to look for when i gain or lose a buff? An example would also be greatly appreciated.

On a side note to make floating combat text would i have to make a frame with only a fonstring as a visible element?
  Reply With Quote
01-17-09, 05:24 PM   #2
Riokou
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 13
You should probably use the event "PLAYER_AURAS_CHANGED". Have a list save each time that event fires and check it with the previous list to see what buff/debuff was added/removed.
  Reply With Quote
01-17-09, 06:51 PM   #3
Davnel
A Fallenroot Satyr
 
Davnel's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 24
The event to check is UNIT_AURA, though you would have an easier time using COMBAT_LOG_EVENT_UNFILTERED. Though it might take longer to get used to

SPELL_AURA_APPLIED and
SPELL_AURA_REMOVED are the types of event your looking to parse from the log.

Anyway to help clear up the wiki page here goes,

First you have a base set of 8 args on ANY COMBAT_LOG_EVENT_UNFILTERED.

Now your looking at specifically at this point arg2 the event type (this is a sub event local to the combat log, NOT the COMBAT_LOG_EVENT_UNFILTERED event), specifically you want to match SPELL_AURA_APPLIED and SPELL_AURA_REMOVED. well come back to these as we need to do a little more work before we move onto the arguments these add.

Right now i'm assuming your tracking a spell on yourself. As such you want to check arg7 == your characters name.

Right now back to SPELL_AURA_APPLIED and SPELL_AURA_REMOVED. These both add an extra 4 arguments (args 9-12). Args 11 and 12 are spellschool and if its a buff/debuff so you can ignore them, 9 and 10 however allow you to check via spellid or spellname.

So quick sum up (borrowed and edited the from the wowwiki page to suit you more.)

Code:
Function Foo_OnLoad()
  this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end

Function Foo_OnEvent(self, event, ...)

  local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...)
-- you can use local type = select(2, ...)
-- and local destName = select(7, ...)


if ( destName == UnitName("player") ) then
   
   if (type == "SPELL_AURA_APPLIED") then
      local spellid, spellname = select(9,...)
      -- do stuff for spell being applied here
  elseif (type == "SPELL_AURA_REMOVED") then
     local spellid, spellname = select(9,...)
     -- do stuff for spell being removed here
  end
end

end
now that should (i think work) or at least set you off on the right tracks
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » listening for when player gains/losses a buff?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off