Adventures in Modding Re:Legend

The game 'Re:Legend' released a few days ago into Early Access, and just like any other normal person my immediate first thought was: Can I mod this? And if so, what can I actually change?

Getting Started with Modding

As the game had no modding API that was visible, the only thing I could do is to figure out what tools I need for injecting new code. And as the game is made with Unity, the same engine that Risk of Rain 2 runs on, I figured I could reuse the toolset from there.

Knowing which .Net SDK to use is half the battle.

All I needed to figure out was which .Net version the game was compiled against, and there was a handy tool for it: Detect It Easy. Loading the Assembly-CSharp.dll into it revealed that the game was built against .Net 4.0, which means that I needed a BepInEx compatible with Unity 2017 and newer.

Thankfully there was a release candidate which actually ended up working: BepInEx 5.0 RC1. After extracting the Unity 2017+ version into the game directory (directory that holds ReLegend.exe) and configuring BepInEx to show a console, I had confirmation that I could load mods. Now it's time to actually get into modding!

Disassembling Assembly-CSharp.dll

If you aren't familiar with Unity, the binary Assembly-CSharp.dll holds compiled and usually optimized compiled game code written in C#, and also usually contains most dependendencies that don't have their own .dll file. So what we need is a disassembly tool that can deal with optimized compiled code and give back a reasonable representation of the actual code.

ILSpy in action.

After a bit of searching for a C# disassembler I decided to use ILSpy, which performed the task better than most other tools and did not crash no matter what I threw at it. Loading Assembly-CSharp.dll into it gave me a near instant disassembled version of the game code, although mostly lacking comments since those get removed.

All that was left was to figure out what to remove first, and how to do it. After some time, I figured that my first mod should be to remove the Tutorial popups and instantly unlock tutorials in the menu due to them often opening up in bad situations in Multiplayer.

Coding the Mod

With the information from Detect It Easy and ILSpy, and some knowledge of BepInEx and 0Harmony, getting a mod to load was pretty easy. The problem was getting it to do the actual right thing, without breaking the game. And the Tutorials were already known for literally freezing players in place if you skip them too fast.

A little while later after delving into the disassembled code, I found the place that I needed to modify: global::TutorialManager::StartDisplayTutorial. The functionality that it currently had was to enable the tutorial panel, disable quitting the game, stop all player interaction, search and initialize the tutorial, unlock the tutorial and then finally set up the UI and display it. We don't want it to do anything but unlock the tutorial.

Skipping Tutorials made easy - they don't even show up now!

As TutorialManagers UnlockTutorial was private, but the unlockTutorials List was not, the override was a simple as just calling SearchTutorial, then adding the tutorial to the unlockTutorials List, and finally just calling EndTutorial().

The Aftermath

With one of the most annoying ways to show tutorials out of the way, the game was much nicer to play, and I had my first experience in modding Re:Legend. I got a bit modding-crazy and made additional mods, like disabling the crafting failure with cooking which seemed to be arbitrary, and attempting to allow players to move while attacking. Unfortunately the latter one failed, but the former one did also work which made the cooking mechanic less dumb.

I've released all the code and mods I've made on GitHub for you to try out. Installing them is easy, there's even a guide on the wiki for it. Building them yourself is a bit different, you will need CMake, Visual Studio 2017 or 2019, .Net SDK 4.0 and the game. But it's not rocket science so it should be pretty easy to build them yourself.

I had a lot of fun writing mods for this game, even if the game itself had no official modding API, and I hope that my delve into Re:Legend modding helps future modders do more amazing stuff than I did. I'd love to hear about what you've done, so feel free to hit me up on Twitter, in the Comments here, or on Discord.

Until next time

- Xaymar

Comments for: Adventures in Modding Re:Legend