Skip to content

Overriding Methods to Add New Functionality

Alex Neargarder edited this page Feb 21, 2024 · 2 revisions

Class Structure of Broforce Bros

Broforce bros have most of their code in two classes "TestVanDammeAnim" and "BroBase". TestVanDammeAnim is the superclass of BroBase, and it actually serves as the superclass for the Mook class as well, which serves as the superclass for most enemies in the game. So the code in TestVanDammeAnim is somewhat more generalized to any sort of character that exists in the game, whereas BroBase is more specifically for the playable characters.

The CustomHero class is a subclass of BroBase, so if you create a class which inherits from CustomHero, you'll basically be working with all the methods you can see in there. BroBase basically uses Rambro's moveset as a baseline for the default behavior for the Primary, Special, and Melee attacks. If you look at Rambro's code you'll see that he doesn't actually override almost any methods, because all of his code is builtin to the BroBase class. So if you create a class which inherits from CustomHero, you'll get all of Rambro's moves as a default.

Overriding Methods

If you want to add your own custom behavior to a bro, then you'll need to override the BroBase / TestVanDammeAnim methods. This wiki isn't meant to be a programming tutorial, so if you are unfamiliar with the concept of overriding methods then I would recommend looking for a tutorial elsewhere. The syntax for overriding methods should be something like this:

protected override void Awake()
{
    base.Awake();
}

When you are looking to add a new Primary, Melee, or Special to a character, then I would first recommend trying to find a similar type of ability in the existing Broforce codebase.