AI Looting and Battle Bug

Today, my first task was to get the AI using yesterday's new "Check Body for Loot" move. As of yesterday, players could choose to just loot an unconscious enemy and leave, rather than having to kill them for their stuff. And in theory, so could the AI. But I hadn't tested it yet.

After a few tests, it appeared AI could actually do so as well, but there were problems. First of all, the AI rarely chose to do so. Secondly, the AI often chose to do so multiple times in the same battle. These two issues turned out to be pretty easy to solve, however. A few prioritization value tweaks, and a condition marking a body as already looted, and AI was acting a little more realistically. In practice, looting the player roughly half the time, and walking away after taking a few items.

But a third problem reared its head, and it was a big one. Every time AI left a battle with the player unconscious, the battle UI would remain even after the last AI left. In some cases, this would overlap an encounter which followed, making it impossible to read.

I spent most of the day trying to figure out why this was happening, and it was only in the last few minutes that I figured it out. As it turns out, there was a bug in the way the game advanced combat turns automatically after the player's been unconscious a while.

A while back, I added code to make the game auto-advance combat turns once the player was unconscious for 3 turns in a row. This was mainly to speed up things for the player, since they had no choice anyway. It also added a neat element of realism, as the UI became a flurry of confusing activity while the player was out.

However, it looks like this was causing a weird nested combat loop bug. The game would auto-end the combat turn, and it would check a few things, and start a new combat turn without finishing off the old one. And this would happen until we were 4-5 combat turns deep.

This definitely broke the flow of combat in cases like the one I was testing, but I'm suspicious about whether it might also be causing some of the issues other players are reporting. Things like endless turn advancing bugs, or other stuck combat screens.

The good news is that removing the auto-advance seems to fix it. A quick test showed it working as it should. The bad news is that I'm not sure how to re-enable the auto-advance without causing the bug. However, I only just figured out the cause a few minutes ago, so I should have some more time to look into it tomorrow.

Other than the above bug, I made a few smaller changes as a result of my day of battle testing. One change was to reduce the frequency of tripping when moving around the battlefield. After a day of combat testing, it was pretty clear combatants trip way too much. I've dialed it down by half, per Sid Meier's game design addage.

The other change I made was to the way items break each turn. I think there was a bug that caused all items to degrade as if time did the damage, even if it was usage or other causes. Many times, this is fine. But in some cases, the item turns into nothing when broken over time, but turns into degraded treasure when simply broken from use. We'll see if these changes improve things in practice.

That's all for today. Hope everyone has a good night!