|
|
|
@ -7,12 +7,14 @@
|
|
|
|
|
#include "../mwworld/action.hpp"
|
|
|
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
|
|
|
|
|
|
#include "steering.hpp"
|
|
|
|
|
#include "movement.hpp"
|
|
|
|
|
#include "creaturestats.hpp"
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiPursue::AiPursue(const std::string &objectId)
|
|
|
|
|
: mObjectId(objectId)
|
|
|
|
|
MWMechanics::AiPursue::AiPursue(const MWWorld::Ptr& actor)
|
|
|
|
|
: mActorId(actor.getClass().getCreatureStats(actor).getActorId())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
MWMechanics::AiPursue *MWMechanics::AiPursue::clone() const
|
|
|
|
@ -23,7 +25,7 @@ bool MWMechanics::AiPursue::execute (const MWWorld::Ptr& actor, float duration)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
|
|
|
|
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
|
|
|
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId); //The target to follow
|
|
|
|
|
|
|
|
|
|
if(target == MWWorld::Ptr())
|
|
|
|
|
return true; //Target doesn't exist
|
|
|
|
@ -33,8 +35,7 @@ bool MWMechanics::AiPursue::execute (const MWWorld::Ptr& actor, float duration)
|
|
|
|
|
|
|
|
|
|
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 100) { //Stop when you get close
|
|
|
|
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
|
|
|
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
|
|
|
|
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
|
|
|
|
|
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|