Hi! I'm working on creating the AI for an enemy that has an healing ability. However, it doesn't behave as intended and I realize I misunderstand how some nodes work.

Here's my AI:

image

(yes, it's a rat that heals lol)

So, what I want to do:

- Check if the rat has enough MP to heal (that's the first Check Status node)
- If it has enough MP, check if there are allies with less than 75% HP (that's the 2nd Check Status node, detailed below)
- Check if those allies with less than 75% HP are within 4 tiles or less from the caster (1st Check Grid Distance node, detailed below)
- Of the allies that satisfy the last 2 previous nodes, pick the one that has the less HP
- Heal (the ability has a 4 tiles range)

And if the rat doesn't have enough MP or if there aren't any allies below 75% HP or if the allies below 75% HP aren't within 4 tiles, the rat casts its little offensive spell (the 4 nodes on the line below). The AI for the attack works as intended.

I was pretty certain I nailed it with my AI schematic, however, it's not doing exactly that. In practice what it does is:

- Check if the rat has enough MP,
- Check if there's an ally with less than 75% HP
- Heal the ally within 4 tiles with the less HP.

So... if there's an ally 8 tiles away with low health but everyone around the rat is at full health, the rat will heal the nearby ally with the less HP (even if it's at full health) instead of attacking.

What am I doing wrong? I have spent a few hours playing with AI and I've been able to achieve pretty much what I wanted so far, but I realize I still misunderstand some of the basic nodes I use often.

(Note: it's important the rat doesn't move with this AI. I handle this with another AI)

Thank you!

  • There are 2 crucial things to consider in the battle AI nodes:
    - what to do with the already found targets (via the Found Targets setting)
    - which additional combatants to check and add to found targets (via Target setting)

    If you want to only keep checking (and filtering) on the already found targets, set the found targets to Check (checking them and removing those that don't match the conditions) and set the target to None (i.e. not checking any additional targets).

    With your current setup you also just check all allies that are in range and add them to the found targets.
    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!
  • Aaaah thank you, now I understand what I did wrong. I thought I was finding new targets then screening them, but I was only adding more to the pool.

    Ok thanks, it helps me understand better the system!
Sign In or Register to comment.