Jump to content

registering AnimationEvent leads to inability to block and/or attack


ChaosWarrior

Recommended Posts

As in the title the issue is that when I register NPC for animation event, then player is loosing ability to attack or block (or both). Is there way to somehow make it work?
At first I noticed this while I was experimenting with a spell effect that makes you fire things like with bloodskaal blade, and now I was registering things to detect if NPC was doing some ranged attacks or just standing.
So the code is in magic effect, I apply spell with console command "cast", notifications show that events firing as expected.

actor trg
int i = 0

Event OnEffectStart(Actor akTarget, Actor akCaster)
	i = 0
	trg = akTarget
	registerforsingleupdate(5)
	if (RegisterForAnimationEvent(trg as ObjectReference, "MRh_SpellFire_Event") && RegisterForAnimationEvent(trg as ObjectReference, "MLh_SpellFire_Event"))
		Debug.Notification("registered")
	endif
endevent

Event OnUpdate()
 	registerforsingleupdate(5)
	i = 0
endevent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
  if (akSource == trg as ObjectReference) && (asEventName == "MRh_SpellFire_Event")
		i+=1
		Debug.Notification(i+"# MRh_SpellFire_Event event sent!")
  endIf
  if (akSource == trg as ObjectReference) && (asEventName == "MLh_SpellFire_Event")
		i+=1
		Debug.Notification(i+"# MLh_SpellFire_Event event sent!")
  endIf
endEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	UnregisterForAnimationEvent(trg as ObjectReference,"MRh_SpellFire_Event")
	UnregisterForAnimationEvent(trg as ObjectReference,"MLh_SpellFire_Event")
	unregisterforupdate()
endevent

UPD it seems to affect player's controls when PC is one who casting, like ">player.cast 1413069f 0005054a left" when doing like ">cast 1413069f 0005054a left" it works using selected reference as caster. But still weird bug.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...