While play-testing the crypt level, I noticed that the small skull that I like to kick around the level was sometimes not responding to my character hitting it all the time, and quickly realized it was failing when a saved game was loaded.
It took a couple of hours to find the obvious bug, which was one of the boolean fields being saved in the wrong sequence. If it didn't double the size of my files, I would be tempted to put a mode in the file saving system where each item saved would have the current file offset saved as well. That way the loading code could assert that the offset was as expected. Come to think of it, I bet that field would compress very well, perhaps I will put that in after all.
Today I put in dynamic costs into the navigation system. Each link between waypoints has a cost of traversal stored with it.
This cost is the distance between the nodes, plus penalties for being near the border of the waypoint graph, and thus fewer neighbors.
With the debug visualization on, I could verify that my character was increasing the cost near where he was. Each object larger than a certain size would give off an increased cost to nearby waypoints. Unfortunately, this had the result of hanging the AI navigation.
Since the AI only searches up to a couple dozen nodes per tick, it calls the a-star routine over and over until it finds a path, gives up, or changes it mind about what to do. Because I was changing the cost function by moving the enemies themselves,
they were getting stuck in an endless loop. So, I took out the dynamic updates for now.
I'm now questioning the need for dynamic cost updates, rather, I'm considering just handling the case of static objects, or dynamic objects that aren't moving lately, that effectively cut off a movement path. A closed door would be one example, but a person who's not moving would be another. When this happens, I can 'cut' some of the neighbor links, perhaps with a temporary array to make undos easy, and then be sure to invalidate any enemy paths when cuts are made or unmade.
Here are some shots of the crypt :