convert line ends
[canaan.git] / prj / cam / src / ai / aimovsug.h
blobc369c1e35bb4322eb9cf84ade90ddd12cf7a00af
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 ///////////////////////////////////////////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/ai/aimovsug.h,v 1.4 1998/10/03 10:30:40 TOML Exp $
8 //
9 // Movement suggestions: the heart of the locomotion movement suggestion
10 // system
13 #ifndef __AIMOVSUG_H
14 #define __AIMOVSUG_H
16 #include <dynarray.h>
17 #include <aitype.h>
19 #pragma once
20 #pragma pack(4)
22 struct sAIMoveSuggestion;
24 ///////////////////////////////////////////////////////////////////////////////
26 // Constants
29 enum eAIMoveSuggKindEnum
31 // Suggestion is an idle action
32 kAIMS_Idle,
34 // Suggestion is a normal locomotion
35 kAIMS_Loco,
37 // Suggestion is a combat maneuver
38 kAIMS_Combat,
40 // Suggestion is an object avoidance/attraction
41 kAIMS_Object,
43 // Suggestion is an danger avoidance
44 kAIMS_Danger,
46 kAIMS_InMax = 0xffffffff
49 typedef unsigned eAIMoveSuggKind;
51 ///////////////////////////////////////
53 enum eAIFacing
55 // Doesn't matter
56 kAIF_Any,
58 // Face direction of movement
59 kAIF_MoveDir,
61 // Face the ultimate destination
62 kAIF_Dest,
64 // Face an alternative position
65 kAIF_AltPos,
67 // Face a specific direction
68 kAIF_SpecificDir,
70 kAIF_TypeMax=0xffffffff // force it use an int
73 ///////////////////////////////////////
75 enum eAISuggestionFlags
77 // Is it a regulation suggestion, as opposed to a positive ability-driven one?
78 kAISF_IsRegulation = 0x01,
81 ///////////////////////////////////////////////////////////////////////////////
83 // FUNCTION: AIComputeWeightedBias
85 // For any given suggestion, the creator assigns a 0-100 rating
86 // indicating confidence about the NEED for the suggestion. This function
87 // weighs the suggestion relative to other suggestions, based on
88 // the kind of suggestion it is
91 int AIComputeWeightedBias(eAIMoveSuggKind kind, int baseBias);
93 ///////////////////////////////////////////////////////////////////////////////
95 // CLASS: cAIMoveSuggestions
97 // @Note (toml 03-31-98): Suggestions are always owned and cleaned up by suggestor
100 class cAIMoveSuggestions : public cDynArray_<sAIMoveSuggestion *, 2>
102 public:
103 cAIMoveSuggestions();
105 void Add(const cAIMoveSuggestions &);
107 void DestroyAll();
110 ///////////////////////////////////////////////////////////////////////////////
112 // STRUCT: sAIFacing
115 struct sAIFacing
117 eAIFacing type;
118 union
120 float ang; // if kAIF_SpecificDir
121 mxs_vector pos; // if kAIF_AltPos
125 ///////////////////////////////////////////////////////////////////////////////
127 // STRUCT: sAIMoveGoal
129 // This is the lowest-level instantaneous movement goal of an AI in motion,
130 // the result of boiling down of numerous movement suggestions
133 struct sAIMoveGoal
135 sAIMoveGoal();
137 // The goal direction, 0 = east
138 floatang dir;
140 // The final goal of the movement process, if any
141 cMxsVector dest;
143 // Facing requirements
144 sAIFacing facing;
146 // How fast should we move
147 eAISpeed speed;
149 // @TBD (toml 03-26-98): Tags?
152 ///////////////////////////////////////////////////////////////////////////////
154 // STRUCT: sAIMoveSuggestion
157 struct sAIMoveSuggestion
159 sAIMoveSuggestion();
160 sAIMoveSuggestion(const sAIMoveSuggestion &);
162 // Set the kind and weighted bias
163 void SetWeightedBias(eAIMoveSuggKind newKind, int newBias);
165 // The kind of the suggestion
166 eAIMoveSuggKind kind;
168 // Suggestion bias (-100%..+100%)
169 int bias;
171 // Flags
172 unsigned flags;
174 // The goal direction, 0 = east
175 floatarc dirArc;
177 // The final goal of the movement process, if any
178 cMxsVector dest;
180 // Facing requirements
181 sAIFacing facing;
183 // How fast should we move
184 eAISpeed speed;
186 // @TBD (toml 03-26-98): Tags?
189 ///////////////////////////////////////////////////////////////////////////////
191 inline cAIMoveSuggestions::cAIMoveSuggestions()
195 ///////////////////////////////////////
197 inline void cAIMoveSuggestions::Add(const cAIMoveSuggestions & from)
199 if (from.Size())
201 const int oldSize = Size();
202 Grow(from.Size());
203 memcpy(AsPointer() + oldSize, from.AsPointer(), sizeof(sAIMoveSuggestion *) * from.Size());
207 ///////////////////////////////////////
209 inline void cAIMoveSuggestions::DestroyAll()
211 for (int i = 0; i < Size(); i++)
213 delete (AsPointer()[i]);
215 SetSize(0);
218 ///////////////////////////////////////////////////////////////////////////////
220 inline sAIMoveGoal::sAIMoveGoal()
222 memset(this, 0, sizeof(sAIMoveGoal));
225 ///////////////////////////////////////////////////////////////////////////////
227 inline sAIMoveSuggestion::sAIMoveSuggestion()
229 memset(this, 0, sizeof(sAIMoveSuggestion));
232 ///////////////////////////////////////
234 inline sAIMoveSuggestion::sAIMoveSuggestion(const sAIMoveSuggestion &from)
236 memcpy(this, &from, sizeof(sAIMoveSuggestion));
239 ///////////////////////////////////////
241 inline void sAIMoveSuggestion::SetWeightedBias(eAIMoveSuggKind newKind, int newBias)
243 kind = newKind;
244 bias = AIComputeWeightedBias(kind, newBias);
247 ///////////////////////////////////////////////////////////////////////////////
249 #pragma pack()
251 #endif /* !__AIMOVSUG_H */