Thread Tools Display Modes
04-10-10, 09:11 AM   #1
obd
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 3
(API) Event that triggers BEFORE spell cast?

Hi.

The title kind of says it all. I need a way to run script before spellcast, before UNIT_SPELLCAST_SENT, but can't find an event to trigger it. Is there one, am I just blind (I did search wowwiki)? If not, is there a workaround besides changing all the spells to macros with /script at the start?
  Reply With Quote
04-10-10, 09:23 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
I don't think there is. "UNIT_SPELLCAST_START" is the earliest you can check and that I believe doesn't always trigger and instead using "UNIT_SPELLCAST_SUCCEEDED" when it doesn't trigger. But in both cases the cast has started.

Unfortunately the computer cannot know when someone is about to cast until they have started to cast.

What exactly do you want your script to do ?
__________________
  Reply With Quote
04-10-10, 09:43 AM   #3
obd
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 3
Nvm, it's just a litlle something for myself. I'll just take the macro-workaround then, since it's not gonna have to be polished for publishing. Thanks tho
  Reply With Quote
04-10-10, 10:06 AM   #4
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Try this:
Code:
hooksecurefunc("CastSpellByName", function(...)
    -- bla bla bla
end)
And make sure to do the same for all other "CastByXXX" functions.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
04-10-10, 12:49 PM   #5
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
Originally Posted by obd View Post
Hi.

The title kind of says it all. I need a way to run script before spellcast, before UNIT_SPELLCAST_SENT, but can't find an event to trigger it. Is there one, am I just blind (I did search wowwiki)? If not, is there a workaround besides changing all the spells to macros with /script at the start?
What are you trying to do? You can't easily tell when a spell is being cast, before it is.


Originally Posted by nightcracker View Post
Try this:
Code:
hooksecurefunc("CastSpellByName", function(...)
    -- bla bla bla
end)
And make sure to do the same for all other "CastByXXX" functions.
Pulling my notes from LHC4, this isn't true, because hooksecurefunc are called after the original function is, you end up with this (with auto self cast on): CastSpellByName -> UNIT_SPELLCAST_SENT -> secure hooks.
  Reply With Quote
04-10-10, 04:27 PM   #6
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
I know secure hooks are after the function, so I was HOPING that this would be the case:

CastSpellByName -> secure hooks -> UNIT_SPELLCAST_SENT


At least I gave it a shot :P
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » (API) Event that triggers BEFORE spell cast?

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