mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-16 16:20:53 +00:00
Merge branch 'aifollow' into 'master'
Base AiFollow activation range on follow distance (bug #7685) Closes #7685 See merge request OpenMW/openmw!3652
This commit is contained in:
commit
c969aa42b7
@ -103,6 +103,7 @@
|
||||
Bug #7665: Alchemy menu is missing the ability to deselect and choose different qualities of an apparatus
|
||||
Bug #7675: Successful lock spell doesn't produce a sound
|
||||
Bug #7679: Scene luminance value flashes when toggling shaders
|
||||
Bug #7685: Corky sometimes doesn't follow Llovyn Andus
|
||||
Bug #7712: Casting doesn't support spells and enchantments with no effects
|
||||
Feature #3537: Shader-based water ripples
|
||||
Feature #5173: Support for NiFogProperty
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user