Hi I'm a newbie addon developer and I'm running into some trouble understanding the SPELL_CAST_SUCCESS event. I wrote a short block of code that is supposed to detect when a specific spell is casted and then trigger a cooldown frame I set up. However, the event only triggers when the spell casted is an instant cast spell such as Corruption or Drain Soul. When I successfully cast a casted spell like Haunt or Shadow Bolt, the event doesn't trigger.
Can someone help me understand why SPELL_CAST_SUCCESS doesn't work for casted spells and what event I should be using instead?
Here is my code for reference:
Code:
function DispelBar_OnEvent(event,...)
local timeStamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = select(1,...)
if(event=="SPELL_CAST_SUCCESS") then
local spellName = select(13,...)
print("SPELL_CAST_SUCCESS"..": "..spellName)
if(spellName == "Haunt") then
CooldownFrame:SetCooldown(GetTime(), 10)
end
end
end
In this example if I changed
Code:
if(spellName == "Haunt")
to an instant cast spell like
Code:
if(spellName == "Corruption")
then it works.
Thanks for all help in advance and let me know if I need to clarify anything.