Jump to content

Papyrus - RegisterForAnimationEvent and OnAnimationEvent - Help me!


Matth85

Recommended Posts

Can you post your script? I cannot imagine what event you are using in a perk script to register for an animation. I didn't even know that perk scripts had events. As far as I know perk scripts are just for running activate fragments.
Link to comment
Share on other sites

The script is running a spell(ability), which holds the magic effect, which holds the script. I pretty much made this to follow the setup of the mod Imbued Weapon Bloodskal. This is the first step of a much bigger thing I am working on; but it's all worth nothing if I can't track the animations!

 

https://gyazo.com/05e0d77143d4d5b6378881002c5638f2

 

 

Scriptname MAT85AranedeanDischargeMEScript extends ActiveMagicEffect

Globalvariable property MAT85AranPowerLevel auto
Weapon property MAT85AranedeanWeapon auto
Actor Property SelfRef auto hidden
ReferenceAlias Property ForcePlayerRef Auto



Event OnEffectStart(Actor akTarget, Actor akCaster)
	
	selfref = akCaster
	registerForAnimationEvent(akCaster, "AttackPowerStanding_FXStart")
	registerForAnimationEvent(akCaster, "AttackPowerRight_FXStart")
	registerForAnimationEvent(akCaster, "AttackPowerLeft_FXStart")
	registerForAnimationEvent(akCaster, "AttackPowerBackward_FXStart")
	registerForAnimationEvent(akCaster, "AttackPowerForward_FXStart")
		
		if	registerForAnimationEvent(akCaster, "AttackPowerStanding_FXStart") as bool == True &&\
			registerForAnimationEvent(akCaster, "AttackPowerRight_FXStart") as bool == True &&\
			registerForAnimationEvent(akCaster, "AttackPowerLeft_FXStart") as bool == True &&\
			registerForAnimationEvent(akCaster, "AttackPowerBackward_FXStart") as bool == True &&\
			registerForAnimationEvent(akCaster, "AttackPowerForward_FXStart") as bool == True
			Debug.Messagebox("Animations Register succesfull")
		endif
EndEvent



;-----------------------------------------------------------------------------------------------

Event OnAnimationEvent(ObjectReference akSource, string EventName)
	

		if EventName == "AttackPowerStanding_FXStart"||\ 
			EventName == "AttackPowerForward_FXStart" ||\ 
			EventName == "AttackPowerRight_FXStart" ||\ 
			EventName == "AttackPowerLeft_FXStart" ||\ 
			EventName == "AttackPowerBackwards_FXStart"

		 	Debug.Messagebox("You did a power attack via the Magic script!")

			;if MAT85AranPowerLevel.getValue() as int == 3
				;Mat85AranPowerLevel.SetValue(0)
				;debug.Messagebox("You fired off a level 3 beam!")
			;elseif MAT85AranPowerLevel.getValue() as int == 2
				;Mat85AranPowerLevel.SetValue(0)
				;debug.Messagebox("You fired off a level 2 beam!")
			;elseif Mat85AranPowerLevel.GetValue() as int == 1
				;Mat85AranPowerLevel.SetValue(0)
				;debug.Messagebox("You fired off a level 1 beam!")
			;endif	
		endif

EndEvent

 

 

 

And for the Objectreference/ReferenceAlias setup I used :

 

 

 

Scriptname MAT85AranedeanDischargeScript extends ReferenceAlias

Globalvariable property MAT85AranPowerLevel auto
Weapon property MAT85AranedeanWeapon auto
Actor property SelfRef auto hidden


Event OnEquipped(Actor akActor)

	if akActor == Game.Getplayer()
		
		registerForAnimationEvent(Game.getplayer(), "AttackPowerStanding_FXStart")
		registerForAnimationEvent(Game.Getplayer(), "AttackPowerRight_FXStart")
		registerForAnimationEvent(Game.Getplayer(), "AttackPowerLeft_FXStart")
		registerForAnimationEvent(Game.Getplayer(), "AttackPowerBackward_FXStart")
		registerForAnimationEvent(Game.Getplayer(), "AttackPowerForward_FXStart")


		if	registerForAnimationEvent(Game.getplayer(), "AttackPowerStanding_FXStart") as bool == True &&\
			registerForAnimationEvent(Game.Getplayer(), "AttackPowerRight_FXStart") as bool == True &&\
			registerForAnimationEvent(Game.Getplayer(), "AttackPowerLeft_FXStart") as bool == True &&\
			registerForAnimationEvent(Game.Getplayer(), "AttackPowerBackward_FXStart") as bool == True &&\
			registerForAnimationEvent(Game.Getplayer(), "AttackPowerForward_FXStart") as bool == True
			Debug.Messagebox("Animations Registered succesfull")
		endif

	endif

EndEvent

Event onUnequipped(Actor akActor)

	if akActor == Game.Getplayer() && Game.getplayer().GetItemCount(MAT85AranedeanWeapon) == 1
		Debug.Messagebox("Aranedean is unequipped. Animations uregistered")
		unregisterForAnimationEvent(Game.Getplayer(), "AttackPowerStanding_FXStart")
		unregisterForAnimationEvent(Game.Getplayer(), "AttackPowerRight_FXStart")
		unregisterForAnimationEvent(Game.Getplayer(), "AttackPowerLeft_FXStart")
		unregisterForAnimationEvent(Game.Getplayer(), "AttackPowerBackward_FXStart")
		unregisterForAnimationEvent(Game.Getplayer(), "AttackPowerForward_FXStart")
	endif
EndEvent

;-----------------------------------------------------------------------------------------------

Event OnAnimationEvent(ObjectReference akSource, string EventName)
 Debug.Messagebox("You did a power attack!")
 	
 	;if aKSource == game.getplayer()

		if  eventname == "AttackPowerStanding_FXStart" ||\ 
			eventname == "AttackPowerForward_FXStart" ||\ 
			eventname == "AttackPowerRight_FXStart" ||\ 
			eventname == "AttackPowerLeft_FXStart" ||\ 
			eventname == "AttackPowerBackwards_FXStart"
			Debug.Messagebox("Perfect!")
		endif
	;endif

EndEvent

 

 

 

Which is linked to the alias of the player, in a empty quest(part from the alias). Nothing happens there though. Otherwise I tried to extend Objectreference and put the same script on the weapon itself. Which got me halfway there; registering but not detecting.

 

And just to clarify a tad here; I have very little experience with scripting in general. I am sort of learning as I go! So far it's going good, minus a couple of issues. (Firstly I found out Sublime Text 2 didn't compile correctly, and now this).

Edited by Matth85
Link to comment
Share on other sites

SOLVED!

 

Apparently these animation events are limited to a greatsword. They were made specifially for Bloodskal.

I'll need to find another way to get the 1 handed power attacks tracked.

 

Thanks for any assistance!

Link to comment
Share on other sites

selfref.GetAnimationVariableBool("bAllowRotation") Worked. With an aditional !selfref.GetAnimationVariableBool("isBlocking") && !selfref.GetAnimationVariableBool("isBashing") && !selfref.GetAnimationVariableBool("isSneaking")

So, I register for WeaponSwing and do:

if  eventname == "weaponSwing" &&\
    selfref.GetAnimationVariableBool("bAllowRotation") &&\
   !selfref.GetAnimationVariableBool("isBlocking") &&\
   !selfref.GetAnimationVariableBool("isBashing") &&\
   !selfref.GetAnimationVariableBool("isSneaking") &&\
  		  

That captures power attacks only. (props to ChizForShiz who told me that, and his mod so I could see how he did it!).

 

That said, I couldn't figure out what GetAnimationVariableBool does. The wiki gave me some vague explanation that told me very little(perhaps it means more to a native english speaker?).

Edited by Matth85
Link to comment
Share on other sites

That's a clever check.

 

WeaponSwing is an AnimEvent triggered between 0.5 and 1.2 sec after the begin of each 1 or 2handed attack.

 

Animation variables are variables in the behavior files, mostly used to exchange information between behaviors and engine. With GetAnimationVariableBool() you get the the value of such AnimVar.

 

bAllowRotation is a (boolean) AnimVar which is set during power attacks.

 

Checks for the other 3 AnimVars you probably don't need. Theya check if you currently block, bash, or sneak. But since you can't power attack when you do either one of these, they won't be set anyway.

Link to comment
Share on other sites

I ran into the issue of Bloodskals projectile only working when in the right hand. Without having debugged too much yet; Could it, by chance, be the animation events? No script specify attack side, so that shouldn't be it. All spells are set to EitherHand. Hm..

 

Very weird to see the player use the effect when doing an unarmed melee power attack with the sword equipped in the left hand (Which doesn't fire it).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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