Hello, I'm making a simple Battle AI for movement on a battle grid.

The priority is rather simple, it goes like this:

- Enemies look for targets within 5 cells (they have 4 movement range + 1 attack range)
- If no target is within 5 cells, enemies target closest and move toward them
- Exclude targets that are dead
- Rank targets by threat (a stats that I created)
- Move to target

Here's a link to an image that shows my battle AI (sorry, I don't know how to show an image in the forums):
https://drive.google.com/file/d/1Z61cyDeg0Prk5KHakO9YWxXHz_ahRRbY/view?usp=sharing

(I can provide you more information about the setups of the other nodes if required)

Now, it works rather well. If two targets are within 5 cells, the enemy will move toward the target with the highest threat. If the highest target is unreachable (due to the cell being blocked for whatever reason), the enemy will move toward the character with the second highest threat.

But, there is one particular situation where it doesn't work: if there are targets within 5 cells and that all of these targets are unreachable, the enemy will not move at all.

Here's a link to an image that shows a situation like this :
https://drive.google.com/file/d/1lSpLWt-DW7T9YQS4bdC6WSVqgVu7sOV2/view?usp=sharing

In this image, the cleric girl is the highest threat hero while the red warrior is the lowest threat. The thief plays before the yellow blob, so it moves on the bridge to attack the warrior (the cleric is within 5 tiles, but is unreacheable this turn). However, the yellow blob does nothing, even though there's another bridge that it could use to get closer to the heroes. But, if both heroes were outside the 5 cells range, the blob would move toward them.

I have tried a lot of things, playing with the different options in the Check Grid Distance and Grid Move nodes, but have been unable to make it work. I wonder if I don't need to use another node, but I haven't been able to figure out which one.

Thank you for your help!
  • Can't see the images (sent access request).

    Usually, if you didn't enable In Move Range in the Grid Move node, a combatant should move as close as it can to a target. Might be that there is no found target based on check nodes before, though.
    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!
  • Oops, I apologize. I was certain anyone with the link could see the images.

    The problem I encountered with ''In Move Range'', is that if I didn't click it, the enemies would always move toward the highest threat character, even if it's not reachable and that another target is reachable. In the case of the image I posted, both the thief and the yellow blob would walk over the 2nd bridge to reach the cleric, ignoring the fighter entirely.

    What I want is to have enemies moving toward the highest threat they can reach this round, and if they can't, they move toward the closest reachable target. However, in the Battle AI schematic I linked, I have never been able to make anything go through the ''Reachable'' end of the ''Grid Move'' node :s

    (Btw, you're a machine! To be able to reply to so many posts in two days, that's crazy! As a teacher, I struggle to reply to the emails of my students the day before they must hand out their work, and none of their emails are half as complicated as the questions people throw at you here!!)
  • Ah, yeah - there's currently a bug in the Grid Move node and Reachable is never called. This will be fixed in the next update.
    Not 100% sure, but using the Next slot as well should work. Unless you're using battle AI's in Queue mode (which you'd have to actively select in the combatan's battle AI setup), the battle AI exits at the first useable action anyway, so continuing on Next slot only happens if Grid Move action isn't used.
    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!
  • edited April 2022
    Ooooh I've done so many tests to trigger ''Reachable'', all in vain. I'm happy to know I'm not crazy haha!

    I did a quick test with the Next slot (I connected it to the same place ''Reachable'' is connected to), and it... somehow worked... but not entirely. What happened on the image I linked is that the Thief moved on the bridge as usual, then the blob... moved only one tile south west on its first turn, even though it can move much farther. Then, on its second turn, the blob decided to move toward the next bridge, moving as far as it can. Then on its third turn, it crossed the 2nd bridge toward the heroes.

    I simply can't explain why it only moved one tile on its first turn, then behaved correctly on its 2nd and 3rd turn... I'll try to play more with the options later this week to figure out what I can do.

    Thanks!
    Post edited by max_power on
Sign In or Register to comment.