skinnytecboy Posted January 28, 2017 Share Posted January 28, 2017 Hey peeps, I seldom ask questions these days, so maybe you'll forgive me for this one. For a couple of days now I've been trying to find a way to fire a simple script when the player mounts a horse. The script itself will interact with another npc who may or may not be in the same cell as the player, which is why I need the player to run the script. After reading up on blank cloak effects, I decided that this was the best approach: Create a blank MGEF cloak ability and give it to the player on game load. On the MGEF I've placed the condition IsRidingMount and pointed it to the player. My script, attached to the MGEF at this stage merely has debug messages. I have found that, without the attached condition, the script will fire, but with it.... nothing works. Can anyone suggest alternatives or walk me through the correct method in case I've missed something simple? Thanks in advance peeps. :) Link to comment Share on other sites More sharing options...
Surilindur Posted January 28, 2017 Share Posted January 28, 2017 (edited) Have you tried registering for a suitable animation event from the player? For example: ; you could add the things here to a script on your other actor as well, as far as I know? Event OnInit() RegisterForAnimationEvent(Game.GetPlayer(), "your_mounting_event_name") ; move this elsewhere!!! EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) Debug.MessageBox("Event (" + asEventName + "), Source (" + akSource + ")") EndEventThere should be animation event lists in the Creation Kit, from the menubar -> Gameplay -> Animations. When selecting an items under one of the trees, there should be a dropdown list of animation event names (in the right side panel) with somewhat clear names. You can test which one activates when mounting a horse or a dragon or something. Hopefully that helps a bit. It has been a while since I did any scripting with Papyrus, but animation events are usually a great way to register for actions performed by an actor, without having to build a complex or performance-hungry polling system or a cloak script. But then again, it will take some time to go through all the various potentially useful events (based on their names alone) to find the correct one for each situation. Edit: The relevant wiki pages: RegisterForAnimationEvent, UnregisterForAnimationEvent and OnAnimationEvent. Edit 2: The text editor here is not great. Fixed the links. Edited January 28, 2017 by Contrathetix Link to comment Share on other sites More sharing options...
skinnytecboy Posted January 28, 2017 Author Share Posted January 28, 2017 (edited) Have you tried registering for a suitable animation event from the player? For example: ; you could add the things here to a script on your other actor as well, as far as I know? Event OnInit() ÃÂ ÃÂ ÃÂ RegisterForAnimationEvent(Game.GetPlayer(), "your_mounting_event_name") ; move this elsewhere!!! EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) ÃÂ ÃÂ ÃÂ Debug.MessageBox("Event (" + asEventName + "), Source (" + akSource + ")") EndEventThere should be animation event lists in the Creation Kit, from the menubar -> Gameplay -> Animations. When selecting an items under one of the trees, there should be a dropdown list of animation event names (in the right side panel) with somewhat clear names. You can test which one activates when mounting a horse or a dragon or something.ÃÂ Hopefully that helps a bit. It has been a while since I did any scripting with Papyrus, but animation events are usually a great way to register for actions performed by an actor, without having to build a complex or performance-hungry polling system or a cloak script. But then again, it will take some time to go through all the various potentially useful events (based on their names alone) to find the correct one for each situation.ÃÂ Edit: The relevant wiki pages: RegisterForAnimationEvent, UnregisterForAnimationEvent and OnAnimationEvent.ÃÂ Edit 2: The text editor here is not great. Fixed the links.Thanks mate. I'm aware of the notion of registration of animation events; there's actually a hex cmD "HorseEnter" oo'err missus ;) Edit: I re-read your comment. So you're suggesting that I just place a script on the player alias? If conditioned, will such a script fire every time conditions are met? Edited January 28, 2017 by skinnytecboy Link to comment Share on other sites More sharing options...
Surilindur Posted January 28, 2017 Share Posted January 28, 2017 You do not need the magic effect at all - that's the thing! You can register for the relevant animation event in the other actor's script. That is what I was trying to explain. Yes, my communication skills are not great. :Pin a script attached to the other actor (for example), register for the "HorseEnter" event emitted by playerin the OnAnimationEvent block in that script, run the commands you need to run when player mounts a horsescript processing only happens when the event fires (because there is no polling, no magic effect, no cloak, nothing!)For example I have used RegisterForAnimationEvent in a quest script to catch player events and it works just fine. :thumbsup: Link to comment Share on other sites More sharing options...
skinnytecboy Posted January 28, 2017 Author Share Posted January 28, 2017 Ha.. I was editing my post whilst you were responding :) Okay. Thanks mate. I will experiment a little more. It's for this guy btw https://www.youtube.com/watch?v=k1VTSWC4t1A I thought it would be funny if he insults the player and teleports away if the player mounts a horse... and then teleports back on dismount. ;) Link to comment Share on other sites More sharing options...
Surilindur Posted January 28, 2017 Share Posted January 28, 2017 (edited) Well you could add it to the player alias, as well, as far as I know. The script. Assuming OnPlayerLoadGame actually fires, and that registering for the same event multiple times does not cause issues, you could use something like this and attach it to the PlayerAlias of whatever quest you may have: ScriptName YourPrefix_HorseMountHandler Extends Actor ; this script is attached to a Player alias in your quest Actor Property YourOtherActor Auto ObjectReference Property HoldingCellMarker Auto ; a marker in your holding cell Event OnPlayerLoadGame() Utility.Wait(0.5) ; wait a little, so that everything really is loaded and ready - might not be necessary, though RegisterForAnimationEvent(Self, "HorseEnter") RegisterForAnimationEvent(Self, "HorseExit") ; <-- replace HorseExit with the exit animation event name! Debug.MessageBox("OnPlayerLoadGame run, events should be registered") EndEvent Event OnAnimationEvent(ObjectReference akSource, String asEventName) Debug.MessageBox("Event (" + asEventName + "), Source (" + akSource + ")") If (asEventName == "HorseEnter" && YourOtherActor.IsEnabled()) YourOtherActor.MoveTo(HoldingCellMarker) YourOtherActor.Disable() ElseIf (asEventName == "HorseExit") ; <-- replace HorseExit with the actual event name If (YourOtherActor.IsDisabled()) YourOtherActor.Enable() EndIf YourOtherActor.MoveTo(Self) EndIf EndEventSomething like that. I have not tested it, though, but it should work. Hopefully that helps a bit. Edit: Fixed a typo, the HoldingCellMarker should be a property. Edited January 28, 2017 by Contrathetix Link to comment Share on other sites More sharing options...
Di0nysys Posted January 29, 2017 Share Posted January 29, 2017 Ha.. I was editing my post whilst you were responding :smile: Okay. Thanks mate. I will experiment a little more. It's for this guy btw https://www.youtube.com/watch?v=k1VTSWC4t1A I thought it would be funny if he insults the player and teleports away if the player mounts a horse... and then teleports back on dismount. :wink:Dude Wowbagger's a legend :D Link to comment Share on other sites More sharing options...
skinnytecboy Posted January 29, 2017 Author Share Posted January 29, 2017 @Dio I'm having a great deal of fun writing insults aimed at vanilla npcs For example Guard "your breath smells terrible. What have you been eating?" Wowbagger response "Your Grandmother" ;) Link to comment Share on other sites More sharing options...
Recommended Posts