FansOfAll
Lazy Duchess
Lazy Duchess

patreon


[TS3] Mono debugging, method replacement!

Hi!

If you're a TS3 script modder, you probably know how much of a struggle modding can be, trying to workaround ways to override behaviors or having to make core mods for simple things.

It's still early, but I've been working on trying to remedy this by taking a closer look at the native code for the Mono runtime embedded in TS3.

In the process I've made some discoveries, such as a "verbosity level" variable in the runtime:

This way it's possible to debug issues with the C# runtime, see the bytecode for functions as the game compiles them and such. It's pretty neat!

Some other things include crash flags, which when disabled can make the game keep running and not crash when hitting certain problems in the C# compiler. This doesn't do a whole lot, but can be kinda helpful in some cases as sometimes my own code would crash because of this and I'd have no idea why.

Another exciting development is the ability to call your own C++ code from C#. I've found the location in the game's executable where "internal" C++ calls are registered in the runtime:

This means we could do more than ever before with script mods. This includes:

Reading/writing files in any format and location. Want to save/load mod settings or data without using Persistable or Tuning XMLs embedded in your .package? no problem.

Make use of any dll, such as discord rich presence integration and such!

And finally, replacing methods/hooking:

This very simple test script replaces the "OnMotherlode" method with a custom one.

Why is this exciting? This wasn't possible before - to do something like this you'd have to make a core mod, which has a lot of compatibility implications and I believe has really held back what we can do with script mods. Well, no more!

This is still a WIP, but the hope is that eventually not only we will be able to replace functions but also Prefix and Postfix custom code into existing ones, so mods can modify or add on top of the same code and still work together!

I'm personally super excited to make something cool with all of this new stuff, and look forward to de-coreify things and improve some of my existing mods (Random Sim Fixes comes to mind, could REALLY benefit from this)

[TS3] Mono debugging, method replacement!

Comments

This sounds fabulous. The TS3 community is really fortunate to have you here. <3

Nenelle


More Creators