From 1ab4683dcecb4947b81dcf6606407b6c46a1eacb Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 28 Dec 2020 19:19:07 +0100 Subject: [PATCH] Tweak follow distance to be more like the original --- apps/openmw/mwmechanics/aifollow.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index f31be9c10a..ec23679977 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -14,6 +14,16 @@ #include "movement.hpp" #include "steering.hpp" +namespace +{ +osg::Vec3f::value_type getHalfExtents(const MWWorld::ConstPtr& actor) +{ + if(actor.getClass().isNpc()) + return 64; + return MWBase::Environment::get().getWorld()->getHalfExtents(actor).y(); +} +} + namespace MWMechanics { int AiFollow::mFollowIndexCounter = 0; @@ -121,13 +131,14 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte { for(auto& follower : followers) { - auto halfExtent = MWBase::Environment::get().getWorld()->getHalfExtents(follower.second).y(); + auto halfExtent = getHalfExtents(follower.second); if(halfExtent > floatingDistance) floatingDistance = halfExtent; } + floatingDistance += 128; } - floatingDistance += MWBase::Environment::get().getWorld()->getHalfExtents(target).y(); - floatingDistance += MWBase::Environment::get().getWorld()->getHalfExtents(actor).y() * 2; + floatingDistance += getHalfExtents(target) + 64; + floatingDistance += getHalfExtents(actor) * 2; short followDistance = static_cast(floatingDistance); if (!mAlwaysFollow) //Update if you only follow for a bit