Learning game modding

Written by on Modified on Read time: 4 min

ChilloutVR describes itself as a social sandbox game. If you’ve heard about VRChat it’s really similar. If you’re older, think SecondLife but in VR. If you’re younger, think Roblox but VR with a focus on socializing.

Modding update

The big selling point for CVR for me was that they promised that modding would be allowed, and the developers delivered in 2021 with the developer update 6.

I got quite excited when that update landed, since I was quite burned out by the state of VRChat modding; It’s officially not allowed by the VRC developers, there’s loads of closed source clients and malicious code, and a whole modding scene that tries to moderate things.

While investigating the injector that the VRChat mods used, MelonLoader, I found BepInEx by browsing the dependencies.

The reason I didn’t just go for the same obvious thing as VRChat used was wine/linux compatibility. MelonLoader requires dotnet framework. Meanwhile the current LTS of BepInEx didn’t.

Also just the fact that BepInEx had a stable branch that worked, and the development branch with all the fancy new features indicated some project matureness to my mind, whereas MelonLoader required their alpha releases to even work with VRChat.

Starting out

The obvious first step is to even get the thing to run. BepInEx and MelonLoader both target Unity instead of invidual games, so there are a few universal (not game specific) mods/plugins for both.

BepInEx Config Manager

So I downloaded the windows Mono version of BepInEx, moved it to the game folder and launched the game once. I then grabbed sinai-dev’s awesome UnityExplorer, and moved it to the plugins folder to ensure that the injecting worked.

And it just worked, without any weird wine prefix dotnet installation on my linux machine just like that.

Meanwhile the VRChat experience required loads of fiddly tweaking with installing dotnet48 and adding version in winecfg.

Writing the first plugin

The first plugin of course was a hello world. Just figuring out the very basics. Thing is though, I don’t use Visual Studio, so I stumbled for quite a while on setting up the propper project. Today I’ve got my properly setup msbuild Directory.Build.props, but I had to build all of that manually, while referencing other open source projects I could find from the internet for help since the Microsoft docs aren’t all that helpful.

After I tested that everything worked and that I could successfully compile and use the plugin, I set out for my initial goal: push to talk from my mouse side button instead of the default “v” keybind.

One problem though; I had no idea how to do that. I knew how to detect the mouse button keypress, but how would I make the game turn the mic on?

Figuring out how the game works internally

So I looked around the internets and modding discord groups. Many people seemed to recommend an archived tool from github called dnSpy. That didn’t have any linux releases though, so I ended up downloading it onto my Windows laptop, as AvaloniaILSpy, the tool I found that did work on Linux, didn’t seem as useful or stable.

Starting out, I had no clue how to use dnSpy. Eventually I did find a search bar though, and found some methods and fields that seemed related to it trough the very helpful analyze function.

So I wrote my own code in an Update function, and it worked! It was a really exciting sight to see that I could modify how the game worked, and improve it.

Harmony patching

Later on, I needed to figure out how to make some methods not run at all at times. So I ended up reading a lot about Harmony, and eventually figured how to use it.

It’s really powerful, and with it you can for example patch getters and setters for fields even. Or just use it for simple cases to run your code right after some game code runs, or like mentioned before, run your code before the function runs and possibly even stop it from running.

A really helpful pattern in my opinion is creating postfixes for game methods to override some things they did - that way you don’t fully disable the game code that might be updated with added functionality in the future, whilst still being able to overwrite things and achieve your goal.

Shameless plug

Of course I need to plug my things, like the discord server I created for ChilloutVR modding, where you can come ask for help, discuss modding, or just overall follow the scene of modding ChilloutVR if you’re interested in it.

And last but definitely not least importantly, a link to the ChilloutVR plugins I’ve created.

I’m not affiliated or representing ChilloutVR or Alphabet Interactive if it wasn’t obvious to someone. I’m also not a lawyer, and am not giving legal advice. It’s up to you to figure out if you’re legally allowed to do the things described in this blogpost. I am quite sure though that if you try to modify the game maliciously, you’ll get banned quite quickly.