darkf / darkfo

DarkFO, a post-nuclear RPG remake (of Fallout 2)
Apache License 2.0
135 stars 12 forks source link

Fix infinite loops in Combat AI #96

Open darkf opened 7 years ago

darkf commented 7 years ago

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.

darkf commented 6 years ago

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...

darkf commented 6 years ago

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.