Modding EtG: Creating a Mod
Last updated
Last updated
Although this video is outdated as it specifies how to set up a mod for Mod The Gungeon (the old mod loader), it is still useful to set up the Visual Studio for Gungeon modding.
Enable .NET 3.5 in your operating system by going to Control Panel > Programs and Features > Turn Windows Features on or off, and select ".NET Framework 3.5 (includes 2.0 and 3.0)"
Install Visual Studio 2022 Community at https://visualstudio.microsoft.com/downloads/ for your workloads, select “.NET desktop development” and “Game Development with Unity”
For the individual components, choose these:
Once that is done, go to this link (https://github.com/SpecialAPI/BepInExExampleModItems), and download the files by clicking on the "Code" tab and pressing "Download ZIP".
Once you have downloaded it, unzip the file and place the folder into your "repos" folder (Usually found at C:\Users\YourName\source\repos)
Your file structure should now resemble something like this. Note that you can rename the folder your project files are in, it doesn't have to be "BepInExExampleModItems-main"
Double-click the file called "Mod.sln". This will open your mod project's code. When you first open it, it is near-guaranteed that you will see a lot of errors, so do not panic. You will need to toggle some stuff for the errors to clear away.
To start, right-click the "References" tab on your side and select "Manage NuGet packages".
Select the "Browse tab".
Select the gear on the right side. (Circled in green)
A window like this should open up now.
Click the green plus button to create a new package, rename the new package to "BepInEx", and change the "Source" tab to this link: https://nuget.bepinex.dev/v3/index.json If you do not have a package that contains this link (https://api.nuget.org/v3/index.json), create a new package called "nuget.org" and use this link in the "Source" tab.
Once you have done that, Click Ok. Set your "package source" to "All".
If you have everything done right, you should now have no errors.
Now, go back to your module class.
Change "MOD NAME" to whatever the name of your mod is.
Note, Version should ALWAYS consist of ONLY 2 decimal points (for example, 1.1.4) as anything more OR less will not be accepted.
Now, replace the relevant parts of GUID. Note to NOT use any special characters or capital letters. each part of the GUID string represents a different thing. "creator": replace this with the creator's name, aka your name / whatever you refer yourself to online. "etg": do NOT change this, this represents the name of the game that is being modded, aka Gungeon. "modname": the name of your mod. TEXT_COLOR is a hex value of whatever color you want your mod's text to be in the F2 console when it is loaded into the game.
Your strings should look like this.
An issue that can occur if you do not change your mod's build name is that it will conflict with other mods. To fix this, go to the "Project" tab at the top and select "Mod Properties" at the very bottom.
Now, change the Assembly name and the Default namespace to a new name (preferably have both be identical)
Remember to save your project after with Ctrl + S. ALSO change any namespaces from your old default namespace name to the NEW one you just set. If you do not do this your mod will likely not build.
If your mod already contains an example item as well, go to the example items file, and change the file path there to have your new Default Namespace name (However I would personally name the Assembly and Default Namespace the same thing for convenience) instead of the old one.
To build your mod, go to the "Build" tab on the top of your screen and press "Build Solution" (The hotkey Ctrl + Shift + B or Ctrl + B will do the same thing)
To be able to run your mod, navigate to the "plugins" folder in Gungeons BepInEx files. (If you are using a mod manager like r2modman, go to settings and select "Browse Profile Folder", and navigate to the plugins folder from there.) Create a new folder in the plugins folder (the name doesn't really matter but for organization call it the name of your mod). You will be placing your mods .dll there (the DLL is the file that will have all your code and stuff for your mod). To find the DLL, go back to your mods project folder and open the "bin" folder.
From there, open the Debug folder. This folder will have a LOT of DLL files, so make sure to only copy the one you will need. Build your project if you haven't already, and find the file that has the name of whatever you set your mods Assembly name to.
Copy this .dll to wherever your mod folder (The one you made to put your mod's .dll in within the plugins folder) and place the .dll into that folder. Since your mod uses Alexandria and MTGAPI as dependencies, make sure to download those properly as well. Now, run the game. (If you are using a mod manager make sure to run the game Modded.)
If you did everything right your mod should log the start-up message into the F2 console.
Now install and launch Visual Studio. Again, a proper guide for it can be located in Kyle's video at the top of the page.