Wolfpack49 Posted March 16, 2021 Share Posted March 16, 2021 Hi there, So I need to be able to do something when I detect that a spell has been cast (could be any spell, it doesn't matter), and I have been looking at the OnSpellCast Event in the CK documentation:https://www.creationkit.com/index.php?title=OnSpellCast_-_ObjectReference I'm following the example pretty closely -- it seems like it's just returning a true/false, but doesn't seem to be registering in game. Is there a step that's missing -- should I be doing a bool Event? Event OnSpellCast(Form akSpell) Spell spellCast = akSpell as Spell if spellCast_debug("Spell was cast") endifEndEvent Link to comment Share on other sites More sharing options...
AnishaDawn Posted March 16, 2021 Share Posted March 16, 2021 (edited) Is that _ a typo in the post or the script? It should catch any casts, though I like to listen to specific ones. If the form cast isn't a spell, it will return none. Spell property thisSpell auto Event OnSpellCast(Form akSpell) Spell spellCast = akSpell as Spell if spellCast == thisSpell ; do fun stuff endif EndEvent Edited March 16, 2021 by AnishaDawn Link to comment Share on other sites More sharing options...
Wolfpack49 Posted March 16, 2021 Author Share Posted March 16, 2021 Thanks for replying -- that's just a shorthand way for debugging in the script -- it's handled via a debug mode function.... Doh! I foolishly forgot to add the Spell property up top, but even once added still doesn't seem to be calling the notification. I should have specified that I am trying to detect any spell cast by the player, not any spell in general.... I am guessing that may change some things. This particular script is set up as: Scriptname ModName Main extends QuestThere's a handler for events in another file using the below, and I notice all "ak" references (akBaseItem, akItemReference) are changed to simple references (item, ref) Scriptname ModNamePlayerAlias extends ReferenceAlias Conditional ModNameMain Property main Auto Event OnItemAdded(Form item, int count, ObjectReference ref, ObjectReference src) main.handle_added_item(item, count, ref, src) EndEventCould it be I need to use another name for akSpell instead? Link to comment Share on other sites More sharing options...
AnishaDawn Posted March 17, 2021 Share Posted March 17, 2021 (edited) The compiler doesn't care about the names of the arguments, it just cares that the order and name of the types aren't changed.I've just gone in the game and tested this to see if I could reproduce your situation. All of these worked as expected: Event OnSpellCast(Form akSpell) if akSpell debug.notification("Spell cast.") endif EndEvent ;=== test 2==== Event OnSpellCast(Form akSpell) if (akSpell as Spell) debug.notification("Spell cast.") endif EndEvent ;=== test 3==== Event OnSpellCast(Form akSpell) if (akSpell as Spell) != none debug.notification("Spell cast.") endif EndEvent Edited March 17, 2021 by AnishaDawn Link to comment Share on other sites More sharing options...
Wolfpack49 Posted March 17, 2021 Author Share Posted March 17, 2021 Thanks Anisha,There must be something else that's not set up correctly. I'll keep testing - thanks for pointers. Link to comment Share on other sites More sharing options...
AnishaDawn Posted March 18, 2021 Share Posted March 18, 2021 Are you using it on a player alias? That's the only way I know of that will listen for player casts. Link to comment Share on other sites More sharing options...
Wolfpack49 Posted March 18, 2021 Author Share Posted March 18, 2021 Yeah, the playeralias script is where all the other Event calls are housed, and they pass on to a handler function in the main Quest script -- that's probably where the rub is. I'll keep playing and see if I can just get the dang debug notification to show. Thanks Anisha! :) Link to comment Share on other sites More sharing options...
dylbill Posted March 18, 2021 Share Posted March 18, 2021 Another thing to try, if you can't get OnSpellCast to work, is to use animation events: https://www.creationkit.com/index.php?title=Animation_Eventshttps://www.creationkit.com/index.php?title=OnAnimationEvent_-_Form Link to comment Share on other sites More sharing options...
Recommended Posts