1. #1

    [WA] Players on the target

    Anyone with a WeakAura that can see how many players that is on that target?

  2. #2
    Make a trigger that suits you, type "%c" in the output's text field, make it update on every frame (not "trigger update") and use this as a custom code function:
    Code:
    if not aura_env.lastCheck then
    	aura_env.lastCheck = 0
    end
    if not aura_env.value then
    	aura_env.value = ""
    end
    
    local curTime = GetTime()
    if (curTime - aura_env.lastCheck) > 0.2 then -- update every 0.2 secs rather than every frame
    	aura_env.lastCheck = curTime
    	if UnitExists("target") then -- if we have no target then why bother
    
    		local groupType = IsInRaid() and "raid" or IsInGroup() and "party" or nil
    		if not groupType then -- if we are not in a group then why bother
    			aura_env.value = ""
    
    		else
    			local players = GetNumGroupMembers()
    			local temp
    			local targetedBy = 0
    			for i = 1, players do
    				temp = string.format("%s%dtarget", groupType, i) -- raid1target, raid2target, raid3target and so on
    				if UnitIsUnit("target", temp) then
    					targetedBy = targetedBy + 1
    				end
    			end
    			aura_env.value = tostring(targetedBy)
    		end
    	end
    end
    return aura_env.value
    Guess the trigger that would suit you is "Status - Conditions - Always true" with "In combat" as a loading option.
    Should work, but I didn't test.

  3. #3
    Rather than an OnUpdate script you should use the event UNIT_TARGET to trigger the scan anytime a unit in the raid/party/instance, or your target/focus/ToT, changes target.

    I will say this now, the code was not tested.

    Code:
    local number = "" -- just in case
    if UnitExists("target") then -- if we have no target then why bother
    	number = 0
    	local targetID = UnitGUID('target') -- your targets GUID
    	local groupType = IsInRaid() and "raid" or IsInGroup() and "party" or nil
    	if groupType then -- if we are in a group then we bother
    		for i = 1, GetNumGroupMembers() do -- funny thing, this isn't Javascript; it calls the function once in Lua.
    			if targetID == UnitGUID(string.format("%s%dtarget", groupType, i)) then
    				number = number + 1
    			end
    		end
    		number = tostring(number)
    	end
    end
    return number
    "I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

  4. #4
    I have this done for myself (working only in raid by pressing shift key)
    trigger > custom > status > events > MODIFIER_STATE_CHANGED

    CUSTOM TRIGGER
    Code:
    function(event, key, state)
        if key == "LSHIFT" or key == "RSHIFT" then
            return state == 1
        end
    end
    CUSTOM UNTRIGGER
    Code:
    function(event, key, state)
        if key == "LSHIFT" or key == "RSHIFT" then -- If it was one of the shift keys that changed,
            return state == 0 -- Then hide if the state is 0 (i.e. the key was released)
        end
    end
    DISPLAY > %c
    Code:
    function()
        local names = ""
        local pt = UnitGUID("playertarget")
        if not pt then
            return ""
        end
        local counter = 0
        local amount = 0
        for i=1, GetNumGroupMembers() do
            local raider = "raid"..i.."target"
            if UnitGUID(raider) == pt then
                local name = UnitName("raid"..i) 
                if name then
                    local _,class = UnitClass("raid"..i)
                    local colorText = RAID_CLASS_COLORS[class] and RAID_CLASS_COLORS[class].colorStr or "ffbbbbbb"
                    names = names .. (counter > 0 and ", " or "") .. "\124c" .. colorText .. name .. "\124r"
                    counter = counter + 1
                    amount = amount + 1
                    if counter > 4 then
                        names = names .. "\124n"
                        counter = 0
                    end
                end
            end
        end
        return amount..": "..names
    end

  5. #5
    Quote Originally Posted by ThePrideless View Post
    Rather than an OnUpdate script you should use the event UNIT_TARGET to trigger the scan anytime a unit in the raid/party/instance, or your target/focus/ToT, changes target.
    I thought about that but the last time I tried UNIT_TARGET, it was a bit delayed. But if you're ok with that, or it's just something only I experience, that's clearly a better solution, because it's more efficient.

    Quote Originally Posted by ThePrideless View Post
    funny thing, this isn't Javascript; it calls the function once in Lua.
    Alright, alright. It was just a "better safe than sorry" policy. I have nothing to do with Javascript though.


    I actually like Translit's approach: show it only when you want it to be shown.
    Though, I am being genuinely curious, why do you guys compare results of UnitGUID() instead of just using UnitIsUnit()? Is there something wrong with the latter?

  6. #6
    Quote Originally Posted by Translit View Post
    I have this done for myself (working only in raid by pressing shift key)
    trigger > custom > status > events > MODIFIER_STATE_CHANGED

    CUSTOM TRIGGER
    Code:
    function(event, key, state)
        if key == "LSHIFT" or key == "RSHIFT" then
            return state == 1
        end
    end
    CUSTOM UNTRIGGER
    Code:
    function(event, key, state)
        if key == "LSHIFT" or key == "RSHIFT" then -- If it was one of the shift keys that changed,
            return state == 0 -- Then hide if the state is 0 (i.e. the key was released)
        end
    end
    DISPLAY > %c
    Code:
    function()
        local names = ""
        local pt = UnitGUID("playertarget")
        if not pt then
            return ""
        end
        local counter = 0
        local amount = 0
        for i=1, GetNumGroupMembers() do
            local raider = "raid"..i.."target"
            if UnitGUID(raider) == pt then
                local name = UnitName("raid"..i) 
                if name then
                    local _,class = UnitClass("raid"..i)
                    local colorText = RAID_CLASS_COLORS[class] and RAID_CLASS_COLORS[class].colorStr or "ffbbbbbb"
                    names = names .. (counter > 0 and ", " or "") .. "\124c" .. colorText .. name .. "\124r"
                    counter = counter + 1
                    amount = amount + 1
                    if counter > 4 then
                        names = names .. "\124n"
                        counter = 0
                    end
                end
            end
        end
        return amount..": "..names
    end
    Thx mate!
    I guess if I want to show it at all time I just make the trigger to the if shift is not down and the untrigger to if shit is pressed?

  7. #7
    Quote Originally Posted by Sinelle View Post
    ...I have nothing to do with Javascript though.


    I actually like Translit's approach: show it only when you want it to be shown.
    Though, I am being genuinely curious, why do you guys compare results of UnitGUID() instead of just using UnitIsUnit()? Is there something wrong with the latter?

    I have been working with Javascript recently and the similarities between it and Lua are scary. That just so happened to be one of the things I disliked about Javascript that I wanted to point it out. Like a big middle finger to Javascript... since my update to Windows 10 deleted my projects.


    The modifier approach is also good. Have not personally used that approach myself but one can never go wrong with button press triggering things.


    My choice of comparing GUID is preference but UnitIsUnit will work just as well.
    "I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

  8. #8
    Quote Originally Posted by DonDalle View Post
    Anyone with a WeakAura that can see how many players that is on that target?
    If you are using ElvUI / TukUI there is an plugin to do just this. It displays the number of people targeting your current target, and also how many is targeting your mouseover targets if you will. The plugin is called Shadow and Light. It also comes with a bunch of other really good tools that complement the already added awesome-ness of ElvUI.

    http://www.curse.com/addons/wow/shadow-and-light-edit

  9. #9
    Quote Originally Posted by Moalim View Post
    If you are using ElvUI / TukUI there is an plugin to do just this. It displays the number of people targeting your current target, and also how many is targeting your mouseover targets if you will. The plugin is called Shadow and Light. It also comes with a bunch of other really good tools that complement the already added awesome-ness of ElvUI.

    http://www.curse.com/addons/wow/shadow-and-light-edit
    I know mate, but I dislike ElvUI, and I dont wanna download an entire addon pack to just use one plugin. And I pref weakauras compared to have 100 addons installed

  10. #10
    Quote Originally Posted by DonDalle View Post
    I know mate, but I dislike ElvUI, and I dont wanna download an entire addon pack to just use one plugin. And I pref weakauras compared to have 100 addons installed
    Fair enough! I tested the trigger WA but changed the trigger key to § which worked out quite well for me as well. Since I am not very good with custom code however, is it possible to change the weakaura of Translit to mouseover instead of player target?

  11. #11
    Quote Originally Posted by Moalim View Post
    change the weakaura of Translit to mouseover instead of player target?
    It's quite easy to do: replace "playertarget" with "mouseover" in the output's custom function.
    Quote Originally Posted by DonDalle View Post
    I guess if I want to show it at all time I just make the trigger to the if shift is not down and the untrigger to if shit is pressed?
    Check the first two replies if you want it to be always displayed.

  12. #12
    Quote Originally Posted by Sinelle View Post
    It's quite easy to do: replace "playertarget" with "mouseover" in the output's custom function.
    Check the first two replies if you want it to be always displayed.
    It's that easy huh? I suspected that I needed to change more.

    Thank you!

Posting Permissions

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