Combat - AnduoGames/ThirdCrisisModding GitHub Wiki

Start a Combat

To start a combat, you need to create the enemies, setup the required combat data and create a CombatStarter component on a new GameObject:

// Note, that shouldClone: true is important here, so that each enemy has their own health pool instead of a shared one.
var soldier1 = CharacterHandler.Create(Character.Get("Soldier"), shouldClone: true);
var soldier2 = CharacterHandler.Create(Character.Get("Soldier"), shouldClone: true);
var soldier3 = CharacterHandler.Create(Character.Get("Soldier"), shouldClone: true);

var combatData = new Asuna.NewCombat.CombatData()
{
    InvolvedCharacters = new List<CharacterHandler>()
    {
        soldier1, soldier2, soldier3, Character.Get("Jenna").Handlers.First()
    },
    PathfindingData = new ANToolkit.Pathfinding.ANPathfindingData()
    {
        Center = new Vector3(2f, 10f),
        // This defines the size that the involved characters can traverse
        Width = 50,
        Depth = 50
    },
    EndCondition = EndCondition.DefeatEnemies,
    InvolveParty = true
};

var combatGameObject = new GameObject();
var starter = combatGameObject.AddComponent<Asuna.NewCombat.CombatStarter>();
starter.data = combatData;
// This instantly starts the combat
starter.Fire();

Asuna.NewCombat.Combat.OnCombatEnd.AddSingleTimeListener(result =>
{
    if(result == Asuna.NewCombat.CombatResult.Victory)
    {
        Debug.Log("Player won the fight!");
    }
});

Set a Characters Faction

To set the Faction of a Character, the easiest way is to get a Character who is already in the Faction you want and assign it from there:

var jewel = CharacterHandler.Create(Character.Get("Jewel"));
jewel.Character.SetOverrideFaction(Character.Get("Wildfire").Faction);
⚠️ **GitHub.com Fallback** ⚠️