mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 22:09:42 +00:00
Base AiFollow activation range on follow distance (bug #7685)
This commit is contained in:
parent
7e3270abc9
commit
5b02b77a39
2 changed files with 18 additions and 15 deletions
|
@ -103,6 +103,7 @@
|
||||||
Bug #7665: Alchemy menu is missing the ability to deselect and choose different qualities of an apparatus
|
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 #7675: Successful lock spell doesn't produce a sound
|
||||||
Bug #7679: Scene luminance value flashes when toggling shaders
|
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
|
Bug #7712: Casting doesn't support spells and enchantments with no effects
|
||||||
Feature #3537: Shader-based water ripples
|
Feature #3537: Shader-based water ripples
|
||||||
Feature #5173: Support for NiFogProperty
|
Feature #5173: Support for NiFogProperty
|
||||||
|
|
|
@ -119,21 +119,6 @@ namespace MWMechanics
|
||||||
const osg::Vec3f targetPos(target.getRefData().getPosition().asVec3());
|
const osg::Vec3f targetPos(target.getRefData().getPosition().asVec3());
|
||||||
const osg::Vec3f targetDir = targetPos - actorPos;
|
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.
|
// 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.
|
// Followers beyond the first usually attempt to stand inside each other.
|
||||||
osg::Vec3f::value_type floatingDistance = 0;
|
osg::Vec3f::value_type floatingDistance = 0;
|
||||||
|
@ -152,6 +137,23 @@ namespace MWMechanics
|
||||||
floatingDistance += getHalfExtents(actor) * 2;
|
floatingDistance += getHalfExtents(actor) * 2;
|
||||||
short followDistance = static_cast<short>(floatingDistance);
|
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
|
if (!mAlwaysFollow) // Update if you only follow for a bit
|
||||||
{
|
{
|
||||||
// Check if we've run out of time
|
// Check if we've run out of time
|
||||||
|
|
Loading…
Reference in a new issue