Quantcast
WoWInterface - View Single Post - Need help with spell activation overlay
View Single Post
12-09-20, 06:46 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Lua Code:
  1. local SPELL_ID = 24275  -- Hammer of Wrath
  2. local SPELL_NAME = GetSpellInfo(SPELL_ID)
  3. local UPDATE_INTERVAL = 0.1
  4.  
  5. local frame = CreateFrame("Frame", nil, UIParent)
  6. frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  7. frame:SetSize(64, 64)
  8. frame:Hide()
  9.  
  10. local texture = frame:CreateTexture()
  11. texture:SetAllPoints(frame)
  12. texture:SetTexture(GetSpellTexture(SPELL_ID))
  13.  
  14. frame:SetScript("OnEvent", function(self, event, spellID)
  15.     if event == "SPELL_ACTIVATION_OVERLAY_GLOW_SHOW" then
  16.         if spellID == SPELL_ID then
  17.             frame:Show()
  18.         end
  19.     elseif event == "SPELL_ACTIVATION_OVERLAY_GLOW_HIDE" then
  20.         if spellID == SPELL_ID then
  21.             frame:Hide()
  22.         end
  23.     end
  24. end)
  25. frame:RegisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_SHOW")
  26. frame:RegisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_HIDE")
  27.  
  28. local timer = UPDATE_INTERVAL
  29. frame:SetScript("OnUpdate", function(self, elapsed)
  30.     timer = timer + elapsed
  31.     if timer < UPDATE_INTERVAL then return end
  32.     timer = 0
  33.  
  34.     if IsSpellInRange(SPELL_NAME, "target") == 1 then
  35.         frame:SetAlpha(1)
  36.     else
  37.         frame:SetAlpha(0.5)
  38.     end
  39. end)
  40.  
  41. frame:SetScript("OnHide", function(self)
  42.     timer = UPDATE_INTERVAL
  43. end)
  Reply With Quote