Jump to content

[LE] Moving horses from SKSE/Papyrus


neonmoe

Recommended Posts

I'm making my first mod, and I haven't touched Bethesda modding tools before, so please bear with me and my misconceptions. I have been programming for a good while, so I have a good grasp on the C++ part, using SKSE functions, and such.

 

The mod I want to exist would enable the player to control their horse in a more immersive fashion in VR. To do this, I need a way to get the horse to move from code, when the player is on it. I've tried a few ways to get the horse to move, but have run into problems in each:

  1. Move the horse via controlling the position of a marker which it would follow. However, it seems that the horse stops following markers (via PathToReference) when the player is on it, rendering this relatively useless. Maybe I could override the mounting somehow, to make the horse think that it doesn't have the player on it? Don't know how that'd be done though.
  2. Move the horse via some "StartMovingInDirection" function, which would really be the ideal, but I haven't found such a thing. Please share if you know of anything along these lines.
  3. Simulate the movement keypresses. This is the one I most recently tried, using DIHookControl::BufferedKeyPress/Release (which is what the Papyrus functions HoldKey and ReleaseKey use), but I think those don't work very well with VR, as the keyboard controls seem to be disabled, and getting the "Forward" key for gamepads didn't seem to return anything useful. I would appreciate suggestions as to how to simulate thumbsticks, if there is a way, as I know that the VR character can be moved by a gamepad's left stick.

    EDIT: After investigating this point further, I found the PlayerControls::GetSingleton()->autoRun variable, which seems to be a boolean controlling auto-run. If it's non-zero, the player starts moving, and if on a mount, the horse starts moving. Good! Problem: when mounted, the auto-run always goes in one direction, and from my testing, it's always along the positive Y axis. I imagine there's some variable that controls this direction. Most of the PlayerControls class seems to be unknown variables, so I'll be doing my own testing on what those do, but I'd appreciate any tips.

Any suggestions towards achieving horse movement via code are appreciated, as well as any general tips on the creation kit and using skse.

 

 

Edit for possible future readers: I gave up on this mod, because my explorations of SKSE led me to believe that there is no way (currently, seems like a lacking part of SKSE) to fake the inputs that result in movement. The Papyrus way had the problem of the horse not moving via AI when mounted, but even if it did work, the latency would've been too much to use for locomotion.

Edited by neonmoe
Link to comment
Share on other sites

Just a thought for #1. Perhaps have it do a check for IsOnMount? Think the reason for this is because when you mount the horse, it is now the "player", so to say. Given that, it would not longer follow it's AI routine via the script. So possibly do an IsOnMount check with the horse, and if so, have the PathToReference run on the player, instead. All speculation, not something I've tested myself.

Link to comment
Share on other sites

Just a thought for #1. Perhaps have it do a check for IsOnMount? Think the reason for this is because when you mount the horse, it is now the "player", so to say. Given that, it would not longer follow it's AI routine via the script. So possibly do an IsOnMount check with the horse, and if so, have the PathToReference run on the player, instead. All speculation, not something I've tested myself.

 

Thank you for the suggestion! It seems, from my testing, that PathToReference doesn't work on the player? I tested DisablePlayerControls before PathToReference as well, in case those were overriding it, but that didn't work either. I imagine the player isn't running the relevant AI code that would actually do what PathToReference wants. That said, the player not being able to be controlled by AI would be a real bummer, can't make a mod where you get seduced by a vampire who makes you do stuff :tongue:

 

I've had some progress on #3, thankfully. SKSE provides a way to toggle auto-run (PlayerControls::GetSingleton()->autoRun), which effectively lets me at least say "go" and "stop". The direction doesn't seem very controllable though, investigating that tomorrow.

Edited by neonmoe
Link to comment
Share on other sites

"PathToReference()" does work on the Player, but it needs to work along with the following functions, with the following order:

- Game.DisablePlayerControls()

- Game.SetPlayerAIDriven()

- PlayerREF.PathToReference()

Then when it has reach its target

- Game.SetPlayerAIDriven()

- Game.DisablePlayerControls()


* "PathToReference()" has the negative that it always needs a clear path between the "Start Sequence Point" and the "Target Path", if anything get or is in the way it will always get interrupted.


* You can also take a look at this topic that contains some more info on "PathToReference()", sorry i don't have too much free time right now to write all that:


Edited by maxarturo
Link to comment
Share on other sites

Thank you for the suggestion! Unfortunately, it seems the VR camera doesn't follow the player when it's controlled by AI, nor does the pathing seem to work when on a horse. Though the horse part might just be a problem on my end.

 

I don't think it's viable to implement the horse movement via PathToReference now, since the AI system is clearly quite fragile, doesn't cooperate with VR, and has more latency than using the player controls even if it did work. Thanks for the help though, this would've taken way longer to figure out without it.

 

Time to start delving deeper into SKSE :sweat:

Link to comment
Share on other sites

"it seems the VR camera doesn't follow the player when it's controlled by AI, nor does the pathing seem to work when on a horse"

- I didn't suggested the use of "PathToReference()", i was just pointing out how it should be used on the Player.

- When Player is in the horse the "PathToReference()" should be targeting the Player and not the horse.

- Although i don't know what you are trying to do, the "PathToReference()" is not a good candidate for use, since is quite unlikely to have a clear path in an exterior cell, "PathToReference()" draws a straight path line between the targets.

- i personally have not experiment with horses, but you could take a look how the start game sequence was made, where the player is in the carriage with only his head movement been possible while the carriage is in movment.

Link to comment
Share on other sites

i personally have not experiment with horses, but you could take a look how the start game sequence was made, where the player is in the carriage with only his head movement been possible while the carriage is in movment.

 

Oh, this is a very good idea, thank you!

 

And yeah, PathToReference was definitely a misstep. The info on it is much appreciated.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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