In this blog post series I will show you how to develop your first mod for the early access title "Valheim". We will use a framework which injects .dll files into the game called BepInEx.
To start off; you of course need access to the game, because there are (probably) game files you'll need to create your own extension of the game. You can buy the game currently on Steam.
In theory, for a basic mod you will need these .dll files, marked blue are found in within the game files and red are from the development framework BepInEx.
My IDE of choice here is Visual Studio, which you can get here. Theres no further changes you need to do for the IDE, so set it up as you please. We later on need to add references to the .dll files, but I'll get to it later.
Everything needs a beginning
And my choice went to the super simple plugin by Quinn Wilton called "Valheim Chest Search". I will use this project (with permission to use, thank you!) as a starting point on how to setup the IDE and then (slowly) begin on a) extending previous work by other and b) starting developing your own ideas. :)
Also I will view your game as already modded. Meaning you have BepInEx successfully installed for your game. I will not show you how to do that, as there are many guides for this on the internet.
Setting up the IDE
After configurating the IDE to your liking, you may start the given project (see above) in VSC (Visual Studio Code), usually by double clicking the projects solution file (.sln).
At the time of writing this post, the latest commit to that repository was this version. So if anything looks different, write me in the comments and remind me to update the post (which I might do ;P).
So.. you open the project file and take a look at the code. You maybe open the projects "Chat.cs" file to take a peak. You think to yourself (looks good to me) and you want to build that project. So you click on "Build" and then "Build project" (Hotkey CTRL+SHIFT+B on Windows), but then yiiiikes.. the error log is filled with .. errors.
An error occured.
What happened? That project referenced stuff thats hidden in other places. Not other source files which you are missing but rather .dll files, the ones we talked about earlier. ;)
How can you tell? Look at the code and see how theres lines with red underlines? The IDE is smart and wanted to show you. :)
We open up the "References" Part of the Projects solution in the (default location) right part of the IDE. The referenced marked with a yellow symbol are the ones the IDE is unable to find.
So we right-click the "Reference" and select "Add Reference" in the context menu. In here you want click the "Browse" Button on the bottom and search for your missing .dll files. The files marked in blue you will find in the games install directory under \steamapps\common\Valheim\valheim_Data\Managed.
The files marked red you need to fetch from BepInEx. Download the latest release from GitHub and extract the .zip file to some convenient location.
Show the IDE those files aswell. They are within \BepInEx_x64_184.108.40.206\BepInEx\core (the folder is called 220.127.116.11 because thats the latest release for me!).
After you've done this, you can build the project and everything shouldnt explode on you. The produced .dll file should reside in \ChestSearch\bin\Debug (or Release folder, depending on whether or not you switched the build) called ChestSearch.dll.
Load the .ddl file into the game, by copying that file to the plugins folder of BepInEx (\steamapps\common\Valheim\BepInEx\plugins)
Loading the created in the game yields that the .dll works as advertised.
Part 2 will show you how to edit the given project. Part 3 will then be a completely new project. Stay tuned!