forked from teamnwah/openmw-tes3coop
Apply the AiTravel maxRange to AiEscort as well (Fixes #2697)
This commit is contained in:
parent
65b5cbe3f7
commit
1f543b4d79
3 changed files with 12 additions and 12 deletions
|
@ -75,6 +75,9 @@ namespace MWMechanics
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isWithinMaxRange(osg::Vec3f(mX, mY, mZ), actor.getRefData().getPosition().asVec3()))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!mCellId.empty() && mCellId != actor.getCell()->getCell()->getCellId().mWorldspace)
|
if (!mCellId.empty() && mCellId != actor.getCell()->getCell()->getCellId().mWorldspace)
|
||||||
return false; // Not in the correct cell, pause and rely on the player to go back through a teleport door
|
return false; // Not in the correct cell, pause and rely on the player to go back through a teleport door
|
||||||
|
|
||||||
|
|
|
@ -94,10 +94,19 @@ namespace MWMechanics
|
||||||
|
|
||||||
ESM::Pathgrid::Point mPrevDest;
|
ESM::Pathgrid::Point mPrevDest;
|
||||||
|
|
||||||
|
bool isWithinMaxRange(const osg::Vec3f& pos1, const osg::Vec3f& pos2) const
|
||||||
|
{
|
||||||
|
// Maximum travel distance for vanilla compatibility.
|
||||||
|
// Was likely meant to prevent NPCs walking into non-loaded exterior cells, but for some reason is used in interior cells as well.
|
||||||
|
// We can make this configurable at some point, but the default *must* be the below value. Anything else will break shoddily-written content (*cough* MW *cough*) in bizarre ways.
|
||||||
|
return (pos1 - pos2).length2() <= 7168*7168;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isNearInactiveCell(const ESM::Position& actorPos);
|
bool isNearInactiveCell(const ESM::Position& actorPos);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,18 +13,6 @@
|
||||||
#include "movement.hpp"
|
#include "movement.hpp"
|
||||||
#include "creaturestats.hpp"
|
#include "creaturestats.hpp"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
bool isWithinMaxRange(const osg::Vec3f& pos1, const osg::Vec3f& pos2)
|
|
||||||
{
|
|
||||||
// Maximum travel distance for vanilla compatibility.
|
|
||||||
// Was likely meant to prevent NPCs walking into non-loaded exterior cells, but for some reason is used in interior cells as well.
|
|
||||||
// We can make this configurable at some point, but the default *must* be the below value. Anything else will break shoddily-written content (*cough* MW *cough*) in bizarre ways.
|
|
||||||
return (pos1 - pos2).length2() <= 7168*7168;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue