|
|
|
@ -119,21 +119,6 @@ namespace MWMechanics
|
|
|
|
|
const osg::Vec3f targetPos(target.getRefData().getPosition().asVec3());
|
|
|
|
|
const osg::Vec3f targetDir = targetPos - actorPos;
|
|
|
|
|
|
|
|
|
|
// AiFollow requires the target to be in range and within sight for the initial activation
|
|
|
|
|
if (!mActive)
|
|
|
|
|
{
|
|
|
|
|
storage.mTimer -= duration;
|
|
|
|
|
|
|
|
|
|
if (storage.mTimer < 0)
|
|
|
|
|
{
|
|
|
|
|
if (targetDir.length2() < 500 * 500 && MWBase::Environment::get().getWorld()->getLOS(actor, target))
|
|
|
|
|
mActive = true;
|
|
|
|
|
storage.mTimer = 0.5f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!mActive)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// In the original engine the first follower stays closer to the player than any subsequent followers.
|
|
|
|
|
// Followers beyond the first usually attempt to stand inside each other.
|
|
|
|
|
osg::Vec3f::value_type floatingDistance = 0;
|
|
|
|
@ -152,6 +137,23 @@ namespace MWMechanics
|
|
|
|
|
floatingDistance += getHalfExtents(actor) * 2;
|
|
|
|
|
short followDistance = static_cast<short>(floatingDistance);
|
|
|
|
|
|
|
|
|
|
// AiFollow requires the target to be in range and within sight for the initial activation
|
|
|
|
|
if (!mActive)
|
|
|
|
|
{
|
|
|
|
|
storage.mTimer -= duration;
|
|
|
|
|
|
|
|
|
|
if (storage.mTimer < 0)
|
|
|
|
|
{
|
|
|
|
|
float activeRange = followDistance + 384.f;
|
|
|
|
|
if (targetDir.length2() < activeRange * activeRange
|
|
|
|
|
&& MWBase::Environment::get().getWorld()->getLOS(actor, target))
|
|
|
|
|
mActive = true;
|
|
|
|
|
storage.mTimer = 0.5f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!mActive)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!mAlwaysFollow) // Update if you only follow for a bit
|
|
|
|
|
{
|
|
|
|
|
// Check if we've run out of time
|
|
|
|
|