Reject AiTravel destinations further than 7168 units away, as in vanilla MW (Fixes #1911)

deque
scrawl 10 years ago
parent 441073b475
commit 2eaceb71ba

@ -1,5 +1,7 @@
#include "aitravel.hpp"
#include <OgreVector3.h>
#include <components/esm/aisequence.hpp>
#include "../mwbase/world.hpp"
@ -70,6 +72,12 @@ namespace MWMechanics
}
}
// 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.
if (Ogre::Vector3(mX, mY, mZ).squaredDistance(Ogre::Vector3(pos.pos)) > 7168*7168)
return false;
bool cellChange = cell->mData.mX != mCellX || cell->mData.mY != mCellY;
if(!mPathFinder.isPathConstructed() || cellChange)
{

Loading…
Cancel
Save