WeakAuras

Timer based on health

  • 5 posts
    #1 Feb 26, 2011 at 06:54 UTC - 0 likes

    I've been trying to make a timer the displays how long my health has been less than 10,000 (so I know its worth while to deathstrike in chimaeron) but it just displays my health, not a timer. Is something like this possible with WeakAuras?

    #2 Feb 26, 2011 at 08:17 UTC - 0 likes

    @vbaspcppguy: Go

    This is a very odd use case, but with a little creativity and custom code, almost anything is possible!

    First of all, WeakAuras basically does not support timers that count upwards at all. It only supports timers that count down to some specific time. This means that we will need to create our own mechanism for determining how long it has been since dipping below 10,000 life. Luckily, the Custom Dynamic Text option of the Text display makes this fairly easy.

    Create a Text display, set its Display Text to "%c", and then set the Custom Function to:

    function()
      return ("%0.1f"):format(GetTime() - (WeakAuras_below10k or 0))
    end
    

    GetTime() returns the number of seconds your computer has been on.

    WeakAuras_below10k is a global variable which we will use later to store the exact time you dipped below 10,000 life. Since WeakAuras_below10k could be nil, it is used in the expression (WeakAuras_below10k or 0) to avoid an arithmetic error.

    ("%0.1f") is a string literal, and format is a method that can be called on strings to format them with data (much like C's printf function).

    Thus, this line of code gets the current time, subtracts the time you first dipped below 10,000 life, and then formats that number into string.

    Now that the mechanism for displaying the timer is in place, we need to create a way to detect when you dip below 10,000 life, and save the time when you do. This can be handled with the Action tab's On Show option.

    Set your display's trigger to Status -> Health, the unit to "Player", and the Health to "< 10000". Then, on the Actions tab, enable the On Show section's Custom option, and in the Custom Code field, enter:

    WeakAuras_below10k = GetTime()
    

    Now, whenever you go below 10,000 life, the display will show. When it does, the global variable WeakAuras_below10k will be set to the current time, which will allow the custom code for the Text display to work properly.

    If you're not interested in the mechanics of how this works, and just want a quick solution, here is my copy of the display in question:

    dKJ)baGlQQ2gvQzd4WI8jucRduYTf0Jfv7euQ9kTBG2pIrPcddYVr68qPtRObJQHdfhKk0PukhdfNtfTqQkxMyXcy5QQfrf5PKwMsYZfAIOenvqMSOmDkFfLQpdvEgO66kSrQGVRsTzOQTRe9rukZIkQPPsMhkjFtG(Rs1OvLXdkUevs3sjCnQs3dLuRKkX4us9AQIltHQgwnRAwHQMnJyasyHeySQUMxnFenAiKaJvf)am3MuWJnIleoH)fB8bj8dNCf5NbVtBWcp9hMSd2edAgkhBe(cc)GDj5XXXpf3dia0BgKhcN(jC02gXfbmR6xWnPGqyXivnbgRAk3MuWyHQgT03ku1m6E(iA0W6RA(iA0WQSljpoo(P4EabGEZG8q4SMWztmOzOCSvRwv7pXHt(fQQHfJunAjBeRoIY(tsa2R(Q(KeG92PyKFYO)QSQ6tsa2RkdcHqvhrzFaoT6R6auwkGw10WO1QMjX8QSCgXaKWgj8h9MWbOG4iCS0blwkeEaraj8aca9MWzqoJqic)jja75V6mRk0muiCFca9MWzqoJqOQpzI7z1HGRHF69886ALB0Lx3Ul(fxRREpZSxDWlcotWZZ1U9IGFEfev8lUcwRASkJF4(xvDzHndC0QAT
    
    Last edited Feb 26, 2011 by Mirrormn
    #3 Feb 26, 2011 at 10:27 UTC - 0 likes

    Wow. I didn't expect such a thorough reply, let alone so fast... It's pretty late right now, but I will definitely read over this this weekend and give it a test and let you know how it goes.

    #4 Oct 01, 2012 at 18:29 UTC - 0 likes

    Needless to say, it works like a charm Mirror. Thanks for your code.

    I have made a small modification to it to track my lifebloom timer. Basically, I made a custom combat log event timer that starts counting down as soon as I cast Lifebloom, and reaches 0 (then, disappears) when Lifebloom expires. Here it is:

    dieqeaGirGlrfLpbsQrrfofrzvivLxHuLULO0UakddQogPSmi6zGyAG6AuPTbHVbjJtPY5aI1rfPMhveDprOoii1cvk9qruteK4IivvBePYhfbDsQiSsGQzksANIIFsfvlfKKNkmvs1vfH8vrI9Q6VIQbt5WKSyIQhtOjtWLLSzK8zi1OrkNwQETiYSbCBISBO8BQA4kflxkphX0vCDLSDLQ(osvmEG05fPwpvKSFuFTR)q6HWdHR)GYJnr3PQNbP7dHozdGkTEb68WzIpexKXlPxGopOwyIt3J5qgdoBSXgBTAwnm2CKaNHdgovcK50u(MKACWgdoBSXgBSXgBSXgBSXgBS5iH1O3LkhYyllBosPujb9QPi5aYfvKHnFJnCzYOphz1KXgdoBSXgBSXgBSXgBSXgBSrVS5iLsLe0RMIKdixy1uS5BSHlJngC2yJn2yJn2yJn2ytgdEHj8qjoDpg56piJQnx)HGpxCrgV03(qCrgV0JukvsqVAksoGCrfzylXSLWA07sLdzm4PuQKGE1uKCa5cRMITeZMg8NppAf6Uhtp9M6XuGops7CkksnpdciGHChi4iq6(qji0NUhtbKpToA0vJC9ppa15uuKAoDzDrHeexq0Cbbexeir5I8uzHDFiueXhqPt2aOstytX20LQgBu(gBfOkXbinBAWSrkrpMaHnf1un2s7xq9(Inrfzkb2uSLANQKd49sG9yAD0OR21Fq8RMyTW6ZJnaQ0v7HWQPMUh7Hg8Jj9M6rTVWMhlsLtRuadTV9bTsbm0Y9BQMA8Tho5JfPYxy95BFu7lS5rYEj5QHTu9OFSWQ9f28y6sLWJfPYjBkaGmkP6BFqRuadThA4444pwKkN4xnXAH1NV9bzjV2xytSOO6G(ipzOd98irjNm9hXdYMcaiJsQEKANQKd49spexKXlLtRlupMUuj85b2ssV1rJUAKNr7b90fgANoxyCyiiXHGddJaYouipvwyupOvD00MthcyCxnnxiqW1qGa1o4tLfE3drpGVD9Nr70TdgfkiiGXXHHrGutd)uzDDFgiNoxqGaR5cVdhIgsiWOqDQSUi(8aWReU(JfPYfbueY3(O5bQR)qAbm9R)5ZdrafHC9hKogAG6buGQe5eq5ZNhDHhP2Pk5aEVeBIkY85b5HgyWGHcm3h7FgnyC8p)a

    Big advantage: it's a local countdown triggered by an event, very high performance (as opposed to a full aura scan). Big disadvantage: Lifebloom's duration is modified by Haste, so the timer might be off by a few milliseconds, depending on how much haste the druid has.

    Cheers! :)

    #5 Oct 22, 2012 at 20:24 UTC - 0 likes

    Replying to myself, my aura had a bug: the lifebloom display timer only reset everytime the aura was shown, instead of everytime I casted Lifebloom. This was an error from my side, because I overlooked the fact that variables are set only when the aura is shown, i.e. On Show. My workaround has been to split the aura in two different auras:

    • a first invisible aura that stores the time value WeakAuras_lbcast = GetTime() everytime lifebloom is cast, dies in 1 second
    • a second aura that displays the WeakAuras_lbcast for 15 seconds everytime lifebloom is cast, dies in 15 seconds

    The trick here is that the first aura dies in 1 second. This means that the command WeakAuras_lbcast = GetTime() will always run On Show (because the first aura always dies in 1 second, so it always shows). Unless you cast lifeblooms faster than once per second, you should be fine this time! :)

    Cheers.

    Aura1: dquyhaqjur6tOc0OqfWPqfKBPOyxQQmmPYXuXYuvEMKAAs01uW2uQ8nvQgNuvDoQunpuH09qfXbrvSquYdvunrujDrPQ0grv9rurzKOIQtkjSsjrMPIs3uQk2jKFIQ0qrfIJsLslfvINszQaDvuH6RuPyTOcQ5QQQ9s(lkmyf6WqTyf5XuXKLYLfTzvYNrPgTuLttvVwsA2QYTvk7wj)g0WrrlhXZrA6cxhW2rL67sIA8ujNxLY6vQA)syDeOSnznznbklsxb)hMnvgcUsz0a7uLA(9PqFdYCX71fndXFORR29(35ET77UxU7RuxZuoiJgyNQu(pmBQmeCLYUX71fndXV8(qD)NH(R)oDD9VRuxZuUt2eK0sYC4dseOqhHoc9j0rOAHocvku3VbfYiWahjy6kKH4f1xztyNQSjqGvBo8bjcuOJqDc9juNq1c1juPqD)guiBctMdFqIaf6i0rOpH6eQwOoHkf6OqwlP4aGGJutYEqCtGYaOjdNhMsflze4lfOSnGx4fOcfYaOjJvYDs0KmNhMsfOmQFX(LY4kx44k4QcfYc)wsMdFqIaf6i0rOpHocvl0rOsHokKrs2E4c8gZuwKUcz0a7uLkwYI0vaqszSE(97XKMSiDf8HRqgFIFFXOBbWncoWfJGGYOb2PkLpCfY4t87lgDlaUrWbUyeeuggiGILSWVLe(WviJpXVVy0Ta4gbh4Irqqz4hZEyHoYMGKwsQyrZqOZrwKUI5WhKiqHocDe6tOJq1cDeQuOJcztqsljSWovBeitzSE(97XKwXiie(cptzoWhKiqHoIF)L3VxVRSRRSC33PZDDnZWGq1I)G71LNHY(7QpF1L3VRRzg2PqMdanGBGPRqwrLkQKSjmPI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RGIMLacIIBWxUmzRcWJM)(vk4(EoPvwNNuzyPC75ZPxvxwRozzYwfvoE6CUdIOvg(8H1kV1it2AL3AKeakBHvm81wpOXtxiiPZqaiYmgFn(ASuJVgZX4RXYghrmbxwpGOvJ8H1diA1O0Vy3wXWxB9aIwnsZFBJVPSMJHpwI8QTYZj4AUIX6klibqNZ0jlR8i2knUYWNWmwfffvMX6cYInaKB8H1yqrb3SgslKM1fKLac(wMS1fKvmOOGBMSvbe8TSoXRA0onUjYKRvIpbrsxtNojiIkicrVxzkrui4Bjicz6J(OCXUbuGmjI3iXXLlRRSGeaDotNSoP3lR8i26bnEkBee8TodbGiZy814iJLACKXCmoYyzJJiMGlRIIgpvCgcarMX4RXxJLA81yogFnw24RlRvERrA(BBSucwZlRNqomIPIkmwzbja6CR01kxz4JcWQqz2SBKWmUS(a3yqz2SBKW4RvUjVQzwYNOO)3F)LL5q4x0hP)8oVY)SUArSvUNfKaOZfHbnmQ8wJcJDikm6K04cyEyCLddrhdFlryq3RgfgZHGNo)DyetfvVcdAyCsEVpaGWnITMF83ir7dRquUFfTYWNvUkrEobrjrmZKNyDwNzpRSKu)IiiZ5VS0OuPs97xK35v(J1vwqcGoNPtw8mZEwzLhKSkkA8uHe4RSkbL)ggNcKUq0IggmmUSkSEjwM4)etWk)gFLJICzda

  • 5 posts

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