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

I can imagine people thinking its your fault when you get an error message that says “Infinite loop detected”, must be frustrating if you know better. :stuck_out_tongue: I see that the guys at Epic ran into issues when increasing the iteration count. I wonder what would happen if they left the limit out in its entirety. You’d get crashes when you actually do have an infinite loop or your call stack doesn’t fit in memory, but what else?

The line of sight checking happens per tile, which is rather painful when you try to envision it. I’m drawing a line from the center of a source tile to the center of a target tile. I recently had an idea for improving it. If I first check the farthest tiles and store the tiles that are passed directly through the center, then only one LOS check has to be done per slope value. So assume the source tile is (0, 0), I should be able to check the tile (4, 2) as part of the LOS check of (8, 4).

Zeus are you familiar with ray casting? What I’m doing right now is actually quite similar to ray casting with axis aligned rectangles. I keep a ray’s status (origin, direction) and update its origin to step from the source tile to the target tile. In each step, I compute which boundary is closer: a horizontal boundary of the grid or a vertical boundary. I step to that boundary, process the tile that is entered next and keep repeating that until the target tile is reached.