WeakAuras

Random dungeon healer mana?

  • 8 posts
    #1 Jun 02, 2011 at 20:14 UTC - 0 likes

    I just started using WeakAuras yesterday, and am giddy with excitement I can make my own triggers. I'm not at my WoW computer atm (read: I'm at work :P ) so I can't test this. I hope someone can confirm if I'm correct, right off the cuff. :)

    So, for the title at hand, am I right in assuming I'd make my own trigger, along the lines of this?

    function()
    	local CheckUnit = SomeWeakAurasGlobalVar;
    	local Role = UnitGroupRolesAssigned(CheckUnit);
    	local CurrentMana = UnitPower(CheckUnit, "SPELL_POWER_MANA");
    	local MaxMana = UnitPowerMax(CheckUnit, "SPELL_POWER_MANA");
    
    	local ManaPercent = CurrentMana/MaxMana;
    	local ManaWarning = .25;
    
    	if(Role == "HEALER" and ManaPercent <= ManaWarning) then
    		return true;
    	else
    		return false;
    	end
    end
    

    I assume for the untrigger, I can have it stop displaying the aura at any percentage I specify, not just .25? (If I've read the tutorials right)

    Also, what is the SomeWeakAurasGlobalVar supposed to be?

    And of course, what a fantastic addon here. I bet the devs hear this all the time, but it really does blow PAC out of the water imo. :)

    #2 Jun 02, 2011 at 21:32 UTC - 0 likes

    That looks mostly right, except you don't have code to identify the healer in your group. Here's a revised trigger with that code added, as well as a few other fixes:

    function()
        local HealerUnit;
        for i=1,GetNumPartyMembers() do
            local CheckUnit = "party"..i;
            if(UnitGroupRolesAssigned("party"..i) == "HEALER") then
                HealerUnit = CheckUnit;
                break;
            end
        end
        
        if(HealerUnit) then
            local ManaPercent = UnitPower(HealerUnit, "SPELL_POWER_MANA")/UnitPowerMax(HealerUnit, "SPELL_POWER_MANA");
            local ManaWarning = .25;
    
            if(ManaPercent <= ManaWarning) then
                return true;
            end
        end
        return false;
    end
    
    #3 Jun 02, 2011 at 21:47 UTC - 0 likes

    Awesome, thanks so much. :)

    Is there a way to return the ManaPercent to a progress bar? It'd be kind of cool to have a healer mana bar in the middle of my screen. :)

    [edit] Nevermind, re-read the custom trigger page.

    "Currently, custom triggers cannot pass Dynamic Information (Duration Info, Icon Info, Name Info, and Stack Info) to displays. This will be implemented in a later version."

    Derp. :) [/edit]

    Last edited Jun 02, 2011 by JonBoy2001
    #4 Jun 02, 2011 at 22:01 UTC - 0 likes

    Yes there is. You can use the Duration Info box on the Custom Trigger page to pass information to a Progress Bar. For this particular scenario, there is a bit of a complication; mana bars look best when you enable them to "fast update" (recalculate on every frame instead of only on UNIT_POWER events), but it is unnecessary to re-scan the group to find the appropriate unit ID for your healer on every frame update. It's more efficient to save the value obtained from the trigger's scan in a global variable, and then use that when it is needed later.

    So, first, change the Custom Trigger to

    function()
        local HealerUnit;
        for i=1,GetNumPartyMembers() do
            local CheckUnit = "party"..i;
            if(UnitGroupRolesAssigned("party"..i) == "HEALER") then
                HealerUnit = CheckUnit;
                break;
            end
        end
        
        WA_HealerUnit = HealerUnit;
        
        if(HealerUnit) then
            local ManaPercent = UnitPower(HealerUnit, "SPELL_POWER_MANA")/UnitPowerMax(HealerUnit, "SPELL_POWER_MANA");
            local ManaWarning = .25;
    
            if(ManaPercent <= ManaWarning) then
                return true;
            end
        end
        return false;
    end
    

    Then you can use this Custom Duration Info function:

    function()
        local HealerUnit = WA_HealerUnit;
        if(HealerUnit) then
            return UnitPower(HealerUnit, "SPELL_POWER_MANA"), UnitPowerMax(HealerUnit, "SPELL_POWER_MANA"), "fastUpdate";
        else
            return 1, 1, true;
        end
    end
    

    You can also use this principle to make your Custom Untrigger function more efficient (although that is less important, since it will be checked much less frequently), like so:

    function()
        local HealerUnit = WA_HealerUnit;
        if(HealerUnit) then
            local ManaPercent = UnitPower(HealerUnit, "SPELL_POWER_MANA")/UnitPowerMax(HealerUnit, "SPELL_POWER_MANA");
            local ManaWarning = .25;
    
            if(ManaPercent <= ManaWarning) then
                return false;
            end
        end
        return true
    end
    
    #5 Jun 02, 2011 at 22:05 UTC - 0 likes

    Sweet! But is the documentation out of date or did I mis-read it? =\

    Also, I could encase the for loop with an if statement like if(not WA_HealerUnit), right? I know it's only a max of 5 loops, but efficiency is efficiency. ;)

    Thinking about that, it'd pick the first healer of my first random, then keep checking for that healer over and over.

    Ahh the fun of debugging before writing code. :D

    Last edited Jun 02, 2011 by JonBoy2001
    #6 Jun 02, 2011 at 22:52 UTC - 0 likes
    Quote from JonBoy2001:

    Thinking about that, it'd pick the first healer of my first random, then keep checking for that healer over and over.

    Indeed. The scan does need to run occasionally to make sure you're always checking the right healer. On one end of the spectrum, it would be possible to actually identify the events that fire when a player chooses a role or joins a random group, and only do a scan on those events, but that would require an extra display and a lot of research and testing. On the other end of the spectrum, simply checking the role of the 5 people in your group probably takes less than a millisecond of CPU time; the only reason I mention efficiency in this context is because there could be 40-200 frame updates between each UNIT_POWER event, so even very small inefficiencies can magnified, but doing a group scan on every frame probably wouldn't even affect your framerate noticeably. Nevertheless, it's good coding practice to avoid such obvious leaks of CPU time.

    Allowing the scan to run on every trigger update is a decent compromise between efficiency and simplicity.

    Last edited Jun 02, 2011 by Mirrormn
    #7 Jun 03, 2011 at 04:26 UTC - 0 likes

    Tried this out tonight and it worked wonderfully. Thank you! I didn't have to acquaint myself with who was the healer, and move unit frames. It was just there. :D

    I do believe the documentation on this project page needs to be updated though. I saw no mention of being able to make my action bar buttons do that spiffy glowy border thing until I was messing around. This was the only feature from PowerAuras, or rather a 'plug-in' for PA, that I missed but I didn't care. But it's really there in WeakAuras, so :D

    I vote this addon be renamed AwesomeAuras. Or AwesomeAlerts or MegaAwesomeActionTimeFunMod. Weak is the polar opposite of this addon. ;)

    #8 Jun 03, 2011 at 04:41 UTC - 0 likes

    Yeah, the documentation is woefully out of date now, especially for some of the advanced features. Ironically, I've actually explained most of WeakAuras' new features in detail, with relevant examples, in various forum threads; I just haven't had the energy to consolidate the information.

    Quote from JonBoy2001:

    I vote this addon be renamed AwesomeAuras. Or AwesomeAlerts or MegaAwesomeActionTimeFunMod. Weak is the polar opposite of this addon.

    Renaming this project to MegaAwesomeActionTimeFunMod immediately XD

  • 8 posts

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