2014-06-12 21:27:04 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
|
|
|
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
|
|
|
|
2022-02-22 23:39:30 +00:00
|
|
|
#include <memory>
|
2014-06-12 21:27:04 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-01-22 14:58:41 +00:00
|
|
|
#include "components/esm/defs.hpp"
|
2014-06-12 21:27:04 +00:00
|
|
|
|
2022-01-22 14:58:41 +00:00
|
|
|
#include "components/esm/util.hpp"
|
2014-12-31 20:27:19 +00:00
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
|
|
|
|
namespace AiSequence
|
|
|
|
{
|
|
|
|
|
|
|
|
// format 0, saved games only
|
|
|
|
// As opposed to AiPackageList, this stores the "live" version of AI packages.
|
|
|
|
|
|
|
|
enum AiPackages
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2022-04-11 22:18:39 +00:00
|
|
|
Ai_Wander = fourCC("WAND"),
|
|
|
|
Ai_Travel = fourCC("TRAV"),
|
|
|
|
Ai_Escort = fourCC("ESCO"),
|
|
|
|
Ai_Follow = fourCC("FOLL"),
|
|
|
|
Ai_Activate = fourCC("ACTI"),
|
|
|
|
Ai_Combat = fourCC("COMB"),
|
|
|
|
Ai_Pursue = fourCC("PURS")
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
struct AiPackage
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2014-06-12 21:27:04 +00:00
|
|
|
virtual ~AiPackage() {}
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct AiWanderData
|
|
|
|
{
|
|
|
|
short mDistance;
|
|
|
|
short mDuration;
|
|
|
|
unsigned char mTimeOfDay;
|
|
|
|
unsigned char mIdle[8];
|
|
|
|
unsigned char mShouldRepeat;
|
|
|
|
};
|
2016-06-09 15:56:01 +00:00
|
|
|
struct AiWanderDuration
|
|
|
|
{
|
|
|
|
float mRemainingDuration;
|
|
|
|
int unused;
|
|
|
|
};
|
2014-06-12 21:27:04 +00:00
|
|
|
struct AiTravelData
|
|
|
|
{
|
|
|
|
float mX, mY, mZ;
|
|
|
|
};
|
|
|
|
struct AiEscortData
|
|
|
|
{
|
|
|
|
float mX, mY, mZ;
|
|
|
|
short mDuration;
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
struct AiWander : AiPackage
|
|
|
|
{
|
|
|
|
AiWanderData mData;
|
2022-04-11 22:18:39 +00:00
|
|
|
AiWanderDuration mDurationData; // was TimeStamp mStartTime
|
2014-06-12 21:27:04 +00:00
|
|
|
|
2014-12-31 20:27:19 +00:00
|
|
|
bool mStoredInitialActorPosition;
|
2022-04-11 22:18:39 +00:00
|
|
|
Vector3 mInitialActorPosition;
|
2014-12-31 20:27:19 +00:00
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
/// \todo add more AiWander state
|
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiTravel : AiPackage
|
|
|
|
{
|
|
|
|
AiTravelData mData;
|
2018-05-25 15:31:31 +00:00
|
|
|
bool mHidden;
|
2021-11-17 19:44:55 +00:00
|
|
|
bool mRepeat;
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiEscort : AiPackage
|
|
|
|
{
|
|
|
|
AiEscortData mData;
|
|
|
|
|
2017-11-21 16:00:51 +00:00
|
|
|
int mTargetActorId;
|
2014-06-12 21:27:04 +00:00
|
|
|
std::string mTargetId;
|
|
|
|
std::string mCellId;
|
|
|
|
float mRemainingDuration;
|
2021-11-17 19:44:55 +00:00
|
|
|
bool mRepeat;
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiFollow : AiPackage
|
|
|
|
{
|
|
|
|
AiEscortData mData;
|
|
|
|
|
2017-11-21 16:00:51 +00:00
|
|
|
int mTargetActorId;
|
2014-06-12 21:27:04 +00:00
|
|
|
std::string mTargetId;
|
|
|
|
std::string mCellId;
|
|
|
|
float mRemainingDuration;
|
|
|
|
|
|
|
|
bool mAlwaysFollow;
|
2014-08-06 19:16:14 +00:00
|
|
|
bool mCommanded;
|
2014-06-12 21:27:04 +00:00
|
|
|
|
2014-12-09 21:25:28 +00:00
|
|
|
bool mActive;
|
2021-11-17 19:44:55 +00:00
|
|
|
bool mRepeat;
|
2014-12-09 21:25:28 +00:00
|
|
|
|
2014-06-12 21:27:04 +00:00
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiActivate : AiPackage
|
|
|
|
{
|
|
|
|
std::string mTargetId;
|
2021-11-17 19:44:55 +00:00
|
|
|
bool mRepeat;
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiCombat : AiPackage
|
|
|
|
{
|
|
|
|
int mTargetActorId;
|
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiPursue : AiPackage
|
|
|
|
{
|
|
|
|
int mTargetActorId;
|
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AiPackageContainer
|
|
|
|
{
|
|
|
|
int mType;
|
|
|
|
|
2022-02-22 23:39:30 +00:00
|
|
|
std::unique_ptr<AiPackage> mPackage;
|
2014-06-12 21:27:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AiSequence
|
2018-05-25 16:07:08 +00:00
|
|
|
{
|
|
|
|
AiSequence() { mLastAiPackage = -1; }
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
std::vector<AiPackageContainer> mPackages;
|
2018-05-25 16:07:08 +00:00
|
|
|
int mLastAiPackage;
|
2014-06-12 21:27:04 +00:00
|
|
|
|
|
|
|
void load(ESMReader& esm);
|
|
|
|
void save(ESMWriter& esm) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AiSequence(const AiSequence&);
|
|
|
|
AiSequence& operator=(const AiSequence&);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|