Combat AI: fallback behaviour

Everything about development and the OpenMW source code.
Post Reply
User avatar
akortunov
Posts: 899
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation

Combat AI: fallback behaviour

Post by akortunov »

Hello!
In both OpenMW and Morrowind archers and mages try to fall back if the enemy is too close.
OpenMW behaviour has two problems:
1. If there is an obstacle behind, NPC runs on place endlessly. In Morrowind NPC just stops in this case.
2. NPC can run off the cliff. This issue is not present in vanilla game.

Take a look at this branch.
I managed to solve the first issue: NPC stops and still uses evading (side) movement if there is an enemy nearby. Sometimes NPCs manage to evade obstacle via side movement.
slide0.png
slide0.png (4.29 KiB) Viewed 3264 times
Unfortunately, I had to use physics raytesting, so I'm aware of performance cost of this solution.

Feel free to test the branch and provide any feedback.
Also please share any ideas how to solve the second issue, or improve solution for the first one.

EDIT: to solve the second issue, I tried to modify approach from the first one:
slide.png
slide.png (4.81 KiB) Viewed 3268 times
Angle A should be more than sMaxSlope.
If the vector has no collisions, there is a cliff nearby.
Unfortunately, it works only partially for now (or I am just dumb).
Also there should be a more more generic place for this code since the normal movement should use it too.
Can we stop the actor during physics simulation?
Post Reply