mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 01:09:43 +00:00
Don't allow setting a new return position if there already is one and we haven't reached it yet
This commit is contained in:
parent
1fd7a07b5e
commit
28ef236f0e
1 changed files with 28 additions and 20 deletions
|
@ -341,26 +341,29 @@ namespace MWMechanics
|
||||||
mChooseAction = false;
|
mChooseAction = false;
|
||||||
mIdleNow = false;
|
mIdleNow = false;
|
||||||
|
|
||||||
Ogre::Vector3 destNodePos = mReturnPosition;
|
if (!mPathFinder.isPathConstructed())
|
||||||
|
|
||||||
ESM::Pathgrid::Point dest;
|
|
||||||
dest.mX = destNodePos[0];
|
|
||||||
dest.mY = destNodePos[1];
|
|
||||||
dest.mZ = destNodePos[2];
|
|
||||||
|
|
||||||
// actor position is already in world co-ordinates
|
|
||||||
ESM::Pathgrid::Point start;
|
|
||||||
start.mX = pos.pos[0];
|
|
||||||
start.mY = pos.pos[1];
|
|
||||||
start.mZ = pos.pos[2];
|
|
||||||
|
|
||||||
// don't take shortcuts for wandering
|
|
||||||
mPathFinder.buildPath(start, dest, actor.getCell(), false);
|
|
||||||
|
|
||||||
if(mPathFinder.isPathConstructed())
|
|
||||||
{
|
{
|
||||||
mMoveNow = false;
|
Ogre::Vector3 destNodePos = mReturnPosition;
|
||||||
mWalking = true;
|
|
||||||
|
ESM::Pathgrid::Point dest;
|
||||||
|
dest.mX = destNodePos[0];
|
||||||
|
dest.mY = destNodePos[1];
|
||||||
|
dest.mZ = destNodePos[2];
|
||||||
|
|
||||||
|
// actor position is already in world co-ordinates
|
||||||
|
ESM::Pathgrid::Point start;
|
||||||
|
start.mX = pos.pos[0];
|
||||||
|
start.mY = pos.pos[1];
|
||||||
|
start.mZ = pos.pos[2];
|
||||||
|
|
||||||
|
// don't take shortcuts for wandering
|
||||||
|
mPathFinder.buildPath(start, dest, actor.getCell(), false);
|
||||||
|
|
||||||
|
if(mPathFinder.isPathConstructed())
|
||||||
|
{
|
||||||
|
mMoveNow = false;
|
||||||
|
mWalking = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,6 +532,7 @@ namespace MWMechanics
|
||||||
mMoveNow = false;
|
mMoveNow = false;
|
||||||
mWalking = false;
|
mWalking = false;
|
||||||
mChooseAction = true;
|
mChooseAction = true;
|
||||||
|
mHasReturnPosition = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // AiWander package not yet completed
|
return false; // AiWander package not yet completed
|
||||||
|
@ -615,7 +619,11 @@ namespace MWMechanics
|
||||||
|
|
||||||
void AiWander::setReturnPosition(const Ogre::Vector3& position)
|
void AiWander::setReturnPosition(const Ogre::Vector3& position)
|
||||||
{
|
{
|
||||||
mHasReturnPosition = true; mReturnPosition = position;
|
if (!mHasReturnPosition)
|
||||||
|
{
|
||||||
|
mHasReturnPosition = true;
|
||||||
|
mReturnPosition = position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiWander::getRandomIdle()
|
void AiWander::getRandomIdle()
|
||||||
|
|
Loading…
Reference in a new issue