|
|
|
@ -92,30 +92,35 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
zTurn(actor, mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
|
|
|
|
|
evadeObstacles(actor, duration, pos);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWMechanics::Movement& movement = actor.getClass().getMovementSettings(actor);
|
|
|
|
|
if(mObstacleCheck.check(actor, duration))
|
|
|
|
|
void MWMechanics::AiPackage::evadeObstacles(const MWWorld::Ptr& actor, float duration, ESM::Position& pos)
|
|
|
|
|
{
|
|
|
|
|
zTurn(actor, mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
|
|
|
|
|
|
|
|
|
|
MWMechanics::Movement& movement = actor.getClass().getMovementSettings(actor);
|
|
|
|
|
if (mObstacleCheck.check(actor, duration))
|
|
|
|
|
{
|
|
|
|
|
// first check if we're walking into a door
|
|
|
|
|
MWWorld::Ptr door = getNearbyDoor(actor);
|
|
|
|
|
if (door != MWWorld::Ptr()) // NOTE: checks interior cells only
|
|
|
|
|
{
|
|
|
|
|
// first check if we're walking into a door
|
|
|
|
|
MWWorld::Ptr door = getNearbyDoor(actor);
|
|
|
|
|
if(door != MWWorld::Ptr()) // NOTE: checks interior cells only
|
|
|
|
|
{
|
|
|
|
|
if(!door.getCellRef().getTeleport() && door.getCellRef().getTrap().empty() && door.getClass().getDoorState(door) == 0) { //Open the door if untrapped
|
|
|
|
|
MWBase::Environment::get().getWorld()->activateDoor(door, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // probably walking into another NPC
|
|
|
|
|
{
|
|
|
|
|
movement.mPosition[0] = 1;
|
|
|
|
|
movement.mPosition[1] = 1;
|
|
|
|
|
if (!door.getCellRef().getTeleport() && door.getCellRef().getTrap().empty() && door.getClass().getDoorState(door) == 0) { //Open the door if untrapped
|
|
|
|
|
MWBase::Environment::get().getWorld()->activateDoor(door, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { //Not stuck, so reset things
|
|
|
|
|
movement.mPosition[1] = 1; //Just run forward
|
|
|
|
|
else // probably walking into another NPC
|
|
|
|
|
{
|
|
|
|
|
movement.mPosition[0] = 1;
|
|
|
|
|
movement.mPosition[1] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
else { //Not stuck, so reset things
|
|
|
|
|
movement.mPosition[1] = 1; //Just run forward
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MWMechanics::AiPackage::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell)
|
|
|
|
|