Combat AI target position selection

Everything about development and the OpenMW source code.
Post Reply
elsid
Posts: 6
Joined: 01 Aug 2017, 08:20

Combat AI target position selection

Post by elsid » 05 Nov 2018, 18:03

Current combat AI logic considers only actor position to attack and random world position to flee. It doesn't consider possibility to reach target. This leads NPC to stay at one position if it can't find path to target position. Current pathfinding logic contains a lot of hacks to avoid this situation which leads to problems like https://gitlab.com/OpenMW/openmw/issues/1997 . To resolve this I suggest to select target position for actor in combat using utility function optimization. Minimum set of factors could be following for this function:
1. Is this position reachable for NPC?
2. Can NPC attack from this position? Should consider available NPC weapon, magic, mana and arrows.
3. Can opponent attack NPC at this position? How much NPC should know about opponent? Is it only visible behavior? Example rules: If my opponent is wearing a sword, it should attack me only by melee. If I saw my opponent wearing a bow, it can attack me by range.

My idea is to avoid situations when NPC can't reach target and to make them less vulnerable to a player. I hope it doesn't brings a lot of gameplay difference to original morrowind and we can implement it in the game engine.

imec
Posts: 37
Joined: 13 May 2012, 22:03

Re: Combat AI target position selection

Post by imec » 06 Nov 2018, 09:19

How do you feel about NPCs being able to flee to regions of the navmesh that are outside of the view of the player? Right now enemies hit with the fear spell will simply walk in straight lines away from the player. The more natural response would be for fleeing actors to try to hide from or lose the player by breaking their line of site.

It could also help melee enemies avoid ranged attacks when they are faced with an enemy that they can't reach. In fact, I'm pretty sure one of Bethesda's games already has this sort of behavior.

User avatar
psi29a
Posts: 4952
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Combat AI target position selection

Post by psi29a » 06 Nov 2018, 10:15

I'm leaning in the direction that if an NPC can't reach its target for melee, out of range or can't get closer for ranged attacks or has run out of mana/projectiles, the best thing it can do is flee until it is out of site of the target. It's a logical conclusion of a flight or fight response, you can't fight, so best flee.

elsid
Posts: 6
Joined: 01 Aug 2017, 08:20

Re: Combat AI target position selection

Post by elsid » 08 Nov 2018, 09:20

Even if NPC need to flee how to choose position to go? Random world position can be unreachable on can be not safe. Problem is more about interior world where most area around NPC is unreachable. Solution is to push NPC to hide by using wall corners. Utility function optimization gives that. The branch "to flee if can't fight" can be a part of utility function.

Post Reply