View Single Post
04-13-21, 02:00 AM   #1
matrixter
A Kobold Labourer
Join Date: Apr 2021
Posts: 1
Great Scorch WeakAura but NEED to alter this code somehow!

I found this great weakaura on wago for Scorch to be able to see what targets are below 30% health and are in scorch/execute range. It shows a glowing scorch icon right on enemy targets nameplates even if I don't have them selected which is great. The link for the WA is here: https://wago.io/DCkx9HrBE

My problem is that I use the personal resource display, which in the code is considered to be a nameplate so whenever I drop below 30% it shows it beside my PRD. I guess because the trigger code specifies "unit" which I'm assuming is the cause for this. It just takes any unit with a nameplate shown so I would like to be able to change it so that it only applies to hostile/neutral units (or w.e but pretty much just not myself). So from the bit of research I've done, I'm guessing I need to alter the code so that it applies to <=4 for the reaction type? IDK and I don't have any clue on writing code so I've come here in the hopes that someone can help me.

Trigger Code:

Code:
function (allstates, event,unit, ...)   
    if event == "NAME_PLATE_UNIT_ADDED" then
        if unit then
            local guid = UnitGUID(unit)                   
            --print(name)
            allstates[guid] = {
                changed = true,
                show = false,
                PassUnit = unit,
                glow = false,
            }            
        end
    end
    
    if event == "NAME_PLATE_UNIT_REMOVED" then
        if unit then
            local guid = UnitGUID(unit)
            if allstates[guid] then
                allstates[guid].changed = true
                allstates[guid].PassUnit = "none"
            end
        end
    end
    
    
    for i = 1,40 do
        local u = "nameplate"..i                
        if UnitExists(u) then
            if  (UnitHealth(u)/UnitHealthMax(u)) < 0.30 and UnitHealth(u) >= 1 then
                --print(u)
                allstates[u] = {
                    changed = true,
                    show = true,          
                    PassUnit = u,
                    glow = true,
                } 
            else
                allstates[u] = {
                    changed = true,
                    show = false,          
                    PassUnit = "none",
                }    
            end
        else
            allstates[u] = {
                changed = true,
                show = false,          
                PassUnit = "none",
            }  
        end
        
    end
    
    return true
    
end
  Reply With Quote