PHARTGAMES / SpaceMonkey

MIT License
44 stars 10 forks source link

Add Mud Runner/Snow Runner support #16

Open PHARTGAMES opened 3 years ago

PHARTGAMES commented 3 years ago

Might work with a LUA file hack.

Download this software to see lua changes https://en-motionhouse.imweb.me/

mchamplain commented 2 years ago

🤔 basic suspension data would be a lot of fun on snowrunner. Would like to help on this if I can, got any "getting started" guide for contributing?

PHARTGAMES commented 2 years ago

🤔 basic suspension data would be a lot of fun on snowrunner. Would like to help on this if I can, got any "getting started" guide for contributing?

GenericTelemetryProvider.sln is the solution

Using Balsa as an example

Duplicate/rename an existing provider and UI

BalsaTelemetryProvider.cs and BalsaUI.cs

So, basically, you decide how you want to get the data in every frame, then call ProcessTransform. Providers run on their own thread separate to the main thread and each ui (dialog) has it's own thread also. (there's thread safety functions for the ui all over the place)

Each provider is based on GenericProviderBase, the main function for all the processing is 'ProcessTransform'

The intention is for the developer to pass a transformation matrix for the frame to ProcessTransform, let the base class control the order of the function calls and then do any provider specific extraction of data from this transform within overridden functions.

So you shouldn't need to change anything inside GenericProviderBase and do everything inside your provider code.

The base class can do most things for you as long as the transform provided is in a left handed coordinate system. (have a look at the Matrix4x4.Identity value).

You can also completely override GenericProviderBase.ProcessTransform and do your own thing as long as you fill out the 'filteredData' structure and call SendFilteredData() at the end of the function.

Put a breakpoint inside GenericProviderBase.ProcessTransform and step into the function calls and it should be pretty obvious what's going on.

Add an instance of the UI to MainForm code (BalsaUI balsaUI;) Add a button and a click callback to the MainForm ui. (balsaButton_Click) Duplicate/rename a default config file for the new provider to the Configs subfolder (BalsaConfig.txt these config files hold all of the filter data.)

When you're happy, do a pull request and I can merge.

If you have any more questions ping me on discord Pezza#6155

mchamplain commented 2 years ago

@PHARTGAMES welp, I spent a few hours trying to figure out how to get the data but I can't figure this out... I tried CheatEngine and drilled down to try and get useful values like the wheels, suspension or just the player position as a starting point, but I either end up with 4k+ values that are always changing slightly but not enough to figure out what part exaclty, and when I try to freeze values it messes up the physics and the truck goes crazy :p

got any other tools you recommend using or any technique to find the data needed for this?

PHARTGAMES commented 2 years ago

@mchamplain Sorry it took a while to reply, It will be a pain to do with cheat engine, you can do it with a lua hack

Extract the Media.zip file in the mudrunner folder

find classes/truck.lua

attached is the lua file that MHServicer uses to extract data.

You just need to figure out how to get that data from the lua file into spacemonkey, probably via udp.

The DCS provider, and the BeamNG providers both send UDP from lua. Should be as simple as including the dependency they use to send udp in lua, and reorganising the packet format to whatever you want to read in spacemonkey.

truck.txt l

mchamplain commented 2 years ago

seems specific to MudRunner/SpinTire... (I don't have those, only snowrunner) in SnowRunner there's no media.zip file, only a media folder, but no lua files anywhere, looks like they got rid of lua scripts in that version