Bloons Tower Defense 6 is a popular Tower Defense Game that originated as a flash game during the "golden ages" of flash games and has captured the interest of thousands of bored school kids in the computer lab and since spun out to be a very popular standalone game series, including a bunch of lore, spinoffs and, as comes par for the course, mods.
This modding scene is fueled not only by the many players, but also Livestreamers that showcase the mighty creativity many mods have introduced into the game. As the game was on multiple sales that dropped its price down to less than a couple bucks, so I picked the game up and after seeing a bunch of content creators stream the game live, checked if any Twitch-based integrations already existed.
The popular "ChaosMod" allowed live chat to effectively control the entire game by moving the mouse cursor and clicking on anything in the game - whilst this is fun, it's also very chaotic and can lead to chat "accidentally" spending hundreds or thousands of real money on the games' microtransactions. Thus, I set out to make an integration that allowed for similar amount of "chaos" by screwing with the Player whilst making sure chat doesn't spend last christmas' savings.
So a couple days before the start of the hackathon, the initial Idea of using Channel Points, which have the advantage of being highly moderateable and limited in quantity, thus making them the perfect candidate for screwing with the Player in a limited fashion - the announcement of the hackathon then kicked motivation into high gear!
What it does
By integrating into the game as a fully-fledged Mod using the popular "MelonLoader" Unity Modding-Injection Tool / API, this Integration seamlessly integrates into the game. Upon startup, a simple OAuth flow is executed and the relevant Rewards are created, allowing the Broadcaster to configure things like cooldown and price on Twitch, choosing exactly what they want to use or not and how often their audience can "help" them.
In a round of Bloons, viewers can then redeem the Rewards to achieve various effects like halving the Player's in-game cash, lifes or selling a random piece of their defenses - which can cause major issues if the Player is not paying close attention. If they are, however, strategizing against their viewers becomes an interesting game of out-witting each other by employing new and usually not so necessary strategies and making the best out of the random dicerolls the Rewards utilize.
How we built it
As mentioned before, the Integration is based on the "MelonLoader" Project, which allows "modding" of almost any Unity Game (that does not actively work against it) as well as the BTD6-Community-made "Mod Helper" that provides a good amount of utility functions to create abstractions of game concepts that are buried deeper within the games' extracted code.
With this as a basis, the remainder is a C#-based implementation of the Implicit OAuth Flow and listening to Reward Redemptions on PubSub, removing the need for any Third Party Server running to relay messages, triggering in-game events based on which Reward has been redeemed.
Challenges we ran into
As with many popular games, BTD6 is regularly updated, making Game Mods unstable throughout their lifetime as updates and internal refactorings of the code base make it hard to stay compatible, especially when the game does not provide any official Modding APIs to the community. However, as can be seen with this game and, for Example, Minecraft, the community usually is quick to do their best to provide updates when things break. It's hard for a library (like the Mod Helper) to be updated quickly, but the BTD6 Modding Community has matured to a point where multiple different people are collaborating to make it as smooth as possible for those looking to get into making and using mods for the current versions of the game.
This made it relatively easy to focus on integrating the things the Mod wants to achieve, even with my limited experience with modding games, C# and .NET.
Accomplishments that we're proud of
As mentioned, my personal experience with C# and .NET was effectively zero before this project, so the simple fact that it works and integrates as well as it does into the game (not requiring any external tools or system-popups) makes me feel incredibly proud, as other mods for different games in the past have always been a huge amount of work with config files and previous setup, whereas this is as simple as installing the mod like any other and then following in-game prompts to reach a usable state very quickly. One comparable thing would be the introduction of in-game manuals that are executed well in Minecraft, like Botania.
What we learned
I learned C# and just how active the BTD6 Modding community actually is! It can be tricky to initially find the correct resources / Discords, but once the main one (linked above) is found, it becomes quite apparent how many people are actively using a myriad of different mods - and the Twitch Community is just as much part of that as well!
What's next for Bloons TD6 Streaming Integration
I'll continue to try and work out bugs as well as adding more features/effects to the Mod as time moves along, since some effects were toyed with, but ended up not working the way I had hoped to. Additionally, it may be worthwhile to add more "beneficial" Effects that help the Player instead of working to their detriment, but it is hard to balance this, especially since the broadcaster is meant to keep configurability on the Twitch side, but that can then be easily abused and considered as "cheating" in the game, which I want to not advocate.