Koikatu: Modding
Most of the up-to-date modding resourced and guides are shared on the Koikatsu Discord server. This is also where you can find most of the English speaking modders working on Koikatu plugins and mods.
Contents
Condensed guide on making plugins
First of all, environment. You need:
- Visual studio 2017 or newer, use the free community version
- KK with BepInEx installed
- Cheat tools plugin (for the included Runtime Unity Editor, press F12)
- dnSpy for reading game and other dll source code and debugging of the game (To do debugging with dnSpy you need to set up a few things for it to work * https://github.com/BepInEx/BepInEx/wiki/dnSpy-Debugging * this is optional and you most likely won't need it until you're doing much more advanced stuff)
- Go to your in-game plugin options and enable bepinex console and all logging levels, including unity logging
Getting started
- Get to roughly know C# and how it works. There are plenty of tutorials on it.
- Grab a simple plugin, for example https://github.com/DeathWeasel1337/KK_Plugins/blob/master/KK_ClothingUnlocker/KK_ClothingUnlocker.cs and see how it's constructed. Try to compile it.
- You need to fix the plugin's references before you can build (point it to dlls from your game install) and build locations (right click on the project in tree view > Preferences > Build).
- Use BepInEx.Logger.Log for showing messages in console
Things to read
Critical
- https://docs.microsoft.com/en-us/dotnet/csharp/getting-started/
- https://github.com/BepInEx/BepInEx/wiki
- https://github.com/pardeike/Harmony/wiki
Optional
- https://github.com/ManlyMarco/KKAPI/wiki
- https://github.com/bbepis/BepisPlugins/tree/master/ConfigurationManager#how-to-make-my-mod-compatible
- https://help.github.com/en/articles/set-up-git
- https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/04/setting-up-and-using-github-in-visual-studio-2017/
- https://github.com/0xd4d/dnSpy/wiki/Debugging-Unity-Games
Tips
- KK is a Unity3D game and is written in C#, skills you gain here will apply to almost all other Unity games
- Koikatu_Data\Managed\Assembly-CSharp.dll has most of the game code in it, open in dnSpy to read and research it
Quick debugging tutorial using dnSpy
Running the game in debugger makes finding causes of issues and understanding how the game works much easier. To run KK in the debugger included in dnSpy you need the following files. The archive contains mono.dll library modified for debugging and BepInEx patcher that is required for the debugging to work correctly. By using the patcher you can no longer use preloader patches in BepInEx, but they have not been used by any plugins so far as far as I know.
More info:
- https://github.com/0xd4d/dnSpy/wiki/Debugging-Unity-Games
- https://github.com/BepInEx/BepInEx/wiki/dnSpy-Debugging
To install just extract the files into game directory and run the patcher. Next, open dnSpy, drop Koikatu.exe on it, click the newly added .exe, and click Start. It should start running the game and dnSpy should enter debugging mode. You can open assembly-csharp or one of your plugins, place a breakpoint at some line and make the code run in game to test it out. Locals are the variables available in the current scope, Watch contains your expressions (you can put arbitrary C# code in these and it will get executed when you hit enter). It's pretty similar to debugging in VS, just more limited.
When you recompile a plugin that is loaded in dnspy then make sure to go file > reload all. If you changed code where a breakpoint was set, then it might mess up and move the breakpoint to some different spot. You can check where all breakpoints are in the breakpoint window.
Adding new items / mod making
Because of the large scope it's difficult to provide a simple step-by-step guide. There are multiple guides available on the discord server in the #mod-modelling channel. You can also ask for help in learning in that channel.