Skip to content

Creating a Bro Via Programming

Alex Neargarder edited this page Jul 26, 2024 · 8 revisions

Getting Started

First you'll want to setup your development environment. Here are some of the tools I would recommend:

After you've installed at the very least Visual Studio or some alternative, I would recommend looking at my Github Repo to see some of the custom bros I've created as examples.

Creating a new Bro

I created a Bro Template which I use when starting a new bro, as well as a script that copies the Bro Template and renames all the files to the name of my new bro. You can find this script in my Scripts folder of my repo. If you want to use this script you can just modify the variables for broforcePath, which should point to your BroMaker folder, and repoPath, which should point to the repo you cloned.

The JSON files for this Bro Template can be found here, as well as some placeholder Rambro sprites, if you replace these sprites with your own they'll show up in game.

If you don't want to worry about all of that, I would just create a new Visual Studio project, and be sure to choose the Class Library (.Net Framework) option. Then you'll want to add references to the .dll files for BroMakerLib and UnityEngine.

The minimum code you need to actually create a bro is simply this

namespace Bro_Template
{
    [HeroPreset("Bro Template", HeroType.Rambro)]
    public class Bro : CustomHero
    {
    }
}

If you add that code to your Visual Studio Project, compile it, and then create a small JSON file and mod file to load your assembly, and then place all those files in a folder in your BroMaker_Storage folder, you'll have a starting off point for creating your bro. With only this code, your bro will basically behave exactly the same as Rambro.

Other Details

Automatically Loading Changes to .dll Files

You may notice if you looked at my Bro Template JSON files that I have a .bat file in there called "CREATE LINK.bat". I use these when I'm working on Custom Bros or mods. Basically they create a symbolic link between the .dll in my bin folder wherever my repo is, and the folder where the .dll actually needs to be in order to be loaded by Broforce.

That way you don't have to manually copy the .dll file over every time you make a change. If you use this method you may notice that Windows likes to create these cache files though, which seem to get loaded instead of the actual linked .dll, so these will prevent your changes from showing up. To solve this I like to add a Post-build event command to my Visual Studio Projects that just deletes these caches, so every time I rebuild my project the cache files are erased, and I'm certain that I have the latest version of my mod ready to be loaded. This should look something like this:

del "%BROPATH%\Brostbuster\*.cache"

You may also notice that I have an variable there for %BROPATH%. I have this setup to shorten the path and also in case we change the path where Custom Bros are stored again sometime in the future. If you're using my Bro Template script then you'll want to either replace this variable with the path to your BroMaker_Storage folder, or just set it up as an Environment Variable on your system.

Another method to do all of this is to have Visual Studio run a command that copies your .dll to wherever you need it, which you can do with the XCOPY command.

Make Sure Not to Use Networked Functions

BroMaker doesn't currently support online multiplayer. The main reason for this is that all the networking functions don't like when we pass in a custom class that doesn't exist in Broforce's existing codebase. We have patches to detect if a networked function is being called with a Custom Bro being passed in, but if you're creating your own Custom Projectiles, you have to make sure that it isn't being passed to any networking functions, such as SpawnProjectileOverNetwork. So there may be some functions you'll have to override in your Custom Bro and Custom Projectile to avoid this.