WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   (API) Event that triggers BEFORE spell cast? (https://www.wowinterface.com/forums/showthread.php?t=31790)

obd 04-10-10 09:11 AM

(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?

Xrystal 04-10-10 09:23 AM

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 ?

obd 04-10-10 09:43 AM

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 :)

nightcracker 04-10-10 10:06 AM

Try this:
Code:

hooksecurefunc("CastSpellByName", function(...)
    -- bla bla bla
end)

And make sure to do the same for all other "CastByXXX" functions.

Shadowed 04-10-10 12:49 PM

Quote:

Originally Posted by obd (Post 184484)
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.


Quote:

Originally Posted by nightcracker (Post 184492)
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.

nightcracker 04-10-10 04:27 PM

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


All times are GMT -6. The time now is 07:54 AM.

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