This is a Python application that allows you to play 1st generation Pokémon games while your Twitch viewers influence the game by voting. Viewers can help or hinder the player's progress.
This is not a "Twitch Plays Pokémon" implementation.
This project is not affiliated with Nintendo or Game Freak. Pokémon character names are trademarks of Nintendo.
The application consists of several layers:
- PyBoy - Python GameBoy emulator
- Twitch Bot - responsible for accepting votes and commands
- Web layer - displays polls and results; this can be further divided into the web server, websocket server and JavaScript layers. The web app is a simple Vue.js application.
- Core application - manages game modification
- State tracker - outputs state txt files into the state folder (which can be) used to display information on the screen when streaming.
In order to run the application, you need to follow a few setup steps.
- Python 3 + pip
- Your own ROM dump of Pokémon Red or Blue
- Install PyBoy and SDL2 following the official instructions
- Clone or download this repository
- Install dependencies with
pip install -r requirements.txt
(you can first optionally setup a virtual environment) - Duplicate
config.ini.example
and rename it toconfig.ini
to create your main configuration file - Make an account on Twitch that will function as your bot
- Request an oauth code and set it as the
IRCToken
in your configuration file - Register an app with Twitch Dev
in order to get a client id. Add it in your configuration file as
ClientId
. - Set the remaining configuration values:
Nick
should be your bot's nickname,Channel
the name of your channel (usually your Twitch username) andPrefix
which will be used for your chat commands (!
by default) - Copy your ROM file into the folder, and set the
FileName
in the config file - If you update the WebSockets port in the config file, update it in the JS file too!
Once you have completed the inital setup, you are ready to launch the application:
python app.py
Several things will happen here: PyBoy will launch the game, local web and websocket
servers will launch on port 8888
and 8765
respectively, and your Twitch bot will
come online. You should see a message on Twitch indicating its readiness.
You can now display the current poll by going to http://localhost:8888
. If you
use OBS Studio, you can setup a Web View that displays that page as part of your
layout.
While you play the game, several different polls will be presented to your viewers. There are two main types of polls: overworld and battle polls. Each viewer can vote once in one poll, but can vote in as many polls as they want. Whenever someone casts a vote, they earn a point. Points can be spent to instantly influence the game.
Votes are cast using the !vote
command in chat, e.g. !vote Cubone
.
Points can be spent using the !spend
command. Currently, the following actions
are supported:
dark
(5 points) - makes it dark in the current areaheal
(5 points) - heals main Pokémonpoison
(10 points) - poisons the first Pokémon in the partywild
(10 points) - triggers a wild Pokémon battle (when in tall grass / inside a cave)summon [PKMN]
(20 points) - summons a specific Pokémon (when in tall grass / inside a cave)playername [NAME]
(50 points) - changes the Player's name to[NAME]
It's a good idea to display the above as part of your layout so that viewers
know what they can do and how much everything costs. They can also check how
many points they've acrued by using the !points
command.
This is a very early version of the project, and therefore the codebase isn't the cleanest. If you would like to contribute, feel free to send a pull request.
If you're thinking about doing some code restructuring, it's best if you first discuss that by creating an issue on GitHub.
A lot things were quickly put together, especially the web part because it only needs to run locally, so not many optimisations have been considered.
GNU Lesser General Public License