-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathNextBotBodyInterface.h
325 lines (260 loc) · 10.5 KB
/
NextBotBodyInterface.h
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
// NextBotBodyInterface.h
// Control and information about the bot's body state (posture, animation state, etc)
// Author: Michael Booth, April 2006
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef _NEXT_BOT_BODY_INTERFACE_H_
#define _NEXT_BOT_BODY_INTERFACE_H_
#include "animation.h"
#include "NextBotComponentInterface.h"
class INextBot;
struct animevent_t;
//----------------------------------------------------------------------------------------------------------------
/**
* The interface for control and information about the bot's body state (posture, animation state, etc)
*/
class IBody : public INextBotComponent
{
public:
IBody( INextBot *bot ) : INextBotComponent( bot ) { }
virtual ~IBody() { }
virtual void Reset( void ) { INextBotComponent::Reset(); } // reset to initial state
virtual void Update( void ) { } // update internal state
/**
* Move the bot to a new position.
* If the body is not currently movable or if it
* is in a motion-controlled animation activity
* the position will not be changed and false will be returned.
*/
virtual bool SetPosition( const Vector &pos );
virtual const Vector &GetEyePosition( void ) const; // return the eye position of the bot in world coordinates
virtual const Vector &GetViewVector( void ) const; // return the view unit direction vector in world coordinates
enum LookAtPriorityType
{
BORING,
INTERESTING, // last known enemy location, dangerous sound location
IMPORTANT, // a danger
CRITICAL, // an active threat to our safety
MANDATORY // nothing can interrupt this look at - two simultaneous look ats with this priority is an error
};
virtual void AimHeadTowards( const Vector &lookAtPos,
LookAtPriorityType priority = BORING,
float duration = 0.0f,
INextBotReply *replyWhenAimed = NULL,
const char *reason = NULL ); // aim the bot's head towards the given goal
virtual void AimHeadTowards( CBaseEntity *subject,
LookAtPriorityType priority = BORING,
float duration = 0.0f,
INextBotReply *replyWhenAimed = NULL,
const char *reason = NULL ); // continually aim the bot's head towards the given subject
virtual bool IsHeadAimingOnTarget( void ) const; // return true if the bot's head has achieved its most recent lookat target
virtual bool IsHeadSteady( void ) const; // return true if head is not rapidly turning to look somewhere else
virtual float GetHeadSteadyDuration( void ) const; // return the duration that the bot's head has not been rotating
virtual float GetHeadAimSubjectLeadTime( void ) const; // return how far into the future we should predict our moving subject's position to aim at when tracking subject look-ats
virtual float GetHeadAimTrackingInterval( void ) const; // return how often we should sample our target's position and velocity to update our aim tracking, to allow realistic slop in tracking
virtual void ClearPendingAimReply( void ) { } // clear out currently pending replyWhenAimed callback
virtual float GetMaxHeadAngularVelocity( void ) const; // return max turn rate of head in degrees/second
enum ActivityType
{
MOTION_CONTROLLED_XY = 0x0001, // XY position and orientation of the bot is driven by the animation.
MOTION_CONTROLLED_Z = 0x0002, // Z position of the bot is driven by the animation.
ACTIVITY_UNINTERRUPTIBLE= 0x0004, // activity can't be changed until animation finishes
ACTIVITY_TRANSITORY = 0x0008, // a short animation that takes over from the underlying animation momentarily, resuming it upon completion
ENTINDEX_PLAYBACK_RATE = 0x0010, // played back at different rates based on entindex
};
/**
* Begin an animation activity, return false if we cant do that right now.
*/
virtual bool StartActivity( Activity act, unsigned int flags = 0 );
virtual int SelectAnimationSequence( Activity act ) const; // given an Activity, select and return a specific animation sequence within it
virtual Activity GetActivity( void ) const; // return currently animating activity
virtual bool IsActivity( Activity act ) const; // return true if currently animating activity matches the given one
virtual bool HasActivityType( unsigned int flags ) const; // return true if currently animating activity has any of the given flags
enum PostureType
{
STAND,
CROUCH,
SIT,
CRAWL,
LIE
};
virtual void SetDesiredPosture( PostureType posture ) { } // request a posture change
virtual PostureType GetDesiredPosture( void ) const; // get posture body is trying to assume
virtual bool IsDesiredPosture( PostureType posture ) const; // return true if body is trying to assume this posture
virtual bool IsInDesiredPosture( void ) const; // return true if body's actual posture matches its desired posture
virtual PostureType GetActualPosture( void ) const; // return body's current actual posture
virtual bool IsActualPosture( PostureType posture ) const; // return true if body is actually in the given posture
virtual bool IsPostureMobile( void ) const; // return true if body's current posture allows it to move around the world
virtual bool IsPostureChanging( void ) const; // return true if body's posture is in the process of changing to new posture
/**
* "Arousal" is the level of excitedness/arousal/anxiety of the body.
* Is changes instantaneously to avoid complex interactions with posture transitions.
*/
enum ArousalType
{
NEUTRAL,
ALERT,
INTENSE
};
virtual void SetArousal( ArousalType arousal ) { } // arousal level change
virtual ArousalType GetArousal( void ) const; // get arousal level
virtual bool IsArousal( ArousalType arousal ) const; // return true if body is at this arousal level
virtual float GetHullWidth( void ) const; // width of bot's collision hull in XY plane
virtual float GetHullHeight( void ) const; // height of bot's current collision hull based on posture
virtual float GetStandHullHeight( void ) const; // height of bot's collision hull when standing
virtual float GetCrouchHullHeight( void ) const; // height of bot's collision hull when crouched
virtual const Vector &GetHullMins( void ) const; // return current collision hull minimums based on actual body posture
virtual const Vector &GetHullMaxs( void ) const; // return current collision hull maximums based on actual body posture
virtual unsigned int GetSolidMask( void ) const; // return the bot's collision mask (hack until we get a general hull trace abstraction here or in the locomotion interface)
virtual unsigned int GetCollisionGroup( void ) const;
};
inline bool IBody::IsHeadSteady( void ) const
{
return true;
}
inline float IBody::GetHeadSteadyDuration( void ) const
{
return 0.0f;
}
inline float IBody::GetHeadAimSubjectLeadTime( void ) const
{
return 0.0f;
}
inline float IBody::GetHeadAimTrackingInterval( void ) const
{
return 0.0f;
}
inline float IBody::GetMaxHeadAngularVelocity( void ) const
{
return 1000.0f;
}
inline bool IBody::StartActivity( Activity act, unsigned int flags )
{
return false;
}
inline int IBody::SelectAnimationSequence( Activity act ) const
{
return 0;
}
inline Activity IBody::GetActivity( void ) const
{
return ACT_INVALID;
}
inline bool IBody::IsActivity( Activity act ) const
{
return false;
}
inline bool IBody::HasActivityType( unsigned int flags ) const
{
return false;
}
inline IBody::PostureType IBody::GetDesiredPosture( void ) const
{
return IBody::STAND;
}
inline bool IBody::IsDesiredPosture( PostureType posture ) const
{
return true;
}
inline bool IBody::IsInDesiredPosture( void ) const
{
return true;
}
inline IBody::PostureType IBody::GetActualPosture( void ) const
{
return IBody::STAND;
}
inline bool IBody::IsActualPosture( PostureType posture ) const
{
return true;
}
inline bool IBody::IsPostureMobile( void ) const
{
return true;
}
inline bool IBody::IsPostureChanging( void ) const
{
return false;
}
inline IBody::ArousalType IBody::GetArousal( void ) const
{
return IBody::NEUTRAL;
}
inline bool IBody::IsArousal( ArousalType arousal ) const
{
return true;
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Width of bot's collision hull in XY plane
*/
inline float IBody::GetHullWidth( void ) const
{
return 26.0f;
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Height of bot's current collision hull based on posture
*/
inline float IBody::GetHullHeight( void ) const
{
switch( GetActualPosture() )
{
case LIE:
return 16.0f;
case SIT:
case CROUCH:
return GetCrouchHullHeight();
case STAND:
default:
return GetStandHullHeight();
}
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Height of bot's collision hull when standing
*/
inline float IBody::GetStandHullHeight( void ) const
{
return 68.0f;
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Height of bot's collision hull when crouched
*/
inline float IBody::GetCrouchHullHeight( void ) const
{
return 32.0f;
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Return current collision hull minimums based on actual body posture
*/
inline const Vector &IBody::GetHullMins( void ) const
{
static Vector hullMins;
hullMins.x = -GetHullWidth()/2.0f;
hullMins.y = hullMins.x;
hullMins.z = 0.0f;
return hullMins;
}
//---------------------------------------------------------------------------------------------------------------------------
/**
* Return current collision hull maximums based on actual body posture
*/
inline const Vector &IBody::GetHullMaxs( void ) const
{
static Vector hullMaxs;
hullMaxs.x = GetHullWidth()/2.0f;
hullMaxs.y = hullMaxs.x;
hullMaxs.z = GetHullHeight();
return hullMaxs;
}
inline unsigned int IBody::GetSolidMask( void ) const
{
return MASK_NPCSOLID;
}
inline unsigned int IBody::GetCollisionGroup( void ) const
{
return COLLISION_GROUP_NONE;
}
#endif // _NEXT_BOT_BODY_INTERFACE_H_