Hi,I now want to achieve a series AI. (active status ->combatant will move or attack etc. inactive -> do nothing and other status. like patrol)
1. combatant will active when player enter in range.
2. combatant will active when player kill a certain amount of enemy. or specific enemy.
3. combatant will active when be attacked.
4. combatant patrol designated routes when patrol status.and combatant will return patrol when combatant switch from other status
5. combatants are stationed in specific areas.when player enter in areas.combatants will attack player.combatants will swithc inactive or patrol when player out of areas.
  • Being active/inactive is best done using a status effect to 'mark' the combatant being in that state. Effects can be hidden e.g. in case you don't want them to be visible to the player.
    The battle AI needs to check if the effect is applied to the combatant and perform different things based on it.

    1) Easiest setup: Using a Trigger Machine on the combatants that add that effect to it when the player enters the collider.

    If you want it based on grid ranges, you can e.g. use a turn start schematic on the combatant to check if an enemy (of the combatant) is within range. Use the Select Grid Cells node for that - it has an option to store the combatants of the cells. Next use a Filter Selected Combatants node to e.g. only use enemies of the combatant. Finally, use a Selected Data Count node to check how many combatants have been found, e.g. count being greather than 0 means there's an enemy within range, so you add the effect to the combatant.

    2) This can be added in the death schematics of your combatants. E.g. use a global variable to count the killed enemies and add the effect to all once enough where killed.

    3) Either add the status effect via target changes of your attacks, or using Change Schematics of your health status value to add the effect on any negative change.

    4) As said at the start - the battle AI needs to check for the status effect (Check Status node). If the effect is not applied, to patrol stuff, e.g. Grid Move node to move to a specific cell type (e.g. you could have cell types to define waypoints).

    5) Basically same as #1.
    Here I'd recommend just using trigger machines - one on trigger enter adding the effect, one on trigger exit to remove the effect.
    Combine the trigger machine with a combatant trigger to easily get all combatants within the area.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.