dnSpy – Cheating Unity games (Monster Train)
In most cases, if you want to cheat single-player game, you will reach out to a good old Cheat Engine. Learning curve is pretty short (at least for some basics), so it is not unusual that Cheat Engine was our first pick when we tried to cheat Monster Train. However, for some games, it can be real pain it the a*s to find the correct addresses where some game values are stored (for example, gold). In that case, it is sometimes easier to change the game logic directly.
So, how can we edit the game without the source code? How can we edit which is already compiled? Luckily for us, some smart people already created a tool which can help us.
dnSpy is a debugger and .NET assembly editor. You can use it to edit and debug assemblies even if you don’t have any source code available. With dnSpy, you can:
- Debug .NET and Unity assemblies
- Edit .NET and Unity assemblies
- Edit methods and classes in C# or Visual Basic with IntelliSense, no source code required
- Add new methods, classes or members in C# or Visual Basic
dnSpy can be found here: https://github.com/dnSpy/dnSpy
So let’s see in practice how we cheated the Monster Train.
Monster Train gold cheat with dnSpy
If you happened to like Slay the Spire, you’re gonna love this. For a long time, we have tried to find a decent replacement for the Slay the Spire game. Although this game doesn’t have a Slay the Spire-ish depth, it is a great roguelike deck-building game, and you won’t make a mistake if you try it. You can find the more info about the game on Steam: https://store.steampowered.com/app/1102190/Monster_Train/
Monster train can be unforgiving if you made a wrong choice during the deck building, so we had to cheat it. 😀 As mentioned before, pinpointing the GOLD address was real pain in the a*s, so we had to change a function for adjusting gold in the game. So let’s see how it can be done:
- First of all, open the dnSpy, and open (Ctrl+O) Assembly-CSharp.dll which is usually located in X:\SteamLibrary\steamapps\common\Monster Train\MonsterTrain_Data\Managed. If you are not sure where your game is installed, you can right click on it in Steam interface, and click on “Manage – Browse local files”.
- After the Assembly-CSharp.dll is loaded, you will see a shitload of classes, methods, and other unfamiliar stuff (unless you are a developer). With dnSpy, you will be able to change some methods , and compile it back into the original file. Right now, we only wants to cheat gold, you let’s find a method which adds the gold. You can search for it manually if you are curious – if now, please follow the pictures.
- Click on this:
- After that, find the SaveManager, and after that, you will find “AdjustGold” method.
- Right click on it, and select the “Edit Method C#” option. You should see something like this: –
As you can see, this method takes gold amount as a parameter, and returns the changed value. If you are not programmer, don’t be afraid. It looks more complicated than it really is. So, let’s change the logic of this function. for example, we can add this line to increase our gold for 1000 every time this method is called.
amount += 1000;
So our code should look like this:
- After you have tweaked the method, click on the “Compile” button in the lower right corner. The window will close, so just click on File – Save all (or press Ctrl + Shift +S).
- And that’s it. You have successfully modded your Monster Train game. Open the game, and enjoy. Using the same method, you will be able to cheat almost all Unity games.