Jump to content

[LE] OnSpellCast not firing


javaplaza

Recommended Posts

actor property targetNPC auto
quest property myQuest auto
int property myStage auto

spell property SPELL001 auto
spell property SPELL002 auto
spell property SPELL003 auto

Event OnSpellCast(Form akSpell)
  Spell spellCast = akSpell as Spell
  
  if spellCast && spellCast == SPELL001
        debug.messagebox("Success!")
	myQuest.setStage(myStage) 
	Utility.Wait(0.2)
	targetNPC.ForceActorValue("Aggression", 0)
	targetNPC.StopCombat()
  endIf

  if spellCast && spellCast == SPELL002
        debug.messagebox("Success!")
	myQuest.setStage(myStage) 
	Utility.Wait(0.2)
	targetNPC.ForceActorValue("Aggression", 0)
	targetNPC.StopCombat()
  endIf
  
  if spellCast && spellCast == SPELL003
        debug.messagebox("Success!")
	myQuest.setStage(myStage) 
	Utility.Wait(0.2)
	targetNPC.ForceActorValue("Aggression", 0)
	targetNPC.StopCombat()
   
     
  endIf  

endEvent

Ive got a quest that requires the player to perform a higher level spell to advance to the next quest stage. Similar to gaining entry to the college of winterhold, but from a list of master level spells only.

 

Here is the script,

attached to the Alias (which is at the top of the alias list)

Specific Reference : 'PlayerRef'

 

But its not firing. Ive tried 2 of the spells from the list.

(Icy Spear, and Unrelenting Force)

 

Any help would be really amazing. I'm not sure where I've gone wrong - thanks.

Edited by javaplaza
Link to comment
Share on other sites

yes all the properties are filled correctly.

 

 

  Reveal hidden contents

 

Link to comment
Share on other sites

i have!

 

 

the quest functions, ive been working it for a few months now. So yes, its started. When I shout / use one of those spells, I don't get a message box and i also check the stage in console before quitting the game when testing.

Edited by javaplaza
Link to comment
Share on other sites

  On 9/24/2019 at 3:23 PM, javaplaza said:

are you saying the script looks fine? :huh:

 

Yes, the code looks like it should execute. Albeit it's wordy; I'd stick the spells in a FormList, use HasForm on that FormList, and then have just one if statement. Alternatively, if you want the explicit list in the properties instead (I don't think it's good practice, but whatever), I'd bundle the repeated

 

 

debug.messagebox("Success!")
    myQuest.setStage(myStage)
    Utility.Wait(0.2)
    targetNPC.ForceActorValue("Aggression", 0)
    targetNPC.StopCombat()

 

Into a function, and then call that from the if blocks. Means you can change the behaviour of all of them at once by editing the code in just one place, which improves debugging reliability and code comprehension.

 

 

Have you tried putting in a debug notification call before the if blocks in OnSpellCast()? Something like Debug.Notification("Casting spell..."), just to see if the event fires at all?

Link to comment
Share on other sites

  Quote

 

Yes, the code looks like it should execute. Albeit it's wordy; I'd stick the spells in a FormList, use HasForm on that FormList, and then have just one if statement. Alternatively, if you want the explicit list in the properties instead (I don't think it's good practice, but whatever), I'd bundle the repeated

 

i dont know what that would look like, but i sure would love to try it out!

 

  Quote

 

 

Have you tried putting in a debug notification call before the if blocks in OnSpellCast()? Something like Debug.Notification("Casting spell..."), just to see if the event fires at all?

 

i have not - and thats a great idea. I'll test it as soon as I'm home in a few minutes.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...