Battle AI

The battle AI controls which actions an AI controlled combatant uses in battle.

All combatants that are not members of the player group are always controlled by AI – player combatants can optionally also be controlled by AI when set up that way in their AI settings.

Battle actions can be:

  • using the combatant’s base attack
  • using an ability
  • using an item
  • defending
  • escaping
  • changing members
  • etc.

Battle AIs are created in Battle > Battle AIs using the node editor.

How it works #

The battle AI, simply put, finds targets by checking for different conditions and uses defined actions accordingly.

E.g. checking your allies health and using healing items/abilities when it’s low, or abuse an enemy’s weakness to a certain attack modifier by checking the enemy’s modifier value and using an ability to exploit it.

Use Mode #

The battle AI can be used in two modes:

  • First Useable
    Uses the first useable action.
    The battle AI exits at this point and doesn’t process any further.
    I.e. the battle AI can only select one action each time it’s executed.
  • Queue
    Adds actions to the combatant’s AI action queue.
    The battle AI continues until the end.
    I.e. the battle AI can queue multiple actions to use them in order they’re added.

The use mode is defined where you select the battle AI to use, e.g. in the combatant’s battle AI setup and equipable AIs (AI behaviours/ruleset).

Additionally, you can define if a battle AI is used at all if actions are already added to the AI action queue at the start of the action selection. I.e. if there are actions queued from a previous turn, the battle AI can either process again (maybe clearing the queue or adding/inserting additional actions), or not process until the action queue is empty.

Using the AI action queue doesn’t mean that a combatant can perform multiple actions in one turn – that’s up to the used battle system and it’s setup.

Action Use Mode #

Action nodes (e.g. Ability or Item) can overrule the use mode.

  • Default
    Uses the battle AI call’s use mode (i.e. either First Useable or Queue).
  • Can Use Check Only
    Only checks if the action can be used and doesn’t use or enqueue the action.
  • Use
    Uses the action, exiting the battle AI and not executing any further battle AI.
  • Queue
    Adds the action to the end of the AI action queue.
  • Insert Queue
    Adds the action to the front of the AI action queue (i.e. it being the next action).

If none of the combatant’s battle AIs returns an action, the first action in the AI action queue will be used.

Finding Targets #

Check/condition nodes are used to find the targets and add them to the battle AI’s found targets – action nodes will use the found targets for their action.

If the found targets don’t match the target type of the action (e.g. an ability targets enemies, but the found targets only contain allies), a target will be selected based on the combatant’s AI settings, e.g. using the nearest target or the user itself (e.g. for defend).
In that case, the found targets are ignored and all possible targets (e.g. all enemies) are used for the selection. Also, an ability with a Single target range (i.e. targeting only one combatant) will only use one of the found/available targets.

Which Targets? #

Check/condition nodes have two important settings to define which combatants will be checked or kept as targets:

  • Found Targets
    Defines how already found targets (from previous nodes) will be handled.
    E.g. you can Keep them, Clear all previously found targets (i.e. remove all) or Check them and remove those who don’t match the conditions.
  • Target
    Defines which combatants will be checked by the node.
    E.g. all Enemy or Ally combatants, or None to check only the previously found targets (according to Found Targets setting).

There are also options to not use the matching combatants as found targets (e.g. to only check for conditions without selecting as targets) and other settings to manage target selection.

Remembering Targets #

You can store and load found targets to reuse them between battle AI executions, or during a battle AI’s execution to switch between different target groups.

Targets can be stored either for the individual combatant, or for the combatant’s group – this is controlled via the Group Target setting in the nodes:

  • Individual
    The targets are available in the combatant’s battle AIs.
  • Group
    The targets are available in the battle AIs of all members in the combatant’s group.

Targets are stored via a target key to identify them, i.e. you can store different target lists.

The Store Targets node will store the currently found targets, the Load Targets node will load stored targets into the current found targets. The Has Stored Targets node checks if targets are stored for a defined target key.

Example #

Check Status node checks for HP < 50% on the allies of the user. All combatants with less than 50% HP are now stored in the found targets – if any where found, the node’s Success slot is executed next, otherwise the Failed slot.

At least one target was found, an Ability node using a single target healing ability is connected to the Success slot and will use the ability on one of the found targets.

Combatant’s Setup #

A combatant can have multiple battle AIs – if none of the battle AIs results in an action, the combatant will try performing it’s base attack (or do nothing if that fails).

The default battle AI for all combatants is defined in Combatants > Combatants > General Settings in the Battle Settings > Default Battle AI.

Each combatant can optionally add additional battle AIs or replace the default battle AIs. When using both, the combatant’s battle AI is used first. The individual combatant’s setup is found in their Battle Settings > Battle AI.

Nodes #

The battle AI nodes are divided into different categories.

Action Queue #

Nodes to manage the combatant’s AI action queue, e.g. clearing the queue or checking the count of added actions.

Action #

Use actions like attack, an ability or item, defend, escape, etc.

If the action can be used, based on the battle AI call’s Use Mode and the action node’s Action Use Mode, the battle AI will either exit at this node and perform the action, or continue to the next node.

If the action can’t be used (e.g. due to an abilities use costs or because the user’s inventory doesn’t contain the item), the battle AI continues at the next node.

Base #

Basic nodes, e.g. using a random next node, a chance check (e.g. 25 % chance), check the game’s difficulty or use another battle AI.

By using another battle AI, you can combine multiple battle AIs – this allows reusing already existing battle AIs in a larger context and create more complex behaviours without getting to crowded.

Check #

Contains all check/condition nodes from other categories.

These nodes (also in the other categories) are usually used to select the targets for action nodes (via the found targets).

Combatant #

Nodes to check a combatant’s state, like the current turn or status.

E.g. is an ally’s HP below 25 %, is an enemy’s attack modifier Fire above 100, is a certain status effect applied to the user of the AI.

You can also use targets that are within combatant triggers of a combatant. Learn more about combatant triggers in this documentation.

Grid Formation #

Nodes to manage the grid formation of the combatant’s group.

Grid formations are only available grid battles.

Learn more about grid formations in this documentation.

Move AI #

Nodes to check the combatant’s Move AI, e.g. to select the current move AI target or use combatants that are valid hunting targets of the move AI.

You can also change the combatant’s move AI or the move AI’s used mode (e.g. switching it to Hunt mode).

Learn more about the move AI in this documentation.

Position #

Nodes to check positional conditions, e.g. distance or orientation of the combatant to a target (e.g. is the user behind the target).

Selected Data #

Nodes to manage selected data, e.g. selecting a combatant or ability and storing it as selected data.

Target #

Nodes to manage the found targets, e.g. clearing all found targets or using the combatant’s last target as found target.

You can also store and load found targets to remember targets between battle AI executions or to switch between different target groups.

Variable #

Nodes to check and change variables.