1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 19:59:55 +00:00
openmw/components/esm3/aipackage.hpp

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

104 lines
2.3 KiB
C++
Raw Normal View History

2012-08-29 17:35:06 +00:00
#ifndef OPENMW_ESM_AIPACKAGE_H
#define OPENMW_ESM_AIPACKAGE_H
2012-09-17 07:37:50 +00:00
#include <string>
2012-08-29 17:35:06 +00:00
#include <vector>
2012-09-17 07:37:50 +00:00
#include "components/esm/esmcommon.hpp"
#include "components/misc/concepts.hpp"
2012-08-29 17:35:06 +00:00
namespace ESM
{
2012-09-17 07:37:50 +00:00
class ESMReader;
class ESMWriter;
2012-08-29 17:35:06 +00:00
struct AIData
{
2023-10-24 15:23:54 +00:00
uint16_t mHello; // This is the base value for greeting distance [0, 65535]
unsigned char mFight, mFlee, mAlarm; // These are probabilities [0, 100]
2023-10-24 15:23:54 +00:00
int32_t mServices; // See the Services enum
void blank();
///< Set record to default state (does not touch the ID).
2012-08-29 17:35:06 +00:00
}; // 12 bytes
struct AIWander
{
2023-10-24 15:23:54 +00:00
int16_t mDistance;
int16_t mDuration;
2012-08-29 17:35:06 +00:00
unsigned char mTimeOfDay;
unsigned char mIdle[8];
unsigned char mShouldRepeat;
2012-08-29 17:35:06 +00:00
};
struct AITravel
{
float mX, mY, mZ;
unsigned char mShouldRepeat;
2012-08-29 17:35:06 +00:00
};
struct AITarget
{
float mX, mY, mZ;
2023-10-24 15:23:54 +00:00
int16_t mDuration;
2012-08-29 17:35:06 +00:00
NAME32 mId;
unsigned char mShouldRepeat;
2012-08-29 17:35:06 +00:00
};
struct AIActivate
{
NAME32 mName;
unsigned char mShouldRepeat;
2012-08-29 17:35:06 +00:00
};
enum AiPackageType : std::uint32_t
2012-08-29 17:35:06 +00:00
{
AI_Wander = 0x575f4941,
AI_Travel = 0x545f4941,
AI_Follow = 0x465f4941,
AI_Escort = 0x455f4941,
AI_Activate = 0x415f4941,
2012-08-29 17:35:06 +00:00
};
inline constexpr std::uint32_t AI_CNDT = 0x54444e43;
2012-08-29 17:35:06 +00:00
/// \note Used for storaging packages in a single container
/// w/o manual memory allocation accordingly to policy standards
struct AIPackage
{
AiPackageType mType;
2012-08-29 17:35:06 +00:00
// Anonymous union
union
{
AIWander mWander;
AITravel mTravel;
AITarget mTarget;
AIActivate mActivate;
};
/// \note for AITarget only, placed here to stick with union,
/// overhead should be not so awful
std::string mCellName;
};
struct AIPackageList
{
std::vector<AIPackage> mList;
/// Add a single AIPackage, assumes subrecord name was already read
void add(ESMReader& esm);
void save(ESMWriter& esm) const;
2012-08-29 17:35:06 +00:00
};
template <Misc::SameAsWithoutCvref<AIData> T>
void decompose(T&& v, const auto& f)
{
char padding[3] = { 0, 0, 0 };
f(v.mHello, v.mFight, v.mFlee, v.mAlarm, padding, v.mServices);
}
2012-08-29 17:35:06 +00:00
}
#endif