Scripting help -- Player.AddSpell() fails

Post » Tue Jun 19, 2012 5:54 am

Hey all, I'm in the early stages of developing a Vampirism rebalance mod for Skyrim. Among other things, this mod adds a spell effect to the player for a few hours after feeding. The spell effect itself works fine, and I've tested adding it with a button, to which is attached the script:

Scriptname VolkiharTestingButton extends ObjectReference{A button to test adding an ability to the player through scripting}Event OnActivate(ObjectReference akActionRef)    Game.GetPlayer().AddSpell(VolkiharBloodEuphoria01)    Debug.MessageBox("Added Blood Euphoria I!")endEventSpell Property VolkiharBloodEuphoria01 Auto

Now, this code snippet works flawlessly. However, when I attempt to add the same function call, Game.GetPlayer().AddSpell(VolkiharBloodEuphoria01) to the VampireFeed() function of PlayerVampireQuestScript, nothing happens. I've tested adding a debug dialogue box to the same function, which DOES work for some reason, but nothing I've tried has allowed the spell effect to actually apply to the player upon feeding.

My question is this: what could cause the function call to fail in one instance but succeed in another, when the script is being compiled properly and is apparently otherwise functional?

For completeness, the entire VampireFeed() function:

Spoiler

Function VampireFeed()    ; Volkihar Mod modifications --------------------------------------------------        ; Testing a direct reference to see whether that's causing this to fail    Actor Player = Game.GetPlayer()    Player.AddSpell(VolkiharBloodEuphoria01)    Debug.MessageBox("Adding blood euphoria I!  Volkihar age: "+VolkiharAge)    ; End Volkihar mod modifications --------------------------------------------------    ;Effects for hiding the change    ;VampireChangeFX.play(game.getPlayer())    VampireTransformDecreaseISMD.applyCrossFade(2.0)    utility.wait(2.0)    imageSpaceModifier.removeCrossFade()    ;VampireChangeFX.stop(game.getPlayer())        Game.IncrementStat( "Necks Bitten" )    VampireFeedMessage.Show()    VampireFeedReady.SetValue(0)    ;Game.ForceThirdPerson()    ;Game.GetPlayer().PlayIdle(VampireFeedingBedRight)    ;Player has fed, regress to Stage 1 Vampirisim    ;Remove Stage 2, 3, and 4 buffs and spells    LastFeedTime =  GameDaysPassed.Value    VampireStatus = 1    VampireProgression(Game.GetPlayer(), 1)    ;Player is no longer hated    Game.GetPlayer().RemoveFromFaction(VampirePCFaction)    Game.GetPlayer().SetAttackActorOnSight(False)    int cfIndex = 0    while (cfIndex < CrimeFactions.GetSize());         Debug.Trace("VAMPIRE: Removing enemy flag from " + CrimeFactions.GetAt(cfIndex))        (CrimeFactions.GetAt(cfIndex) as Faction).SetPlayerEnemy(false)        cfIndex += 1    endwhile    ;Start checking GameTime again if we weren't already    UnregisterforUpdateGameTime()    RegisterForUpdateGameTime(12)    EndFunction
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Tue Jun 19, 2012 12:40 pm

What type of spell is VolkiharBloodEuphoria01? Unless it's a spell that the player needs to have added to their spell book, you should be using http://www.creationkit.com/Cast_-_Spell and http://www.creationkit.com/DispelSpell_-_Actor to add and remove it.

Cipscis
User avatar
JUDY FIGHTS
 
Posts: 3420
Joined: Fri Jun 23, 2006 4:25 am

Post » Tue Jun 19, 2012 11:36 am

Do you have the spell property properly set up on the vampire script?
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Tue Jun 19, 2012 2:59 pm

Hey, appreciate the response, I altered my code to temporarily add my VolkiharBloodEuphoria spell to the player and cast it on them. However, even with the altered approach, the cast fails when called from the VampireFeed() function but not when identical code is called from a script attached to a button. For reference, my code in both cases is:

Game.GetPlayer().AddSpell(VolkiharBloodEuphoria01)VolkiharBloodEuphoria01.Cast(Game.GetPlayer())Debug.MessageBox("Adding blood euphoria I!")

I've double-checked that I have the correct variable references set in the Creation Kit for the vampire quest script variables. The output I get from the debug log is:

[02/21/2012 - 12:38:13AM] error: Cannot add a None spell to the actorstack:	[ (00000014)].Actor.AddSpell() - "" Line ?	[PlayerVampireQuest (000EAFD5)].playervampirequestscript.VampireFeed() - "PlayerVampireQuestScript.psc" Line 236	[ (000CF02C)].PRKF_VampireFeedBeds_000CF02C.Fragment_0() - "PRKF_VampireFeedBeds_000CF02C.psc" Line 9[02/21/2012 - 12:38:13AM] error: Cannot call Cast() on a None object, aborting function callstack:	[PlayerVampireQuest (000EAFD5)].playervampirequestscript.VampireFeed() - "PlayerVampireQuestScript.psc" Line 238	[ (000CF02C)].PRKF_VampireFeedBeds_000CF02C.Fragment_0() - "PRKF_VampireFeedBeds_000CF02C.psc" Line 9

I don't know quite what this would indicate, I checked whether VolkiharBloodEuphoria01 was being set to None somewhere in the vampire script but it's only used in this function call.

Is there a reason why this is failing only when called from the vampire quest script?

EDIT: I did confirm that the spell property was properly set up on both scripts.
User avatar
David Chambers
 
Posts: 3333
Joined: Fri May 18, 2007 4:30 am

Post » Tue Jun 19, 2012 10:25 am

[02/21/2012 - 12:38:13AM] error: Cannot add a None spell to the actorstack:	[ (00000014)].Actor.AddSpell() - "" Line ?	[PlayerVampireQuest (000EAFD5)].playervampirequestscript.VampireFeed() - "PlayerVampireQuestScript.psc" Line 236	[ (000CF02C)].PRKF_VampireFeedBeds_000CF02C.Fragment_0() - "PRKF_VampireFeedBeds_000CF02C.psc" Line 9[02/21/2012 - 12:38:13AM] error: Cannot call Cast() on a None object, aborting function callstack:	[PlayerVampireQuest (000EAFD5)].playervampirequestscript.VampireFeed() - "PlayerVampireQuestScript.psc" Line 238	[ (000CF02C)].PRKF_VampireFeedBeds_000CF02C.Fragment_0() - "PRKF_VampireFeedBeds_000CF02C.psc" Line 9
That error really sounds like you don't have a spell property pointing to the correct spell... It's trying to add a None spell, which I would think means there is no spell specified for it to cast.

BTW you don't need to add and then cast the spell, just cast should be fine.
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Mon Jun 18, 2012 10:54 pm

That error really sounds like you don't have a spell property pointing to the correct spell... It's trying to add a None spell, which I would think means there is no spell specified for it to cast.

BTW you don't need to add and then cast the spell, just cast should be fine.

Mhm, I thought this as well, but I've triple-checked that the spell property does point to the same spell in both cases.

Is there anything that could be overriding this, or any other place that this could be failing?
User avatar
Farrah Barry
 
Posts: 3523
Joined: Mon Dec 04, 2006 4:00 pm

Post » Tue Jun 19, 2012 12:47 am

what kind of spell is it? is it an ability (constant effect) or a long duration fire and forget?
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Tue Jun 19, 2012 6:11 am

It's a long-duration fire-and-forget.
User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Tue Jun 19, 2012 3:06 am

You do actually have the
Spell Property VolkiharBloodEuphoria01 Auto
property included somewhere in the script that contains the VampireFeed function right?
User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Tue Jun 19, 2012 1:56 am

Mhm, it is.
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Tue Jun 19, 2012 3:13 am

I never had much success directly manipulating existing scripts (in fact, I highly recommend *against* doing that).

Where in the PlayerVampireQuestScript did you add this function call?

edit: pardon me, I just noticed you put it up there!

Wow. If you're dead positive that the property is filled in the PlayerVampireQuestScript, then I have not even a clue what could be the cause. Sorry for being no help whatsoever :(
User avatar
Becky Palmer
 
Posts: 3387
Joined: Wed Oct 04, 2006 4:43 am

Post » Tue Jun 19, 2012 4:16 am

Alright, thanks for the help from everyone. I've decided that ultimately it'll be easiest to just re-write the entire vampire script ( :dry:), since it appears that this is some sort of obscure bug related to modifying existing scripts rather than my making a mistake in my setup.

I'll keep this thread updated if I find anything else out, in case someone else has similar issues.
User avatar
LADONA
 
Posts: 3290
Joined: Wed Aug 15, 2007 3:52 am

Post » Mon Jun 18, 2012 11:45 pm

Open your volkiharwhatever01 spell and change its type to destruction/resto/whatever you want, since you have it set to "none" which is why your script doesn't work
User avatar
cosmo valerga
 
Posts: 3477
Joined: Sat Oct 13, 2007 10:21 am


Return to V - Skyrim