Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.02 KB | None | 0 0
  1. -- Arena Style for compact raid frame more buffs and debuffs, and show debuffs outside of the unit frame
  2.  
  3.  
  4. -- Initialized database defaults
  5. local defaults = {enable = true, buffnum = 6, debuffnum = 10, max = 5, cc = true, dir = "right"}
  6.  
  7. ArenaStyleDB = ArenaStyleDB or defaults
  8. ArenaStyle = CreateFrame("Frame")
  9. ArenaStyle.cache = {}
  10.  
  11. -- default buff number
  12. local DEFAULT_BUFF = 3
  13.  
  14. -- default debuff number
  15. local DEFAULT_DEBUFF = 3
  16.  
  17. local function log(msg) DEFAULT_CHAT_FRAME:AddMessage("|cffCD32CDArenaStyle:|r " .. msg) end
  18.  
  19. function ArenaStyle:OnLoad()
  20.     -- Initialize the db
  21.     self.db = ArenaStyleDB
  22.     for k,v in pairs(defaults) do
  23.         if self.db[k] == nil then self.db[k] = defaults[k] end
  24.     end
  25.     -- Initialize command table
  26.     SlashCmdList["ArenaStyle"] = function(msg) self:Command(msg, tbl) end
  27.     SLASH_ArenaStyle1 = "/as"
  28.     SLASH_ArenaStyle2 = "/ArenaStyle"
  29.     log("type /as to config ArenaStyle.")
  30.     -- Register event
  31.     --self:RegisterEvent("RAID_ROSTER_UPDATE")
  32.     --self:RegisterEvent("PARTY_MEMBERS_CHANGED")
  33.     --self:RegisterEvent("UNIT_PET")
  34.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  35.     self:RegisterEvent("PLAYER_REGEN_DISABLED")
  36.     self:RegisterEvent("PLAYER_REGEN_ENABLED")
  37.     self:RegisterEvent("UNIT_AURA")
  38.     CompactRaidFrameContainer:HookScript("OnEvent", ArenaStyle.OnRosterUpdate)
  39.     CompactRaidFrameContainer:HookScript("OnHide", ArenaStyle.ResetStyle)
  40.     CompactRaidFrameContainer:HookScript("OnShow", ArenaStyle.OnRosterUpdate)
  41. end
  42.  
  43. -- Command table
  44. function ArenaStyle:Command(msg , tbl)
  45.     local cmdtbl = tbl or
  46.     {
  47.         ["buff"] = function(arg)
  48.             if tonumber(arg) and tonumber(arg) >= DEFAULT_BUFF then
  49.                 self.db.buffnum = tonumber(arg)
  50.                 log("buff number set to be "..self.db.buffnum)
  51.                 self:ResetStyle()
  52.                 self:OnRosterUpdate()
  53.             else
  54.                 log("invalid input(must be numbers and over 3)")
  55.             end
  56.         end,
  57.         ["debuff"] = function(arg)
  58.             if tonumber(arg) and tonumber(arg) >= DEFAULT_DEBUFF then
  59.                 self.db.debuffnum = tonumber(arg)
  60.                 log("debuff number set to be "..self.db.debuffnum)
  61.                 self:ResetStyle()
  62.                 self:OnRosterUpdate()
  63.             else
  64.                 log("invalid input(must be numbers and over 3)")
  65.             end
  66.         end,
  67.         ["max"] = function(arg)
  68.             if tonumber(arg) and tonumber(arg) >= 0 then
  69.                 self.db.max = tonumber(arg)
  70.                 log("the maximum number to apply arena style set to be "..self.db.max)
  71.                 self:OnRosterUpdate()
  72.             else
  73.                 log("invalid input(must be numbers and non-negative)")
  74.             end
  75.         end,
  76.         ["off"] = function()
  77.             self.db.enable = false
  78.             log("set to be disabled")
  79.             self:ResetStyle()
  80.         end,
  81.         ["on"] = function()
  82.             self.db.enable = true
  83.             log("set to be enabled")
  84.             self:OnRosterUpdate()
  85.         end,
  86.         ["cc"] = function()
  87.             self.db.cc = not self.db.cc
  88.             if self.db.cc then
  89.                 log("display cc first")
  90.             else
  91.                 log("doesn't display cc first")
  92.             end
  93.         end,
  94.         ["left"] = function()
  95.             self.db.left = not self.db.left
  96.             if self.db.left then
  97.                 log("display debuffs on left")
  98.             else
  99.                 log("display debuffs on right")
  100.             end
  101.             self:ResetStyle()
  102.             self:OnRosterUpdate()
  103.         end,
  104.         --["apply"] = function() self:ApplyStyle() log("arena style applied") end,
  105.         ["status"] = function() log ("addon[".. (self.db.enable and "on]" or "off]").."  buff["..self.db.buffnum.."]".."  debuff["..self.db.debuffnum.."]".."  cc["..(self.db.enable and "on]" or "off]").."  max["..self.db.max.."]".."  position["..(self.db.left and "left" or "right").."]") end,
  106.         --["reset"] = function() self:ResetStyle() log("reset to default style") end,
  107.         --["reset"] = function() ArenaStyleDB = {}; log("reset ArenaStyle's database") end,
  108.         ["help"] = function() log("\n'/as debuff [number]' to set debuff number\n'/as buff [number]' to set buff number\n'/as cc' to display cc first\n'/as max [number]' to set the maximum number of party or raid members to auto apply arena style\n'/as [on/off]' to enable or disable the addon\n'/as left' to display debuffs on left or right") end,
  109.         -- \n'/as status' to see the status\n'/as reset' to reset database(works after reloading)
  110.     }
  111.     local cmd, arg = string.split(" ", msg, 2)
  112.     local entry = cmdtbl[cmd:lower()]
  113.     local which = type(entry)
  114.     if which == "function" then
  115.         entry(arg)
  116.     elseif which == "table" then
  117.         self:Command(arg or "" , entry)
  118.     else
  119.         self:Command("help")
  120.     end
  121. end
  122. --[[function CompactRaidFrameContainer_OnEvent(self, event, ...)
  123.     if ( event == "RAID_ROSTER_UPDATE" or event == "PARTY_MEMBERS_CHANGED" ) then
  124.         CompactRaidFrameContainer_UpdateDisplayedUnits(self);
  125.         CompactRaidFrameContainer_TryUpdate(self);
  126.     elseif ( event == "UNIT_PET" ) then
  127.         if ( self.displayPets ) then
  128.             local unit = ...;
  129.             if ( unit == "player" or strsub(unit, 1, 4) == "raid" or strsub(unit, 1, 5) == "party" ) then
  130.                 CompactRaidFrameContainer_TryUpdate(self);
  131.             end
  132.         end
  133.     end
  134. end]]
  135. -- When roster updated, auto apply arena style or reset style
  136. function ArenaStyle:OnRosterUpdate()
  137.     local _,areaType = IsInInstance()
  138.     if areaType == "raid" or areaType == "party" then ArenaStyle:ResetStyle() return end
  139.     if not ArenaStyle.db.enable then return end
  140.     if not CompactRaidFrameContainer:IsVisible() then return end
  141.     local n = GetNumGroupMembers()
  142.     if n <= ArenaStyle.db.max and n > 0 then ArenaStyle:ApplyStyle() else ArenaStyle:ResetStyle() end
  143. end
  144.  
  145. -- If in raid reset style
  146. function ArenaStyle:OnZoneChanged()
  147.     local _,areaType = IsInInstance()
  148.     self:ResetStyle()
  149.     if areaType ~= "raid" then self:ApplyStyle() end
  150. end
  151.  
  152. -- Apply arena style to the compact raid frame
  153. function ArenaStyle:ApplyStyle()
  154.     if CompactRaidFrameManager.container.groupMode == "flush" then
  155.         for i = 1,80 do
  156.             local f = _G["CompactRaidFrame"..i]
  157.             if f and not self.cache[f] and f.inUse and f.maxBuffs ~= 0 and #f.buffFrames == DEFAULT_BUFF and f.unit and not strfind(f.unit,"pet") and not strfind(f.unit,"target") then
  158.                 self:ApplyFrame(f)
  159.                 self:UpdateAura(f.unit)
  160.             end
  161.             if f and not f.inUse and self.cache[f] then
  162.                 self:ResetFrame(f)
  163.             end
  164.         end
  165.     elseif CompactRaidFrameManager.container.groupMode == "discrete" then
  166.         for i = 1,8 do
  167.             for j = 1,5 do
  168.                 local f = _G["CompactRaidGroup"..i.."Member"..j]
  169.                 if f and not self.cache[f] and f.maxBuffs ~= 0 and #f.buffFrames == DEFAULT_BUFF and f.unit and not strfind(f.unit,"pet") and not strfind(f.unit,"target") then
  170.                     self:ApplyFrame(f)
  171.                     self:UpdateAura(f.unit)
  172.                 end
  173.                 if f and not f.unit and self.cache[f] then
  174.                     self:ResetFrame(f)
  175.                 end
  176.             end
  177.         end
  178.     end
  179. end
  180.  
  181. -- data from LoseControl
  182. local spellIds = {
  183.     -- Death Knight
  184.     [108194] = "CC",        -- Asphyxiate
  185.     [115001] = "CC",        -- Remorseless Winter
  186.     [47476]  = "Silence",       -- Strangulate
  187.     [96294]  = "Root",      -- Chains of Ice (Chilblains)
  188.     --[45524]  = "Snare",       -- Chains of Ice
  189.     --[50435]  = "Snare",       -- Chilblains
  190.     --[43265]  = "Snare",       -- Death and Decay (Glyph of Death and Decay) - no way to distinguish between glyphed spell and normal. :(
  191.     --[115000] = "Snare",       -- Remorseless Winter
  192.     --[115018] = "Immune",      -- Desecrated Ground
  193.     --[48707]  = "ImmuneSpell", -- Anti-Magic Shell
  194.     --[48792]  = "Other",       -- Icebound Fortitude
  195.     --[49039]  = "Other",       -- Lichborne
  196.     --[51271] = "Other",        -- Pillar of Frost
  197.     -- Death Knight Ghoul
  198.     [91800]  = "CC",        -- Gnaw
  199.     [91797]  = "CC",        -- Monstrous Blow (Dark Transformation)
  200.     [91807]  = "Root",      -- Shambling Rush (Dark Transformation)
  201.     -- Druid
  202.     [113801] = "CC",        -- Bash (Force of Nature - Feral Treants)
  203.     --[102795] = "CC",      -- Bear Hug
  204.     [33786]  = "CC",        -- Cyclone
  205.     [99]     = "CC",        -- Disorienting Roar
  206.     --[2637]   = "CC",      -- Hibernate
  207.     [22570]  = "CC",        -- Maim
  208.     [5211]   = "CC",        -- Mighty Bash
  209.     --[9005]   = "CC",      -- Pounce
  210.     --[102546] = "CC",      -- Pounce (Incarnation)
  211.     [114238] = "Silence",       -- Fae Silence (Glyph of Fae Silence)
  212.     [81261]  = "Silence",       -- Solar Beam
  213.     [339]    = "Root",      -- Entangling Roots
  214.     [113770] = "Root",      -- Entangling Roots (Force of Nature - Balance Treants)
  215.     --[19975]  = "Root",        -- Entangling Roots (Nature's Grasp)
  216.     [45334]  = "Root",      -- Immobilized (Wild Charge - Bear)
  217.     [102359] = "Root",      -- Mass Entanglement
  218.     --[50259]  = "Snare",       -- Dazed (Wild Charge - Cat)
  219.     --[58180]  = "Snare",       -- Infected Wounds
  220.     --[61391]  = "Snare",       -- Typhoon
  221.     --[127797] = "Snare",       -- Ursol's Vortex
  222.     --[???] = "Snare",      -- Wild Mushroom: Detonate
  223.     -- Druid Symbiosis
  224.     --[110698] = "CC",      -- Hammer of Justice (Paladin)
  225.     --[113004] = "CC",      -- Intimidating Roar [Fleeing in fear] (Warrior)
  226.     --[113056] = "CC",      -- Intimidating Roar [Cowering in fear] (Warrior)
  227.     --[126458] = "Disarm",      -- Grapple Weapon (Monk)
  228.     --[110693] = "Root",        -- Frost Nova (Mage)
  229.     --[110610] = "Snare",       -- Ice Trap (Hunter)
  230.     --[110617] = "Immune",      -- Deterrence (Hunter)
  231.     --[110715] = "Immune",      -- Dispersion (Priest)
  232.     --[110700] = "Immune",      -- Divine Shield (Paladin)
  233.     --[110696] = "Immune",      -- Ice Block (Mage)
  234.     --[110570] = "ImmuneSpell", -- Anti-Magic Shell (Death Knight)
  235.     --[110788] = "ImmuneSpell", -- Cloak of Shadows (Rogue)
  236.     --[113002] = "ImmuneSpell", -- Spell Reflection (Warrior)
  237.     --[110791] = "Other",       -- Evasion (Rogue)
  238.     --[110575] = "Other",       -- Icebound Fortitude (Death Knight)
  239.     --[122291] = "Other",       -- Unending Resolve (Warlock)
  240.     -- Hunter
  241.     [117526] = "CC",        -- Binding Shot
  242.     [3355]   = "CC",        -- Freezing Trap
  243.     --[1513]   = "CC",      -- Scare Beast
  244.     --[19503]  = "CC",      -- Scatter Shot
  245.     [19386]  = "CC",        -- Wyvern Sting
  246.     --[34490]  = "Silence",     -- Silencing Shot
  247.     --[19185]  = "Root",        -- Entrapment
  248.     [64803]  = "Root",      -- Entrapment
  249.     [128405] = "Root",      -- Narrow Escape
  250.     --[35101]  = "Snare",       -- Concussive Barrage
  251.     --[5116]   = "Snare",       -- Concussive Shot
  252.     --[61394]  = "Snare",       -- Frozen Wake (Glyph of Freezing Trap)
  253.     --[13810]  = "Snare",       -- Ice Trap
  254.     --[19263]  = "Immune",      -- Deterrence
  255.     -- Hunter Pets
  256.     --[90337]  = "CC",      -- Bad Manner (Monkey)
  257.     [24394]  = "CC",        -- Intimidation
  258.     --[126246] = "CC",      -- Lullaby (Crane)
  259.     --[126355] = "CC",      -- Paralyzing Quill (Porcupine)
  260.     --[126423] = "CC",      -- Petrifying Gaze (Basilisk)
  261.     [50519]  = "CC",        -- Sonic Blast (Bat)
  262.     --[56626]  = "CC",      -- Sting (Wasp)
  263.     --[96201]  = "CC",      -- Web Wrap (Shale Spider)
  264.     --[50541]  = "Disarm",      -- Clench (Scorpid)
  265.     --[91644]  = "Disarm",      -- Snatch (Bird of Prey)
  266.     --[90327]  = "Root",        -- Lock Jaw (Dog)
  267.     --[50245]  = "Root",        -- Pin (Crab)
  268.     --[54706]  = "Root",        -- Venom Web Spray (Silithid)
  269.     --[4167]   = "Root",        -- Web (Spider)
  270.     --[50433]  = "Snare",       -- Ankle Crack (Crocolisk)
  271.     --[54644]  = "Snare",       -- Frost Breath (Chimaera)
  272.     --[54216]  = "Other",       -- Master's Call (root and snare immune only)
  273.     -- Mage
  274.     --[118271] = "CC",      -- Combustion Impact
  275.     [44572]  = "CC",        -- Deep Freeze
  276.     [31661]  = "CC",        -- Dragon's Breath
  277.     [118]    = "CC",        -- Polymorph
  278.     [61305]  = "CC",        -- Polymorph: Black Cat
  279.     [28272]  = "CC",        -- Polymorph: Pig
  280.     [61721]  = "CC",        -- Polymorph: Rabbit
  281.     [61780]  = "CC",        -- Polymorph: Turkey
  282.     [28271]  = "CC",        -- Polymorph: Turtle
  283.     [82691]  = "CC",        -- Ring of Frost
  284.     [102051] = "Silence",       -- Frostjaw (also a root)
  285.     --[55021]  = "Silence",     -- Silenced - Improved Counterspell
  286.     [122]    = "Root",      -- Frost Nova
  287.     [111340] = "Root",      -- Ice Ward
  288.     --[121288] = "Snare",       -- Chilled (Frost Armor)
  289.     --[120]    = "Snare",       -- Cone of Cold
  290.     --[116]    = "Snare",       -- Frostbolt
  291.     --[44614]  = "Snare",       -- Frostfire Bolt
  292.     --[113092] = "Snare",       -- Frost Bomb
  293.     --[31589]  = "Snare",       -- Slow
  294.     --[45438]  = "Immune",      -- Ice Block
  295.     --[115760] = "ImmuneSpell", -- Glyph of Ice Block
  296.     -- Mage Water Elemental
  297.     [33395]  = "Root",      -- Freeze
  298.     -- Monk
  299.     [123393] = "CC",        -- Breath of Fire (Glyph of Breath of Fire)
  300.     --[126451] = "CC",      -- Clash
  301.     --[122242] = "CC",      -- Clash (not sure which one is right)
  302.     [119392] = "CC",        -- Charging Ox Wave
  303.     [120086] = "CC",        -- Fists of Fury
  304.     [119381] = "CC",        -- Leg Sweep
  305.     [115078] = "CC",        -- Paralysis
  306.     --[117368] = "Disarm",      -- Grapple Weapon
  307.     [140023] = "Disarm",        -- Ring of Peace
  308.     --[137461] = "Disarm",      -- Disarmed (Ring of Peace)
  309.     [137460] = "Silence",       -- Silenced (Ring of Peace)
  310.     --[116709] = "Silence",     -- Spear Hand Strike
  311.     [116706] = "Root",      -- Disable
  312.     --[113275] = "Root",        -- Entangling Roots (Symbiosis)
  313.     --[123407] = "Root",        -- Spinning Fire Blossom
  314.     --[116095] = "Snare",       -- Disable
  315.     --[118585] = "Snare",       -- Leer of the Ox
  316.     --[123727] = "Snare",       -- Dizzying Haze
  317.     --[123586] = "Snare",       -- Flying Serpent Kick
  318.     --[131523] = "ImmuneSpell", -- Zen Meditation
  319.     -- Paladin
  320.     [105421] = "CC",        -- Blinding Light
  321.     --[115752] = "CC",      -- Blinding Light (Glyph of Blinding Light)
  322.     [105593] = "CC",        -- Fist of Justice
  323.     [853]    = "CC",        -- Hammer of Justice
  324.     [119072] = "CC",        -- Holy Wrath
  325.     [20066]  = "CC",        -- Repentance
  326.     [10326]  = "CC",        -- Turn Evil
  327.     [145067] = "CC",        -- Turn Evil (Evil is a Point of View)
  328.     [31935]  = "Silence",       -- Avenger's Shield
  329.     --[110300] = "Snare",       -- Burden of Guilt
  330.     --[63529]  = "Snare",       -- Dazed - Avenger's Shield
  331.     --[20170]  = "Snare",       -- Seal of Justice
  332.     --[642]    = "Immune",      -- Divine Shield
  333.     --[31821]  = "Other",       -- Aura Mastery
  334.     --[1022]   = "Other",       -- Hand of Protection
  335.     -- Priest
  336.     --[113506] = "CC",      -- Cyclone (Symbiosis)
  337.     [605]    = "CC",        -- Dominate Mind
  338.     [88625]  = "CC",        -- Holy Word: Chastise
  339.     [64044]  = "CC",        -- Psychic Horror
  340.     [8122]   = "CC",        -- Psychic Scream
  341.     --[113792] = "CC",      -- Psychic Terror (Psyfiend)
  342.     [9484]   = "CC",        -- Shackle Undead
  343.     [87204]  = "CC",        -- Sin and Punishment
  344.     [15487]  = "Silence",       -- Silence
  345.     --[64058]  = "Disarm",      -- Psychic Horror
  346.     --[113275] = "Root",        -- Entangling Roots (Symbiosis)
  347.     [87194]  = "Root",      -- Glyph of Mind Blast
  348.     [114404] = "Root",      -- Void Tendril's Grasp
  349.     --[15407]  = "Snare",       -- Mind Flay
  350.     --[47585]  = "Immune",      -- Dispersion
  351.     --[114239] = "ImmuneSpell", -- Phantasm
  352.     -- Rogue
  353.     [2094]   = "CC",        -- Blind
  354.     [1833]   = "CC",        -- Cheap Shot
  355.     [1776]   = "CC",        -- Gouge
  356.     [408]    = "CC",        -- Kidney Shot
  357.     --[113953] = "CC",      -- Paralysis (Paralytic Poison)
  358.     [6770]   = "CC",        -- Sap
  359.     [1330]   = "Silence",       -- Garrote - Silence
  360.     --[51722]  = "Disarm",      -- Dismantle
  361.     --[115197] = "Root",        -- Partial Paralysis
  362.     --[3409]   = "Snare",       -- Crippling Poison
  363.     --[26679]  = "Snare",       -- Deadly Throw
  364.     --[119696] = "Snare",       -- Debilitation
  365.     --[31224]  = "ImmuneSpell", -- Cloak of Shadows
  366.     --[45182]  = "Other",       -- Cheating Death
  367.     --[5277]   = "Other",       -- Evasion
  368.     --[76577]  = "Other",       -- Smoke Bomb
  369.     --[88611]  = "Other",       -- Smoke Bomb
  370.     -- Shaman
  371.     --[76780]  = "CC",      -- Bind Elemental
  372.     [77505]  = "CC",        -- Earthquake
  373.     [51514]  = "CC",        -- Hex
  374.     [118905] = "CC",        -- Static Charge (Capacitor Totem)
  375.     --[113287] = "Silence",     -- Solar Beam (Symbiosis)
  376.     [64695]  = "Root",      -- Earthgrab (Earthgrab Totem)
  377.     [63685]  = "Root",      -- Freeze (Frozen Power)
  378.     --[3600]   = "Snare",       -- Earthbind (Earthbind Totem)
  379.     --[77478]  = "Snare",       -- Earthquake (Glyph of Unstable Earth)
  380.     --[8034]   = "Snare",       -- Frostbrand Attack
  381.     --[8056]   = "Snare",       -- Frost Shock
  382.     --[51490]  = "Snare",       -- Thunderstorm
  383.     --[8178]   = "ImmuneSpell", -- Grounding Totem Effect (Grounding Totem)
  384.     -- Shaman Primal Earth Elemental
  385.     [118345] = "CC",        -- Pulverize
  386.     -- Warlock
  387.     [710]    = "CC",        -- Banish
  388.     [137143] = "CC",        -- Blood Horror
  389.     --[54786]  = "CC",      -- Demonic Leap (Metamorphosis)
  390.     [5782]   = "CC",        -- Fear
  391.     [118699] = "CC",        -- Fear
  392.     [130616] = "CC",        -- Fear (Glyph of Fear)
  393.     [5484]   = "CC",        -- Howl of Terror
  394.     [22703]  = "CC",        -- Infernal Awakening
  395.     [6789]   = "CC",        -- Mortal Coil
  396.     --[132412] = "CC",      -- Seduction (Grimoire of Sacrifice)
  397.     [30283]  = "CC",        -- Shadowfury
  398.     --[104045] = "CC",      -- Sleep (Metamorphosis)
  399.     [132409] = "Silence",       -- Spell Lock (Grimoire of Sacrifice)
  400.     [31117]  = "Silence",       -- Unstable Affliction
  401.     --[18223]  = "Snare",       -- Curse of Exhaustion
  402.     --[47960]  = "Snare",       -- Shadowflame
  403.     --[110913] = "Other",       -- Dark Bargain
  404.     --[104773] = "Other",       -- Unending Resolve
  405.     -- Warlock Pets
  406.     [89766]  = "CC",        -- Axe Toss (Felguard/Wrathguard)
  407.     [115268] = "CC",        -- Mesmerize (Shivarra)
  408.     [6358]   = "CC",        -- Seduction (Succubus)
  409.     --[115782] = "Silence",     -- Optical Blast (Observer)
  410.     --[24259]  = "Silence",     -- Spell Lock (Felhunter)
  411.     --[118093] = "Disarm",      -- Disarm (Voidwalker/Voidlord)
  412.     -- Warrior
  413.     [7922]   = "CC",        -- Charge Stun
  414.     [118895] = "CC",        -- Dragon Roar
  415.     [5246]   = "CC",        -- Intimidating Shout (aoe)
  416.     --[20511]  = "CC",      -- Intimidating Shout (targeted)
  417.     [132168] = "CC",        -- Shockwave
  418.     [107570] = "CC",        -- Storm Bolt
  419.     [132169] = "CC",        -- Storm Bolt
  420.     [105771] = "Root",      -- Warbringer
  421.     [18498]  = "Silence",       -- Silenced - Gag Order (PvE only)
  422.     --[676]    = "Disarm",      -- Disarm
  423.     [107566] = "Root",      -- Staggering Shout
  424.     --[1715]   = "Snare",       -- Hamstring
  425.     --[12323]  = "Snare",       -- Piercing Howl
  426.     --[129923] = "Snare",       -- Sluggish (Glyph of Hindering Strikes)
  427.     --[137637] = "Snare",       -- Warbringer
  428.     --[46924]  = "Immune",      -- Bladestorm
  429.     --[23920]  = "ImmuneSpell", -- Spell Reflection
  430.     --[114028] = "ImmuneSpell", -- Mass Spell Reflection
  431.     --[18499]  = "Other",       -- Berserker Rage
  432.     -- Other
  433.     [30217]  = "CC",        -- Adamantite Grenade
  434.     [67769]  = "CC",        -- Cobalt Frag Bomb
  435.     [30216]  = "CC",        -- Fel Iron Bomb
  436.     [107079] = "CC",        -- Quaking Palm
  437.     [13327]  = "CC",        -- Reckless Charge
  438.     [20549]  = "CC",        -- War Stomp
  439.     [25046]  = "Silence",       -- Arcane Torrent (Energy)
  440.     [28730]  = "Silence",       -- Arcane Torrent (Mana)
  441.     [50613]  = "Silence",       -- Arcane Torrent (Runic Power)
  442.     [69179]  = "Silence",       -- Arcane Torrent (Rage)
  443.     [80483]  = "Silence",       -- Arcane Torrent (Focus)
  444.     [129597] = "Silence",       -- Arcane Torrent (Chi)
  445.     [39965]  = "Root",      -- Frost Grenade
  446.     [55536]  = "Root",      -- Frostweave Net
  447.     [13099]  = "Root",      -- Net-o-Matic
  448.     --[1604]   = "Snare",       -- Dazed
  449.     -- PvE
  450.     --[123456] = "PvE",     -- This is just an example, not a real spell
  451. }
  452.  
  453. for k, v in pairs(spellIds) do
  454.     local name = GetSpellInfo(k)
  455.     if not name then
  456.         log(" unknown spellId: " .. k)
  457.         spellIds[k] = nil
  458.     end
  459. end
  460.  
  461. local function isPriorityDebuff(unit, index, filter)
  462.     local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId, canApplyAura, isBossDebuff = UnitDebuff(unit, index, filter);
  463.     if ( spellIds[spellId] or spellId == 30108 or spellId == 34914 or isBossDebuff) then  
  464.         return true
  465.     else
  466.         return false
  467.     end
  468. end
  469. -- Update aura for each unit
  470. function ArenaStyle:UpdateAura(uid)
  471.     for f,v in pairs(self.cache) do
  472.         if f.unit == uid then
  473.             local filter = nil
  474.             local buffNum = 1
  475.             local index = 1
  476.             while buffNum <= self.db.buffnum do
  477.                 local buffName = UnitBuff(uid, index, filter);
  478.                 if ( buffName ) then
  479.                     if ( CompactUnitFrame_UtilShouldDisplayBuff(uid, index, filter) ) then
  480.                         if buffNum > DEFAULT_BUFF then
  481.                             local buffFrame = v.buffFrames[buffNum]
  482.                             CompactUnitFrame_UtilSetBuff(buffFrame, uid, index, filter)
  483.                         end
  484.                         buffNum = buffNum + 1
  485.                     end
  486.                 else
  487.                     break
  488.                 end
  489.                 index = index + 1
  490.             end
  491.             for i=buffNum, self.db.buffnum do
  492.                 local buffFrame = v.buffFrames[i]
  493.                 if buffFrame then
  494.                     buffFrame:Hide()
  495.                 end
  496.             end
  497.             local debuffNum = 1
  498.             index = 1
  499.             if ( f.optionTable.displayOnlyDispellableDebuffs ) then
  500.                 filter = "RAID"
  501.             end
  502.             if self.db.cc then
  503.                 while debuffNum <= self.db.debuffnum do
  504.                     local debuffName = UnitDebuff(uid, index, nil)
  505.                     if ( debuffName ) then
  506.                         if ( CompactUnitFrame_UtilShouldDisplayDebuff(uid, index, nil) and isPriorityDebuff(uid, index, nil)) then
  507.                             local debuffFrame = v.debuffFrames[debuffNum]
  508.                             CompactUnitFrame_UtilSetDebuff(debuffFrame, uid, index, nil)
  509.                             debuffFrame:SetSize(f.buffFrames[3]:GetSize()*1.5,f.buffFrames[3]:GetSize()*1.5)
  510.                             debuffNum = debuffNum + 1
  511.                         end
  512.                     else
  513.                         break
  514.                     end
  515.                     index = index + 1
  516.                 end
  517.                 index = 1
  518.                 while debuffNum <= self.db.debuffnum do
  519.                     local debuffName = UnitDebuff(uid, index, filter)
  520.                     if ( debuffName ) then
  521.                         if ( CompactUnitFrame_UtilShouldDisplayDebuff(uid, index, filter) and not isPriorityDebuff(uid, index, filter)) then
  522.                             local debuffFrame = v.debuffFrames[debuffNum]
  523.                             CompactUnitFrame_UtilSetDebuff(debuffFrame, uid, index, filter)
  524.                             debuffFrame:SetSize(f.buffFrames[3]:GetSize())
  525.                             debuffNum = debuffNum + 1
  526.                         end
  527.                     else
  528.                         break
  529.                     end
  530.                     index = index + 1
  531.                 end
  532.             else
  533.                 while debuffNum <= self.db.debuffnum do
  534.                     local debuffName = UnitDebuff(uid, index, filter)
  535.                     if ( debuffName ) then
  536.                         if ( CompactUnitFrame_UtilShouldDisplayDebuff(uid, index, filter) ) then
  537.                             local debuffFrame = v.debuffFrames[debuffNum]
  538.                             CompactUnitFrame_UtilSetDebuff(debuffFrame, uid, index, filter)
  539.                             debuffFrame:SetSize(f.buffFrames[3]:GetSize())
  540.                             debuffNum = debuffNum + 1
  541.                         end
  542.                     else
  543.                         break
  544.                     end
  545.                     index = index + 1
  546.                 end
  547.             end
  548.             for i=debuffNum, self.db.debuffnum do
  549.                 local debuffFrame = v.debuffFrames[i];
  550.                 if debuffFrame then
  551.                     debuffFrame:Hide()
  552.                 end
  553.             end
  554.             break
  555.         end
  556.     end
  557. end
  558. -- Apply style for each frame
  559. function ArenaStyle:ApplyFrame(f)
  560.     self.cache[f] = {}
  561.     local scf = self.cache[f]
  562.     f:SetScript("OnSizeChanged",function() ArenaStyle:ResetFrame(f) ArenaStyle:ApplyFrame(f) end)
  563.     if not scf.buffFrames then scf.buffFrames = {} end
  564.     if not scf.debuffFrames then scf.debuffFrames = {} end
  565.     for j = DEFAULT_BUFF + 1, self.db.buffnum do
  566.         if not scf.buffFrames[j] then
  567.             scf.buffFrames[j] = CreateFrame("Button",nil,UIParent,"ArenaStyleBuffTemplate")
  568.             scf.buffFrames[j].unit = f.buffFrames[3]:GetSize()
  569.             --scf.buffFrames[j]:EnableMouse(false)
  570.             if j == DEFAULT_BUFF + 1 then
  571.                 scf.buffFrames[j]:SetPoint("RIGHT",f.buffFrames[3],"LEFT")
  572.             else
  573.                 scf.buffFrames[j]:SetPoint("RIGHT",scf.buffFrames[j-1],"LEFT")
  574.             end
  575.             scf.buffFrames[j]:SetSize(f.buffFrames[3]:GetSize())
  576.         end
  577.     end
  578.     for j = 1,self.db.debuffnum do
  579.         if not scf.debuffFrames[j] then
  580.             scf.debuffFrames[j] = CreateFrame("Button",nil,UIParent,"ArenaStyleDebuffTemplate")
  581.             scf.debuffFrames[j].unit = f.unit
  582.             scf.debuffFrames[j].baseSize = f.buffFrames[3]:GetSize()
  583.             --scf.debuffFrames[j]:EnableMouse(false)
  584.             if j == 1 then
  585.                 scf.debuffFrames[j]:ClearAllPoints()
  586.                 if self.db.left then
  587.                     scf.debuffFrames[j]:SetPoint("BOTTOMRIGHT", f, "BOTTOMLEFT",-1,10)
  588.                 else
  589.                     scf.debuffFrames[j]:SetPoint("BOTTOMLEFT", f, "BOTTOMRIGHT",1,10)
  590.                 end
  591.             else
  592.                 if self.db.left then
  593.                     scf.debuffFrames[j]:SetPoint("BOTTOMRIGHT",scf.debuffFrames[j-1],"BOTTOMLEFT")
  594.                 else
  595.                     scf.debuffFrames[j]:SetPoint("BOTTOMLEFT",scf.debuffFrames[j-1],"BOTTOMRIGHT")
  596.                 end
  597.                
  598.             end
  599.             --f.debuffFrames[j]:SetSize(f.buffFrames[3]:GetSize())
  600.             scf.debuffFrames[j]:SetSize(f.buffFrames[3]:GetSize())
  601.             scf.debuffFrames[j]:Hide()
  602.         end
  603.     end
  604.     for j = 1,#f.debuffFrames do
  605.         f.debuffFrames[j]:Hide()
  606.         f.debuffFrames[j]:SetScript("OnShow",f.debuffFrames[j].Hide)
  607.     end
  608. end
  609. -- Reset to the original style
  610. function ArenaStyle:ResetStyle()
  611.     for f,_ in pairs(ArenaStyle.cache) do
  612.         ArenaStyle:ResetFrame(f)
  613.     end
  614. end
  615. -- Reset style to each cached frame
  616. function ArenaStyle:ResetFrame(f)
  617.     for k,v in pairs(self.cache[f].buffFrames) do
  618.         if v then
  619.             v:Hide()
  620.         end
  621.     end
  622.     for k,v in pairs(self.cache[f].debuffFrames) do
  623.         if v then
  624.             v:Hide()
  625.         end
  626.     end
  627.     f:SetScript("OnSizeChanged",nil)
  628.     for j = 1,#f.debuffFrames do
  629.         f.debuffFrames[j]:SetScript("OnShow",nil)
  630.     end
  631.     self.cache[f] = nil
  632. end
  633. function ArenaStyle:OnCombat()
  634.     -- todo
  635. end
  636. function ArenaStyle:LeaveCombat()
  637.     -- todo
  638. end
  639.  
  640. -- Event handling
  641. local function OnEvent(self,event,...)
  642.     if event == "VARIABLES_LOADED" then self:OnLoad()
  643.     elseif event == "GROUP_ROSTER_UPDATE" or event == "UNIT_PET" then self:OnRosterUpdate()
  644.     elseif event == "PLAYER_ENTERING_WORLD" then self:OnRosterUpdate()
  645.     elseif event == "PLAYER_REGEN_DISABLED" then self:OnCombat()
  646.     elseif event == "PLAYER_REGEN_ENABLED" then self:LeaveCombat()
  647.     elseif event == "UNIT_AURA" then self:UpdateAura(...) end
  648. end
  649.  
  650. ArenaStyle:SetScript("OnEvent",OnEvent)
  651. ArenaStyle:RegisterEvent("VARIABLES_LOADED")
  652. _G.ArenaStyle = ArenaStyle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement