|
|
|
@ -13,6 +13,8 @@
|
|
|
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwphysics/collisiontype.hpp"
|
|
|
|
|
|
|
|
|
|
#include "pathgrid.hpp"
|
|
|
|
|
#include "creaturestats.hpp"
|
|
|
|
|
#include "movement.hpp"
|
|
|
|
@ -234,6 +236,9 @@ void MWMechanics::AiPackage::openDoors(const MWWorld::Ptr& actor)
|
|
|
|
|
// note: AiWander currently does not open doors
|
|
|
|
|
if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getClass().getDoorState(door) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!isDoorOnTheWay(actor, door))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ((door.getCellRef().getTrap().empty() && door.getCellRef().getLockLevel() <= 0 ))
|
|
|
|
|
{
|
|
|
|
|
world->activate(door, actor);
|
|
|
|
@ -402,3 +407,16 @@ DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MWMechanics::AiPackage::isDoorOnTheWay(const MWWorld::Ptr& actor, const MWWorld::Ptr& door) const
|
|
|
|
|
{
|
|
|
|
|
if (mPathFinder.getPathSize() == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const auto world = MWBase::Environment::get().getWorld();
|
|
|
|
|
const auto halfExtents = world->getHalfExtents(actor);
|
|
|
|
|
const auto position = actor.getRefData().getPosition().asVec3() + osg::Vec3f(0, 0, halfExtents.z());
|
|
|
|
|
const auto destination = mPathFinder.getPath().front() + osg::Vec3f(0, 0, halfExtents.z());
|
|
|
|
|
|
|
|
|
|
return world->castRay(position, destination, MWPhysics::CollisionType_Door) == door;
|
|
|
|
|
}
|
|
|
|
|