mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Initialize MWMechanics::AiSequence from ESM::AiPackageList
This commit is contained in:
parent
04b90b7d14
commit
16cacb338a
4 changed files with 51 additions and 0 deletions
|
@ -79,6 +79,8 @@ namespace MWClass
|
|||
|
||||
data->mCreatureStats.setLevel(ref->mBase->mData.mLevel);
|
||||
|
||||
data->mCreatureStats.getAiSequence().fill(ref->mBase->mAiPackage);
|
||||
|
||||
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||
|
|
|
@ -215,6 +215,8 @@ namespace MWClass
|
|||
autoCalculateAttributes(ref->mBase, data->mCreatureStats);
|
||||
}
|
||||
|
||||
data->mCreatureStats.getAiSequence().fill(ref->mBase->mAiPackage);
|
||||
|
||||
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
#include "aipackage.hpp"
|
||||
|
||||
#include "aiwander.hpp"
|
||||
#include "aiescort.hpp"
|
||||
#include "aitravel.hpp"
|
||||
#include "aifollow.hpp"
|
||||
#include "aiactivate.hpp"
|
||||
|
||||
void MWMechanics::AiSequence::copy (const AiSequence& sequence)
|
||||
{
|
||||
for (std::list<AiPackage *>::const_iterator iter (sequence.mPackages.begin());
|
||||
|
@ -77,3 +83,40 @@ void MWMechanics::AiSequence::queue (const AiPackage& package)
|
|||
{
|
||||
mPackages.push_back (package.clone());
|
||||
}
|
||||
|
||||
void MWMechanics::AiSequence::fill(const ESM::AIPackageList &list)
|
||||
{
|
||||
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;
|
||||
std::vector<int> idles;
|
||||
for (int i=0; i<8; ++i)
|
||||
idles.push_back(data.mIdle[i]);
|
||||
package = new MWMechanics::AiWander(data.mDistance, data.mDuration, data.mTimeOfDay, idles, data.mUnk);
|
||||
}
|
||||
else if (it->mType == ESM::AI_Escort)
|
||||
{
|
||||
ESM::AITarget data = it->mTarget;
|
||||
package = new MWMechanics::AiEscort(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
||||
}
|
||||
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;
|
||||
package = new MWMechanics::AiActivate(data.mName.toString());
|
||||
}
|
||||
else //if (it->mType == ESM::AI_Follow)
|
||||
{
|
||||
ESM::AITarget data = it->mTarget;
|
||||
package = new MWMechanics::AiFollow(data.mId.toString(), data.mDuration, data.mX, data.mY, data.mZ);
|
||||
}
|
||||
mPackages.push_back(package);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
|
@ -48,6 +50,8 @@ namespace MWMechanics
|
|||
void queue (const AiPackage& package);
|
||||
///< Add \a package to the end of the sequence (executed after all other packages have been
|
||||
/// completed)
|
||||
|
||||
void fill (const ESM::AIPackageList& list);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue