|
|
|
@ -157,8 +157,10 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f&
|
|
|
|
|
{
|
|
|
|
|
const ESM::Pathgrid* pathgrid
|
|
|
|
|
= world->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->getCell());
|
|
|
|
|
const DetourNavigator::Flags navigatorFlags = getNavigatorFlags(actor);
|
|
|
|
|
const DetourNavigator::AreaCosts areaCosts = getAreaCosts(actor, navigatorFlags);
|
|
|
|
|
mPathFinder.buildLimitedPath(actor, position, dest, actor.getCell(), getPathGridGraph(pathgrid),
|
|
|
|
|
agentBounds, getNavigatorFlags(actor), getAreaCosts(actor), endTolerance, pathType);
|
|
|
|
|
agentBounds, navigatorFlags, areaCosts, endTolerance, pathType);
|
|
|
|
|
mRotateOnTheRunChecks = 3;
|
|
|
|
|
|
|
|
|
|
// give priority to go directly on target if there is minimal opportunity
|
|
|
|
@ -486,14 +488,12 @@ DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DetourNavigator::AreaCosts MWMechanics::AiPackage::getAreaCosts(const MWWorld::Ptr& actor) const
|
|
|
|
|
DetourNavigator::AreaCosts MWMechanics::AiPackage::getAreaCosts(
|
|
|
|
|
const MWWorld::Ptr& actor, DetourNavigator::Flags flags) const
|
|
|
|
|
{
|
|
|
|
|
DetourNavigator::AreaCosts costs;
|
|
|
|
|
const DetourNavigator::Flags flags = getNavigatorFlags(actor);
|
|
|
|
|
const MWWorld::Class& actorClass = actor.getClass();
|
|
|
|
|
|
|
|
|
|
const float swimSpeed = (flags & DetourNavigator::Flag_swim) == 0 ? 0.0f : actorClass.getSwimSpeed(actor);
|
|
|
|
|
|
|
|
|
|
const float walkSpeed = [&] {
|
|
|
|
|
if ((flags & DetourNavigator::Flag_walk) == 0)
|
|
|
|
|
return 0.0f;
|
|
|
|
@ -502,6 +502,14 @@ DetourNavigator::AreaCosts MWMechanics::AiPackage::getAreaCosts(const MWWorld::P
|
|
|
|
|
return actorClass.getRunSpeed(actor);
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
const float swimSpeed = [&] {
|
|
|
|
|
if ((flags & DetourNavigator::Flag_swim) == 0)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
if (hasWaterWalking(actor))
|
|
|
|
|
return walkSpeed;
|
|
|
|
|
return actorClass.getSwimSpeed(actor);
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
const float maxSpeed = std::max(swimSpeed, walkSpeed);
|
|
|
|
|
|
|
|
|
|
if (maxSpeed == 0)
|
|
|
|
|