1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:53:52 +00:00
openmw/components/esm3/aisequence.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

174 lines
3.8 KiB
C++
Raw Normal View History

2014-06-12 21:27:04 +00:00
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
#include <memory>
2014-06-12 21:27:04 +00:00
#include <string>
#include <vector>
#include "components/esm/defs.hpp"
2014-06-12 21:27:04 +00:00
#include "components/esm/util.hpp"
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
{
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;
};
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;
AiWanderDuration mDurationData; // was TimeStamp mStartTime
2014-06-12 21:27:04 +00:00
bool mStoredInitialActorPosition;
Vector3 mInitialActorPosition;
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;
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;
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;
int mTargetActorId;
2014-06-12 21:27:04 +00:00
std::string mTargetId;
std::string mCellId;
float mRemainingDuration;
bool mAlwaysFollow;
bool mCommanded;
2014-06-12 21:27:04 +00:00
bool mActive;
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 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;
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