Thread Tools Display Modes
03-05-13, 01:28 AM   #1
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
what event should i register

I have an addon that monitors buffs and i have it display the duration left but since I'm currently using
"RegisterEvent("UNIT_AURA", "player")" it only fires if i gain or lose a buff.

So my question is, what's the correct event to have updated durations on buffs?

Last edited by Spawnova : 03-05-13 at 01:32 AM.
  Reply With Quote
03-05-13, 01:39 AM   #2
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
I believe that you will need an OnUpdate function to continually poll the buff(s) for their current duration. Additionally, you'll likely need some throttling of the function, as it fires for every frame update, which could be 60+ times per second. You are most likely interested in seconds or tenths of a second.

Last edited by Clamsoda : 03-05-13 at 01:41 AM.
  Reply With Quote
03-05-13, 01:50 AM   #3
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
Thanks, I've included that and now it works just fine =)
  Reply With Quote
03-05-13, 10:31 AM   #4
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Clamsoda View Post
I believe that you will need an OnUpdate function to continually poll the buff(s) for their current duration.
On the contrary, an OnUpdate function is not needed and possible even advised against.

You need to use COMBAT_LOG_EVENT_UNFILTERED. http://www.wowwiki.com/API_COMBAT_LOG_EVENT and look at the sub events:

SPELL_AURA_APPLIED,
SPELL_AURA_REMOVED,
SPELL_AURA_REFRESH

and possible more.

You can use the arguments to filter by spell id / destGUID.

Last edited by ravagernl : 03-05-13 at 10:33 AM.
  Reply With Quote
03-05-13, 02:15 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You still need an OnUpdate script to update the time visibly displayed by your fontstring, statusbar, etc.

Also, I'd argue that using CLEU to detect aura changes on a single unit is actually less efficient than using RegisterUnitEvent with UNIT_AURA. Not only does CLEU fire for every aura change on every unit, it also fires for thousands of other things.

However, you shouldn't poll UnitAura every time your OnUpdate script runs. Store the aura's expiration time or remaining duration in a variable, and use that in your OnUpdate script to update your GUI.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-06-13, 10:27 AM   #6
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
I stand corrected. I was under the impression that BuffFrame/DebuffFrame both use CLEU, but it seems they also use an onupdate script.

Sorry for giving false info!
  Reply With Quote
03-06-13, 04:03 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by ravagernl View Post
I was under the impression that BuffFrame/DebuffFrame both use CLEU, but it seems they also use an onupdate script.
Even if they used CLEU instead of UNIT_AURA to detect auras being added or removed, they would still need an OnUpdate script to update the displayed duration text, because CLEU only tells you when an aura is added or removed (or refreshed, but that's bascially the same thing). CLEU doesn't re-fire 10 times a second for every aura to tell you that the aura's remaining duration has decreased by 1/10th of a second.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-09-13, 04:49 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Hmm...if you re-apply a buff that is already on that unit you still need to update the expiration time of the aura already in your queue list.

lua Code:
  1. /run f=CreateFrame("Frame");f:RegisterUnitEvent("UNIT_AURA","player","vehicle");f:SetScript("OnEvent",function(self,...) print(...) end);

Plus if an aura is removed you need to run over the queue list to find out which aura is it.

For rFilter3 I decided to have a single onUpdate script that runs over all auras updating the timers/icons.

To bad that UNIT_AURA does not tell you about the aura that got applied.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 03-09-13 at 04:56 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » what event should i register


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