This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Arena Frames

By: berlin on Sep 29th, 2011 (edited)  |  syntax: Lua  |  size: 3.38 KB  |  views: 1,558  |  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 WoD
  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.  
  18.         trinket = CreateFrame("Frame", arenaFrame.."Trinket", ArenaEnemyFrames)
  19.         trinket:SetSize(24, 24)
  20.         trinket:SetPoint("TOPRIGHT", arenaFrame, 32, -6)
  21.  
  22.         trinket.icon = trinket:CreateTexture(nil, "BORDER")
  23.         trinket.icon:SetAllPoints()
  24.         trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01")
  25.  
  26.         trinket.cooldown = CreateFrame("Cooldown", nil, trinket, "CooldownFrameTemplate")
  27.         trinket.cooldown:SetAllPoints(trinket.icon)
  28.         trinket.cooldown:SetScript("OnHide", hideTrinket)
  29.  
  30.         trinket.lastUsed = nil
  31.         trinket:Hide()
  32.         trinkets["arena"..i] = trinket
  33.     end
  34.     self:UnregisterEvent("ADDON_LOADED")
  35. end
  36.  
  37. function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  38.     if not trinkets[unitID] then return end
  39.     if spellID == 59752 or spellID == 42292 then
  40.         trinkets[unitID]:Show()
  41.         CooldownFrame_SetTimer(trinkets[unitID].cooldown, GetTime(), 120, 1)
  42.         trinkets[unitID].lastUsed = GetTime()
  43.         SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY")
  44.     elseif spellID == 7744 then
  45.         if not trinkets[unitID]:IsShown() or (GetTime() - trinkets[unitID].lastUsed) > 90 then
  46.             trinkets[unitID]:Show()
  47.             CooldownFrame_SetTimer(trinkets[unitID].cooldown, GetTime(), 30, 1)
  48.         end
  49.         SendChatMessage("WotF used by: "..GetUnitName(unitID, true), "PARTY")
  50.     end
  51. end
  52.  
  53. function events:PLAYER_ENTERING_WORLD()
  54.     local _, instanceType = IsInInstance()
  55.     if instanceType == "arena" then
  56.         for _, trinket in pairs(trinkets) do
  57.             trinket:Hide()
  58.         end
  59.         self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  60.     elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  61.         for _, trinket in pairs(trinkets) do
  62.             trinket:Hide()
  63.         end
  64.         self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  65.     end
  66. end
  67.  
  68. SLASH_TESTAEF1 = "/testaef"
  69. SlashCmdList["TESTAEF"] = function(msg, editBox)
  70.     if not IsAddOnLoaded("Blizzard_ArenaUI") then
  71.         LoadAddOn("Blizzard_ArenaUI")
  72.     end
  73.     ArenaEnemyFrames:Show()
  74.     local arenaFrame
  75.     for i = 1, MAX_ARENA_ENEMIES do
  76.         arenaFrame = _G["ArenaEnemyFrame"..i]
  77.         arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  78.         arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARRIOR"]))
  79.         arenaFrame.name:SetText("Dispelme")
  80.         arenaFrame:Show()
  81.         trinkets["arena"..i]:Show()
  82.         CooldownFrame_SetTimer(trinkets["arena"..i], GetTime(), 120, 1)
  83.     end
  84. end
  85.  
  86. events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  87. events:RegisterEvent("ADDON_LOADED")
  88. events:RegisterEvent("PLAYER_ENTERING_WORLD")
clone this paste RAW Paste Data