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 ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
float followDistance = 180; // The distances below are approximations based on observations of the original engine.
// 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 // If only one actor is following the target, it uses 186.
int i=0; // 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); std::list<int> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowingIndices(target);
followers.sort(); if (followers.size() >= 2)
for (std::list<int>::iterator it = followers.begin(); it != followers.end(); ++it)
{ {
if (*it == mFollowIndex) followDistance = 313;
followDistance *= (i+1); short i = 0;
++i; 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 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) 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; followDistance += threshold;
} }

Loading…
Cancel
Save