I'm a live coder and sometimes I also like to play video games. As usual I like to offer my community some interaction in my stream. As I want to play Valheim, I started to develop a mod so that my viewers can interact with me directly in game. I made a first version without a graphical interface, with a nodejs server that handled the connection to Twitch and that communicated with the mod in Websocket. It was not easy at all for the end user to install and configure it. After one of my viewers told me about the Twitch Channel Points Hackathon I decided to make a new version by integrating everything in the mod and offering a GUI to configure anything directly in game.
Fun fact, I spent more than 150 hours coding this mod and less than 80 playing the game...
What it does
- In game Twitch authentication.
- Create managed reward in game. (Edit is planned)
- Auto enable/disable managed reward when the game start/stop/quit.
- Viewers can :
- Print a message in the HUD (center or top left).
- Send a message to the broadcaster via Hugin (the crow in the tutorial).
- Change weather for a predefined duration.
- Start events for a predefined duration (ex.: blobs horde).
- Spawn different entity (more or less aggressive, Troll, Boar, etc..) configurable in game by the broadcaster.
How we built it
By turning a lot of coffee into lines of code. More seriously I started to learn Unity and C# for this project. Unfortunately Valheim doesn't provide modding out of the box so I also had to dive into the world of BepInEx and HarmonyX. Another important ingredient is my community. The whole project was done live on my Twitch channel with the daily support of my viewers. Only happiness ❤
Challenges we ran into
If you watch my replay you will see that every day was a challenge.
First I had to setup a build for Valheim modding (almost no documentation) with a language I didn't know, dealing with different versions of Unity/Mono/.Net etc..
Then I had to figure out how to integrate a custom UI. I first tried to code the interface directly in C# but I quickly realized that it's a huge task. So I found a solution to make my interface directly in Unity and export my prefab as a DLL that I could embed in my mod.
The next challenge was to find a WebSocket library that works in my particular setup. After several tries I finally found my happiness and I could start to code my own Twitch Auth lib.
Last but not least I had to find the in-game actions and make it work together. Be able to configure actions, channel points and save state between game sessions.
Accomplishments that we're proud of
The whole project was a challenge and I am very proud to have overcome all the steps with the help of my community without whom I would never have gotten this far!
What we learned
What's next for Valheim Twitch Mod
- Take advantage of other Twitch events like raids, sub, gifts, etc...
- Integrate quests proposed by the audience such as picking 100 flowers in less than 15 minutes under the pressure of 15 trolls.
- Since I published the mod on Nexus & Thunderstore I have a lot of feedback and requests to add interactions. I'm looking forward to see how far we can go.
P.S.: Sorry for the poor English this text is translated with www.DeepL.com/Translator (free version)