BepInEx Mods: Create a new Battle Action

From Astrea Wiki
Jump to navigation Jump to search
  • Download Astrea BepInEx Mod Template. This template comes with an example of how to Create a new Battle Action (that can be used on dice or virtues).
  • On the folder Patches/BattleActions there are two useful scripts, "BattleActionExample.cs" and "BattleActionCreator.cs".
    • Use "BattleActionExample.cs" as a template for creating new Battle Actions. This battle action example is an action that deals X Purification to an enemy and then reroll the enemy dice.
      • Change the name of the file and the class to the name of the action.
      • Use the function SetupModdedBattleAction() to add the data of the battle action, like name, description, input, etc. Inside the function itself there are instructions on how to fill each parameter.
        • The sprite parameter need to be changed to the name of the image that will be used on the battle action. Just change the "PurifyEnemyReroll.png" string to the name of the image. This image need to be added to the Resources folder that is located on the root folder of the plugin. Use a 512x512 pixels image. In the example the "PurifyEnemyReroll.png" is located on the Resources folder.
      • Add the logic of the action by overriding one of the following functions depending on the target and value of the action. The example uses the CastTargetAmount function because it is a single target battle action (deal Purification to a single enemy) and a battle action with a value (deal X Purification).
        public virtual void AreaCastTarget(List<GameObject> targets, GameObject source) { }
        public virtual void AreaCastTargetAmount(List<GameObject> targets, int amount, GameObject source) { }
        public virtual void CastTarget(GameObject target, GameObject source) { }
        public virtual void CastTargetAmount(GameObject target, int amount, GameObject source) { }
        public virtual void CastAmount(int amount, GameObject source) { }
        public virtual void Cast(GameObject source) { }
        
      • You can create as many battle actions as you like on the same plugin.
    • Use "BattleActionCreator.cs" to create/inject the battle actions in game. For each battle action that you created you will need to call the following function using the name of the battle action:
      __instance.CreateBattleAction(new BattleActionExample());
      
  • After creating the battle actions and building your plugin you can use it in game by adding the battle action to a die that already exists following this guide Modify Die or to a new die following this guide Create New Character Die.

Note1: You will notice there is a class called ModHelper that is being used on this example. This class was created by the devs to make modders life easier, there are already a few functions that will help modding, but devs said that they can add more functions and references if modders request them.
Note2: The Astrea BepInEx Mod Template also has a small example on how to use HarmonyX on the class BattleActionCreator.cs.

Go Back to Mods page: Mods