|
|
@ -28,30 +28,35 @@ struct AiFollowStorage : AiTemporaryBase
|
|
|
|
int AiFollow::mFollowIndexCounter = 0;
|
|
|
|
int AiFollow::mFollowIndexCounter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
|
|
|
|
AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
|
|
|
|
: mAlwaysFollow(false), mCommanded(false), mRemainingDuration(duration), mX(x), mY(y), mZ(z)
|
|
|
|
: mAlwaysFollow(false), mCommanded(false), mDuration(duration), mRemainingDuration(duration), mX(x), mY(y), mZ(z)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AiFollow::AiFollow(const std::string &actorId,const std::string &cellId,float duration, float x, float y, float z)
|
|
|
|
AiFollow::AiFollow(const std::string &actorId,const std::string &cellId,float duration, float x, float y, float z)
|
|
|
|
: mAlwaysFollow(false), mCommanded(false), mRemainingDuration(duration), mX(x), mY(y), mZ(z)
|
|
|
|
: mAlwaysFollow(false), mCommanded(false), mDuration(duration), mRemainingDuration(duration), mX(x), mY(y), mZ(z)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(cellId), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(cellId), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AiFollow::AiFollow(const std::string &actorId, bool commanded)
|
|
|
|
AiFollow::AiFollow(const std::string &actorId, bool commanded)
|
|
|
|
: mAlwaysFollow(true), mCommanded(commanded), mRemainingDuration(0), mX(0), mY(0), mZ(0)
|
|
|
|
: mAlwaysFollow(true), mCommanded(commanded), mDuration(0), mRemainingDuration(0), mX(0), mY(0), mZ(0)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
, mActorRefId(actorId), mActorId(-1), mCellId(""), mActive(false), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
|
|
|
|
AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
|
|
|
|
: mAlwaysFollow(follow->mAlwaysFollow), mCommanded(follow->mCommanded), mRemainingDuration(follow->mRemainingDuration)
|
|
|
|
: mCommanded(follow->mCommanded), mRemainingDuration(follow->mRemainingDuration)
|
|
|
|
, mX(follow->mData.mX), mY(follow->mData.mY), mZ(follow->mData.mZ)
|
|
|
|
, mX(follow->mData.mX), mY(follow->mData.mY), mZ(follow->mData.mZ)
|
|
|
|
, mActorRefId(follow->mTargetId), mActorId(-1)
|
|
|
|
, mActorRefId(follow->mTargetId), mActorId(-1)
|
|
|
|
, mCellId(follow->mCellId), mActive(follow->mActive), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
, mCellId(follow->mCellId), mActive(follow->mActive), mFollowIndex(mFollowIndexCounter++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// mDuration isn't saved in the save file, so just giving it "1" for now if the package has a duration.
|
|
|
|
|
|
|
|
// The exact value of mDuration only matters for repeating packages
|
|
|
|
|
|
|
|
if (mRemainingDuration != 0)
|
|
|
|
|
|
|
|
mDuration = 1;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mDuration = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
|
|
|
bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
|
|
@ -101,11 +106,14 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte
|
|
|
|
if(!mAlwaysFollow) //Update if you only follow for a bit
|
|
|
|
if(!mAlwaysFollow) //Update if you only follow for a bit
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Check if we've run out of time
|
|
|
|
//Check if we've run out of time
|
|
|
|
if (mRemainingDuration != 0)
|
|
|
|
if (mDuration != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRemainingDuration -= duration;
|
|
|
|
mRemainingDuration -= ((duration*MWBase::Environment::get().getWorld()->getTimeScaleFactor()) / 3600);
|
|
|
|
if (duration <= 0)
|
|
|
|
if (mRemainingDuration <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mRemainingDuration = mDuration;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if((pos.pos[0]-mX)*(pos.pos[0]-mX) +
|
|
|
|
if((pos.pos[0]-mX)*(pos.pos[0]-mX) +
|
|
|
@ -228,4 +236,10 @@ int AiFollow::getFollowIndex() const
|
|
|
|
return mFollowIndex;
|
|
|
|
return mFollowIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AiFollow::fastForward(const MWWorld::Ptr& actor, AiState &state)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Update duration counter
|
|
|
|
|
|
|
|
mRemainingDuration--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|