2012-09-04 11:25:53 +00:00
|
|
|
|
|
|
|
#include "aisequence.hpp"
|
|
|
|
|
|
|
|
#include "aipackage.hpp"
|
2014-10-08 08:58:52 +00:00
|
|
|
#include "aistate.hpp"
|
2012-09-04 11:25:53 +00:00
|
|
|
|
2013-07-30 22:55:08 +00:00
|
|
|
#include "aiwander.hpp"
|
|
|
|
#include "aiescort.hpp"
|
|
|
|
#include "aitravel.hpp"
|
|
|
|
#include "aifollow.hpp"
|
|
|
|
#include "aiactivate.hpp"
|
2013-09-25 16:01:36 +00:00
|
|
|
#include "aicombat.hpp"
|
2014-05-12 20:05:30 +00:00
|
|
|
#include "aipursue.hpp"
|
2013-07-30 22:55:08 +00:00
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
#include <components/esm/aisequence.hpp>
|
|
|
|
|
2013-10-31 08:43:12 +00:00
|
|
|
#include "../mwworld/class.hpp"
|
2013-09-10 14:16:13 +00:00
|
|
|
#include "creaturestats.hpp"
|
|
|
|
#include "npcstats.hpp"
|
2013-10-31 08:43:12 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
2013-09-10 14:16:13 +00:00
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
|
|
|
|
void AiSequence::copy (const AiSequence& sequence)
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
|
|
|
|
iter!=sequence.mPackages.end(); ++iter)
|
|
|
|
mPackages.push_back ((*iter)->clone());
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
AiSequence::AiSequence() : mDone (false), mLastAiPackage(-1) {}
|
2012-09-04 11:25:53 +00:00
|
|
|
|
2014-09-26 15:12:48 +00:00
|
|
|
AiSequence::AiSequence (const AiSequence& sequence)
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
copy (sequence);
|
2014-09-26 15:12:48 +00:00
|
|
|
mDone = sequence.mDone;
|
|
|
|
mLastAiPackage = sequence.mLastAiPackage;
|
2012-09-04 11:25:53 +00:00
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
AiSequence& AiSequence::operator= (const AiSequence& sequence)
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
if (this!=&sequence)
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
copy (sequence);
|
2013-12-06 06:36:16 +00:00
|
|
|
mDone = sequence.mDone;
|
2014-09-26 15:12:48 +00:00
|
|
|
mLastAiPackage = sequence.mLastAiPackage;
|
2012-09-04 11:25:53 +00:00
|
|
|
}
|
2014-04-27 17:03:33 +00:00
|
|
|
|
2012-09-04 11:25:53 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
AiSequence::~AiSequence()
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
int AiSequence::getTypeId() const
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
if (mPackages.empty())
|
|
|
|
return -1;
|
2014-04-27 17:03:33 +00:00
|
|
|
|
2012-09-04 11:25:53 +00:00
|
|
|
return mPackages.front()->getTypeId();
|
|
|
|
}
|
|
|
|
|
2014-05-18 16:13:46 +00:00
|
|
|
bool AiSequence::getCombatTarget(MWWorld::Ptr &targetActor) const
|
2014-01-07 00:12:37 +00:00
|
|
|
{
|
|
|
|
if (getTypeId() != AiPackage::TypeIdCombat)
|
|
|
|
return false;
|
|
|
|
const AiCombat *combat = static_cast<const AiCombat *>(mPackages.front());
|
2014-05-17 15:20:57 +00:00
|
|
|
|
2014-05-18 16:13:46 +00:00
|
|
|
targetActor = combat->getTarget();
|
2014-05-15 20:03:48 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-27 18:30:52 +00:00
|
|
|
std::list<AiPackage*>::const_iterator AiSequence::begin() const
|
|
|
|
{
|
|
|
|
return mPackages.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<AiPackage*>::const_iterator AiSequence::end() const
|
|
|
|
{
|
|
|
|
return mPackages.end();
|
|
|
|
}
|
|
|
|
|
2014-12-14 18:35:34 +00:00
|
|
|
std::list<AiPackage*>::const_iterator AiSequence::erase(std::list<AiPackage*>::const_iterator package)
|
2014-08-06 19:16:14 +00:00
|
|
|
{
|
|
|
|
// Not sure if manually terminated packages should trigger mDone, probably not?
|
|
|
|
for(std::list<AiPackage*>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
|
|
|
{
|
|
|
|
if (package == it)
|
|
|
|
{
|
2014-12-14 18:35:34 +00:00
|
|
|
return mPackages.erase(it);
|
2014-08-06 19:16:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
throw std::runtime_error("can't find package to erase");
|
|
|
|
}
|
|
|
|
|
2014-07-20 20:34:20 +00:00
|
|
|
bool AiSequence::isInCombat() const
|
|
|
|
{
|
|
|
|
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
|
|
|
{
|
|
|
|
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const
|
|
|
|
{
|
|
|
|
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
|
|
|
{
|
|
|
|
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
|
|
|
{
|
|
|
|
const AiCombat *combat = static_cast<const AiCombat *>(*it);
|
|
|
|
if (combat->getTarget() == actor)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
void AiSequence::stopCombat()
|
2014-01-07 00:12:37 +00:00
|
|
|
{
|
2015-01-05 18:33:51 +00:00
|
|
|
for(std::list<AiPackage*>::iterator it = mPackages.begin(); it != mPackages.end(); )
|
2014-01-14 12:22:50 +00:00
|
|
|
{
|
2015-01-05 18:33:51 +00:00
|
|
|
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
|
|
|
it = mPackages.erase(it);
|
|
|
|
else
|
|
|
|
++it;
|
2014-01-14 12:22:50 +00:00
|
|
|
}
|
2014-01-07 00:12:37 +00:00
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
void AiSequence::stopPursuit()
|
2014-04-02 04:18:22 +00:00
|
|
|
{
|
2015-01-05 18:33:51 +00:00
|
|
|
for(std::list<AiPackage*>::iterator it = mPackages.begin(); it != mPackages.end(); )
|
2014-04-02 04:18:22 +00:00
|
|
|
{
|
2015-01-05 18:33:51 +00:00
|
|
|
if ((*it)->getTypeId() == AiPackage::TypeIdPursue)
|
|
|
|
it = mPackages.erase(it);
|
|
|
|
else
|
|
|
|
++it;
|
2014-04-02 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
bool AiSequence::isPackageDone() const
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
return mDone;
|
|
|
|
}
|
|
|
|
|
2014-10-08 08:58:52 +00:00
|
|
|
void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float duration)
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
2015-01-13 17:09:10 +00:00
|
|
|
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
2013-09-10 14:16:13 +00:00
|
|
|
{
|
2013-11-18 11:33:09 +00:00
|
|
|
if (!mPackages.empty())
|
2013-09-25 16:01:36 +00:00
|
|
|
{
|
2014-05-03 10:09:34 +00:00
|
|
|
MWMechanics::AiPackage* package = mPackages.front();
|
|
|
|
mLastAiPackage = package->getTypeId();
|
2014-05-15 20:03:48 +00:00
|
|
|
|
|
|
|
// if active package is combat one, choose nearest target
|
|
|
|
if (mLastAiPackage == AiPackage::TypeIdCombat)
|
|
|
|
{
|
2014-05-18 12:10:14 +00:00
|
|
|
std::list<AiPackage *>::iterator itActualCombat;
|
2014-05-15 20:03:48 +00:00
|
|
|
|
|
|
|
float nearestDist = std::numeric_limits<float>::max();
|
|
|
|
Ogre::Vector3 vActorPos = Ogre::Vector3(actor.getRefData().getPosition().pos);
|
|
|
|
|
2014-05-24 19:05:30 +00:00
|
|
|
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();)
|
2014-05-15 20:03:48 +00:00
|
|
|
{
|
|
|
|
if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break;
|
|
|
|
|
2014-05-18 19:15:22 +00:00
|
|
|
MWWorld::Ptr target = static_cast<const AiCombat *>(*it)->getTarget();
|
2014-05-15 20:03:48 +00:00
|
|
|
|
2014-05-18 19:15:22 +00:00
|
|
|
// target disappeared (e.g. summoned creatures)
|
|
|
|
if (target.isEmpty())
|
2014-05-15 20:03:48 +00:00
|
|
|
{
|
2014-05-19 19:29:35 +00:00
|
|
|
delete *it;
|
2014-05-24 19:05:30 +00:00
|
|
|
it = mPackages.erase(it);
|
2014-05-18 19:15:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-14 15:56:41 +00:00
|
|
|
const ESM::Position &targetPos = target.getRefData().getPosition();
|
2014-05-18 19:15:22 +00:00
|
|
|
|
|
|
|
float distTo = (Ogre::Vector3(targetPos.pos) - vActorPos).length();
|
|
|
|
if (distTo < nearestDist)
|
|
|
|
{
|
|
|
|
nearestDist = distTo;
|
|
|
|
itActualCombat = it;
|
|
|
|
}
|
2014-05-24 19:05:30 +00:00
|
|
|
++it;
|
2014-05-15 20:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-24 19:05:30 +00:00
|
|
|
if (!mPackages.empty())
|
2014-05-18 19:15:22 +00:00
|
|
|
{
|
2014-05-24 19:05:30 +00:00
|
|
|
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
|
|
|
|
{
|
|
|
|
// move combat package with nearest target to the front
|
|
|
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
|
|
|
}
|
|
|
|
|
|
|
|
package = mPackages.front();
|
|
|
|
mLastAiPackage = package->getTypeId();
|
2014-05-18 19:15:22 +00:00
|
|
|
}
|
2014-05-24 19:05:30 +00:00
|
|
|
else
|
2014-05-15 20:03:48 +00:00
|
|
|
{
|
2014-05-24 19:05:30 +00:00
|
|
|
mDone = true;
|
|
|
|
return;
|
2014-05-15 20:03:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-08 08:58:52 +00:00
|
|
|
if (package->execute (actor,state,duration))
|
2013-10-27 12:50:29 +00:00
|
|
|
{
|
2014-05-03 10:09:34 +00:00
|
|
|
// To account for the rare case where AiPackage::execute() queued another AI package
|
2014-05-03 10:23:22 +00:00
|
|
|
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
2014-05-03 10:09:34 +00:00
|
|
|
std::list<MWMechanics::AiPackage*>::iterator toRemove =
|
|
|
|
std::find(mPackages.begin(), mPackages.end(), package);
|
|
|
|
mPackages.erase(toRemove);
|
|
|
|
delete package;
|
2013-11-18 11:33:09 +00:00
|
|
|
mDone = true;
|
2013-09-25 16:01:36 +00:00
|
|
|
}
|
2013-11-18 11:33:09 +00:00
|
|
|
else
|
2014-01-28 19:57:37 +00:00
|
|
|
{
|
2014-04-27 17:03:33 +00:00
|
|
|
mDone = false;
|
2014-01-28 19:57:37 +00:00
|
|
|
}
|
2013-09-10 14:16:13 +00:00
|
|
|
}
|
2012-09-04 11:25:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
void AiSequence::clear()
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
|
|
|
for (std::list<AiPackage *>::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter)
|
|
|
|
delete *iter;
|
2013-11-18 11:33:09 +00:00
|
|
|
|
2012-09-04 11:25:53 +00:00
|
|
|
mPackages.clear();
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor)
|
2012-09-04 11:25:53 +00:00
|
|
|
{
|
2014-08-03 20:29:50 +00:00
|
|
|
if (actor == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
|
|
|
throw std::runtime_error("Can't add AI packages to player");
|
|
|
|
|
2014-05-03 10:23:22 +00:00
|
|
|
if (package.getTypeId() == AiPackage::TypeIdCombat || package.getTypeId() == AiPackage::TypeIdPursue)
|
2014-04-29 07:09:51 +00:00
|
|
|
{
|
|
|
|
// Notify AiWander of our current position so we can return to it after combat finished
|
|
|
|
for (std::list<AiPackage *>::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter)
|
|
|
|
{
|
2014-05-12 20:05:30 +00:00
|
|
|
if((*iter)->getTypeId() == AiPackage::TypeIdPursue && package.getTypeId() == AiPackage::TypeIdPursue
|
|
|
|
&& static_cast<const AiPursue*>(*iter)->getTarget() == static_cast<const AiPursue*>(&package)->getTarget())
|
|
|
|
{
|
|
|
|
return; // target is already pursued
|
|
|
|
}
|
2014-06-16 23:10:37 +00:00
|
|
|
if((*iter)->getTypeId() == AiPackage::TypeIdCombat && package.getTypeId() == AiPackage::TypeIdCombat
|
|
|
|
&& static_cast<const AiCombat*>(*iter)->getTarget() == static_cast<const AiCombat*>(&package)->getTarget())
|
|
|
|
{
|
|
|
|
return; // already in combat with this actor
|
|
|
|
}
|
2014-05-12 20:05:30 +00:00
|
|
|
else if ((*iter)->getTypeId() == AiPackage::TypeIdWander)
|
2014-04-29 07:09:51 +00:00
|
|
|
static_cast<AiWander*>(*iter)->setReturnPosition(Ogre::Vector3(actor.getRefData().getPosition().pos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-27 17:03:33 +00:00
|
|
|
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
2013-11-18 11:33:09 +00:00
|
|
|
{
|
2014-09-30 20:57:38 +00:00
|
|
|
if((*it)->getPriority() <= package.getPriority())
|
2014-01-16 05:57:50 +00:00
|
|
|
{
|
2013-11-18 11:33:09 +00:00
|
|
|
mPackages.insert(it,package.clone());
|
2014-01-16 05:57:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-18 11:33:09 +00:00
|
|
|
}
|
|
|
|
|
2014-09-30 20:57:38 +00:00
|
|
|
mPackages.push_front (package.clone());
|
2012-09-04 11:25:53 +00:00
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
AiPackage* MWMechanics::AiSequence::getActivePackage()
|
2014-01-12 13:01:54 +00:00
|
|
|
{
|
|
|
|
if(mPackages.empty())
|
|
|
|
throw std::runtime_error(std::string("No AI Package!"));
|
|
|
|
else
|
|
|
|
return mPackages.front();
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
void AiSequence::fill(const ESM::AIPackageList &list)
|
2013-07-30 22:55:08 +00:00
|
|
|
{
|
|
|
|
for (std::vector<ESM::AIPackage>::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it)
|
|
|
|
{
|
|
|
|
MWMechanics::AiPackage* package;
|
|
|
|
if (it->mType == ESM::AI_Wander)
|
|
|
|
{
|
|
|
|
ESM::AIWander data = it->mWander;
|
2014-06-12 21:27:04 +00:00
|
|
|
std::vector<unsigned char> idles;
|
|
|
|
idles.reserve(8);
|
2013-07-30 22:55:08 +00:00
|
|
|
for (int i=0; i<8; ++i)
|
|
|
|
idles.push_back(data.mIdle[i]);
|
2015-03-06 22:04:54 +00:00
|
|
|
package = new MWMechanics::AiWander(data.mDistance, data.mDuration, data.mTimeOfDay, idles, data.mShouldRepeat != 0);
|
2013-07-30 22:55:08 +00:00
|
|
|
}
|
|
|
|
else if (it->mType == ESM::AI_Escort)
|
|
|
|
{
|
|
|
|
ESM::AITarget data = it->mTarget;
|
2014-05-16 10:11:34 +00:00
|
|
|
package = new MWMechanics::AiEscort(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
2013-07-30 22:55:08 +00:00
|
|
|
}
|
|
|
|
else if (it->mType == ESM::AI_Travel)
|
|
|
|
{
|
|
|
|
ESM::AITravel data = it->mTravel;
|
|
|
|
package = new MWMechanics::AiTravel(data.mX, data.mY, data.mZ);
|
|
|
|
}
|
|
|
|
else if (it->mType == ESM::AI_Activate)
|
|
|
|
{
|
|
|
|
ESM::AIActivate data = it->mActivate;
|
2014-04-02 04:18:22 +00:00
|
|
|
package = new MWMechanics::AiActivate(data.mName.toString());
|
2013-07-30 22:55:08 +00:00
|
|
|
}
|
|
|
|
else //if (it->mType == ESM::AI_Follow)
|
|
|
|
{
|
|
|
|
ESM::AITarget data = it->mTarget;
|
2014-05-16 10:11:34 +00:00
|
|
|
package = new MWMechanics::AiFollow(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
2013-07-30 22:55:08 +00:00
|
|
|
}
|
|
|
|
mPackages.push_back(package);
|
|
|
|
}
|
|
|
|
}
|
2014-05-17 15:20:57 +00:00
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
void AiSequence::writeState(ESM::AiSequence::AiSequence &sequence) const
|
|
|
|
{
|
|
|
|
for (std::list<AiPackage *>::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter)
|
|
|
|
{
|
|
|
|
(*iter)->writeState(sequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
|
|
|
|
{
|
2014-06-14 13:35:35 +00:00
|
|
|
if (!sequence.mPackages.empty())
|
|
|
|
clear();
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin();
|
|
|
|
it != sequence.mPackages.end(); ++it)
|
|
|
|
{
|
|
|
|
switch (it->mType)
|
|
|
|
{
|
|
|
|
case ESM::AiSequence::Ai_Wander:
|
|
|
|
{
|
|
|
|
MWMechanics::AiWander* wander = new AiWander(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiWander*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(wander);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Travel:
|
|
|
|
{
|
|
|
|
MWMechanics::AiTravel* travel = new AiTravel(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiTravel*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(travel);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Escort:
|
|
|
|
{
|
|
|
|
MWMechanics::AiEscort* escort = new AiEscort(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiEscort*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(escort);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Follow:
|
|
|
|
{
|
|
|
|
MWMechanics::AiFollow* follow = new AiFollow(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiFollow*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(follow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Activate:
|
|
|
|
{
|
|
|
|
MWMechanics::AiActivate* activate = new AiActivate(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiActivate*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(activate);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Combat:
|
|
|
|
{
|
|
|
|
MWMechanics::AiCombat* combat = new AiCombat(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiCombat*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(combat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESM::AiSequence::Ai_Pursue:
|
|
|
|
{
|
|
|
|
MWMechanics::AiPursue* pursue = new AiPursue(
|
2015-01-12 18:57:54 +00:00
|
|
|
static_cast<ESM::AiSequence::AiPursue*>(it->mPackage));
|
2014-06-12 21:27:04 +00:00
|
|
|
mPackages.push_back(pursue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-31 17:41:57 +00:00
|
|
|
void AiSequence::fastForward(const MWWorld::Ptr& actor, AiState& state)
|
|
|
|
{
|
|
|
|
if (!mPackages.empty())
|
|
|
|
{
|
|
|
|
MWMechanics::AiPackage* package = mPackages.front();
|
|
|
|
package->fastForward(actor, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-17 15:20:57 +00:00
|
|
|
} // namespace MWMechanics
|