Dev Diary #13: Pathfinding, Line of Sight, and More

I wasn’t really sure what to call this post, since I’ve been working a lot on tidying up Ambience but haven’t really been particularly stuck on one single thing to write a “gamedev grievance” about! So I figured I’d write up a short summary of the many things I got up to this week:

  • Fixed pathfinding. Well, sort of. I noticed that in large rooms, the game would sometimes lag at the start of a turn if the A* pathfinding algorithm couldn’t find a valid path to the player. One way of fixing this would be to run the A* algorithm branching from both the player and each enemy simultaneously, but this would require rewriting a lot of my code. Instead, I modified the code I already had to make it work a lot faster and more efficiently when finding a path. For example, I changed one of my data structures from a list to a map, which runs much faster in GameMaker: Studio. There’s still a bit of lag sometimes, but only in large dungeons with lots of enemies, and even then it’s nowhere near as bad as it was.
  • Fixed the battle log. I finally decided to implement turn announcements in the battle log, so the player has a better idea of what happened when (and also to give the game a more rogue-like feel overall).  My approach was a bit unconventional – since there are a variety of ways a turn can start in Ambience, I added the announcement for a new turn at the end of the previous turn – which made things a bit tricky. In the end, though, I think I got it working okay.
  • Modified room and dungeon layout. Now floors are bigger, with more rooms and more enemies – which means more fun!
  • Improved graphics – including several mugshots and the Cactus Crawler sprite. I’ve been meaning to fix up the latter for quite some time, but again only got around to it now.
    A wild Cactus Crawler appeared!

    Fixed the line of sight algorithm… again. I implemented the system I’m currently using a while ago, but I’m still having to fine-tune it occasionally. Specifically, when the player activates an Ambience and modifies the map – say by drying up pools of water using the Ambience of Sun – the game unnecessarily modifies some of the “corridor cells” to become “room cells”, giving the player too much line of sight extending into adjacent rooms. The solution: don’t change those cells into room cells. Easy!

  • The playthrough continues… I’m playing through the game as an ordinary player would to get an authentic idea of the game’s difficulty at each stage of the game. Along the way, I’ve discovered that Ambience is actually fairly challenging – even for me as the developer. At any stage, the player could go from being perfectly fine to on the brink of defeat in as little as one or two turns. I don’t mind the challenge, though. It’s all part of the roguelike nature, after all.

Leave a Reply

Your email address will not be published. Required fields are marked *