Want more features on Pastebin? Sign Up, it's FREE!
Guest

Arena Frames

By: berlin on Sep 29th, 2011  |  syntax: Lua  |  size: 2.97 KB  |  views: 1,394  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- Updated for MoP
  2.  
  3. local trinkets = {}
  4. local events = CreateFrame("Frame")
  5.  
  6. function events:ADDON_LOADED(addonName)
  7.     if addonName ~= "Blizzard_ArenaUI" then return end
  8.     -- ArenaEnemyFrames:SetScale(1.3)
  9.     -- ArenaPrepFrames:SetScale(1.3)
  10.     ArenaEnemyFrame1:ClearAllPoints()
  11.     ArenaPrepFrame1:ClearAllPoints()
  12.     local arenaFrame, trinket
  13.     for i = 1, MAX_ARENA_ENEMIES do
  14.         arenaFrame = "ArenaEnemyFrame"..i
  15.         -- _G[arenaFrame]:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -187, -200)
  16.         -- _G["ArenaPrepFrame"..i]:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -187, -200)
  17.         trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", ArenaEnemyFrames)
  18.         trinket:SetPoint("TOPRIGHT", arenaFrame, 32, -6)
  19.         trinket:SetSize(24, 24)
  20.         trinket.icon = trinket:CreateTexture(nil, "BACKGROUND")
  21.         trinket.icon:SetAllPoints()
  22.         trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01")
  23.         trinket:Hide()
  24.         trinket.lastUsed = nil
  25.         trinkets["arena"..i] = trinket
  26.     end
  27.     self:UnregisterEvent("ADDON_LOADED")
  28. end
  29.  
  30. function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  31.     if not trinkets[unitID] then return end
  32.     if spellID == 59752 or spellID == 42292 then
  33.         CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 120, 1)
  34.         trinkets[unitID].lastUsed = GetTime()
  35.         SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY")
  36.     elseif spellID == 7744 then
  37.         if not trinkets[unitID]:IsShown() or (GetTime() - trinkets[unitID].lastUsed) > 90 then
  38.             CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 30, 1)
  39.         end
  40.         SendChatMessage("WotF used by: "..GetUnitName(unitID, true), "PARTY")
  41.     end
  42. end
  43.  
  44. function events:PLAYER_ENTERING_WORLD()
  45.     local _, instanceType = IsInInstance()
  46.     if instanceType == "arena" then
  47.         self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  48.     elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  49.         for _, trinket in pairs(trinkets) do
  50.             trinket:Hide()
  51.         end
  52.         self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  53.     end
  54. end
  55.  
  56. SLASH_TESTAEF1 = "/testaef"
  57. SlashCmdList["TESTAEF"] = function(msg, editBox)
  58.     if not IsAddOnLoaded("Blizzard_ArenaUI") then
  59.         LoadAddOn("Blizzard_ArenaUI")
  60.     end
  61.     ArenaEnemyFrames:Show()
  62.     local arenaFrame
  63.     for i = 1, MAX_ARENA_ENEMIES do
  64.         arenaFrame = _G["ArenaEnemyFrame"..i]
  65.         arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  66.         arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  67.         arenaFrame.name:SetText("Dispelme")
  68.         arenaFrame:Show()
  69.         CooldownFrame_SetTimer(trinkets["arena"..i], GetTime(), 120, 1)
  70.     end
  71. end
  72.  
  73. events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  74. events:RegisterEvent("ADDON_LOADED")
  75. events:RegisterEvent("PLAYER_ENTERING_WORLD")
clone this paste RAW Paste Data