Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. function (allstates)
  2. if not InCombatLockdown() then
  3. if IsInRaid() then
  4. local myzone = GetZoneText()
  5. for i=1, GetNumGroupMembers() do
  6. local unit = WeakAuras.raidUnits[i]
  7. local name = UnitName(unit)
  8. local guid = UnitGUID(unit)
  9. local zone = select(7,GetRaidRosterInfo(i))
  10. if UnitGroupRolesAssigned(unit) == "HEALER" and not allstates[guid] and UnitIsConnected(unit) and zone == myzone then --give them a state
  11. allstates[guid] = {}
  12. allstates[guid].name = name
  13. allstates[guid].guid = guid
  14. allstates[guid].class = select(3,UnitClass(unit))
  15. allstates[guid].request = GetTime()
  16. allstates[guid].progressType = "static"
  17. allstates[guid].value = UnitPower(unit,0)
  18. allstates[guid].total = UnitPowerMax(unit,0)
  19. allstates[guid].button = aura_env.getButton(guid)
  20. allstates[guid].show = true
  21. allstates[guid].changed = true
  22. elseif UnitGroupRolesAssigned(unit) ~= "HEALER" and allstates[guid] then --take away their state
  23. allstates[guid].button:Hide()
  24. allstates[guid].show = false
  25. allstates[guid].changed = true
  26. end
  27. end
  28. else
  29. for _,s in pairs(allstates) do
  30. s.button:Hide()
  31. s.show = false
  32. s.changed = true
  33. end
  34. end
  35. for n,s in pairs(allstates) do
  36. if (not UnitExists(s.name)) or (not UnitIsConnected(s.name)) then --garbagecollect
  37. s.button:Hide()
  38. s.show = false
  39. s.changed = true
  40. end
  41. end
  42. for i=1, GetNumGroupMembers() do
  43. local name,_,_,_,_,_,zone = GetRaidRosterInfo(i)
  44. local guid = UnitGUID(WeakAuras.raidUnits[i])
  45. if allstates[guid] and zone ~= GetZoneText() then
  46. allstates[guid].button:Hide()
  47. allstates[guid].show = false
  48. allstates[guid].changed = true
  49. end
  50. end
  51. end
  52. for n,s in pairs(allstates) do
  53. s.value = UnitPower(s.name,0)
  54. s.total = UnitPowerMax(s.name,0)
  55. s.changed = true
  56. end
  57. return true
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement