File: aisequence.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (172 lines) | stat: -rw-r--r-- 3,859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

#include <components/esm/refid.hpp>
#include <components/esm/vector3.hpp>

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
        {
            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")
        };

        struct AiPackage
        {
            virtual ~AiPackage() {}
        };

        struct AiWanderData
        {
            int16_t mDistance;
            int16_t mDuration;
            std::uint8_t mTimeOfDay;
            std::uint8_t mIdle[8];
            std::uint8_t mShouldRepeat;
        };

        struct AiWanderDuration
        {
            float mRemainingDuration;
        };

        struct AiTravelData
        {
            float mX, mY, mZ;
        };

        struct AiEscortData
        {
            float mX, mY, mZ;
            int16_t mDuration;
        };

        struct AiWander : AiPackage
        {
            AiWanderData mData;
            AiWanderDuration mDurationData; // was TimeStamp mStartTime

            bool mStoredInitialActorPosition;
            Vector3 mInitialActorPosition;

            /// \todo add more AiWander state

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiTravel : AiPackage
        {
            AiTravelData mData;
            bool mHidden;
            bool mRepeat;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiEscort : AiPackage
        {
            AiEscortData mData;

            int32_t mTargetActorId;
            ESM::RefId mTargetId;
            std::string mCellId;
            float mRemainingDuration;
            bool mRepeat;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiFollow : AiPackage
        {
            AiEscortData mData;

            int32_t mTargetActorId;
            ESM::RefId mTargetId;
            std::string mCellId;
            float mRemainingDuration;

            bool mAlwaysFollow;
            bool mCommanded;

            bool mActive;
            bool mRepeat;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiActivate : AiPackage
        {
            ESM::RefId mTargetId;
            bool mRepeat;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiCombat : AiPackage
        {
            int32_t mTargetActorId;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiPursue : AiPackage
        {
            int32_t mTargetActorId;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        };

        struct AiPackageContainer
        {
            int32_t mType;

            std::unique_ptr<AiPackage> mPackage;
        };

        struct AiSequence
        {
            AiSequence() { mLastAiPackage = -1; }

            std::vector<AiPackageContainer> mPackages;
            int32_t mLastAiPackage;

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;

        private:
            AiSequence(const AiSequence&);
            AiSequence& operator=(const AiSequence&);
        };

    }

}

#endif