1. #1

    [API] UnitBuff not giving the max value of a shield (ice barrier) anymore ?

    Hello Folks,

    i used to have a weakaura for my ice barrier where the color of the icon was changing depending on the %pf the shield left. The custom function for the color stuff was :

    Code:
    function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
        local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, 
        shouldConsolidate, spellId, canApplyAura, isBossDebuff, value1, value2, value3,value4,value5 = UnitBuff("player", "Ice Barrier");
        if value4 ~= nill then
            local percent = value4/value5 
            if percent < 0.9 and percent>=0.7  then
                return 0, 1, 0, 1
            end
            if percent < 0.7 and percent>=0.45  then
                return .9, 1, 0, 1
            end
            if percent < 0.45 and percent>=0.2  then
                return .8, .5, 0, 1
            end
            if percent < 0.2 then
                return 1, 0, 0, 1
            end
        end
        return r1,g1,b1, a1
    end
    value5 used to give the max value of the shield but it's now always returning 1. is there another way of getting the max value of a shield or am i missing something ?

  2. #2
    You can type the following in chat, with Ice Barrier active, to see all the values returned:

    Code:
    /dump UnitBuff("player", "Ice Barrier")

    However, according to the names of the variables you have pasted there, this code is older than Legion.

    Patch 7.0.3 (2016-07-19): Added return values "nameplateShowAll" and "timeMod"; change "shouldConsolidate" to "nameplateShowPersonal".

    Those two values were added before the value1,value2,... group, which pushed everything after two returns to the right, making "value4" and "value5" the 19th and 20th return instead of the 17th and 18th before. The following code should work for you (also took the liberty of cleaning the code up):

    Code:
    function(_,r,g,b,a)
        local _,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,shieldLeft,shieldMax=UnitBuff("player","Ice Barrier")
        if type(shieldLeft)=="number" and type(shieldMax)=="number" then
            local percent=shieldLeft/shieldMax 
            if percent<0.9 and percent>=0.7 then
                r,g,b,a=0,1,0,1
            elseif percent<0.7 and percent>=0.45 then
                r,g,b,a=.9,1,0,1
            elseif percent<0.45 and percent>=0.2 then
                r,g,b,a=.8,.5,0,1
            elseif percent<0.2 then
                r,g,b,a=1,0,0,1
            end
        end
        return r,g,b,a
    end

    If it doesn't work, then use the dump command I mentioned and look for the two values in the text that gets printed to your chat window, then count how many _, in the local line.
    Last edited by Kanegasi; 2017-11-27 at 12:37 AM.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  3. #3
    Quote Originally Posted by Kanegasi View Post
    ...
    Thanks for the answer,

    however i'm testing all the functions with the dump before writing it and even with the dump, i can not find the said max value. the last 2 values given by the dump are a 0 and a 1 which i can not identify the purpose for ?

  4. #4
    Pit Lord shade3891's Avatar
    15+ Year Old Account
    Join Date
    Oct 2008
    Location
    Boat to the Dragon Ilses
    Posts
    2,307
    Amy reason you don't use the condition system in Weakaura?
    Seems a lot easier to colour an icon that way based on percentages..

  5. #5
    So, I pulled out my mage to see the dump results. Turns out the values didn't move from 17 and 18, whatever was in 16 and 15 probably swapped around, but the max is indeed missing. However, the max is in the tooltip, you'll have to get it out of there in your function. I do the same thing in my Ret weakaura "Crusade of Old War" to get Crusade's max time and stack values, so I can help you with this. Try using this code:

    Code:
    function(_,r,g,b,a)
        if aura_env then
            if not aura_env.icebarrierName then aura_env.icebarrierName=GetSpellInfo(11426) end
            local _,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,shieldLeft=UnitBuff("player",aura_env.icebarrierName)
            if shieldLeft and not aura_env.shieldMax then
                aura_env.shieldMax=tonumber(GetSpellDescription(11426):gsub("[,%.]",""):match("%d%d%d+"))
            elseif not shieldLeft then aura_env.shieldMax=nil end
            if type(shieldLeft)=="number" and type(aura_env.shieldMax)=="number" then
                local percent=shieldLeft/aura_env.shieldMax 
                if percent<0.9 and percent>=0.7 then
                    r,g,b,a=0,1,0,1
                elseif percent<0.7 and percent>=0.45 then
                    r,g,b,a=.9,1,0,1
                elseif percent<0.45 and percent>=0.2 then
                    r,g,b,a=.8,.5,0,1
                elseif percent<0.2 then
                    r,g,b,a=1,0,0,1
                end
            end
        end
        return r,g,b,a
    end

    I don't call Ice Barrier directly by name, I get its name through the spell ID. This allows the code to be universal just in case someone else with a different language wants the code. Also, the table "aura_env" is part of WeakAura and is an isolated table usable only by that aura. I save the spell name and shield max value to that table so I don't have to call it every frame the aura refreshes.
    Last edited by Kanegasi; 2017-11-29 at 02:45 PM. Reason: adjust matching pattern
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

Posting Permissions

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