Fix infinite loops in Combat AI
darkf opened this issue · 2 comments
Can happen in several situations. I've noticed with the final challenge in arcaves, as well as in Klamath Downtown.
If it finds itself getting into an infinite loop it should report that and provide more information.
The logic should also be inspected and possibly cleaned up.
I've added a failsafe recursion bail-out in case this happens.
I also fixed one of the causes: combat wouldn't end when changing elevation, so combatants on the old elevation would still try to walk towards / attack the player, which isn't possible. It would then get stuck being unproductive and softlock the game.
The rest of the logic should still be audited...
NPCs now prefer the closer targets instead of arbitrary ones.
NPCs should stop trying to target NPCs they can't see (don't have a line of sight / objCanSeeObj) or have a path to, so they don't try to creep towards an NPC across the map or inside a room.
In fact, NPCs in rooms might not even need to be triggered as hostile. This should be checked.