PlayerRef Property Not Working Correctly

Post » Tue Nov 20, 2012 2:50 pm

Hi!

So, I've been going back and replacing a bunch of game.getPlayer() calls with a PlayerRef property, because it's more efficient.

However, despite the property being set to the PlayerRef(00000014) in the CK, once the script is running, the property seems to be a NONE. The following error (and more like it) appear in my Papyrus logs:

[11/11/2012 - 03:35:06AM] error: Cannot call HasMagicEffect() on a None object, aborting function callstack:[Active effect 7 on  (00000014)].ishicobattlemageweaponbuffscript.OnSpellCast() - "ishicobattlemageweaponbuffscript.psc" Line 56

Am I doing something wrong? Forgetting something?
User avatar
ChloƩ
 
Posts: 3351
Joined: Sun Apr 08, 2007 8:15 am

Post » Tue Nov 20, 2012 2:32 pm

-

Can I see the entire script, please?
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am

Post » Tue Nov 20, 2012 2:35 am

Scriptname ishicobattlemageweaponbuffscript extends activemagiceffect  {script to apply weapon damage buff when spell is cast}MagicEffect Property buffEffect1  AutoMagicEffect Property buffEffect2  AutoMagicEffect Property buffEffect3  AutoMagicEffect Property buffEffect4  AutoMagicEffect Property buffEffect5  AutoSpell Property buffSpell1  AutoSpell Property buffSpell2  AutoSpell Property buffSpell3  AutoSpell Property buffSpell4  AutoSpell Property buffSpell5  AutoMagicEffect Property dispelEffect1  AutoMagicEffect Property dispelEffect2  AutoMagicEffect Property dispelEffect3  AutoMagicEffect Property dispelEffect4  AutoMagicEffect Property dispelEffect5  AutoSpell Property dispelSpell1  AutoSpell Property dispelSpell2  AutoSpell Property dispelSpell3  AutoSpell Property dispelSpell4  AutoSpell Property dispelSpell5  AutoSpell Property rampdownSpell1  AutoSpell Property rampdownSpell2  AutoSpell Property rampdownSpell3  AutoSpell Property rampdownSpell4  Auto Actor Property playerRef AutoEvent OnSpellCast(Form akSpell)Spell castSpell = akSpell as SpellIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect1) == 0 && playerRef.hasMagicEffect(buffEffect2) == 0 && playerRef.hasMagicEffect(buffEffect3) == 0 && playerRef.hasMagicEffect(buffEffect4) == 0 && playerRef.hasMagicEffect(buffEffect5) == 0buffSpell1.cast(playerRef, playerRef)debug.trace("buff 1 applied!")ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect1) == 1buffSpell2.cast(playerRef, playerRef)debug.trace("buff 2 applied!")ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect2) == 1buffSpell3.cast(playerRef, playerRef)debug.trace("buff 3 applied!")ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect3) == 1buffSpell4.cast(playerRef, playerRef)debug.trace("buff 4 applied!")ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect4) == 1buffSpell5.cast(playerRef, playerRef) debug.trace("buff 5 applied!")ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(buffEffect5) == 1buffSpell5.cast(playerRef, playerRef)EndIfIf castSpell.getPerk() != None && playerRef.hasMagicEffect(dispelEffect5) == 1rampdownSpell4.cast(playerRef, playerRef)ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(dispelEffect4) == 1rampdownSpell3.cast(playerRef, playerRef)ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(dispelEffect3) == 1rampdownSpell2.cast(playerRef, playerRef)ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(dispelEffect2) == 1rampdownSpell1.cast(playerRef, playerRef)ElseIf castSpell.getPerk() != None && playerRef.hasMagicEffect(dispelEffect1) == 1playerRef.dispelSpell(rampdownSpell1)EndIfEndEvent 
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Tue Nov 20, 2012 9:11 am

Thanks, did you try to use a Debug.Messagebox? Maybe the error comes from the logging and it actually works ingame? Or maybe you need a new save for the changes to be successfully applied?
User avatar
Nikki Morse
 
Posts: 3494
Joined: Fri Aug 25, 2006 12:08 pm

Post » Tue Nov 20, 2012 6:05 pm

Thanks, did you try to use a Debug.Messagebox? Maybe the error comes from the logging and it actually works ingame? Or maybe you need a new save for the changes to be successfully applied?

The script failed to work before I added the debug tracing... I added those lines to see if that part of the script was firing at all. The error with "hasMagicEffect() cannot be called on a NONE object" occurs on the first If line, before the script even gets to the debug trace calls.

That I might need a new save didn't occur to me. I'll try that now.
User avatar
Judy Lynch
 
Posts: 3504
Joined: Fri Oct 20, 2006 8:31 am

Post » Tue Nov 20, 2012 5:48 pm

Nope, loaded the save, no change :<
User avatar
Prohibited
 
Posts: 3293
Joined: Tue Jun 12, 2007 6:13 am

Post » Tue Nov 20, 2012 9:00 am

Damn :stare:
That's strange, because you said you filled the properties... Are you using a modified Update.esm? I had an issue with one of my mods that caused all my properties to be set to NULL, and I think it was because I modded this file to be compatible with the Creation Kit... :down:
User avatar
Amy Gibson
 
Posts: 3540
Joined: Wed Oct 04, 2006 2:11 pm

Post » Tue Nov 20, 2012 4:32 am

Removed post
User avatar
steve brewin
 
Posts: 3411
Joined: Thu Jun 21, 2007 7:17 am

Post » Tue Nov 20, 2012 8:46 am

I thought Events received by ObjectReference would also be received by ActiveMagicEffect?
User avatar
FLYBOYLEAK
 
Posts: 3440
Joined: Tue Oct 30, 2007 6:41 am

Post » Tue Nov 20, 2012 3:55 pm

Damn :stare:
That's strange, because you said you filled the properties... Are you using a modified Update.esm? I had an issue with one of my mods that caused all my properties to be set to NULL, and I think it was because I modded this file to be compatible with the Creation Kit... :down:

I cleaned Update.esm with TES5Edit, but other than that I haven't touched it.

The property definitely says it's set in the CK. Is there any way to make sure it's set elsewhere (in Edit or anything)?
User avatar
Luna Lovegood
 
Posts: 3325
Joined: Thu Sep 14, 2006 6:45 pm

Post » Tue Nov 20, 2012 11:33 am

I thought Events received by ObjectReference would also be received by ActiveMagicEffect?

ActiveMagicEffects receive all the events that the ObjectReference they're active on receives, yes.

[EDIT] And though I think it's understood, I didn't say it clearly, so... the script worked perfectly fine when I was using a variable and a getPlayer() call. It's only since replacing those with the Property that the script has stopped working.
User avatar
Veronica Martinez
 
Posts: 3498
Joined: Tue Jun 20, 2006 9:43 am

Post » Tue Nov 20, 2012 2:37 pm

Really, really strange behaviour... Could you test it on someone else's computer?
User avatar
helen buchan
 
Posts: 3464
Joined: Wed Sep 13, 2006 7:17 am

Post » Tue Nov 20, 2012 5:49 am

No :/
User avatar
!beef
 
Posts: 3497
Joined: Wed Aug 16, 2006 4:41 pm

Post » Tue Nov 20, 2012 9:21 am

Aaand, I just removed the property, declared playerRef as an actor variable to game.getPlayer(), made no other changes... the script works perfectly.
User avatar
Rudi Carter
 
Posts: 3365
Joined: Fri Sep 01, 2006 11:09 pm

Post » Tue Nov 20, 2012 2:27 pm

Well, it looks like your ActiveMagicEffect does not like this particular property... That's strange, maybe it gets removed after the effect is no more on the player? That'd be lame though
User avatar
Amanda Furtado
 
Posts: 3454
Joined: Fri Dec 15, 2006 4:22 pm


Return to V - Skyrim