WeakAuras

Displaying the cooldown time of an ability?

  • 4 posts
    #1 Sep 08, 2011 at 01:26 UTC - 0 likes

    First let me say this is an amazing addon. It's too bad I don't know anything about lua to really take advantage of the possible options.

    There was an old cooldown tracking bar addon that had a feature I just loved. It would zoom in (grow) the cooldown bar of the ability when you tried to use the ability but it was still on cooldown. The addon no longer functions, and I've yet to find another working addon that had the feature. Then I found WeakAuras, and I figured that feature could totally be done inside of it. The problem is I think it requires a custom lua function to achieve.

    What I've done was make simple cooldown tracking progress bars for the abilities I want to track. Then made duplicates of them in the same spot on screen. The duplicates trigger off the combat log when it detects I'm trying to use an ability that's on cooldown. Then the duplicates have a start animation that fires and then they hide. This all works perfect. The problem is the duplicate progress bars that fire and animate don't contain the correct progress of the ability cooldown. They simply have the default 2 second progress. I'm guessing there's a way to grab the correct cooldown time of the ability to put inside the "Left/Right Text" boxes by using the "%c" custom lua command. I just don't have a clue how to do it.

    If anyone knows a way, I'd love to hear how.

    Last edited Sep 08, 2011 by drykill2
    #2 Sep 08, 2011 at 17:04 UTC - 0 likes

    Personally I would just replace the second progress bar display with a simple icon display.

    But, in case you really want to have a progress-bar with correct duration (its possible), you will have to use a custom trigger for the second display.

    • Type: Custom -> Event
    • Events: COMBAT_LOG_EVENT_UNFILTERED, WA_FORCE_HIDE_<SPELL ID HERE> (last one only if you want auto-hide)
    • Custom (Show) Code:
    function(event, timestamp, message, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
      -- Early exit
      if event ~= "COMBAT_LOG_EVENT_UNFILTERED" then return end
    
      -- Check spell cast (might be SPELL_CAST_FAILED)
      if message == "SPELL_CAST_START" then
        -- Additional arguments
        local spellId, spellName, spellSchool = ...
        
        -- Compare caster and spell
        if sourceGUID == UnitGUID("player") and spellId == <SPELL ID HERE> then
          -- Spell on cooldown?
          local start, duration = GetSpellCooldown(<SPELL ID HERE>)
    
          -- Show display?
          if start and start > 0 and duration and duration > 1.5 then
    
            -- Remove this if you don't want auto-hiding
            if WA_FORCE_HIDE_<SPELL ID HERE>_TIMER then
              WeakAurasTimers:CancelTimer(WA_FORCE_HIDE_<SPELL ID HERE>_TIMER, true)
            end
    
            WA_FORCE_HIDE_<SPELL ID HERE>_TIMER = WeakAurasTimers:ScheduleTimer(WeakAuras.ScanEvents, <DURATION TO SHOW DISPLAY>, "WA_FORCE_HIDE_<SPELL ID HERE>")
    
            
            return true
          end
        end
      end
    end
    
    • Custom Hide Code:
    function(event)
    
      -- Hide if force to (remove if you don't want auto hiding)
      if event == "WA_FORCE_HIDE_<SPELL ID HERE>" then
        -- Reset
        WA_FORCE_HIDE_<SPELL ID HERE>_TIMER = nil
    
        return true
      end
    
    
      -- Default: Don't hide
      return false
    end
    
    • Custom Duration Code:
    function()
      -- Query wow
      local start, duration = GetSpellCooldown(<SPELL ID HERE>)
    
      -- Format bad return
      if not start or not duration then
        start = 0
        duration = 0
      end
    
      -- Return duration, endTime
      return duration, start + duration
    end
    

    The only problem is, since this progress bar now uses the correct duration information, it won't just disappear after a few seconds.

    EDIT: Nevermind, added the some "force hide" to the hide code.

    PS: Make sure to replace all <> tags ;) And if you get error feel free to post, as this was only dry-coded :)

    Last edited Sep 08, 2011 by CommanderSirow
    #3 Sep 09, 2011 at 04:42 UTC - 0 likes

    Thank you for the response, I'll try it out when I get home from work tomorrow.

    #4 Sep 10, 2011 at 00:42 UTC - 0 likes

    Just had to change SPELL_CAST_START to SPELL_CAST_FAILED and it worked flawlessly.

    -- Check spell cast (might be SPELL_CAST_FAILED)
      if message == "SPELL_CAST_START" then
    

    A million thanks :)

  • 4 posts

You must login to post a comment. Don't have an account? Register to get one!