2014-01-24 19:16:50 +01:00
|
|
|
#include "aifollow.hpp"
|
2014-06-12 23:27:04 +02:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/aisequence.hpp>
|
|
|
|
#include <components/esm3/loadcell.hpp>
|
2023-01-19 17:31:45 +01:00
|
|
|
#include <components/misc/algorithm.hpp>
|
2014-06-12 23:27:04 +02:00
|
|
|
|
2014-01-11 12:06:36 +01:00
|
|
|
#include "../mwbase/environment.hpp"
|
2014-12-09 16:02:07 +01:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2014-01-11 12:06:36 +01:00
|
|
|
#include "../mwbase/world.hpp"
|
2016-06-17 23:07:16 +09:00
|
|
|
|
2014-03-29 18:36:32 +01:00
|
|
|
#include "../mwworld/cellstore.hpp"
|
2014-01-11 12:06:36 +01:00
|
|
|
#include "../mwworld/class.hpp"
|
2016-06-17 23:07:16 +09:00
|
|
|
|
2014-04-23 02:57:48 -04:00
|
|
|
#include "creaturestats.hpp"
|
2014-01-29 20:29:07 +01:00
|
|
|
#include "steering.hpp"
|
|
|
|
|
2020-12-28 19:19:07 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
osg::Vec3f::value_type getHalfExtents(const MWWorld::ConstPtr& actor)
|
|
|
|
{
|
|
|
|
if (actor.getClass().isNpc())
|
|
|
|
return 64;
|
|
|
|
return MWBase::Environment::get().getWorld()->getHalfExtents(actor).y();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
int AiFollow::mFollowIndexCounter = 0;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
AiFollow::AiFollow(const ESM::RefId& actorId, float duration, float x, float y, float z, bool repeat)
|
2021-11-16 22:04:04 +01:00
|
|
|
: TypedAiPackage<AiFollow>(repeat)
|
|
|
|
, mAlwaysFollow(false)
|
|
|
|
, mDuration(duration)
|
2020-05-16 21:08:39 +02:00
|
|
|
, mRemainingDuration(duration)
|
|
|
|
, mX(x)
|
|
|
|
, mY(y)
|
|
|
|
, mZ(z)
|
2017-11-21 20:00:51 +04:00
|
|
|
, mActive(false)
|
2015-04-30 19:24:27 -05:00
|
|
|
, mFollowIndex(mFollowIndexCounter++)
|
2014-08-17 17:01:04 +02:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mTargetActorRefId = actorId;
|
2014-08-17 17:01:04 +02:00
|
|
|
}
|
2014-01-11 12:06:36 +01:00
|
|
|
|
2018-11-02 14:24:43 +03:00
|
|
|
AiFollow::AiFollow(
|
2023-01-19 17:31:45 +01:00
|
|
|
const ESM::RefId& actorId, std::string_view cellId, float duration, float x, float y, float z, bool repeat)
|
2018-11-02 14:24:43 +03:00
|
|
|
: TypedAiPackage<AiFollow>(repeat)
|
|
|
|
, mAlwaysFollow(false)
|
2021-11-17 20:44:55 +01:00
|
|
|
, mDuration(duration)
|
2018-11-02 14:24:43 +03:00
|
|
|
, mRemainingDuration(duration)
|
2022-09-22 21:26:05 +03:00
|
|
|
, mX(x)
|
|
|
|
, mY(y)
|
|
|
|
, mZ(z)
|
2017-11-21 20:00:51 +04:00
|
|
|
, mCellId(cellId)
|
|
|
|
, mActive(false)
|
2018-11-02 14:24:43 +03:00
|
|
|
, mFollowIndex(mFollowIndexCounter++)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mTargetActorRefId = actorId;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-01-11 12:06:36 +01:00
|
|
|
|
2022-07-17 19:36:48 +03:00
|
|
|
AiFollow::AiFollow(const MWWorld::Ptr& actor, bool commanded)
|
|
|
|
: TypedAiPackage<AiFollow>(makeDefaultOptions().withShouldCancelPreviousAi(!commanded))
|
2020-05-16 21:08:39 +02:00
|
|
|
, mAlwaysFollow(true)
|
2022-07-17 19:36:48 +03:00
|
|
|
, mDuration(0)
|
|
|
|
, mRemainingDuration(0)
|
2022-09-22 21:26:05 +03:00
|
|
|
, mX(0)
|
|
|
|
, mY(0)
|
|
|
|
, mZ(0)
|
2022-07-17 19:36:48 +03:00
|
|
|
, mActive(false)
|
|
|
|
, mFollowIndex(mFollowIndexCounter++)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2017-11-21 20:00:51 +04:00
|
|
|
mTargetActorRefId = actor.getCellRef().getRefId();
|
2022-07-17 19:36:48 +03:00
|
|
|
mTargetActorId = actor.getClass().getCreatureStats(actor).getActorId();
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-07-28 17:28:00 +02:00
|
|
|
|
2015-09-26 01:55:12 +02:00
|
|
|
AiFollow::AiFollow(const ESM::AiSequence::AiFollow* follow)
|
|
|
|
: TypedAiPackage<AiFollow>(
|
|
|
|
makeDefaultOptions().withShouldCancelPreviousAi(!follow->mCommanded).withRepeat(follow->mRepeat))
|
2020-05-16 21:08:39 +02:00
|
|
|
, mAlwaysFollow(follow->mAlwaysFollow)
|
2015-09-26 01:55:12 +02:00
|
|
|
, mDuration(follow->mData.mDuration)
|
|
|
|
, mRemainingDuration(follow->mRemainingDuration)
|
2014-08-17 17:01:04 +02:00
|
|
|
, mX(follow->mData.mX)
|
|
|
|
, mY(follow->mData.mY)
|
|
|
|
, mZ(follow->mData.mZ)
|
2015-04-30 19:24:27 -05:00
|
|
|
, mCellId(follow->mCellId)
|
|
|
|
, mActive(follow->mActive)
|
2015-09-26 01:55:12 +02:00
|
|
|
, mFollowIndex(mFollowIndexCounter++)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2015-09-26 01:55:12 +02:00
|
|
|
mTargetActorRefId = follow->mTargetId;
|
|
|
|
mTargetActorId = follow->mTargetActorId;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2015-09-26 01:55:12 +02:00
|
|
|
|
2017-08-13 18:05:35 +04:00
|
|
|
bool AiFollow::execute(
|
|
|
|
const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
|
|
|
{
|
|
|
|
const MWWorld::Ptr target = getTarget();
|
|
|
|
|
2018-11-02 14:24:43 +03:00
|
|
|
// Target is not here right now, wait for it to return
|
|
|
|
// Really we should be checking whether the target is currently registered with the MechanicsManager
|
|
|
|
if (target == MWWorld::Ptr() || !target.getRefData().getCount() || !target.getRefData().isEnabled())
|
2017-08-13 18:05:35 +04:00
|
|
|
return false;
|
|
|
|
|
2018-11-02 14:24:43 +03:00
|
|
|
actor.getClass().getCreatureStats(actor).setDrawState(DrawState::Nothing);
|
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
AiFollowStorage& storage = state.get<AiFollowStorage>();
|
|
|
|
|
|
|
|
bool& rotate = storage.mTurnActorToTarget;
|
|
|
|
if (rotate)
|
|
|
|
{
|
2018-11-02 14:24:43 +03:00
|
|
|
if (zTurn(actor, storage.mTargetAngleRadians))
|
2014-12-09 22:25:28 +01:00
|
|
|
rotate = false;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-12-25 23:57:01 +01:00
|
|
|
const osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3());
|
2018-11-02 14:24:43 +03:00
|
|
|
const osg::Vec3f targetPos(target.getRefData().getPosition().asVec3());
|
2020-12-25 23:57:01 +01:00
|
|
|
const osg::Vec3f targetDir = targetPos - actorPos;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-12-25 23:57:01 +01:00
|
|
|
// AiFollow requires the target to be in range and within sight for the initial activation
|
|
|
|
if (!mActive)
|
2017-03-26 16:51:32 +09:00
|
|
|
{
|
2020-12-28 19:19:07 +01:00
|
|
|
storage.mTimer -= duration;
|
2014-12-09 16:02:07 +01:00
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
if (storage.mTimer < 0)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2017-02-18 01:38:21 +09:00
|
|
|
if (targetDir.length2() < 500 * 500 && MWBase::Environment::get().getWorld()->getLOS(actor, target))
|
2014-12-09 22:25:28 +01:00
|
|
|
mActive = true;
|
|
|
|
storage.mTimer = 0.5f;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
}
|
2017-02-18 01:38:21 +09:00
|
|
|
if (!mActive)
|
2014-12-09 22:25:28 +01:00
|
|
|
return false;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2017-02-18 01:38:21 +09:00
|
|
|
// In the original engine the first follower stays closer to the player than any subsequent followers.
|
2014-06-12 23:27:04 +02:00
|
|
|
// Followers beyond the first usually attempt to stand inside each other.
|
|
|
|
osg::Vec3f::value_type floatingDistance = 0;
|
|
|
|
auto followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowingByIndex(target);
|
2017-02-18 01:38:21 +09:00
|
|
|
if (followers.size() >= 2 && followers.cbegin()->first != mFollowIndex)
|
2014-06-12 23:27:04 +02:00
|
|
|
{
|
2016-06-11 22:34:49 +09:00
|
|
|
for (auto& follower : followers)
|
|
|
|
{
|
|
|
|
auto halfExtent = getHalfExtents(follower.second);
|
|
|
|
if (halfExtent > floatingDistance)
|
|
|
|
floatingDistance = halfExtent;
|
|
|
|
}
|
2020-12-28 19:19:07 +01:00
|
|
|
floatingDistance += 128;
|
2014-06-12 23:27:04 +02:00
|
|
|
}
|
2020-12-28 19:19:07 +01:00
|
|
|
floatingDistance += getHalfExtents(target) + 64;
|
|
|
|
floatingDistance += getHalfExtents(actor) * 2;
|
2020-12-25 23:57:01 +01:00
|
|
|
short followDistance = static_cast<short>(floatingDistance);
|
2014-03-05 11:24:39 +01:00
|
|
|
|
2018-11-02 14:24:43 +03:00
|
|
|
if (!mAlwaysFollow) // Update if you only follow for a bit
|
2014-01-12 11:38:58 +01:00
|
|
|
{
|
2017-02-18 01:38:21 +09:00
|
|
|
// Check if we've run out of time
|
|
|
|
if (mDuration > 0)
|
2014-03-05 11:24:39 +01:00
|
|
|
{
|
2017-02-18 01:38:21 +09:00
|
|
|
mRemainingDuration -= ((duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor()) / 3600);
|
|
|
|
if (mRemainingDuration <= 0)
|
2021-11-17 20:44:55 +01:00
|
|
|
{
|
|
|
|
mRemainingDuration = mDuration;
|
2014-03-05 11:24:39 +01:00
|
|
|
return true;
|
2021-11-17 20:44:55 +01:00
|
|
|
}
|
2014-03-05 11:24:39 +01:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2021-11-17 20:44:55 +01:00
|
|
|
osg::Vec3f finalPos(mX, mY, mZ);
|
|
|
|
if ((actorPos - finalPos).length2() < followDistance * followDistance) // Close-ish to final position
|
2014-03-05 11:24:39 +01:00
|
|
|
{
|
2017-02-18 01:38:21 +09:00
|
|
|
if (actor.getCell()->isExterior()) // Outside?
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2023-01-21 17:45:23 +01:00
|
|
|
if (mCellId.empty()) // No cell to travel to
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-11-17 20:44:55 +01:00
|
|
|
mRemainingDuration = mDuration;
|
2014-03-05 11:24:39 +01:00
|
|
|
return true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
}
|
2023-04-02 22:00:39 +02:00
|
|
|
else if (mCellId == actor.getCell()->getCell()->getWorldSpace()) // Cell to travel to
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2021-11-17 20:44:55 +01:00
|
|
|
mRemainingDuration = mDuration;
|
|
|
|
return true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-03-05 11:24:39 +01:00
|
|
|
}
|
2014-01-12 11:38:58 +01:00
|
|
|
}
|
2014-01-11 12:06:36 +01:00
|
|
|
|
2017-08-13 18:05:35 +04:00
|
|
|
short baseFollowDistance = followDistance;
|
|
|
|
short threshold = 30; // to avoid constant switching between moving/stopping
|
2016-08-19 22:15:26 +03:00
|
|
|
if (storage.mMoving)
|
2017-08-13 18:05:35 +04:00
|
|
|
followDistance -= threshold;
|
2022-09-22 21:26:05 +03:00
|
|
|
else
|
2016-08-19 22:15:26 +03:00
|
|
|
followDistance += threshold;
|
2014-01-11 12:06:36 +01:00
|
|
|
|
2017-08-13 18:05:35 +04:00
|
|
|
if (targetDir.length2() <= followDistance * followDistance)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2017-08-13 18:05:35 +04:00
|
|
|
float faceAngleRadians = std::atan2(targetDir.x(), targetDir.y());
|
|
|
|
|
2018-11-02 14:24:43 +03:00
|
|
|
if (!zTurn(actor, faceAngleRadians, osg::DegreesToRadians(45.f)))
|
2017-08-13 18:05:35 +04:00
|
|
|
{
|
2018-11-02 14:24:43 +03:00
|
|
|
storage.mTargetAngleRadians = faceAngleRadians;
|
|
|
|
storage.mTurnActorToTarget = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2017-08-13 18:05:35 +04:00
|
|
|
|
|
|
|
return false;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
|
2017-08-13 18:05:35 +04:00
|
|
|
storage.mMoving = !pathTo(actor, targetPos, duration, baseFollowDistance); // Go to the destination
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2017-08-13 18:05:35 +04:00
|
|
|
if (storage.mMoving)
|
|
|
|
{
|
|
|
|
// Check if you're far away
|
|
|
|
if (targetDir.length2() > 450 * 450)
|
|
|
|
actor.getClass().getCreatureStats(actor).setMovementFlag(
|
|
|
|
MWMechanics::CreatureStats::Flag_Run, true); // Make NPC run
|
|
|
|
else if (targetDir.length2()
|
|
|
|
< 325 * 325) // Have a bit of a dead zone, otherwise npc will constantly flip between running and not
|
|
|
|
// when right on the edge of the running threshold
|
|
|
|
actor.getClass().getCreatureStats(actor).setMovementFlag(
|
|
|
|
MWMechanics::CreatureStats::Flag_Run, false); // make NPC walk
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2016-01-03 18:20:34 +01:00
|
|
|
}
|
2015-09-26 01:55:12 +02:00
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId AiFollow::getFollowedActor()
|
2016-08-14 18:02:13 +02:00
|
|
|
{
|
2016-08-19 22:15:26 +03:00
|
|
|
return mTargetActorRefId;
|
|
|
|
}
|
2014-04-23 02:57:48 -04:00
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
bool AiFollow::isCommanded() const
|
2014-08-06 21:16:14 +02:00
|
|
|
{
|
2020-05-16 21:08:39 +02:00
|
|
|
return !mOptions.mShouldCancelPreviousAi;
|
2014-08-06 21:16:14 +02:00
|
|
|
}
|
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
void AiFollow::writeState(ESM::AiSequence::AiSequence& sequence) const
|
2014-06-12 23:27:04 +02:00
|
|
|
{
|
2022-05-29 13:24:48 +02:00
|
|
|
auto follow = std::make_unique<ESM::AiSequence::AiFollow>();
|
2014-06-12 23:27:04 +02:00
|
|
|
follow->mData.mX = mX;
|
|
|
|
follow->mData.mY = mY;
|
|
|
|
follow->mData.mZ = mZ;
|
2021-11-17 20:44:55 +01:00
|
|
|
follow->mData.mDuration = mDuration;
|
2017-11-21 20:00:51 +04:00
|
|
|
follow->mTargetId = mTargetActorRefId;
|
|
|
|
follow->mTargetActorId = mTargetActorId;
|
2014-06-12 23:27:04 +02:00
|
|
|
follow->mRemainingDuration = mRemainingDuration;
|
|
|
|
follow->mCellId = mCellId;
|
|
|
|
follow->mAlwaysFollow = mAlwaysFollow;
|
2020-05-16 21:08:39 +02:00
|
|
|
follow->mCommanded = isCommanded();
|
2014-12-09 22:25:28 +01:00
|
|
|
follow->mActive = mActive;
|
2021-11-17 20:44:55 +01:00
|
|
|
follow->mRepeat = getRepeat();
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2014-06-12 23:27:04 +02:00
|
|
|
ESM::AiSequence::AiPackageContainer package;
|
|
|
|
package.mType = ESM::AiSequence::Ai_Follow;
|
2022-02-23 00:39:30 +01:00
|
|
|
package.mPackage = std::move(follow);
|
|
|
|
sequence.mPackages.push_back(std::move(package));
|
2014-06-12 23:27:04 +02:00
|
|
|
}
|
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
int AiFollow::getFollowIndex() const
|
2014-12-09 16:02:07 +01:00
|
|
|
{
|
|
|
|
return mFollowIndex;
|
|
|
|
}
|
2014-12-09 22:25:28 +01:00
|
|
|
|
2016-06-11 22:34:49 +09:00
|
|
|
void AiFollow::fastForward(const MWWorld::Ptr& actor, AiState& state)
|
|
|
|
{
|
2017-02-18 01:38:21 +09:00
|
|
|
// Update duration counter if this package has a duration
|
|
|
|
if (mDuration > 0)
|
|
|
|
mRemainingDuration--;
|
2016-06-11 22:34:49 +09:00
|
|
|
}
|
|
|
|
|
2014-12-09 22:25:28 +01:00
|
|
|
}
|