Path finding and action planning for Fire Emblem-like games (large images beware)

While the voting process is on-going I’m spending some time improving user friendliness. Before, you could iterate over all tiles of a unit’s action grid yourself and query per tile whether it was reachable, occupied (and by whom), had enemies within your attack range, etc. I have been thinking of how to improve on that, to decrease the number of nodes you need to get the result you want. I now made a search function that you can use to retrieve all tiles that satisfy conditions set by you. Of course you can still use the single tile queries, they are useful for their own purposes like handling player input.

When searching, there are a number of conditions for which you can specify whether they should be True (1), False (2), or you Don’t care (3) per tile. Only tiles that satisfy all are returned. As for occupant, you may require it to be None or Self (1), Enemy (2), Ally (3) or again Don’t care (4). Default is always Don’t care. Here is how it looks, assuming that “MyLevelGrid” is set up to represent your level and MyGridCharacter is placed on that level:

Here are example uses of the search function:

  • For displaying tiles, for example find all reachable tiles and paint them blue. Find all attackable, non-reachable tiles and paint them red. (Attackable AND non-reachable because blue has priority over red)
  • For an AI character that hasn’t moved yet, find all reachable, unoccupied tiles* and make a decision from the search results. Then use your selected coordinates to retrieve the corresponding path from the Action Grid. You can set “Enemies Within Attack Range” to true to only consider positions from which the unit can attack in this turn.
  • For an AI character that has moved, compute the action grid with Max Movement Cost set to 0. Find all attackable tiles with an enemy occupant. Choose a tile from the returned list, use the tile coordinates to retrieve the occupant from the Action Grid

Note: Tiles can be reachable and occupied at the same time, because some units are allowed to move through others. Who can move through whom can be defined by you.

Hope this search function is intuitive, feedback is welcome. :slight_smile: