Guest User

raid.lua

a guest
Nov 18th, 2010
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.45 KB | None | 0 0
  1. if not StufRaid then return end
  2.  
  3. -- Raid Group module base
  4. local core = StufRaid
  5. local a = CreateFrame("Frame", nil, core)
  6. core.raid = a
  7. local invehicle, vehicleowner = core.invehicle, core.vehicleowner
  8. local aggroed = core.aggroed
  9.  
  10. local units, groups, labels = { }, { }, { }
  11. a.units, a.groups, a.labels = units, groups, labels
  12.  
  13. -- layout settings made local
  14. local layout, s40
  15. local bordc, aggroc, targetc
  16. local hpdb, mpdb, namedb, hptdb, mptdb
  17. local hpbgcm, hpbarcm, mpbgcm, mpbarcm, namecm, hptcm, mptcm
  18. local showlooter, showleader, showcombaticon, charlimit
  19. local bcount, dcount, acount, hidebuffs
  20. local w, h, ooralpha, deadalpha = 0, 0, 1, 1
  21. local dbver = 0
  22.  
  23. -- globals made local
  24. local pairs = pairs
  25. local strsub = string.utf8sub or string.sub
  26. local UnitExists, UnitIsUnit = UnitExists, UnitIsUnit
  27.  
  28. -- local functions
  29. local UpdateUnit, UpdateHealth
  30.  
  31.  
  32. local tog = 0
  33. local UnitAffectingCombat, UnitIsConnected = UnitAffectingCombat, UnitIsConnected
  34. local UnitIsVisible, IsSpellInRange, UnitInRange = UnitIsVisible, IsSpellInRange, UnitInRange
  35. local function UpdateGeneral()  -- update basic stuff
  36.     tog = (tog > 2 and 0) or (tog + 1)
  37.     for u, uf in pairs(units) do  -- periodically check for status flags and unit range
  38.         local vu = invehicle[u] or u
  39.         if showcombaticon and tog == 2 then  -- check for combat
  40.             if UnitAffectingCombat(vu) then
  41.                 uf.combaticon:Show()
  42.             else
  43.                 uf.combaticon:Hide()
  44.             end
  45.         elseif tog == 0 then  -- check if connected
  46.             if not UnitIsConnected(u) and UnitExists(u) then
  47.                 uf.hptexttext:SetText(core.offlinetext)
  48.                 uf.dced = true
  49.             elseif uf.dced then
  50.                 uf.dced = nil
  51.                 UpdateHealth(vu, uf)
  52.             end
  53.         end
  54.         -- update overlay opacity
  55.         if uf.dead or uf.dced then
  56.             uf.border:SetAlpha(deadalpha)
  57.         elseif not UnitIsVisible(vu) or (s40 and IsSpellInRange(s40, vu) ~= 1) or (not s40 and not UnitInRange(vu)) then
  58.             uf.border:SetAlpha(ooralpha)
  59.         else
  60.             uf.border:SetAlpha(1)
  61.         end
  62.     end
  63. end
  64. local function UpdateAggro(atable)  -- check for aggro
  65.     if aggroc.a < 0.05 then return end
  66.     for u, value in pairs(atable) do
  67.         local uf = units[u]
  68.         if uf then
  69.             if value == 1 then
  70.                 if not uf.aggroed then
  71.                     uf.border:SetBackdropBorderColor(aggroc.r, aggroc.g, aggroc.b, aggroc.a)
  72.                     uf.aggroed, uf.targeted = true, nil
  73.                 end
  74.             elseif value == 0 and uf.aggroed then
  75.                 uf.border:SetBackdropBorderColor(bordc.r, bordc.g, bordc.b, bordc.a)
  76.                 uf.aggroed = nil
  77.             end
  78.         end
  79.     end
  80. end
  81. local function UpdateTarget(hastarget)  -- current target highlighting
  82.     if targetc.a < 0.05 then return end
  83.     if hastarget then
  84.         for u, uf in pairs(units) do
  85.             if not uf.aggroed then  -- color border if it's your current target and doesn't have aggro
  86.                 if UnitIsUnit("target", invehicle[u] or u) then
  87.                     if not uf.targeted then
  88.                         uf.border:SetBackdropBorderColor(targetc.r, targetc.g, targetc.b, targetc.a)
  89.                         uf.targeted = true
  90.                     end
  91.                 elseif uf.targeted then
  92.                     uf.border:SetBackdropBorderColor(bordc.r, bordc.g, bordc.b, bordc.a)
  93.                     uf.targeted = nil
  94.                 end
  95.             end
  96.         end
  97.     else
  98.         for u, uf in pairs(units) do
  99.             if uf.targeted then  -- clear target border
  100.                 uf.border:SetBackdropBorderColor(bordc.r, bordc.g, bordc.b, bordc.a)
  101.                 uf.targeted = nil
  102.             end
  103.         end
  104.     end
  105. end
  106.  
  107. local GetLootMethod, UnitIsPartyLeader = GetLootMethod, UnitIsPartyLeader
  108. local function UpdateRaid(inraid, incombat, hidearena)
  109.     local haschild
  110.     for u, uf in pairs(units) do
  111.         units[u] = nil
  112.     end
  113.     if inraid and not hidearena then
  114.         for index, gf in pairs(groups) do  -- update title visibility
  115.             for i = 1, 40, 1 do
  116.                 local uf = gf:GetAttribute("child"..i)
  117.                 if not uf then break end
  118.                 if uf:IsShown() then
  119.                     local u = uf:GetAttribute("unit")
  120.                     uf.unit = u
  121.                     units[u] = uf
  122.                    
  123.                     if showlooter then uf.looticon:Hide() end
  124.                     if showleader then uf.leadericon:Hide() end
  125.                    
  126.                     if i == 1 then
  127.                         haschild = true
  128.                         labels[index]:Show()
  129.                     end
  130.                 elseif i == 1 then
  131.                     labels[index]:Hide()
  132.                 end
  133.             end
  134.         end
  135.         if showlooter then  -- update loot icon
  136.             local method, pid, rid = GetLootMethod()
  137.             local looter = (method == "master" and "raid"..rid) or nil
  138.             local uf = looter and units[looter]
  139.             if uf then
  140.                 uf.looticon:Show()
  141.             end
  142.         end
  143.         if showleader then  -- update leader icon
  144.             if not leader or not UnitIsPartyLeader(leader) then  -- look for new leader
  145.                 for u, uf in pairs(units) do
  146.                     if UnitIsPartyLeader(u) then
  147.                         uf.leadericon:Show()
  148.                         leader = u
  149.                         break
  150.                     end
  151.                 end
  152.             else  -- refresh current leader icon
  153.                 local uf = leader and units[leader]
  154.                 if uf then
  155.                     uf.leadericon:Show()
  156.                 end
  157.             end
  158.         end
  159.         tog = 3
  160.         UpdateGeneral()
  161.     else
  162.         for index, gf in pairs(groups) do
  163.             labels[index]:Hide()
  164.             if not incombat then
  165.                 if hidearena then
  166.                     gf:Hide()
  167.                 elseif not gf:IsShown() and not gf.db.hide then
  168.                     gf:Show()
  169.                 end
  170.             end
  171.         end
  172.     end
  173.     -- update anchor visibility, only done out of combat since it is protected
  174.     if haschild and layout.showanchor and not incombat then
  175.         a:EnableMouse(true)
  176.         a:SetBackdropColor(0, 0, 0, 0.4)
  177.     elseif not incombat then
  178.         a:EnableMouse(false)
  179.         a:SetBackdropColor(0, 0, 0, 0)
  180.     end
  181. end
  182.  
  183. -- Health
  184. local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax
  185. local UnitGetIncomingHeals = UnitGetIncomingHeals
  186. local UnitIsDeadOrGhost, UnitIsGhost = UnitIsDeadOrGhost, UnitIsGhost
  187. function UpdateHealth(u, uf)
  188.     uf = uf or units[vehicleowner[u] or u]
  189.     if not uf then return end
  190.     u = uf.activeunit
  191.     if UnitIsDeadOrGhost(u) then
  192.         uf.hptexttext:SetText((UnitIsGhost(u) and core.ghosttext) or core.deadtext)
  193.         uf.hpbarbar:SetValue((hpdb.fulldead and 1) or 0.00001)
  194.         uf.border:SetAlpha(deadalpha)
  195.         uf.dead = true
  196.     else
  197.         local current, total = UnitHealth(u), UnitHealthMax(u)
  198.         local frac = (current == 0 and 0.00001) or (current >= total and 1) or (current / total)
  199.         uf.frachp = frac
  200.         uf.maxhp = total
  201.         uf.hpbarbar:SetValue(frac)
  202.         uf.hptexttext:SetValue(current, total, frac)
  203.         uf.dead = nil
  204.         if hpdb.incheal and uf.hpbar.incbar then
  205.             local incheal = (UnitGetIncomingHeals(u) or 0) / total
  206.             if incheal ~= uf.previnc then
  207.                 if incheal + frac > 1.1 then
  208.                     incheal = 1.1 - frac
  209.                 end
  210.                 if incheal == 0 then
  211.                     uf.hpbar.incbar:Hide()
  212.                 else
  213.                     uf.hpbar.incbar:SetValue((incheal > 1 and 1) or (incheal < 0 and 0) or incheal)
  214.                     uf.hpbar.incbar:Show()
  215.                 end
  216.                 uf.previnc = incheal
  217.             end
  218.         end
  219.     end
  220. end
  221.  
  222. -- Power
  223. local UnitPower, UnitPowerMax, UnitPowerType = UnitPower, UnitPowerMax, UnitPowerType
  224. local function UpdatePower(u, ptype, uf)
  225.     uf = uf or units[vehicleowner[u] or u]
  226.     if not uf then return end
  227.     u = uf.activeunit
  228.     if uf.powertype == 0 then
  229.         local current, total = UnitPower(u), UnitPowerMax(u)
  230.         local frac = (current == 0 and 0.00001) or (current >= total and 1) or (current / total)
  231.         uf.mptexttext:SetValue(current, total, current == 0 and 0 or frac)
  232.         uf.mpbarbar:SetValue(frac)
  233.     else
  234.         uf.mptexttext:SetText("")
  235.         uf.mpbarbar:SetValue(0.00001)
  236.     end
  237. end
  238. local function UpdatePowerType(u, uf)
  239.     uf = uf or units[u]
  240.     if not uf then return end
  241.     uf.powertype = ((invehicle[u] or vehicleowner[u]) and 1) or UnitPowerType(u)
  242.    
  243.     uf.hpbar.bg:SetVertexColor(hpbgcm(uf, hpdb, "bgcolor", "bgalpha"))
  244.     uf.hpbarbar:SetVertexColor(hpbarcm(uf, hpdb, "barcolor", "baralpha"))
  245.     uf.mpbar.bg:SetVertexColor(mpbgcm(uf, mpdb, "bgcolor", "bgalpha"))
  246.     uf.mpbarbar:SetVertexColor(mpbarcm(uf, mpdb, "barcolor", "baralpha"))
  247.     uf.nametexttext:SetTextColor(namecm(uf, namedb, "fontcolor"))
  248.     uf.hptexttext:SetTextColor(hptcm(uf, hptdb, "fontcolor"))
  249.     uf.mptexttext:SetTextColor(mptcm(uf, mptdb, "fontcolor"))
  250.    
  251.     UpdatePower(u, nil, uf)
  252. end
  253.  
  254. -- Raid Target Icons
  255. local GetRaidTargetIndex, SetRaidTargetIconTexture = GetRaidTargetIndex, SetRaidTargetIconTexture
  256. local function UpdateRaidTarget(u, uf)
  257.     if layout.raidicon.hide then return end
  258.     if u and uf then
  259.         local iconindex = GetRaidTargetIndex(u)
  260.         if iconindex then
  261.             SetRaidTargetIconTexture(uf.raidicon.icon, iconindex)
  262.             uf.raidicon:Show()
  263.         else
  264.             uf.raidicon:Hide()
  265.         end
  266.     else
  267.         for u, uf in pairs(units) do
  268.             local iconindex = GetRaidTargetIndex(invehicle[u] or u)
  269.             if iconindex then
  270.                 SetRaidTargetIconTexture(uf.raidicon.icon, iconindex)
  271.                 uf.raidicon:Show()
  272.             else
  273.                 uf.raidicon:Hide()
  274.             end
  275.         end
  276.     end
  277. end
  278.  
  279. local UpdateAura = core.UpdateAura
  280. local function UpdateRaidAura(u, uf)
  281.     uf = uf or units[vehicleowner[u] or u]
  282.     if uf then
  283.         UpdateAura(uf.activeunit, uf, bcount, dcount, acount, hidebuffs)
  284.     end
  285. end
  286.  
  287. local function UpdateVehicle(u)  -- update to reflect vehicle possession
  288.     local uf = units[u]
  289.     if uf then
  290.         uf.uname = nil
  291.         UpdateUnit(u, uf)
  292.     end
  293. end
  294.  
  295. local UpdateAlerts = core.UpdateAlerts
  296. local function UpdateReadyCheck()  -- ready check alerts
  297.     core.CheckReady(true)
  298.     for u, uf in pairs(units) do
  299.         UpdateAlerts(u, uf, acount)
  300.     end
  301. end
  302. local function UpdateReadyCheckFinish()
  303.     core.CheckReady(false)
  304.     for u, uf in pairs(units) do
  305.         UpdateAlerts(u, uf, acount)
  306.     end
  307. end
  308.  
  309. local function VoiceStart(u)
  310.     local uf = units[u]
  311.     if uf then
  312.         uf.voiceicon:Show()
  313.     end
  314. end
  315. local function VoiceStop(u)
  316.     local uf = units[u]
  317.     if uf then
  318.         uf.voiceicon:Hide()
  319.     end
  320. end
  321.  
  322. local function updatepet(uf, event, a1)
  323.     if a1 == uf.unit then
  324.         uf:UnregisterEvent("UNIT_PET")
  325.         uf.uname = nil
  326.         UpdateUnit(a1, uf)
  327.     end
  328. end
  329.  
  330. local UnitName, UnitClass = UnitName, UnitClass
  331. UpdateUnit = function(u, uf)
  332.     uf = uf or units[u]
  333.     if not uf then return end
  334.    
  335.     local name = UnitName(u)
  336.     local vu = invehicle[u] or u
  337.     if uf.uname == name and uf.activeunit == vu then return end
  338.     if uf.activeunit ~= vu and vehicleowner[vu] then
  339.         uf:RegisterEvent("UNIT_PET")
  340.         uf:SetScript("OnEvent", updatepet)
  341.     end
  342.     uf.uname, uf.activeunit = name, vu
  343.     uf.class, uf.CLASS = UnitClass(u)
  344.     uf.nametexttext:SetValue(name, u, charlimit, "")
  345.     uf.border:SetBackdropBorderColor(bordc.r, bordc.g, bordc.b, bordc.a)
  346.     UpdatePowerType(vu, uf)
  347.     UpdateHealth(vu, uf)
  348.     UpdateRaidAura(vu, uf)
  349.     UpdateRaidTarget(vu, uf)
  350.     if uf.voiceicon then
  351.         uf.voiceicon:Hide()
  352.     end
  353.     if uf.aggroed and not aggroed[vu] then
  354.         uf.border:SetBackdropBorderColor(bordc.r, bordc.g, bordc.b, bordc.a)
  355.         uf.aggroed = nil
  356.     elseif not uf.aggroed and aggroed[vu] then
  357.         uf.border:SetBackdropBorderColor(aggroc.r, aggroc.g, aggroc.b, aggroc.a)
  358.         uf.aggroed = true
  359.         uf.targeted = nil
  360.     end
  361. end
  362.  
  363. local function FastHealthOnUpdate(this)
  364.     this.dofasthp = not this.dofasthp
  365.     if not this.dofasthp then return end
  366.     UpdateHealth(this.unit, this.uf)
  367. end
  368. local function CreateRaidUnit(uf)  -- dress up the unit frame given by secure handlers
  369.     if uf.dbver == dbver then return end  -- don't update frame if unnecessary
  370.     uf.dbver = dbver
  371.     core.CreateUnitBase(uf, layout, a, nil, FastHealthOnUpdate)
  372.  
  373.     core.CreateBar(uf, layout, "mpbar")
  374.     core.CreateText(uf, layout, "mptext")
  375.    
  376.     core.CreateAura(uf, layout, "buff")
  377.     core.CreateAura(uf, layout, "debuff")
  378.     core.CreateAura(uf, layout, "alert")
  379.    
  380.     core.CreateIcon(uf, layout, "looticon", "Interface\\GroupFrame\\UI-Group-MasterLooter")
  381.     core.CreateIcon(uf, layout, "leadericon", "Interface\\GroupFrame\\UI-Group-LeaderIcon")
  382.     core.CreateIcon(uf, layout, "voiceicon", "Interface\\Common\\VoiceChat-Speaker")
  383.     core.CreateIcon(uf, layout, "combaticon", "Interface\\CharacterFrame\\UI-StateIcon")
  384.  
  385.         local bg = CreateFrame("Frame", nil, uf)
  386.         bg:SetBackdrop({
  387.             bgFile = 'Interface\\ChatFrame\\ChatFrameBackground',
  388.             edgeFile = 'Interface\\ChatFrame\\ChatFrameBackground',
  389.             edgeSize = 1,
  390.         })
  391.         bg:SetBackdropColor(0, 0, 0, .4)
  392.         bg:SetBackdropBorderColor(0, 0, 0)
  393.         bg:SetFrameStrata("BACKGROUND")
  394.         bg:SetPoint("TOPLEFT", uf, -1, 1)
  395.         bg:SetPoint("BOTTOMRIGHT", uf, 1, -1)
  396.  
  397.     if uf.unit then
  398.         units[uf.unit] = uf
  399.     end
  400. end
  401.  
  402. local function UpdateAttribute(this, name, value)
  403.     if name ~= "unit" then return end
  404.     if value then
  405.         units[value] = this
  406.         this.unit = value
  407.         UpdateUnit(value, this)
  408.     else
  409.         for u, uf in pairs(units) do
  410.             if uf == this then
  411.                 units[u] = nil
  412.             end
  413.         end
  414.     end
  415. end
  416. local function HeaderConfig(header, buttonName)
  417.     local uf
  418.     if type(buttonName) == "string" then
  419.         uf = _G[buttonName]
  420.     else
  421.         return
  422.     end
  423.     uf:SetScript("OnAttributeChanged", UpdateAttribute)
  424.     CreateRaidUnit(uf)
  425. end
  426.  
  427. local function CreateRaidGroup(index)
  428.     local db = layout["group"..index]
  429.     local f, label = groups[index], labels[index]
  430.     if not db or db.hide then
  431.         if f then
  432.             f:Hide()
  433.         end
  434.         if label then
  435.             label:SetAlpha(0)
  436.         end
  437.         return
  438.     end
  439.     if not f then
  440.         f = CreateFrame("Frame", "StufRaidHeader"..index, a, "SecureRaidGroupHeaderTemplate")
  441.         f.initialConfigFunction = HeaderConfig
  442.         f:SetAttribute("minWidth", w)
  443.         f:SetAttribute("minHeight", h)
  444.         f:SetAttribute("initialConfigFunction", [===[
  445.             local header = self:GetParent()
  446.             self:SetWidth(header:GetAttribute("minWidth"))
  447.             self:SetHeight(header:GetAttribute("minHeight"))
  448.             self:SetAttribute("type1", "target")
  449.             self:SetAttribute("*type1", "target")
  450.             self:SetAttribute("toggleForVehicle", true)
  451.             header:CallMethod("initialConfigFunction", self:GetName())
  452.         ]===])
  453.         f:SetAttribute("template", "SecureUnitButtonTemplate")
  454.         f:SetWidth(8)
  455.         f:SetHeight(8)
  456.         f.db = db
  457.         label = a:CreateFontString(nil, "ARTWORK")
  458.         label:Hide()
  459.        
  460.  
  461.  
  462.        
  463.         groups[index], labels[index] = f, label
  464.     end
  465.     f:SetAttribute("minWidth", w)
  466.     f:SetAttribute("minHeight", h)
  467.     if layout.byclass then
  468.         core.SetupGroup(f, label, a, db, db.classorder or "WARRIOR", "CLASS", w, h)
  469.     else
  470.         core.SetupGroup(f, label, a, db, db.order or "1", "GROUP", w, h)
  471.     end
  472.     f:Show()
  473.  
  474.  
  475.  
  476. end
  477.  
  478. local cm = core.colormethods
  479. local function raidinit(db, dbc)
  480.     -- cache global settings
  481.     bordc, targetc, aggroc = db.bordc, db.targetc, db.aggroc
  482.     ooralpha, deadalpha = db.ooralpha, db.deadalpha
  483.     s40 = core.s40
  484.    
  485.     -- cache raid layout settings
  486.     layout = db.raid
  487.     w, h = layout.w, layout.h
  488.     hpdb, mpdb = layout.hpbar, layout.mpbar
  489.     namedb, hptdb, mptdb = layout.nametext, layout.hptext, layout.mptext
  490.     hpbgcm, hpbarcm = cm[hpdb.bgcolormethod or "solid"], cm[hpdb.barcolormethod or "solid"]
  491.     mpbgcm, mpbarcm = cm[mpdb.bgcolormethod or "solid"], cm[mpdb.barcolormethod or "solid"]
  492.     namecm = cm[namedb.colormethod or "class"]
  493.     hptcm = cm[hptdb.colormethod or "solid"]
  494.     mptcm = cm[mptdb.colormethod or "solid"]
  495.     charlimit = namedb.chars > 0 and namedb.chars or nil
  496.     showcombaticon, showlooter, showleader = not layout.combaticon.hide, not layout.looticon.hide, not layout.leadericon.hide
  497.     bcount = not layout.buff.hide and dbc.bshow ~= "hide" and (layout.buff.cols * layout.buff.rows)
  498.     dcount = not layout.debuff.hide and dbc.dshow ~= "hide" and (layout.debuff.cols * layout.debuff.rows)
  499.     acount = not layout.alert.hide and (layout.alert.cols * layout.alert.rows)
  500.     hidebuffs = layout.debuff.hidebuff
  501.    
  502.     if not a:IsMovable() then  -- setup the anchor frame and make it movable, handled in the core
  503.         core.MakeMover(a, layout)
  504.     end
  505.     a:SetPoint("TOPLEFT", UIParent, "TOPLEFT", layout.anchorx, layout.anchory)
  506.     if db.strata then a:SetFrameStrata(db.strata) end
  507.    
  508.     dbver = dbver + 1
  509.     local changed
  510.     if dbver > 1 then
  511.         changed = true
  512.     else
  513.         core.AddEvent("UNIT_HEALTH", UpdateHealth)
  514.         core.AddEvent("UNIT_MAXHEALTH", UpdateHealth)
  515.         core.AddEvent("UNIT_ENTERED_VEHICLE", UpdateVehicle)
  516.         core.AddEvent("UNIT_EXITED_VEHICLE", UpdateVehicle)
  517.     end
  518.     if hpdb.incheal then
  519.         core.AddEvent("UNIT_HEAL_PREDICTION", UpdateHealth)
  520.     elseif changed then
  521.         core.RemoveEvent("UNIT_HEAL_PREDICTION", UpdateHealth)
  522.     end
  523.     if not layout.mpbar.hide or not layout.mptext.hide then
  524.         core.AddEvent("UNIT_POWER", UpdatePower)
  525.         core.AddEvent("UNIT_MAXPOWER", UpdatePower)
  526.         core.AddEvent("UNIT_DISPLAYPOWER", UpdatePowerType)
  527.     elseif changed then
  528.         core.RemoveEvent("UNIT_POWER", UpdatePower)
  529.         core.RemoveEvent("UNIT_MAXPOWER", UpdatePower)
  530.         core.RemoveEvent("UNIT_DISPLAYPOWER", UpdatePowerType)
  531.     end
  532.     if bcount or dcount or acount then
  533.         core.AddEvent("UNIT_AURA", UpdateRaidAura)
  534.     elseif changed then
  535.         core.RemoveEvent("UNIT_AURA", UpdateRaidAura)
  536.     end
  537.     if acount then
  538.         core.AddEvent("READY_CHECK", UpdateReadyCheck)
  539.         core.AddEvent("READY_CHECK_CONFIRM", UpdateReadyCheck)
  540.         core.AddEvent("READY_CHECK_FINISHED", UpdateReadyCheckFinish)
  541.     elseif changed then
  542.         core.RemoveEvent("READY_CHECK", UpdateReadyCheck)
  543.         core.RemoveEvent("READY_CHECK_CONFIRM", UpdateReadyCheck)
  544.         core.RemoveEvent("READY_CHECK_FINISHED", UpdateReadyCheckFinish)
  545.     end
  546.     if not layout.raidicon.hide then
  547.         core.AddEvent("RAID_TARGET_UPDATE", UpdateRaidTarget)
  548.     elseif changed then
  549.         core.RemoveEvent("RAID_TARGET_UPDATE", UpdateRaidTarget)
  550.     end
  551.     if not layout.voiceicon.hide then
  552.         core.AddEvent("VOICE_START", VoiceStart)
  553.         core.AddEvent("VOICE_STOP", VoiceStop)
  554.     elseif changed then
  555.         core.RemoveEvent("VOICE_START", VoiceStart)
  556.         core.RemoveEvent("VOICE_STOP", VoiceStop)
  557.     end
  558.    
  559.     for i = 1, 10, 1 do
  560.         CreateRaidGroup(i)
  561.     end
  562.     if dbver > 1 then  -- user must be configuring, so apply new settings
  563.         for index, gf in pairs(groups) do
  564.             for i = 1, 40, 1 do
  565.                 local child = gf:GetAttribute("child"..i)
  566.                 if not child then break end
  567.                 local config = child:GetAttribute("initialConfigFunction")
  568.                 if config then config(child) end
  569.                 if child.unit and UnitExists(child.unit) then
  570.                     child.uname = nil
  571.                     UpdateUnit(child.unit, child)
  572.                 end
  573.             end
  574.         end
  575.         UpdateRaid(UnitExists("raid1"), InCombatLockdown())
  576.     end
  577. end
  578. core.AddInitFunction("raid", raidinit, UpdateRaid, UpdateGeneral, UpdateAggro, UpdateTarget)
Advertisement
Add Comment
Please, Sign In to add comment