GnatGoSplat Posted September 10, 2012 Share Posted September 10, 2012 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 More sharing options...
Ghaunadaur Posted September 10, 2012 Share Posted September 10, 2012 I read something on the wiki page that OnLoad() is not very reliable. You could try to use OnIinit() or OnCellAttach() instead. Link to comment Share on other sites More sharing options...
GnatGoSplat Posted September 11, 2012 Author Share Posted September 11, 2012 (edited) Thanks, I just tried both OnInit() and OnCellAttach(). Unfortunately, OnLoad() is the only event that seems to fire across loading screens. Edited September 11, 2012 by GnatGoSplat Link to comment Share on other sites More sharing options...
hamseungyeon Posted October 20, 2012 Share Posted October 20, 2012 Thanks, I just tried both OnInit() and OnCellAttach(). Unfortunately, OnLoad() is the only event that seems to fire across loading screens. Did you find a better place to register the events? Link to comment Share on other sites More sharing options...
GnatGoSplat Posted October 20, 2012 Author Share Posted October 20, 2012 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. Link to comment Share on other sites More sharing options...
hamseungyeon Posted October 21, 2012 Share Posted October 21, 2012 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 More sharing options...
steve40 Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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 October 22, 2012 by steve40 Link to comment Share on other sites More sharing options...
Recommended Posts