Adjust AI follow distances

(Fixes #3225)
pull/190/head
Allofich 8 years ago
parent 97dbd07ed2
commit 6253a5218e

@ -92,16 +92,23 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
float followDistance = 180;
// When there are multiple actors following the same target, they form a group with each group member at 180*(i+1) distance to the target
int i=0;
// The distances below are approximations based on observations of the original engine.
// If only one actor is following the target, it uses 186.
// If there are multiple actors following the same target, they form a group with each group member at 313 + (130 * i) distance to the target.
short followDistance = 186;
std::list<int> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowingIndices(target);
followers.sort();
for (std::list<int>::iterator it = followers.begin(); it != followers.end(); ++it)
if (followers.size() >= 2)
{
if (*it == mFollowIndex)
followDistance *= (i+1);
++i;
followDistance = 313;
short i = 0;
followers.sort();
for (std::list<int>::iterator it = followers.begin(); it != followers.end(); ++it)
{
if (*it == mFollowIndex)
followDistance += 130 * i;
++i;
}
}
if (!mAlwaysFollow) //Update if you only follow for a bit
@ -139,7 +146,7 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte
if (!storage.mMoving)
{
const float threshold = 10; // to avoid constant switching between moving/stopping
const short threshold = 10; // to avoid constant switching between moving/stopping
followDistance += threshold;
}

Loading…
Cancel
Save