Quantcast
Great Scorch WeakAura but NEED to alter this code somehow! - WoWInterface
 
Thread Tools Display Modes
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
04-13-21, 12:49 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 573
I posted on your MMOC thread, but I'll answer here as well. UnitCanAttack will filter for hostile or neutral units, and I'm pretty sure you can't attack yourself so your nameplate will be left alone. The nameplate loop logic was also a bit redundant.

Lua Code:
  1. function(allstates, event, unit, ...)
  2.     if event == "NAME_PLATE_UNIT_ADDED" then
  3.         if unit then
  4.             local guid = UnitGUID(unit)
  5.             allstates[guid] = {
  6.                 changed = true,
  7.                 show = false,
  8.                 PassUnit = unit,
  9.                 glow = false,
  10.             }
  11.         end
  12.     end
  13.     if event == "NAME_PLATE_UNIT_REMOVED" then
  14.         if unit then
  15.             local guid = UnitGUID(unit)
  16.             if allstates[guid] then
  17.                 allstates[guid].changed = true
  18.                 allstates[guid].PassUnit = "none"
  19.             end
  20.         end
  21.     end
  22.     for i = 1,40 do
  23.         local u = "nameplate"..i
  24.         if UnitExists(u) and UnitCanAttack("player",unit) and
  25.                 UnitHealth(u)>=1 and (UnitHealth(u)/UnitHealthMax(u))<.3 then
  26.             allstates[u] = {
  27.                 changed = true,
  28.                 show = true,
  29.                 PassUnit = u,
  30.                 glow = true,
  31.             }
  32.         else
  33.             allstates[u] = {
  34.                 changed = true,
  35.                 show = false,
  36.                 PassUnit = "none",
  37.             }
  38.         end
  39.     end
  40.     return true
  41. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Great Scorch WeakAura but NEED to alter this code somehow!

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off