Jump to content

Using OnAnimationEvent to capture draw/sheathe event


GnatGoSplat

Recommended Posts

This code is attached to a custom follower, I want to run some code when the follower draws or sheathes her weapon. The script extends Actor. It works most of the time, but not all of the time. I registered the animation events in OnLoad for lack of an understanding of a better place for it.

 

Event OnLoad()
RegisterForAnimationEvent(Self, "BeginWeaponDraw")
RegisterForAnimationEvent(Self, "BeginWeaponSheathe")
endEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
 	if (akSource == self)
   		if (asEventName == "BeginWeaponDraw")
                    [ ... code to execute when weapon drawn ... ]
	endif
   		if (asEventName == "BeginWeaponSheathe")
                    [ ... code to execute when weapon sheathed ... ]
	endif
 	endIf
endEvent

 

Is there a better place to register these events, or is there a better way to accomplish this that's more reliable?

Link to comment
Share on other sites

  • 1 month later...

Kind of. I have the events registering in both OnLoad() and OnLocationChange(). While playing the game, location changes frequently so if it ever stops working, it won't be that way for very long.

 

Ah ya true thanks for the info. Kinda funny how we have to come up with all these hacks for something that should be pretty simple huh?

Link to comment
Share on other sites

You could use a scripted magic effect (applied as a constant effect on the follower ie. maybe as a permanent ability) with the Condition Function "isWeaponOut == 2" set on it.

 

 

ScriptName myScript Extends ActiveMagicEffect

Event OnEffectStart(Actor Target, Actor Caster)
if (Target == self)
	[ ... code to execute when weapon drawn ... ]
endif
endEvent

Event OnEffectFinish(Actor Target, Actor Caster)
       if (Target == self)
	[ ... code to execute when weapon sheathed ... ]
endif
endEvent

 

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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