Banner and Crosspost

Home    Overlay   Discord   Mutators   Maps   Integration   Links   About

January 7, 2020

Fluffy Chatbot

Fluffy Chat Bot

In this post I want to look at the chatbot I wrote in Python – what it can do and how does that work. After that, let's see what more can be done with twitch integration I added to my [MM] maps.

Most of this bot's functionality has been integrated into Co-op Overlay. I recommend to check that one instead.

The bot

The core is a basic bot that executes common actions like linking twitter, this website, and so on. That's pretty boring. However, it also identifies mutators that are being played, and posts them into the chat. It then combines their Brutal+ difficulty score and calculates equivalent Brutal+ difficulty.

The bot first takes a screenshot of the area where mutator icons are, and then it looks for known mutator images via openCV template matching function. The function works similarly as 2D convolution. If the match is good, a mutator is found. Finally, mutators are sorted by their position on-screen, assigned descriptions, difficulty scores and posted in the chat.

The fact that their icons are always in the same position, of the same scale and orientation makes this problem relatively simple.

Game integration

Finding mutators was done purely via looking at your screen. I didn't use StarCraft API or interacted with the game in any way. However, you can do a lot more with some changes to maps. I added these following commands that affect the game directly (on my maps).

!message → sends in-game message

!join → viewer joins player army as a random unit.

  • !join 2  → joins your ally's army.
  • Repeated command usage will switch the unit.
  • Viewer kills are displayed on the mission score screen

I like !join command the most because it doesn't affect the game itself, but watching any game is more engaging if you see yourself in the game. And if you die, you get a notification showing your kills.

!mutator X → enables X mutator
(!mutator  X disable → disables mutator)

!spawn unit_ID unit_amount player_number → spawns units at player camera location
unit IDs can be found here

!resources res_amount player_number → adds or subtracts resources for the player

~ ~ ~

This game integration is done through StarCraft II's bank system. Maps have the option to save and small XML files on your PC with some data. This is usually used to saved preferences, campaign progression or map scores. In this case the chatbot is writing commands in one such file, and the map is periodically reading these commands, interpreting and executing them.

For streamers in-game:

  • -spawnlimit X → limits the spawn of units to X per command

Other notes

The bot is fully working, and I will use it when I stream. For me it's a fun project to learn more Python, work with the game, and see what can be done. Right now it's not easy to set up, but I'm including a link, so take a look if you want (

There are some issues, and while they don't affect me, they would have to be resolved for better portability (support for different resolutions and aspect rations, getting the compiled size down).

EDIT: I added a lightweight version that doesn't support mutator identification from screenshots, but it has basic commands that are configurable from the config file, and has full integration to MM maps. Compiled size to .exe file is small (~7MB).

Recent posts



Powered by Blogger

Main post