WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Event question: SPELL_CAST_SUCCESS (https://www.wowinterface.com/forums/showthread.php?t=44949)

indoviet 10-25-12 01:38 PM

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.

SDPhantom 10-25-12 02:27 PM

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.

indoviet 10-25-12 02:36 PM

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.

Trololol 10-30-12 11:53 PM

To avoid any client/locale issues, it's probably best to use spell ID instead of spell name in if statments

myrroddin 10-31-12 07:38 AM

Quote:

Originally Posted by indoviet (Post 267710)
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.


All times are GMT -6. The time now is 01:36 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI