Thread Tools Display Modes
10-25-12, 01:38 PM   #1
indoviet
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 8
Event question: SPELL_CAST_SUCCESS

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.
  Reply With Quote
10-25-12, 02:27 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,315
I ran into something like this before and I forgot how I handled it. I'll have to take a look at combat log events again and see what comes up. You should be able to run the /etrace command and it'll show you a log of every event firing when they happen.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 10-25-12 at 02:29 PM.
  Reply With Quote
10-25-12, 02:36 PM   #3
indoviet
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 8
Thanks a lot for the etrace command I didn't know it existed. Very useful! With it I found that UNIT_SPELLCAST_SUCCEEDED can be used instead.

Thanks again

Followup question: Why wouldnt' SPELL_CAST_SUCCESS work? The descriptions of it in all the documentation I've read never seem to mention any exceptions.

Last edited by indoviet : 10-25-12 at 02:41 PM.
  Reply With Quote
10-30-12, 11:53 PM   #4
Trololol
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 13
To avoid any client/locale issues, it's probably best to use spell ID instead of spell name in if statments
  Reply With Quote
10-31-12, 07:38 AM   #5
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by indoviet View Post
Thanks a lot for the etrace command I didn't know it existed. Very useful! With it I found that UNIT_SPELLCAST_SUCCEEDED can be used instead.

Thanks again

Followup question: Why wouldnt' SPELL_CAST_SUCCESS work? The descriptions of it in all the documentation I've read never seem to mention any exceptions.
Because you are using the combat log events, which do not necessarily fire in the order you expect. If I were to guess, I would say you are getting _SUCCESS before the _CAST event is finished. CLEU is a last resort event; you should always check specific events whenever possible, if they exist. 98% of what happens in the game can be mapped to events that are not COMBAT_LOG_EVENT_UNFILTERED.

Why does CLEU fire in strange order? There is no solid answer, but latency, user/client CPU/RAM, ISP quality, and many other factors have their impact. The SPELLCAST events fire only on the client, and have no client-Blizzard-client loop, which is why they always work.

But that's my best guess.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Event question: SPELL_CAST_SUCCESS

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off