Merge pull request #1537 from drummyfish/guardfix

Check the real distance to target in AIPursue (issue #4184)
new-script-api
scrawl 7 years ago committed by GitHub
commit 801f2d42d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,8 +50,13 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte
//Set the target desition from the actor //Set the target desition from the actor
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos; 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) &&
abs(dest.mZ - 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 target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached
return true; return true;
} }

Loading…
Cancel
Save