Twitch streaming is a popular thing nowadays, and an ever-important aspect of that is interacting with your viewership or community. So we wanted to make something fun in which viewers (from anywhere, not just Twitch!) can influence your gameplay with random events.
What it does
ScrewThisGame provides a platform for people to register any game with a supported mod, which will then be hooked up and ready to go for their viewers to send a multitude of commands to, which will be periodically received and shown in the game. This involves spawning enemies nearby, adding (de)buffs, throwing your item on the floor, chugging a potion, teleporting you home, and whatever else we could get our hands on in each game mod.
How we built it
To make it 'platform-centric', and extensible, we had to avoid the monolith:
the frontend, platform bots (Twitch/Discord), and Twilio can be used to pipe peoples chat commands to a:
Backend server, which maintains a queue of commands for each user's game. This handles clients registering their games and receiving an ID.
Each game pops some HTTP to the backend to take some items from its queue, for that client.
The game mod receives the packet and interprets it accordingly. That's all there is to it.
The frontend displays all available games to screw up, with very spammable buttons for each 'event' viewers can send to the game.
We decided to split the workload, so each person would take on a sub-category of the work, working on individual functionalities. For example, Toby wrote the backend, while Daniel wrote the frontend.
Challenges we ran into
Currently, 3 game mods are supported: TF2, Minecraft and Terraria, the latter two having quite undocumented APIs, relying a lot on experience to work your way around the modding environments. This meant doing certain tasks became a game of cat and mouse trawling through large amounts of decompiled game source looking for relevant functions or props. Good luck working out what
if (num78 == 22) num79 = ... is supposed to mean!
Accomplishments that we're proud of
Supporting a relatively large amount of games in a short space while rolling the infrastructure for the entire system is a feat we're really happy with. Especially given writing the Minecraft and Terraria plugins was totally new ground for the entire team.
What we learned
Terraria's modding environment was completely new to us, while being generally unfamiliar with C# other than "it's a bit like C++", and that ended up being really fun once we got the hang of game events and decompiling traces.
All of Minecraft's APIs changed significantly since the last time any of us ever looked at it, so that was quite the rabbit hole of problem navigating through a sea of not-documentation.
For the backend, we learned how MongoDB Atlas worked, given none of have ever used it before. SpringBoot was new to two of us as well, and it was nice to see another viable alternative to Node's Express server.
We also learned how to incorporate REST into the Source Engine via TF2's plugin - REST and HTTP is not a default function of source, instead requiring a C++ extension in order to expose the net API functions to SourceMod plugins.
What's next for ScrewThisGame
The platform is already extensible for new mods to be added, so adding mods for new games that we didn't have time for - Don't Starve Together, Factorio etc. - any survival, open world, sandbox style game with a nice API would be perfect for this.
Improvements to all the mods are planned, to make more complex events available beyond our 24-hour expertise of these mod APIs.
The backend could also be made to be more parameterised and flexible.