TestRunnerSRL / bizhawk-co-op

Syncs inventory, ammo, and more of multiple players for a coop experience
GNU Lesser General Public License v3.0
56 stars 41 forks source link

Bizhawk Co-op Netplay

bizhawk-co-op is a Lua script for BizHawk that allows two or more people to play a co-op experience by sharing inventory/ammo/hp over the network. This will work with vanilla versions of the games and also randomizers.

Metroid: Zero Mission Co-op

Health and ammo is shared. Items obtained by a player are given to everyone. Items locations are split such that each item can be optained by only one player. The other players will find a screw attack block in its place. The items at the unknown item locations, power grip location, and imago location can be obtained by either player. Events such as boss deaths are also shared.

Link to the Past Co-op

Items obtained by a player are given to everyone. Items locations are split such that each item can be optained by only one player. It's usually a good idea to spread out on the overworld and communicate which items still need to be checked by who. With Split Keys or Raid Bosses enabled, it's highly recommended to enter dungeons together. The following can are configurable:

Players Boss HP
1 1x
2 3.5x
3 9.5x
4 23.5x
5 55.5x
... ...

Ocarina of Time Cross World Co-op

Nothing is shared, however there are now player specific items which are mixed between all the worlds. So if you obtain an item for yourself only you get it. If you obtain an item for another player then only they get it. This effectively means everyone will be playing different intermingled seeds.

This works with the latest OoT Randomizer found on the website https://www.ootrandomizer.com and the latest major release of the source code GitHub. Set the Player Count to the number and use the same settings and seed. Each player should then set a unique Player ID (from 1 to the Player Count). The output filename should be the same for every player except the last number which indicates the player ID (excluding -comp). The logic will guarantee that every player can beat the game.

Setup

There are two different methods to install.

You will need the following:

Directory structure

The locations of files is very important! Make sure to put them in the right place. After unzipping BizHawk (1), you should be able to find the executable EmuHawk.exe, we will call the folder containing it BizHawkRoot/.

First, in luasocket (3), you should find three folders, a file, and an executable: lua/, mime/, socket/, lua5.1.dll, and lua5.1.exe. Place mime/ and socket/ in BizHawkRoot/, and place the contents of lua/ in BizHawkRoot/Lua/. Place lua5.1.dll in BizHawkRoot/dll/. You do not need lua5.1.exe.

Next, the bizhawk co-op distribution includes two important things: the main lua script bizhawk co-op.lua and a folder bizhawk-co-op/. Place both of these in BizHawkRoot/.

Once this is done, your directory structure should look like this:

(1) BizHawk-2.x/ 
(4)   bizhawk-co-op/
(1)   dll/
(3)     lua5.1.dll
        ...
(3)   mime/
        ...
(3)   socket/
        ...
(1)   Lua/
(3)     socket/
(3)     ltn12.lua
(3)     mime.lua
(3)     socket.lua

(4)   bizhawk co-op.lua
(1)   EmuHawk.exe
      ...

bizhawk-co-op Configuration

If using Bizhawk 2.2.2+, go to Config -> Customize... -> Advanced and set Lua Core to Lua+LuaInterface. NLua does not support LuaSockets properly. After changing this setting, you need to close and restart the emulator for the setting to properly update.

Once you have everything else properly set up, you can run the bizhawk-coop script to do some final setup before syncing and playing a game. To run the script in BizHawk, go to Tools -> Lua Console, and the Lua Console should open up. At this point, I suggest checking Settings -> Disable Script on Load and Settings -> Autoload. The former will allow you to choose when to start the script after opening it instead of it running automatically, and the latter will open the Lua Console automatically when you load EmuHawk.

Next, go to Script -> Open Script... and open bizhawk co-op.lua (it should be in BizHawk-2.x/ root.) Make sure you are running a game, and then double click bizhawk co-op (or click it and then press the green check mark) to run the script. The window has the following important configurations:

Make sure to click Save Settings, and you should be ready to play!

Syncing with bizhawk-coop

The host should first enter their name and password and click Create Room to host. Then the clients should click Refresh and select the appropriate room, enter their name and the room password, and click Join Room. The bizhawk-co-op script will run some consistency checks on your configurations to make sure you are running the same code. If these all passes then the players will be connected. So if you encounter any issues connecting to one another, make sure all players possess an up to date script.

Supported Systems

bizhawk-co-op will only run on a Windows OS because of BizHawk support.

Credits

Created by TestRunner.

BizHawk, Lua, Luasocket, and kikito's sha1 script. Lua, luasocket, and sha1.lua all fall under the MIT license.

Issues

If you have any problems with the script (and restarting BizHawk does not fix them,) contact me (TestRunner (@Test_Runner) on Twitter or on Discord. You can also submit an issue here on the GitHub.