forked from mirror/openmw-tes3mp
aiwander: reset path on cell change
remove redundant mIsWanderDestReady var
This commit is contained in:
parent
0775ed75ea
commit
a22fc43947
2 changed files with 3 additions and 11 deletions
|
@ -113,7 +113,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<unsigned char>& idle, bool repeat):
|
AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<unsigned char>& idle, bool repeat):
|
||||||
mDistance(distance), mDuration(duration), mRemainingDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle),
|
mDistance(distance), mDuration(duration), mRemainingDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle),
|
||||||
mRepeat(repeat), mStoredInitialActorPosition(false), mIsWanderDestReady(false)
|
mRepeat(repeat), mStoredInitialActorPosition(false)
|
||||||
{
|
{
|
||||||
mIdle.resize(8, 0);
|
mIdle.resize(8, 0);
|
||||||
init();
|
init();
|
||||||
|
@ -191,7 +191,6 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
// get or create temporary storage
|
// get or create temporary storage
|
||||||
AiWanderStorage& storage = state.get<AiWanderStorage>();
|
AiWanderStorage& storage = state.get<AiWanderStorage>();
|
||||||
|
|
||||||
|
|
||||||
const MWWorld::CellStore*& currentCell = storage.mCell;
|
const MWWorld::CellStore*& currentCell = storage.mCell;
|
||||||
MWMechanics::CreatureStats& cStats = actor.getClass().getCreatureStats(actor);
|
MWMechanics::CreatureStats& cStats = actor.getClass().getCreatureStats(actor);
|
||||||
|
@ -201,6 +200,7 @@ namespace MWMechanics
|
||||||
bool cellChange = currentCell && (actor.getCell() != currentCell);
|
bool cellChange = currentCell && (actor.getCell() != currentCell);
|
||||||
if(!currentCell || cellChange)
|
if(!currentCell || cellChange)
|
||||||
{
|
{
|
||||||
|
stopWalking(actor, storage);
|
||||||
currentCell = actor.getCell();
|
currentCell = actor.getCell();
|
||||||
storage.mPopulateAvailableNodes = true;
|
storage.mPopulateAvailableNodes = true;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (mPathFinder.isPathConstructed())
|
if (mPathFinder.isPathConstructed())
|
||||||
{
|
{
|
||||||
mIsWanderDestReady = true;
|
|
||||||
storage.setState(Wander_Walking);
|
storage.setState(Wander_Walking);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,7 +379,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (mPathFinder.isPathConstructed())
|
if (mPathFinder.isPathConstructed())
|
||||||
{
|
{
|
||||||
mIsWanderDestReady = true;
|
|
||||||
storage.setState(Wander_Walking, true);
|
storage.setState(Wander_Walking, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -476,7 +474,7 @@ namespace MWMechanics
|
||||||
float duration, AiWanderStorage& storage, ESM::Position& pos)
|
float duration, AiWanderStorage& storage, ESM::Position& pos)
|
||||||
{
|
{
|
||||||
// Are we there yet?
|
// Are we there yet?
|
||||||
if (mIsWanderDestReady && pathTo(actor, mPathFinder.getPath().back(), duration, DESTINATION_TOLERANCE))
|
if (pathTo(actor, mPathFinder.getPath().back(), duration, DESTINATION_TOLERANCE))
|
||||||
{
|
{
|
||||||
stopWalking(actor, storage);
|
stopWalking(actor, storage);
|
||||||
storage.setState(Wander_ChooseAction);
|
storage.setState(Wander_ChooseAction);
|
||||||
|
@ -659,8 +657,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (mPathFinder.isPathConstructed())
|
if (mPathFinder.isPathConstructed())
|
||||||
{
|
{
|
||||||
mIsWanderDestReady = true;
|
|
||||||
|
|
||||||
// Remove this node as an option and add back the previously used node (stops NPC from picking the same node):
|
// Remove this node as an option and add back the previously used node (stops NPC from picking the same node):
|
||||||
ESM::Pathgrid::Point temp = storage.mAllowedNodes[randNode];
|
ESM::Pathgrid::Point temp = storage.mAllowedNodes[randNode];
|
||||||
storage.mAllowedNodes.erase(storage.mAllowedNodes.begin() + randNode);
|
storage.mAllowedNodes.erase(storage.mAllowedNodes.begin() + randNode);
|
||||||
|
@ -717,7 +713,6 @@ namespace MWMechanics
|
||||||
void AiWander::stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
void AiWander::stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
mPathFinder.clearPath();
|
mPathFinder.clearPath();
|
||||||
mIsWanderDestReady = false;
|
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,7 +945,6 @@ namespace MWMechanics
|
||||||
, mTimeOfDay(wander->mData.mTimeOfDay)
|
, mTimeOfDay(wander->mData.mTimeOfDay)
|
||||||
, mRepeat(wander->mData.mShouldRepeat != 0)
|
, mRepeat(wander->mData.mShouldRepeat != 0)
|
||||||
, mStoredInitialActorPosition(wander->mStoredInitialActorPosition)
|
, mStoredInitialActorPosition(wander->mStoredInitialActorPosition)
|
||||||
, mIsWanderDestReady(false)
|
|
||||||
{
|
{
|
||||||
if (mStoredInitialActorPosition)
|
if (mStoredInitialActorPosition)
|
||||||
mInitialActorPosition = wander->mInitialActorPosition;
|
mInitialActorPosition = wander->mInitialActorPosition;
|
||||||
|
|
|
@ -108,8 +108,6 @@ namespace MWMechanics
|
||||||
osg::Vec3f mInitialActorPosition;
|
osg::Vec3f mInitialActorPosition;
|
||||||
bool mStoredInitialActorPosition;
|
bool mStoredInitialActorPosition;
|
||||||
|
|
||||||
bool mIsWanderDestReady;
|
|
||||||
|
|
||||||
void getAllowedNodes(const MWWorld::Ptr& actor, const ESM::Cell* cell, AiWanderStorage& storage);
|
void getAllowedNodes(const MWWorld::Ptr& actor, const ESM::Cell* cell, AiWanderStorage& storage);
|
||||||
|
|
||||||
void trimAllowedNodes(std::vector<ESM::Pathgrid::Point>& nodes, const PathFinder& pathfinder);
|
void trimAllowedNodes(std::vector<ESM::Pathgrid::Point>& nodes, const PathFinder& pathfinder);
|
||||||
|
|
Loading…
Reference in a new issue