1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

check the real distance to target in aipursue

This commit is contained in:
Miloslav Číž 2017-11-02 20:01:22 +01:00
parent 5e69f6033f
commit f34223fce9

View file

@ -50,8 +50,13 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte
//Set the target desition from the actor
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
ESM::Position aPos = actor.getRefData().getPosition();
if (pathTo(actor, dest, duration, 100)) {
float pathTolerance = 100.0;
if (pathTo(actor, dest, duration, pathTolerance) &&
MWMechanics::distance(dest,aPos.pos[0],aPos.pos[1],aPos.pos[2]) < pathTolerance) // check the true distance in case the target is far away in Z-direction
{
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached
return true;
}