Un-reverted actorId for AiPursue

deque
scrawl 11 years ago
parent e266aff561
commit 92c5bb56e0

@ -759,7 +759,7 @@ namespace MWMechanics
&& MWBase::Environment::get().getWorld()->getLOS(ptr, player) && MWBase::Environment::get().getWorld()->getLOS(ptr, player)
&& MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr)) && MWBase::Environment::get().getMechanicsManager()->awarenessCheck(player, ptr))
{ {
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr); creatureStats.getAiSequence().stack(AiPursue(player), ptr);
creatureStats.setAlarmed(true); creatureStats.setAlarmed(true);
npcStats.setCrimeId(MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId()); npcStats.setCrimeId(MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId());
} }
@ -788,7 +788,7 @@ namespace MWMechanics
else if (!creatureStats.isHostile() && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue) else if (!creatureStats.isHostile() && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue)
{ {
if (ptr.getClass().isClass(ptr, "Guard")) if (ptr.getClass().isClass(ptr, "Guard"))
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr); creatureStats.getAiSequence().stack(AiPursue(player), ptr);
else else
{ {
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player); MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);

@ -7,12 +7,14 @@
#include "../mwworld/action.hpp" #include "../mwworld/action.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp" #include "movement.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
MWMechanics::AiPursue::AiPursue(const std::string &objectId) MWMechanics::AiPursue::AiPursue(const MWWorld::Ptr& actor)
: mObjectId(objectId) : mActorId(actor.getClass().getCreatureStats(actor).getActorId())
{ {
} }
MWMechanics::AiPursue *MWMechanics::AiPursue::clone() const 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 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()) if(target == MWWorld::Ptr())
return true; //Target doesn't exist 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 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; actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false); target.getClass().activate(target,actor).get()->execute(actor); //Arrest player
MWWorld::Class::get(target).activate(target,actor).get()->execute(actor); //Arrest player
return true; return true;
} }
else { else {

@ -16,14 +16,14 @@ namespace MWMechanics
{ {
public: public:
///Constructor ///Constructor
/** \param objectId Actor to pursue **/ /** \param actor Actor to pursue **/
AiPursue(const std::string &objectId); AiPursue(const MWWorld::Ptr& actor);
virtual AiPursue *clone() const; virtual AiPursue *clone() const;
virtual bool execute (const MWWorld::Ptr& actor,float duration); virtual bool execute (const MWWorld::Ptr& actor,float duration);
virtual int getTypeId() const; virtual int getTypeId() const;
private: private:
std::string mObjectId; int mActorId; // The actor to pursue
int mCellX; int mCellX;
int mCellY; int mCellY;
}; };

Loading…
Cancel
Save