Merge pull request #1240 from Allofich/follow

Adjust AI follow distances
This commit is contained in:
scrawl 2017-03-26 20:35:11 +02:00 committed by GitHub
commit 2a74f79bf1

View file

@ -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;
} }