1. #1
    Deleted

    [WeakAura] LF Help - Target %hp display

    Hello everyone.

    Basicly im looking for a WeakAura which shows the hp (in %) of my current target. And in addition to that the color of this should change based on the hp of the target. I.e. when its above 80% its green, under 40% its red and so on.
    The Problem at this is, how do I put all this in ONE WeakAura?
    Atm I got a group of multiple strings which trigger when a specific condition is given. But the problem on this is, one of the Strings i.e. got its trigger set to "<40%" but it triggers at 40.99% aswell, and not only when its really under 40.
    Any ideas?

    Would be much appreciated.
    Regards.

  2. #2
    Just heading to bed so I can't type it up for you but you're going to need to use a custom function. Have it update on the event that target HP changes then you can use logic to return the % as a string and return a text color based on your conditions.

  3. #3
    Deleted
    I dont think I'm able to create that

  4. #4
    Deleted
    I have no idea if this is going to work, and can't test it until later today, but try putting this

    Display
    Code:
    function()if UnitExists("target") then
     local percent = (UnitHealth("target")/UnitHealthMax("target"))*100
     return ("%i"):format(percent)
    else
     return "0%"
    end
    Animation

    Code:
     function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
        
        local _,_,percent = UnitHealthMax("target")
        local red, green, blue, alpha = 0,0,0,0
        
        if percent >=80 then
            red, green, blue = 0,1,0
        elseif percent >40 then
            red, green, blue = 1,0,0
             else
            red, green, blue = 1,1,1
        end
        return red, green, blue, 1
    end

  5. #5
    Deleted
    Quote Originally Posted by Woolock View Post
    I have no idea if this is going to work, and can't test it until later today, but try putting this

    Display
    Code:
    function()if UnitExists("target") then
     local percent = (UnitHealth("target")/UnitHealthMax("target"))*100
     return ("%i"):format(percent)
    else
     return "0%"
    end
    Animation

    Code:
     function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
        
        local _,_,percent = UnitHealthMax("target")
        local red, green, blue, alpha = 0,0,0,0
        
        if percent >=80 then
            red, green, blue = 0,1,0
        elseif percent >40 then
            red, green, blue = 1,0,0
             else
            red, green, blue = 1,1,1
        end
        return red, green, blue, 1
    end
    Not able to test it atm eigther.
    But does the i.e. ">40" trigger when exactly 40% is given? or does it trigger like at "40.99%" BossHp aswell? since somehow it IS 40%. If it does how can you avoid it so it exactly got the color when Killshot (35.00%) range is set? ofc If it does it like this you can put it to >34 so it takes 34,99% ? but you leak 0,01% with htis method aswell, so its kinda not perfekt.

  6. #6
    It works. And with the 40.99-problem, why you dont change the number to 39? In your case it should trigger at 39.99% ^^

  7. #7
    Deleted
    Quote Originally Posted by Platinengel View Post
    It works. And with the 40.99-problem, why you dont change the number to 39? In your case it should trigger at 39.99% ^^
    Possible to post the WA string for the things mentionied above ? And what do you have to put there then when the following things have to be shown:

    100-80% red color
    79-36% orange color
    35% yellow
    above 35 green

    is it:
    >=80 red
    >35 orange
    =35 yellow
    else green ?

    Dont know how to put it exactly because of the .99% thingy.
    Basicly I want it like i mentioned it above.
    100-80 red
    till 35 orange
    exact 35 yellow
    and under 34 green

  8. #8
    Deleted
    Exactly 35% is practically impossible. Let me try to explain:
    Boss with 1654987 hp (just a random number). 35% of that is 579245.45. The boss will never be at 579245.45 hp, but rather at 579246 and then 579245 (if he somehow took only 1 damage ;P).
    So checking for exact numbers won't do anything.

    Concerning your problem with the 35%, the same rules apply. If you have stored the percentage in a variable "percent" and use the following code:
    Code:
    percent > 35
    it will return true for 35.0000000000001 and only evaluate to false once it reaches exactly 35 (which is practically impossible as I said) or less.

    I'm bad with RGB so no guarantees that this works:
    Code:
    if percent >= 80 then
      red, green, blue = 1,0,0
    elseif percent > 35 then
      red, green, blue = 1,0.5,0.15
    else
      red, green, blue = 0,1,0
    end
    return red, green, blue, 1

  9. #9
    Deleted
    Quote Originally Posted by Hamsda View Post
    Exactly 35% is practically impossible. Let me try to explain:
    Boss with 1654987 hp (just a random number). 35% of that is 579245.45. The boss will never be at 579245.45 hp, but rather at 579246 and then 579245 (if he somehow took only 1 damage ;P).
    So checking for exact numbers won't do anything.

    Concerning your problem with the 35%, the same rules apply. If you have stored the percentage in a variable "percent" and use the following code:
    Code:
    percent > 35
    it will return true for 35.0000000000001 and only evaluate to false once it reaches exactly 35 (which is practically impossible as I said) or less.

    I'm bad with RGB so no guarantees that this works:
    Code:
    if percent >= 80 then
      red, green, blue = 1,0,0
    elseif percent > 35 then
      red, green, blue = 1,0.5,0.15
    else
      red, green, blue = 0,1,0
    end
    return red, green, blue, 1
    so this does 100-80 red, 79-35orange and under 35 green? and where do I put this and do I need any other kind of stuff like to define %HP like the guy above posted earlier? I dont even know if I need to put it >35 and <=35 or <36 and >=35.
    Basicly I need it red when its 80 or above and green when I could use killshot which is 35.

  10. #10
    Worked it out for you.

    Here is the weakaura-string:

    Code:
    d4t7faGEPu0TjL2fPsBJOSpPu50QyziXSf15LsUjer)crkFJuSojsStiSxLDtL9d(jeHHHWVLQvjLspdrnyudhsDqeP6usIJbLZrGfsQOLkrslMu1YjzrsspvvpgPEUinocAQIyYsX0fMgHUkePlt56Q0gHOomvTzj12LsvFuIunlO6ZezEsKYirK8DPuy0evJhsCjsfUfK01KW9qeRejnkjQ)kr8WwYET7B23SK91Dx8N20gcYI7P75UAjdbLHSWcrHeec1qikkqafbIRg1cYdb5HSqzycLvqwKqSGSmrncxnQfKhcXHGyX(Mtk6SVvIHsSxh07PVPrxBIHsSV(6OJt3vUcqfyGbg4CN2NbgTPOnx4LmGjb4Yi1Dcsz(CiVC1WRKSOAfsdPUtqkZNd5iPhLYvdVsYIQvQ0wmccGkWadmWklUkhWLRQJt1kLsDxP1hLrBkAZfEjRcq1Cn7VUqDKKm1s2FDNyF4vswSy)XDIsO7ArNTWAgcS9H6ijzQLSpAH22Ng(4MU)6oX(WRKSy)1zT3CXE)n67VPwjOnfT5c5MphYN(93uRKR7etNl2RmPt3L0cTTpmuI9TXPjKpK1qrOOaYceGPrgfYueiB1OkkCV3D06Jt3TK9A9h3s2t3ZDvPoKfQrqbfzfyfIYOiqKSGvJAb59nxLpoD3(909CxPZHSqrrkeIyYkeffjxGjC1OwqEpDp3vL(qGT)MALekVln7dB63FtTs8z0Y9t)(OfABp9nn6A3Ns7ZwRHaBVpJwUFii2JYqqSV1qqSNUN7QKwOT9030ORDpDp3vK(qGT)MALq3ZD105E6EURq(6O3RS4QCaxFD0XP7kJghyfgoWsy4aRhdhypgoWkk4alrbhy9uWb2tPcqfyGbg4CN2NbgTPOnx4LmGjb4Yi1Dcsz(CiVC1WRKSOAfsdPUtqkZNd5iPhLYvdVsYIQvQ0wmccGkWadmW5oTpdSYAWbwszMdhy95RbmjatGtGtaubgyGb(udmAtrBUWlza3oGfsaCi3CavGbgyGbgyGbwzn4alPmZHdS(81aMeGXWjWjaQadmWaB5u7udmAtrBUWlza3oGjxaCi3CavGbgyGbgyGbwzn4alPmZHdS(81aMeGXWj0TaNqxScGkWadmWwo1o1aJ2u0Ml8sgWLgjataCi3CavGbgyGbgyGbwzn4alPmZHdS(81aMeGXWXWXaQadmWaB5udyGvwdoWskZC4aRpFnGjbycCmCcGkWadmWMRbOcmWadSYIRYbSYAWbwszMdhy95RHdmgq1Cn7v9Wh2qqSpL2NnugcSfl27UAtuhjjtLoey7pn7t8kjlawh7LBhj5XqwutbgHmccnK1qiOqMWvJQOM9OGe11PwmKrTGqMgnceiIjJIgrbIIRgvXI95UVzj7Bo11h6BoATK9AV54SKfl2R6zBj71EZXzjlwSp8zZflzV2BoolzXI9kpTTK9AV54SKflwSVfsuxNAXqiOqxzIcfjRPyX(09u0ftxcDXKTV9dbMifSfBa

    function:

    Code:
    function()
        local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100
        return ("%i"):format(percentage)
    end

    animation:

    Code:
    function(p, r1, g1, b1, a1, r2, g2, b2, a2)
        local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100
        local red, green, blue = 0,0,0
        if percentage > 80 then
            red, green, blue = 1,0,0
        elseif percentage > 35 then
            red, green, blue = 1,0.5,0.15
        elseif percentage <= 0 then
            red, green, blue = 1,1,1
        else  red, green, blue = 0,1,0
        end
        return red, green, blue, 1
    end


    DONT FORGET TO change the gradient here:



    If you want, you can change colors, percent-stages or even play a sound when your target hits a certain %.

  11. #11
    Deleted
    Quote Originally Posted by Platinengel View Post
    Worked it out for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admWaB5u7udmAtrBUWlza3oGjxaCi3CavGbgyGbgyGbwzn4alPmZHdS(81aMeGXWj0TaNqxScGkWadmWwo1o1aJ2u0Ml8sgWLgjataCi3CavGbgyGbgyGbwzn4alPmZHdS(81aMeGXWXWXaQadmWaB5udyGvwdoWskZC4aRpFnGjbycCmCcGkWadmWMRbOcmWadSYIRYbSYAWbwszMdhy95RHdmgq1Cn7v9Wh2qqSpL2NnugcSfl27UAtuhjjtLoey7pn7t8kjlawh7LBhj5XqwutbgHmccnK1qiOqMWvJQOM9OGe11PwmKrTGqMgnceiIjJIgrbIIRgvXI95UVzj7Bo11h6BoATK9AV54SKfl2R6zBj71EZXzjlwSp8zZflzV2BoolzXI9kpTTK9AV54SKflwSVfsuxNAXqiOqxzIcfjRPyX(09u0ftxcDXKTV9dbMifSfBa

    function:

    Code:
    function()
        local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100
        return ("%i"):format(percentage)
    end

    animation:

    Code:
    function(p, r1, g1, b1, a1, r2, g2, b2, a2)
        local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100
        local red, green, blue = 0,0,0
        if percentage > 80 then
            red, green, blue = 1,0,0
        elseif percentage > 35 then
            red, green, blue = 1,0.5,0.15
        elseif percentage <= 0 then
            red, green, blue = 1,1,1
        else  red, green, blue = 0,1,0
        end
        return red, green, blue, 1
    end


    DONT FORGET TO change the gradient here:



    If you want, you can change colors, percent-stages or even play a sound when your target hits a certain %.
    Thanks alot. And the other guys who answered in here aswell.

  12. #12
    Heya, tried to use the imported version and all I get is this error when trying to use it:

    Code:
    Message: integer overflow attempting to store -1.#IND
    Time: 11/04/15 21:09:33
    Count: 910
    Stack: [C]: in function `format'
    [string "return function()..."]:3: in function <[string "return function()..."]:1>
    Interface\AddOns\WeakAuras\RegionTypes\text.lua:98: in function `UpdateCustomText'
    Interface\AddOns\WeakAuras\WeakAuras.lua:2844: in function <Interface\AddOns\WeakAuras\WeakAuras.lua:2840>
    
    Locals: (*temporary) = "%i"
    (*temporary) = -1.#IND
    Last edited by Kiingy; 2015-11-04 at 10:18 AM.

  13. #13
    Thats not an addon-related Error. Even if it says "WeakAuras".

    Many people seem to get those errors lately..I'd try to delete your CACHE-folder in wow directory.

    Does this error occure only when you load this specific aura?

  14. #14
    Sorry to necro an old thread, but in regards to that error, I've found out whats causing it and could use some help fixing it.

    This part: local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100, runs without checking whether you have a target.

    So while editing or when it's selected the aura is visible and the animations are run, thus the animation needs to be written in a way that works even if you don't have a target. Which I have no idea how to do!

    Anyone know how to fix it?

  15. #15
    Can surround it with a check for if you have a target if you want:

    Code:
    if UnitExists("target") ~= nil then
        local percentage = (UnitHealth("target")/UnitHealthMax("target"))*100
    end
    But if it's only an issue while you're editing the aura then I don't really see the issue just suppress the error and move on.

  16. #16
    Problem is it spams the error, like 100's of them within a few seconds.

  17. #17
    Then add the 'fix' I put in the message.

  18. #18
    Doesn't work, error still spams.

    Edit: Found a way to fix it
    Last edited by Kiingy; 2016-02-12 at 09:41 PM.

Posting Permissions

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