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.

 

 

Scriptname DFLTOSpellChecker extends ReferenceAlias

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

spell property SPELL001 auto
spell property SPELL002 auto
spell property SPELL003 auto
spell property SPELL004 auto
spell property SPELL005 auto
spell property SPELL006 auto
spell property SPELL007 auto
spell property SPELL008 auto
spell property SPELL009 auto
spell property SPELL010 auto
spell property SPELL011 auto
spell property SPELL012 auto
spell property SPELL013 auto
spell property SPELL014 auto
spell property SPELL015 auto
spell property SPELL016 auto
spell property SPELL017 auto
spell property SPELL018 auto
spell property SPELL019 auto
spell property SPELL020 auto
spell property SPELL021 auto
spell property SPELL022 auto
spell property SPELL023 auto
spell property SPELL024 auto
spell property SPELL025 auto
spell property SPELL026 auto
spell property SPELL027 auto
spell property SPELL028 auto
spell property SPELL029 auto
spell property SPELL030 auto
spell property SPELL031 auto
spell property SPELL032 auto
spell property SPELL033 auto
spell property SPELL034 auto
spell property SPELL035 auto
spell property SPELL036 auto
spell property SPELL037 auto
spell property SPELL038 auto
spell property SPELL039 auto
spell property SPELL040 auto


Event OnSpellCast(Form akSpell)
Spell spellCast = akSpell as Spell

;shout

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

;destruction

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

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

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

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

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

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

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

;illusion

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

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

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

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

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

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

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

;resoration

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

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

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

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

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

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

;conjuration

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

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

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

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

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

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

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

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

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

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

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

;alteration

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

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

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

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

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

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

endEvent

 

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

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

 

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!

 

 

 

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...