Jump to content

Curious about pathfinding logic in a game like Fire Emblem


Wist
 Share

Recommended Posts

I tried bugging Hextator on IRC but he wasn't responding to my gentlemanly pings.

I'm currently working on a Fire Emblem related project (which essentially involves a replication of fundamental Fire Emblem mechanics in a StarCraft map run through a custom mod). I have most of the systems I need either planned out or already in place, including robust grid and coordinate systems, but one element I haven't been able to work out an elegant approach to is pathfinding (if this is the correct word to use in this context?).

Here's what I can do so far:

If a player selects a unit, I easily can show any tiles the selected unit could move to. For example, if a unit in question has a movement range of 5, I can show the following (X is the unit and # is a valid tile):

          #
        # # #
      # # # # #
    # # # # # # #
  # # # # # # # # #
# # # # # X # # # # #
  # # # # # # # # #
    # # # # # # #
      # # # # #
        # # #
          #

If there are obstacles (such as water, cliffs, or the edge of the battlefield) I can remove those from the list of valid tiles. I can do the same if a tile is occupied by another unit (B is an obstacle, U is an enemy unit):

          B
        B B B
      # # # # #
    # # # # U # #
  # # # # # # # # #
# # B B # X # # U # #
  # B B # # # # # #
    # # U # # B #
      # # # B #
        # # #
          #

This results in the following pattern of tiles (- means a tile cannot be walked on):

          -
        - - -
      # # # # #
    # # # # - # #
  # # # # # # # # #
# # - - # X # # - # #
  # - - # # # # # #
    # # - # # - #
      # # # - #
        # # #
          #

The problem is that other tiles need to be recognized as invalid because obstructions prevent the unit from reaching them in at most five steps.

T7J2YxJ.png

Sorry it's a bit confusing. Red lines represent possible unit paths near and around obstructions. Blue dots tiles that should not be reachable because of obstacles in the unit's paths even though those tiles don't host any obstacles themselves. I need to figure out a way to figure out which the blue tiles are in game so that I don't show them as valid target locations, producing the following tile map:

          -
        - - -
      # # # # #
    # # # # - # #
  # # # # # # # # #
- - - - # X # # - - -
  - - - # # # # # #
    - - - # # - #
      # # # - -
        # # #
          #

Maybe the following will help too. How would one emulate Fire Emblem's calculating that enemy units in the way should prevent Dorcas from walking onto tile 5 (and not putting a blue square overlay there)?

WL3HKpG.jpg

Does anyone here know how Fire Emblem figures out which tiles can and cannot be reached on any given turn, or at least a logical approach one could use to figure this out? I could brute force test every possible path, but I'd rather adopt a sensible algorithm, if anybody has any ideas? Any input, even just ideas, would be very much appreciated!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...