+ Reply to Thread
Results 1 to 8 of 8

  Click here to go to the first Rift Team post in this thread.   Thread: How to check for buff timers

  1. #1
    Champion
    Join Date
    Jun 2011
    Posts
    561

    Default How to check for buff timers

    Hi guys

    While thinking about how to improve the buff counters for nkThings I became unsure if I'm doing the right thing.

    There's an add and a remove event for buffs which I'm using. However the change event only fires if the buff fundamentally changes. Either I'm blind or I didn't find any event which fires if the remaining duration of a buff changes.

    This means that I had to implement an event.upate.begin routine which checks for new buff duration and updates the timers. In order to not have a to big impact on performance I throttle these checks. Only once per second the check for updated remaining times is done.

    Isn't there any better way to do this? The problem with a fixed check interval is that the remaining starts as soon as a buff is cast. Currently I'm rounding the remaining time to the full second. This of course means therefore it's remaining will always be slighty incorrect.

    Anybody got a better idea? I really hope someone can tell me that I missing something fundamentally

    Cheers
    N.
    Last edited by Naifu; 04-27-2012 at 01:44 AM.

  2. #2
    Plane Touched
    Join Date
    Jan 2011
    Posts
    281

    Default

    I don't know if ZorbasBuffBars (of the example addons by Trion) has the "best practice" approach, but you might take a look at how he does things there?

  3. #3
    Telaran
    Join Date
    Mar 2012
    Posts
    72

    Default

    Do you have an example buff that has this problem? I wasn't aware that the change event wouldn't fire for a change in duration, so I probably need to look at handling this issue as well otherwise I'll end up with timers under/overrunning.

  4.   Click here to go to the next Rift Team post in this thread.   #4
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Naifu View Post
    Hi guys

    While thinking about how to improve the buff counters for nkThings I became unsure if I'm doing the right thing.

    There's an add and a remove event for buffs which I'm using. However the change event only fires if the buff fundamentally changes. Either I'm blind or I didn't find any event which fires if the remaining duration of a buff changes.
    The important number is the time that the buff will end. The change message won't fire unless that changes, because otherwise it would be firing every frame as fractions of a second are shaved off the buff (which sort of defeats the purpose of having an event). Changes in buff ending time are extraordinarily rare, however, they usually just run until they finish.

    Once you've queried the buff details once, you should be able to store the buff ending time - I believe Inspect.Buff.Detail provides this directly, there isn't even extra math involved - then calculate the duration easily and efficiently without going through the addon system. This is what Zorba's Buff Bars does.
    Last edited by ZorbaTHut; 04-27-2012 at 05:44 AM.

  5. #5
    Champion
    Join Date
    Jun 2011
    Posts
    561

    Default

    Yes this would solve the need to query Inspect.Buff.Detail and I hadn't thought of that approach. Good thinking.

    However still I'd need to update the buff timer with system.update.beginn right?

    Cheers
    N.

  6. #6
    Ascendant Credo's Avatar
    Join Date
    Jan 2011
    Posts
    4,172

    Default

    Very nice! I'm going to try that as well!
    Even free cost too much now

  7.   This is the last Rift Team post in this thread.   #7
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Naifu View Post
    However still I'd need to update the buff timer with system.update.beginn right?
    Yes, you would, but this should be a lot speedier than querying every single buff every frame.

  8. #8
    Champion
    Join Date
    Jun 2011
    Posts
    561

    Default

    Made the change and works perfectly. I'm more happy with the approach now as it gives a lot more accuracy in buff timer calculationg.

    However the addon cpu time didn't change at all. It could even be slightly higher by 0.1 or 0.2%. That is most probably due to a slightly higher update cycle of the text displaying the buff counter. I'm a freak for code optimization and doing as few updates as possible. Before I only did the UI update of buff counter once every second for all buffs / debuffs now each buff / debuff is treated individually.

    So I'd say more computations and UI updates with same addon cpu usage = instant winner.

    Cheers
    N.
    Last edited by Naifu; 04-27-2012 at 10:34 PM.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts