Ship Damage, Breathing, and More Path Fixing

Hey Folks! With the floor and wall tiles now supporting damage, I figured I'd try an experiment with ship damage. And in the process, also tackled some issues with breathing and pathfinding.

For the ship damage, I wanted to see what would happen if I raycast a line through the ship, and applied damage to everything on its path. I set some initial damage amount and path, follow the path looking for each damage-compatible object, and keep applying damage until all the energy is spent. And for simplicity, it happens in a ray parallel to the ship floor, so we only hit walls. Even though this is unlikely in practice, it avoids the "hole in floor beneath giant obstacle" issue with repairs.

As you can see in today's image, the damage follows a line from the top left to the bottom right in this example. I added a yellow line for clarity, to trace the path. The damage done was not enough to stop the "thing" that pelted the ship. Only about 60% of the hyperkinetic object's energy was spent.

Of course, these are also some wildly guessed numbers for incoming damage and wall strength, which are subject to change.

The good news is that this went pretty much as expected, and wasn't hard to setup! I can even get fancy and control the incoming vector if I want, but I'm not sure that's necessary just yet. For now, this represents micrometeoroids, hyperballistic munitions, and maybe a prototype for future radiation propagation paths. The more stuff I setup damage states for, the more interesting things that can happen. And consequently, the more interesting gameplay we can have, too. Finding spare parts and tools to fix this damage by, say, scouring derelicts is a gameloop in itself!

As one final tweak, I edited Destructable objects and CondOwners (all game logic objects) to support on-demand stat resolution. So I can apply damage and not have to wait for the polling timer to catch it. It can happen instantly now, which should make timing of sound and visual effects easier and more visceral. Also, this may be a useful foothold for making a more robust stat-logic handler in the future, instead of the current system, which uses a lot of abstract data.

Anyway, some good progress there. But today's update wasn't without its issues.

Pathfinding reared its head again, this time while trying to access some container items on the ship. I struggled a bit to fix these before I realized one of them was facing a wall. But there was still a necessary tweak to the code to give up when the next path node equaled the current one, which means there is nowhere to go. I also noticed a few bugs in certain interactions targeting the self, which paradoxically required standing in front of oneself. Finally, I removed a bit of an optimization in the pathfinding code that tried to avoid recalculating. Now, it just recalculates as needed. It might come back to bite me later, but right now, it's simpler and a lot more reliable. And that's important to keeping momentum.

Once that was done, I turned my attention to breathing, as I was seeing some unusual hypoxia log messages. The timing seemed weird, so I added some debug info to the UI message log. In doing this, I realized the stat window for AI wasn't updating in real-time, and was just showing a snapshot of the AI when it opened, so I fixed that.

And after a bit of familiarizing with the old system, plus research, I realized it had an extra step of indirection in there. The AI had a timer to control how often it needed to breathe, and the breathing system the AI used had a separate timer to control how often it checked for the signal. I was able to remove that AI timer and just have the breather system look to see if the AI was low on oxygen. This resulted in a simpler system, with less unpredictability due to conflicting timers.

And as a bonus, I have restored confidence in the system working as it should now. The AI's oxygen needs gradually increase over time, while the breather slowly decreases it. Whenever the O2 levels on the ship are low, the needs outstrip the breathing benefits. And when O2 is at nominal levels, the needs slowly decrease.

I think the only other thing I might do there is add an unconscious phase when in critical hypoxia, since there is currently only "fine" and "dead." Realistically, there's a stage or two between where the AI should be sluggish and/or down. But unconsciousness might be a tricky thing. We'll see how I feel tomorrow!