forked from mirror/openmw-tes3mp
Revert "Change all AI packages (except AiActivate) to use ActorIds"
Causes potential infinite loops (AiSequence::fill -> AiPackage() -> getCreatureStats -> ensureCustomData -> ..)
This reverts commit 2e9985c1a3
.
This commit is contained in:
parent
028e00c98f
commit
36d9ae17cc
11 changed files with 61 additions and 86 deletions
|
@ -540,7 +540,7 @@ namespace MWMechanics
|
||||||
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
MWMechanics::CreatureStats& summonedCreatureStats = ref.getPtr().getClass().getCreatureStats(ref.getPtr());
|
||||||
|
|
||||||
// Make the summoned creature follow its master and help in fights
|
// Make the summoned creature follow its master and help in fights
|
||||||
AiFollow package(ptr);
|
AiFollow package(ptr.getRefData().getHandle());
|
||||||
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
|
summonedCreatureStats.getAiSequence().stack(package, ref.getPtr());
|
||||||
int creatureActorId = summonedCreatureStats.getActorId();
|
int creatureActorId = summonedCreatureStats.getActorId();
|
||||||
|
|
||||||
|
@ -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), ptr);
|
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(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())
|
else if (!creatureStats.isHostile())
|
||||||
{
|
{
|
||||||
if (ptr.getClass().isClass(ptr, "Guard"))
|
if (ptr.getClass().isClass(ptr, "Guard"))
|
||||||
creatureStats.getAiSequence().stack(AiPursue(player), ptr);
|
creatureStats.getAiSequence().stack(AiPursue(player.getClass().getId(player)), ptr);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
MWBase::Environment::get().getMechanicsManager()->startCombat(ptr, player);
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace MWMechanics
|
||||||
// NOTE: MIN_DIST_TO_DOOR_SQUARED is defined in obstacle.hpp
|
// NOTE: MIN_DIST_TO_DOOR_SQUARED is defined in obstacle.hpp
|
||||||
|
|
||||||
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
|
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
|
||||||
mTargetActorId(actor.getClass().getCreatureStats(actor).getActorId()),
|
mTarget(actor),
|
||||||
mTimerAttack(0),
|
mTimerAttack(0),
|
||||||
mTimerReact(0),
|
mTimerReact(0),
|
||||||
mTimerCombatMove(0),
|
mTimerCombatMove(0),
|
||||||
|
@ -153,9 +153,7 @@ namespace MWMechanics
|
||||||
|| actor.getClass().getCreatureStats(actor).getHealth().getCurrent() <= 0)
|
|| actor.getClass().getCreatureStats(actor).getHealth().getCurrent() <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
if(mTarget.getClass().getCreatureStats(mTarget).isDead())
|
||||||
|
|
||||||
if(target.getClass().getCreatureStats(target).isDead())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//Update every frame
|
//Update every frame
|
||||||
|
@ -327,7 +325,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
Ogre::Vector3 vActorPos(pos.pos);
|
Ogre::Vector3 vActorPos(pos.pos);
|
||||||
Ogre::Vector3 vTargetPos(target.getRefData().getPosition().pos);
|
Ogre::Vector3 vTargetPos(mTarget.getRefData().getPosition().pos);
|
||||||
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
|
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
|
||||||
|
|
||||||
bool isStuck = false;
|
bool isStuck = false;
|
||||||
|
@ -398,7 +396,7 @@ namespace MWMechanics
|
||||||
else // remote pathfinding
|
else // remote pathfinding
|
||||||
{
|
{
|
||||||
bool preferShortcut = false;
|
bool preferShortcut = false;
|
||||||
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, target);
|
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, mTarget);
|
||||||
|
|
||||||
if(mReadyToAttack) isStuck = false;
|
if(mReadyToAttack) isStuck = false;
|
||||||
|
|
||||||
|
@ -434,7 +432,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
mFollowTarget = false;
|
mFollowTarget = false;
|
||||||
|
|
||||||
buildNewPath(actor, target); //may fail to build a path, check before use
|
buildNewPath(actor); //may fail to build a path, check before use
|
||||||
|
|
||||||
//delete visited path node
|
//delete visited path node
|
||||||
mPathFinder.checkWaypoint(pos.pos[0],pos.pos[1],pos.pos[2]);
|
mPathFinder.checkWaypoint(pos.pos[0],pos.pos[1],pos.pos[2]);
|
||||||
|
@ -478,9 +476,9 @@ namespace MWMechanics
|
||||||
//less than in time of playing weapon anim from 'start' to 'hit' tags (t_swing)
|
//less than in time of playing weapon anim from 'start' to 'hit' tags (t_swing)
|
||||||
//then start attacking
|
//then start attacking
|
||||||
float speed1 = actorCls.getSpeed(actor);
|
float speed1 = actorCls.getSpeed(actor);
|
||||||
float speed2 = target.getClass().getSpeed(target);
|
float speed2 = mTarget.getClass().getSpeed(mTarget);
|
||||||
if(target.getClass().getMovementSettings(target).mPosition[0] == 0
|
if(mTarget.getClass().getMovementSettings(mTarget).mPosition[0] == 0
|
||||||
&& target.getClass().getMovementSettings(target).mPosition[1] == 0)
|
&& mTarget.getClass().getMovementSettings(mTarget).mPosition[1] == 0)
|
||||||
speed2 = 0;
|
speed2 = 0;
|
||||||
|
|
||||||
float s1 = distToTarget - weapRange;
|
float s1 = distToTarget - weapRange;
|
||||||
|
@ -572,9 +570,9 @@ namespace MWMechanics
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiCombat::buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target)
|
void AiCombat::buildNewPath(const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 newPathTarget = Ogre::Vector3(target.getRefData().getPosition().pos);
|
Ogre::Vector3 newPathTarget = Ogre::Vector3(mTarget.getRefData().getPosition().pos);
|
||||||
|
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
|
@ -629,12 +627,9 @@ namespace MWMechanics
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AiCombat::getTargetId() const
|
const std::string &AiCombat::getTargetId() const
|
||||||
{
|
{
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
return mTarget.getRefData().getHandle();
|
||||||
if (target.isEmpty())
|
|
||||||
return "";
|
|
||||||
return target.getRefData().getHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace MWMechanics
|
||||||
virtual unsigned int getPriority() const;
|
virtual unsigned int getPriority() const;
|
||||||
|
|
||||||
///Returns target ID
|
///Returns target ID
|
||||||
std::string getTargetId() const;
|
const std::string &getTargetId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathFinder mPathFinder;
|
PathFinder mPathFinder;
|
||||||
|
@ -53,7 +53,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
ESM::Position mLastPos;
|
ESM::Position mLastPos;
|
||||||
MWMechanics::Movement mMovement;
|
MWMechanics::Movement mMovement;
|
||||||
int mTargetActorId;
|
MWWorld::Ptr mTarget;
|
||||||
|
|
||||||
const MWWorld::CellStore* mCell;
|
const MWWorld::CellStore* mCell;
|
||||||
ObstacleCheck mObstacleCheck;
|
ObstacleCheck mObstacleCheck;
|
||||||
|
@ -63,7 +63,7 @@ namespace MWMechanics
|
||||||
MWWorld::CellRefList<ESM::Door>::List::iterator mDoorIter;
|
MWWorld::CellRefList<ESM::Door>::List::iterator mDoorIter;
|
||||||
MWWorld::CellRefList<ESM::Door>& mDoors;
|
MWWorld::CellRefList<ESM::Door>& mDoors;
|
||||||
|
|
||||||
void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target);
|
void buildNewPath(const MWWorld::Ptr& actor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/timestamp.hpp"
|
#include "../mwworld/timestamp.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
|
||||||
|
|
||||||
#include "steering.hpp"
|
#include "steering.hpp"
|
||||||
#include "movement.hpp"
|
#include "movement.hpp"
|
||||||
|
|
||||||
|
@ -21,8 +19,8 @@
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
AiEscort::AiEscort(const MWWorld::Ptr& actor, int duration, float x, float y, float z)
|
AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z)
|
||||||
: mActorId(actor.getClass().getCreatureStats(actor).getActorId()), mX(x), mY(y), mZ(z), mDuration(duration)
|
: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration)
|
||||||
, mCellX(std::numeric_limits<int>::max())
|
, mCellX(std::numeric_limits<int>::max())
|
||||||
, mCellY(std::numeric_limits<int>::max())
|
, mCellY(std::numeric_limits<int>::max())
|
||||||
{
|
{
|
||||||
|
@ -40,8 +38,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AiEscort::AiEscort(const MWWorld::Ptr& actor, const std::string &cellId,int duration, float x, float y, float z)
|
AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z)
|
||||||
: mActorId(actor.getClass().getCreatureStats(actor).getActorId()), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
|
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
|
||||||
, mCellX(std::numeric_limits<int>::max())
|
, mCellX(std::numeric_limits<int>::max())
|
||||||
, mCellY(std::numeric_limits<int>::max())
|
, mCellY(std::numeric_limits<int>::max())
|
||||||
{
|
{
|
||||||
|
@ -77,14 +75,7 @@ namespace MWMechanics
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId);
|
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->getPtr(mActorId, false);
|
||||||
if (follower.isEmpty())
|
|
||||||
{
|
|
||||||
// The follower disappeared
|
|
||||||
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float* const leaderPos = actor.getRefData().getPosition().pos;
|
const float* const leaderPos = actor.getRefData().getPosition().pos;
|
||||||
const float* const followerPos = follower.getRefData().getPosition().pos;
|
const float* const followerPos = follower.getRefData().getPosition().pos;
|
||||||
double differenceBetween[3];
|
double differenceBetween[3];
|
||||||
|
|
|
@ -15,11 +15,11 @@ namespace MWMechanics
|
||||||
/// Implementation of AiEscort
|
/// Implementation of AiEscort
|
||||||
/** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time
|
/** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time
|
||||||
\implement AiEscort **/
|
\implement AiEscort **/
|
||||||
AiEscort(const MWWorld::Ptr& actor,int duration, float x, float y, float z);
|
AiEscort(const std::string &actorId,int duration, float x, float y, float z);
|
||||||
/// Implementation of AiEscortCell
|
/// Implementation of AiEscortCell
|
||||||
/** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time
|
/** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time
|
||||||
\implement AiEscortCell **/
|
\implement AiEscortCell **/
|
||||||
AiEscort(const MWWorld::Ptr& actor,const std::string &cellId,int duration, float x, float y, float z);
|
AiEscort(const std::string &actorId,const std::string &cellId,int duration, float x, float y, float z);
|
||||||
|
|
||||||
virtual AiEscort *clone() const;
|
virtual AiEscort *clone() const;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace MWMechanics
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mActorId;
|
std::string mActorId;
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
float mX;
|
float mX;
|
||||||
float mY;
|
float mY;
|
||||||
|
|
|
@ -11,26 +11,23 @@
|
||||||
|
|
||||||
#include "steering.hpp"
|
#include "steering.hpp"
|
||||||
|
|
||||||
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor,float duration, float x, float y, float z)
|
MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
|
||||||
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mCellId(""), AiPackage()
|
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId), mCellId(""), AiPackage()
|
||||||
{
|
{
|
||||||
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
|
|
||||||
}
|
}
|
||||||
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor,const std::string &cellId,float duration, float x, float y, float z)
|
MWMechanics::AiFollow::AiFollow(const std::string &actorId,const std::string &cellId,float duration, float x, float y, float z)
|
||||||
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mCellId(cellId), AiPackage()
|
: mAlwaysFollow(false), mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId), mCellId(cellId), AiPackage()
|
||||||
{
|
{
|
||||||
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiFollow::AiFollow(const MWWorld::Ptr& actor)
|
MWMechanics::AiFollow::AiFollow(const std::string &actorId)
|
||||||
: mAlwaysFollow(true), mDuration(0), mX(0), mY(0), mZ(0), mCellId(""), AiPackage()
|
: mAlwaysFollow(true), mDuration(0), mX(0), mY(0), mZ(0), mActorId(actorId), mCellId(""), AiPackage()
|
||||||
{
|
{
|
||||||
mActorId = actor.getClass().getCreatureStats(actor).getActorId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
|
bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId); //The target to follow
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mActorId, false); //The target to follow
|
||||||
|
|
||||||
if(target == MWWorld::Ptr()) return true; //Target doesn't exist
|
if(target == MWWorld::Ptr()) return true; //Target doesn't exist
|
||||||
|
|
||||||
|
@ -78,8 +75,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
|
|
||||||
std::string MWMechanics::AiFollow::getFollowedActor()
|
std::string MWMechanics::AiFollow::getFollowedActor()
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mActorId); //The target to follow
|
return mActorId;
|
||||||
return target.getCellRef().mRefID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const
|
MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const
|
||||||
|
|
|
@ -15,11 +15,11 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Follow Actor for duration or until you arrive at a world position
|
/// Follow Actor for duration or until you arrive at a world position
|
||||||
AiFollow(const MWWorld::Ptr& actor,float duration, float X, float Y, float Z);
|
AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z);
|
||||||
/// Follow Actor for duration or until you arrive at a position in a cell
|
/// Follow Actor for duration or until you arrive at a position in a cell
|
||||||
AiFollow(const MWWorld::Ptr& actor,const std::string &CellId,float duration, float X, float Y, float Z);
|
AiFollow(const std::string &ActorId,const std::string &CellId,float duration, float X, float Y, float Z);
|
||||||
/// Follow Actor indefinitively
|
/// Follow Actor indefinitively
|
||||||
AiFollow(const MWWorld::Ptr& actor);
|
AiFollow(const std::string &ActorId);
|
||||||
|
|
||||||
virtual AiFollow *clone() const;
|
virtual AiFollow *clone() const;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace MWMechanics
|
||||||
float mX;
|
float mX;
|
||||||
float mY;
|
float mY;
|
||||||
float mZ;
|
float mZ;
|
||||||
int mActorId; // The actor we should follow
|
std::string mActorId;
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
#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 MWWorld::Ptr& actor)
|
MWMechanics::AiPursue::AiPursue(const std::string &objectId)
|
||||||
: mActorId(actor.getClass().getCreatureStats(actor).getActorId())
|
: mObjectId(objectId)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
MWMechanics::AiPursue *MWMechanics::AiPursue::clone() const
|
MWMechanics::AiPursue *MWMechanics::AiPursue::clone() const
|
||||||
|
@ -25,7 +23,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()->searchPtrViaActorId(mActorId); //The target to follow
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
||||||
|
|
||||||
if(target == MWWorld::Ptr())
|
if(target == MWWorld::Ptr())
|
||||||
return true; //Target doesn't exist
|
return true; //Target doesn't exist
|
||||||
|
@ -35,7 +33,8 @@ 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;
|
||||||
target.getClass().activate(target,actor).get()->execute(actor); //Arrest player
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
|
||||||
|
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 actor Actor to pursue **/
|
/** \param objectId Actor to pursue **/
|
||||||
AiPursue(const MWWorld::Ptr& actor);
|
AiPursue(const std::string &objectId);
|
||||||
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:
|
||||||
int mActorId; // The actor to pursue
|
std::string mObjectId;
|
||||||
int mCellX;
|
int mCellX;
|
||||||
int mCellY;
|
int mCellY;
|
||||||
};
|
};
|
||||||
|
|
|
@ -175,8 +175,7 @@ void MWMechanics::AiSequence::fill(const ESM::AIPackageList &list)
|
||||||
else if (it->mType == ESM::AI_Escort)
|
else if (it->mType == ESM::AI_Escort)
|
||||||
{
|
{
|
||||||
ESM::AITarget data = it->mTarget;
|
ESM::AITarget data = it->mTarget;
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(data.mId.toString(), false);
|
package = new MWMechanics::AiEscort(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
||||||
package = new MWMechanics::AiEscort(target, data.mDuration, data.mX, data.mY, data.mZ);
|
|
||||||
}
|
}
|
||||||
else if (it->mType == ESM::AI_Travel)
|
else if (it->mType == ESM::AI_Travel)
|
||||||
{
|
{
|
||||||
|
@ -191,8 +190,7 @@ void MWMechanics::AiSequence::fill(const ESM::AIPackageList &list)
|
||||||
else //if (it->mType == ESM::AI_Follow)
|
else //if (it->mType == ESM::AI_Follow)
|
||||||
{
|
{
|
||||||
ESM::AITarget data = it->mTarget;
|
ESM::AITarget data = it->mTarget;
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(data.mId.toString(), false);
|
package = new MWMechanics::AiFollow(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
||||||
package = new MWMechanics::AiFollow(target, data.mDuration, data.mX, data.mY, data.mZ);
|
|
||||||
}
|
}
|
||||||
mPackages.push_back(package);
|
mPackages.push_back(package);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,6 @@ namespace MWScript
|
||||||
|
|
||||||
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPtr(actorID, true);
|
|
||||||
|
|
||||||
Interpreter::Type_Float duration = runtime[0].mFloat;
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -108,7 +107,7 @@ namespace MWScript
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
// discard additional arguments (reset), because we have no idea what they mean.
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||||
|
|
||||||
MWMechanics::AiEscort escortPackage(actor, duration, x, y, z);
|
MWMechanics::AiEscort escortPackage(actorID, duration, x, y, z);
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
|
||||||
|
|
||||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
||||||
|
@ -127,7 +126,6 @@ namespace MWScript
|
||||||
|
|
||||||
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPtr(actorID, true);
|
|
||||||
|
|
||||||
std::string cellID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string cellID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -147,7 +145,7 @@ namespace MWScript
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
// discard additional arguments (reset), because we have no idea what they mean.
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||||
|
|
||||||
MWMechanics::AiEscort escortPackage(actor, cellID, duration, x, y, z);
|
MWMechanics::AiEscort escortPackage(actorID, cellID, duration, x, y, z);
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
|
||||||
|
|
||||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
||||||
|
@ -283,7 +281,6 @@ namespace MWScript
|
||||||
|
|
||||||
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPtr(actorID, true);
|
|
||||||
|
|
||||||
Interpreter::Type_Float duration = runtime[0].mFloat;
|
Interpreter::Type_Float duration = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -300,7 +297,7 @@ namespace MWScript
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
// discard additional arguments (reset), because we have no idea what they mean.
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||||
|
|
||||||
MWMechanics::AiFollow followPackage(actor, duration, x, y ,z);
|
MWMechanics::AiFollow followPackage(actorID, duration, x, y ,z);
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
|
||||||
|
|
||||||
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
|
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
|
||||||
|
@ -319,7 +316,6 @@ namespace MWScript
|
||||||
|
|
||||||
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actorID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPtr(actorID, true);
|
|
||||||
|
|
||||||
std::string cellID = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string cellID = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -339,8 +335,8 @@ namespace MWScript
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
// discard additional arguments (reset), because we have no idea what they mean.
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
||||||
|
|
||||||
MWMechanics::AiFollow followPackage(actor, cellID, duration, x, y ,z);
|
MWMechanics::AiFollow followPackage(actorID, cellID, duration, x, y ,z);
|
||||||
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
|
||||||
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
|
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue