From 531bca1273e7b9dbd98b34a5f3747a3099467d71 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 5 Jul 2015 18:09:13 +0200 Subject: [PATCH] Add a threshold for changing aicombat targets (Fixes #2755) --- apps/openmw/mwmechanics/aisequence.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 3e1f89624..fb6450d16 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -184,6 +184,11 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac const ESM::Position &targetPos = target.getRefData().getPosition(); float distTo = (targetPos.asVec3() - vActorPos).length(); + + // Small threshold for changing target + if (it == mPackages.begin()) + distTo = std::max(0.f, distTo - 50.f); + if (distTo < nearestDist) { nearestDist = distTo;