Inconsistent OnAnimation behavior

Post » Tue Apr 02, 2013 3:06 am

I'm desperately trying to figure out what on earth is wrong with this script. I have set up a Start game enabled quest, generated the SEQ file and attached this script to a player alias [flagging it as Reserved].

The trace shows that the animation event is *always* registered properly, implying that the script always run as expected on a new game but the OnAnimation event doesn't always fire up. When it does, it does *only* upon reloading a save, and *not* always. However, once a game is reloaded and the OnAnimation event *does* fire up, it always work in subsequent saves and reloads. It's completely inconsistent and I don't have the slightest clue why. Any ideas?

Spoiler

Scriptname SpellsFailurePlayer extends ReferenceAlias  Sound Property MAGFail Auto	Actor Property PlayerREF AutoEvent OnInit()	if RegisterForAnimationEvent(PlayerREF, "BeginCastLeft")		Debug.Trace("Left Cast registered on " + PlayerREF )		Debug.Notification("Left Cast registered on " + PlayerREF )	endif				if RegisterForAnimationEvent(PlayerREF, "BeginCastRight")		Debug.Trace("Right Cast registered on " + PlayerREF )		Debug.Notification("Right Cast registered on " + PlayerREF )	endifEndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)		debug.Trace(self + ": source = " + akSource + " event = " + asEventName)	float RandomLeft = Utility.RandomFloat(1.0, 100.0)	float RandomRight = Utility.RandomFloat(1.0, 100.0)		Bool SpellFail = false		Spell LeftHandSpell = PlayerREF.GetEquippedSpell(0)	Spell RightHandSpell = PlayerREF.GetEquippedSpell(1)	if ( (asEventName == "BeginCastLeft") && ( LeftHandSpell ) )		float LeftFailChance  = RandomLeft - PlayerREF.GetBaseActorValue( LeftHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() )		Debug.Trace("Left, random " + RandomLeft + ", LeftFailChance " + LeftFailChance )  		if ( LeftFailChance > 30 )			if ( LeftHandSpell.getEffectiveMagickaCost(PlayerREF) > 0 )				float randomwait = Utility.RandomFloat(0.0,1.0)				Utility.Wait(randomwait)				PlayerREF.InterruptCast()				SpellFail = true			endif		endif	endif		if ( (asEventName == "BeginCastRight") && ( RightHandSpell ) )			float RightFailChance = RandomRight - PlayerREF.GetBaseActorValue( RightHandSpell.GetNthEffectMagicEffect(0).GetAssociatedSkill() )		Debug.Trace("Right, random " + RandomRight + ", RightFailChance " + RightFailChance )			if ( RightFailChance > 30 )			if ( RightHandSpell.getEffectiveMagickaCost(PlayerREF) > 0 )				float randomwait = Utility.RandomFloat(0.0,1.0)				Utility.Wait(randomwait)				PlayerREF.InterruptCast()				SpellFail = true			endif		endif	endif		if ( SpellFail )		MAGFail.play(PlayerREF)	endif	EndEvent
User avatar
mimi_lys
 
Posts: 3514
Joined: Mon Apr 09, 2007 11:17 am

Return to V - Skyrim