]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/game/ai/AI.h
hello world
[icculus/iodoom3.git] / neo / game / ai / AI.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #ifndef __AI_H__
30 #define __AI_H__
31
32 /*
33 ===============================================================================
34
35         idAI
36
37 ===============================================================================
38 */
39
40 const float     SQUARE_ROOT_OF_2                        = 1.414213562f;
41 const float     AI_TURN_PREDICTION                      = 0.2f;
42 const float     AI_TURN_SCALE                           = 60.0f;
43 const float     AI_SEEK_PREDICTION                      = 0.3f;
44 const float     AI_FLY_DAMPENING                        = 0.15f;
45 const float     AI_HEARING_RANGE                        = 2048.0f;
46 const int       DEFAULT_FLY_OFFSET                      = 68;
47
48 #define ATTACK_IGNORE                   0
49 #define ATTACK_ON_DAMAGE                1
50 #define ATTACK_ON_ACTIVATE              2
51 #define ATTACK_ON_SIGHT                 4
52
53 // defined in script/ai_base.script.  please keep them up to date.
54 typedef enum {
55         MOVETYPE_DEAD,
56         MOVETYPE_ANIM,
57         MOVETYPE_SLIDE,
58         MOVETYPE_FLY,
59         MOVETYPE_STATIC,
60         NUM_MOVETYPES
61 } moveType_t;
62
63 typedef enum {
64         MOVE_NONE,
65         MOVE_FACE_ENEMY,
66         MOVE_FACE_ENTITY,
67
68         // commands < NUM_NONMOVING_COMMANDS don't cause a change in position
69         NUM_NONMOVING_COMMANDS,
70
71         MOVE_TO_ENEMY = NUM_NONMOVING_COMMANDS,
72         MOVE_TO_ENEMYHEIGHT,
73         MOVE_TO_ENTITY, 
74         MOVE_OUT_OF_RANGE,
75         MOVE_TO_ATTACK_POSITION,
76         MOVE_TO_COVER,
77         MOVE_TO_POSITION,
78         MOVE_TO_POSITION_DIRECT,
79         MOVE_SLIDE_TO_POSITION,
80         MOVE_WANDER,
81         NUM_MOVE_COMMANDS
82 } moveCommand_t;
83
84 typedef enum {
85         TALK_NEVER,
86         TALK_DEAD,
87         TALK_OK,
88         TALK_BUSY,
89         NUM_TALK_STATES
90 } talkState_t;
91
92 //
93 // status results from move commands
94 // make sure to change script/doom_defs.script if you add any, or change their order
95 //
96 typedef enum {
97         MOVE_STATUS_DONE,
98         MOVE_STATUS_MOVING,
99         MOVE_STATUS_WAITING,
100         MOVE_STATUS_DEST_NOT_FOUND,
101         MOVE_STATUS_DEST_UNREACHABLE,
102         MOVE_STATUS_BLOCKED_BY_WALL,
103         MOVE_STATUS_BLOCKED_BY_OBJECT,
104         MOVE_STATUS_BLOCKED_BY_ENEMY,
105         MOVE_STATUS_BLOCKED_BY_MONSTER
106 } moveStatus_t;
107
108 #define DI_NODIR        -1
109
110 // obstacle avoidance
111 typedef struct obstaclePath_s {
112         idVec3                          seekPos;                                        // seek position avoiding obstacles
113         idEntity *                      firstObstacle;                          // if != NULL the first obstacle along the path
114         idVec3                          startPosOutsideObstacles;       // start position outside obstacles
115         idEntity *                      startPosObstacle;                       // if != NULL the obstacle containing the start position 
116         idVec3                          seekPosOutsideObstacles;        // seek position outside obstacles
117         idEntity *                      seekPosObstacle;                        // if != NULL the obstacle containing the seek position 
118 } obstaclePath_t;
119
120 // path prediction
121 typedef enum {
122         SE_BLOCKED                      = BIT(0),
123         SE_ENTER_LEDGE_AREA     = BIT(1),
124         SE_ENTER_OBSTACLE       = BIT(2),
125         SE_FALL                         = BIT(3),
126         SE_LAND                         = BIT(4)
127 } stopEvent_t;
128
129 typedef struct predictedPath_s {
130         idVec3                          endPos;                                         // final position
131         idVec3                          endVelocity;                            // velocity at end position
132         idVec3                          endNormal;                                      // normal of blocking surface
133         int                                     endTime;                                        // time predicted
134         int                                     endEvent;                                       // event that stopped the prediction
135         const idEntity *        blockingEntity;                         // entity that blocks the movement
136 } predictedPath_t;
137
138 //
139 // events
140 //
141 extern const idEventDef AI_BeginAttack;
142 extern const idEventDef AI_EndAttack;
143 extern const idEventDef AI_MuzzleFlash;
144 extern const idEventDef AI_CreateMissile;
145 extern const idEventDef AI_AttackMissile;
146 extern const idEventDef AI_FireMissileAtTarget;
147 extern const idEventDef AI_AttackMelee;
148 extern const idEventDef AI_DirectDamage;
149 extern const idEventDef AI_JumpFrame;
150 extern const idEventDef AI_EnableClip;
151 extern const idEventDef AI_DisableClip;
152 extern const idEventDef AI_EnableGravity;
153 extern const idEventDef AI_DisableGravity;
154 extern const idEventDef AI_TriggerParticles;
155 extern const idEventDef AI_RandomPath;
156
157 class idPathCorner;
158
159 typedef struct particleEmitter_s {
160         particleEmitter_s() {
161                 particle = NULL;
162                 time = 0;
163                 joint = INVALID_JOINT;
164         };
165         const idDeclParticle *particle;
166         int                                     time;
167         jointHandle_t           joint;
168 } particleEmitter_t;
169
170 class idMoveState {
171 public:
172                                                         idMoveState();
173
174         void                                    Save( idSaveGame *savefile ) const;
175         void                                    Restore( idRestoreGame *savefile );
176
177         moveType_t                              moveType;
178         moveCommand_t                   moveCommand;
179         moveStatus_t                    moveStatus;
180         idVec3                                  moveDest;
181         idVec3                                  moveDir;                        // used for wandering and slide moves
182         idEntityPtr<idEntity>   goalEntity;
183         idVec3                                  goalEntityOrigin;       // move to entity uses this to avoid checking the floor position every frame
184         int                                             toAreaNum;
185         int                                             startTime;
186         int                                             duration;
187         float                                   speed;                          // only used by flying creatures
188         float                                   range;
189         float                                   wanderYaw;
190         int                                             nextWanderTime;
191         int                                             blockTime;
192         idEntityPtr<idEntity>   obstacle;
193         idVec3                                  lastMoveOrigin;
194         int                                             lastMoveTime;
195         int                                             anim;
196 };
197
198 class idAASFindCover : public idAASCallback {
199 public:
200                                                 idAASFindCover( const idVec3 &hideFromPos );
201                                                 ~idAASFindCover();
202
203         virtual bool            TestArea( const idAAS *aas, int areaNum );
204
205 private:
206         pvsHandle_t                     hidePVS;
207         int                                     PVSAreas[ idEntity::MAX_PVS_AREAS ];
208 };
209
210 class idAASFindAreaOutOfRange : public idAASCallback {
211 public:
212                                                 idAASFindAreaOutOfRange( const idVec3 &targetPos, float maxDist );
213
214         virtual bool            TestArea( const idAAS *aas, int areaNum );
215
216 private:
217         idVec3                          targetPos;
218         float                           maxDistSqr;
219 };
220
221 class idAASFindAttackPosition : public idAASCallback {
222 public:
223                                                 idAASFindAttackPosition( const idAI *self, const idMat3 &gravityAxis, idEntity *target, const idVec3 &targetPos, const idVec3 &fireOffset );
224                                                 ~idAASFindAttackPosition();
225
226         virtual bool            TestArea( const idAAS *aas, int areaNum );
227
228 private:
229         const idAI                      *self;
230         idEntity                        *target;
231         idBounds                        excludeBounds;
232         idVec3                          targetPos;
233         idVec3                          fireOffset;
234         idMat3                          gravityAxis;
235         pvsHandle_t                     targetPVS;
236         int                                     PVSAreas[ idEntity::MAX_PVS_AREAS ];
237 };
238
239 class idAI : public idActor {
240 public:
241         CLASS_PROTOTYPE( idAI );
242
243                                                         idAI();
244                                                         ~idAI();
245
246         void                                    Save( idSaveGame *savefile ) const;
247         void                                    Restore( idRestoreGame *savefile );
248
249         void                                    Spawn( void );
250         void                                    HeardSound( idEntity *ent, const char *action );
251         idActor                                 *GetEnemy( void ) const;
252         void                                    TalkTo( idActor *actor );
253         talkState_t                             GetTalkState( void ) const;
254
255         bool                                    GetAimDir( const idVec3 &firePos, idEntity *aimAtEnt, const idEntity *ignore, idVec3 &aimDir ) const;
256
257         void                                    TouchedByFlashlight( idActor *flashlight_owner );
258
259                                                         // Outputs a list of all monsters to the console.
260         static void                             List_f( const idCmdArgs &args );
261
262                                                         // Finds a path around dynamic obstacles.
263         static bool                             FindPathAroundObstacles( const idPhysics *physics, const idAAS *aas, const idEntity *ignore, const idVec3 &startPos, const idVec3 &seekPos, obstaclePath_t &path );
264                                                         // Frees any nodes used for the dynamic obstacle avoidance.
265         static void                             FreeObstacleAvoidanceNodes( void );
266                                                         // Predicts movement, returns true if a stop event was triggered.
267         static bool                             PredictPath( const idEntity *ent, const idAAS *aas, const idVec3 &start, const idVec3 &velocity, int totalTime, int frameTime, int stopEvent, predictedPath_t &path );
268                                                         // Return true if the trajectory of the clip model is collision free.
269         static bool                             TestTrajectory( const idVec3 &start, const idVec3 &end, float zVel, float gravity, float time, float max_height, const idClipModel *clip, int clipmask, const idEntity *ignore, const idEntity *targetEntity, int drawtime );
270                                                         // Finds the best collision free trajectory for a clip model.
271         static bool                             PredictTrajectory( const idVec3 &firePos, const idVec3 &target, float projectileSpeed, const idVec3 &projGravity, const idClipModel *clip, int clipmask, float max_height, const idEntity *ignore, const idEntity *targetEntity, int drawtime, idVec3 &aimDir );
272
273 protected:
274         // navigation
275         idAAS *                                 aas;
276         int                                             travelFlags;
277
278         idMoveState                             move;
279         idMoveState                             savedMove;
280
281         float                                   kickForce;
282         bool                                    ignore_obstacles;
283         float                                   blockedRadius;
284         int                                             blockedMoveTime;
285         int                                             blockedAttackTime;
286
287         // turning
288         float                                   ideal_yaw;
289         float                                   current_yaw;
290         float                                   turnRate;
291         float                                   turnVel;
292         float                                   anim_turn_yaw;
293         float                                   anim_turn_amount;
294         float                                   anim_turn_angles;
295
296         // physics
297         idPhysics_Monster               physicsObj;
298
299         // flying
300         jointHandle_t                   flyTiltJoint;
301         float                                   fly_speed;
302         float                                   fly_bob_strength;
303         float                                   fly_bob_vert;
304         float                                   fly_bob_horz;
305         int                                             fly_offset;                                     // prefered offset from player's view
306         float                                   fly_seek_scale;
307         float                                   fly_roll_scale;
308         float                                   fly_roll_max;
309         float                                   fly_roll;
310         float                                   fly_pitch_scale;
311         float                                   fly_pitch_max;
312         float                                   fly_pitch;
313
314         bool                                    allowMove;                                      // disables any animation movement
315         bool                                    allowHiddenMovement;            // allows character to still move around while hidden
316         bool                                    disableGravity;                         // disables gravity and allows vertical movement by the animation
317         bool                                    af_push_moveables;                      // allow the articulated figure to push moveable objects
318         
319         // weapon/attack vars
320         bool                                    lastHitCheckResult;
321         int                                             lastHitCheckTime;
322         int                                             lastAttackTime;
323         float                                   melee_range;
324         float                                   projectile_height_to_distance_ratio;    // calculates the maximum height a projectile can be thrown
325         idList<idVec3>                  missileLaunchOffset;
326
327         const idDict *                  projectileDef;
328         mutable idClipModel             *projectileClipModel;
329         float                                   projectileRadius;
330         float                                   projectileSpeed;
331         idVec3                                  projectileVelocity;
332         idVec3                                  projectileGravity;
333         idEntityPtr<idProjectile> projectile;
334         idStr                                   attack;
335
336         // chatter/talking
337         const idSoundShader             *chat_snd;
338         int                                             chat_min;
339         int                                             chat_max;
340         int                                             chat_time;
341         talkState_t                             talk_state;
342         idEntityPtr<idActor>    talkTarget;
343
344         // cinematics
345         int                                             num_cinematics;
346         int                                             current_cinematic;
347
348         bool                                    allowJointMod;
349         idEntityPtr<idEntity>   focusEntity;
350         idVec3                                  currentFocusPos;
351         int                                             focusTime;
352         int                                             alignHeadTime;
353         int                                             forceAlignHeadTime;
354         idAngles                                eyeAng;
355         idAngles                                lookAng;
356         idAngles                                destLookAng;
357         idAngles                                lookMin;
358         idAngles                                lookMax;
359         idList<jointHandle_t>   lookJoints;
360         idList<idAngles>                lookJointAngles;
361         float                                   eyeVerticalOffset;
362         float                                   eyeHorizontalOffset;
363         float                                   eyeFocusRate;
364         float                                   headFocusRate;
365         int                                             focusAlignTime;
366
367         // special fx
368         float                                   shrivel_rate;
369         int                                             shrivel_start;
370         
371         bool                                    restartParticles;                       // should smoke emissions restart
372         bool                                    useBoneAxis;                            // use the bone vs the model axis
373         idList<particleEmitter_t> particles;                            // particle data
374
375         renderLight_t                   worldMuzzleFlash;                       // positioned on world weapon bone
376         int                                             worldMuzzleFlashHandle;
377         jointHandle_t                   flashJointWorld;
378         int                                             muzzleFlashEnd;
379         int                                             flashTime;
380
381         // joint controllers
382         idAngles                                eyeMin;
383         idAngles                                eyeMax;
384         jointHandle_t                   focusJoint;
385         jointHandle_t                   orientationJoint;
386
387         // enemy variables
388         idEntityPtr<idActor>    enemy;
389         idVec3                                  lastVisibleEnemyPos;
390         idVec3                                  lastVisibleEnemyEyeOffset;
391         idVec3                                  lastVisibleReachableEnemyPos;
392         idVec3                                  lastReachableEnemyPos;
393         bool                                    wakeOnFlashlight;
394
395         // script variables
396         idScriptBool                    AI_TALK;
397         idScriptBool                    AI_DAMAGE;
398         idScriptBool                    AI_PAIN;
399         idScriptFloat                   AI_SPECIAL_DAMAGE;
400         idScriptBool                    AI_DEAD;
401         idScriptBool                    AI_ENEMY_VISIBLE;
402         idScriptBool                    AI_ENEMY_IN_FOV;
403         idScriptBool                    AI_ENEMY_DEAD;
404         idScriptBool                    AI_MOVE_DONE;
405         idScriptBool                    AI_ONGROUND;
406         idScriptBool                    AI_ACTIVATED;
407         idScriptBool                    AI_FORWARD;
408         idScriptBool                    AI_JUMP;
409         idScriptBool                    AI_ENEMY_REACHABLE;
410         idScriptBool                    AI_BLOCKED;
411         idScriptBool                    AI_OBSTACLE_IN_PATH;
412         idScriptBool                    AI_DEST_UNREACHABLE;
413         idScriptBool                    AI_HIT_ENEMY;
414         idScriptBool                    AI_PUSHED;
415
416         //
417         // ai/ai.cpp
418         //
419         void                                    SetAAS( void );
420         virtual void                    DormantBegin( void );   // called when entity becomes dormant
421         virtual void                    DormantEnd( void );             // called when entity wakes from being dormant
422         void                                    Think( void );
423         void                                    Activate( idEntity *activator );
424         int                                             ReactionTo( const idEntity *ent );
425         bool                                    CheckForEnemy( void );
426         void                                    EnemyDead( void );
427         virtual bool                    CanPlayChatterSounds( void ) const;
428         void                                    SetChatSound( void );
429         void                                    PlayChatter( void );
430         virtual void                    Hide( void );
431         virtual void                    Show( void );
432         idVec3                                  FirstVisiblePointOnPath( const idVec3 origin, const idVec3 &target, int travelFlags ) const;
433         void                                    CalculateAttackOffsets( void );
434         void                                    PlayCinematic( void );
435
436         // movement
437         virtual void                    ApplyImpulse( idEntity *ent, int id, const idVec3 &point, const idVec3 &impulse );
438         void                                    GetMoveDelta( const idMat3 &oldaxis, const idMat3 &axis, idVec3 &delta );
439         void                                    CheckObstacleAvoidance( const idVec3 &goalPos, idVec3 &newPos );
440         void                                    DeadMove( void );
441         void                                    AnimMove( void );
442         void                                    SlideMove( void );
443         void                                    AdjustFlyingAngles( void );
444         void                                    AddFlyBob( idVec3 &vel );
445         void                                    AdjustFlyHeight( idVec3 &vel, const idVec3 &goalPos );
446         void                                    FlySeekGoal( idVec3 &vel, idVec3 &goalPos );
447         void                                    AdjustFlySpeed( idVec3 &vel );
448         void                                    FlyTurn( void );
449         void                                    FlyMove( void );
450         void                                    StaticMove( void );
451
452         // damage
453         virtual bool                    Pain( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
454         virtual void                    Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
455
456         // navigation
457         void                                    KickObstacles( const idVec3 &dir, float force, idEntity *alwaysKick );
458         bool                                    ReachedPos( const idVec3 &pos, const moveCommand_t moveCommand ) const;
459         float                                   TravelDistance( const idVec3 &start, const idVec3 &end ) const;
460         int                                             PointReachableAreaNum( const idVec3 &pos, const float boundsScale = 2.0f ) const;
461         bool                                    PathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const;
462         void                                    DrawRoute( void ) const;
463         bool                                    GetMovePos( idVec3 &seekPos );
464         bool                                    MoveDone( void ) const;
465         bool                                    EntityCanSeePos( idActor *actor, const idVec3 &actorOrigin, const idVec3 &pos );
466         void                                    BlockedFailSafe( void );
467
468         // movement control
469         void                                    StopMove( moveStatus_t status );
470         bool                                    FaceEnemy( void );
471         bool                                    FaceEntity( idEntity *ent );
472         bool                                    DirectMoveToPosition( const idVec3 &pos );
473         bool                                    MoveToEnemyHeight( void );
474         bool                                    MoveOutOfRange( idEntity *entity, float range );
475         bool                                    MoveToAttackPosition( idEntity *ent, int attack_anim );
476         bool                                    MoveToEnemy( void );
477         bool                                    MoveToEntity( idEntity *ent );
478         bool                                    MoveToPosition( const idVec3 &pos );
479         bool                                    MoveToCover( idEntity *entity, const idVec3 &pos );
480         bool                                    SlideToPosition( const idVec3 &pos, float time );
481         bool                                    WanderAround( void );
482         bool                                    StepDirection( float dir );
483         bool                                    NewWanderDir( const idVec3 &dest );
484
485         // effects
486         const idDeclParticle    *SpawnParticlesOnJoint( particleEmitter_t &pe, const char *particleName, const char *jointName );
487         void                                    SpawnParticles( const char *keyName );
488         bool                                    ParticlesActive( void );
489
490         // turning
491         bool                                    FacingIdeal( void );
492         void                                    Turn( void );
493         bool                                    TurnToward( float yaw );
494         bool                                    TurnToward( const idVec3 &pos );
495
496         // enemy management
497         void                                    ClearEnemy( void );
498         bool                                    EnemyPositionValid( void ) const;
499         void                                    SetEnemyPosition( void );
500         void                                    UpdateEnemyPosition( void );
501         void                                    SetEnemy( idActor *newEnemy );
502
503         // attacks
504         void                                    CreateProjectileClipModel( void ) const;
505         idProjectile                    *CreateProjectile( const idVec3 &pos, const idVec3 &dir );
506         void                                    RemoveProjectile( void );
507         idProjectile                    *LaunchProjectile( const char *jointname, idEntity *target, bool clampToAttackCone );
508         virtual void                    DamageFeedback( idEntity *victim, idEntity *inflictor, int &damage );
509         void                                    DirectDamage( const char *meleeDefName, idEntity *ent );
510         bool                                    TestMelee( void ) const;
511         bool                                    AttackMelee( const char *meleeDefName );
512         void                                    BeginAttack( const char *name );
513         void                                    EndAttack( void );
514         void                                    PushWithAF( void );
515
516         // special effects
517         void                                    GetMuzzle( const char *jointname, idVec3 &muzzle, idMat3 &axis );
518         void                                    InitMuzzleFlash( void );
519         void                                    TriggerWeaponEffects( const idVec3 &muzzle );
520         void                                    UpdateMuzzleFlash( void );
521         virtual bool                    UpdateAnimationControllers( void );
522         void                                    UpdateParticles( void );
523         void                                    TriggerParticles( const char *jointName );
524
525         // AI script state management
526         void                                    LinkScriptVariables( void );
527         void                                    UpdateAIScript( void );
528
529         //
530         // ai/ai_events.cpp
531         //
532         void                                    Event_Activate( idEntity *activator );
533         void                                    Event_Touch( idEntity *other, trace_t *trace );
534         void                                    Event_FindEnemy( int useFOV );
535         void                                    Event_FindEnemyAI( int useFOV );
536         void                                    Event_FindEnemyInCombatNodes( void );
537         void                                    Event_ClosestReachableEnemyOfEntity( idEntity *team_mate );
538         void                                    Event_HeardSound( int ignore_team );
539         void                                    Event_SetEnemy( idEntity *ent );
540         void                                    Event_ClearEnemy( void );
541         void                                    Event_MuzzleFlash( const char *jointname );
542         void                                    Event_CreateMissile( const char *jointname );
543         void                                    Event_AttackMissile( const char *jointname );
544         void                                    Event_FireMissileAtTarget( const char *jointname, const char *targetname );
545         void                                    Event_LaunchMissile( const idVec3 &muzzle, const idAngles &ang );
546         void                                    Event_AttackMelee( const char *meleeDefName );
547         void                                    Event_DirectDamage( idEntity *damageTarget, const char *damageDefName );
548         void                                    Event_RadiusDamageFromJoint( const char *jointname, const char *damageDefName );
549         void                                    Event_BeginAttack( const char *name );
550         void                                    Event_EndAttack( void );
551         void                                    Event_MeleeAttackToJoint( const char *jointname, const char *meleeDefName );
552         void                                    Event_RandomPath( void );
553         void                                    Event_CanBecomeSolid( void );
554         void                                    Event_BecomeSolid( void );
555         void                                    Event_BecomeNonSolid( void );
556         void                                    Event_BecomeRagdoll( void );
557         void                                    Event_StopRagdoll( void );
558         void                                    Event_SetHealth( float newHealth );
559         void                                    Event_GetHealth( void );
560         void                                    Event_AllowDamage( void );
561         void                                    Event_IgnoreDamage( void );
562         void                                    Event_GetCurrentYaw( void );
563         void                                    Event_TurnTo( float angle );
564         void                                    Event_TurnToPos( const idVec3 &pos );
565         void                                    Event_TurnToEntity( idEntity *ent );
566         void                                    Event_MoveStatus( void );
567         void                                    Event_StopMove( void );
568         void                                    Event_MoveToCover( void );
569         void                                    Event_MoveToEnemy( void );
570         void                                    Event_MoveToEnemyHeight( void );
571         void                                    Event_MoveOutOfRange( idEntity *entity, float range );
572         void                                    Event_MoveToAttackPosition( idEntity *entity, const char *attack_anim );
573         void                                    Event_MoveToEntity( idEntity *ent );
574         void                                    Event_MoveToPosition( const idVec3 &pos );
575         void                                    Event_SlideTo( const idVec3 &pos, float time );
576         void                                    Event_Wander( void );
577         void                                    Event_FacingIdeal( void );
578         void                                    Event_FaceEnemy( void );
579         void                                    Event_FaceEntity( idEntity *ent );
580         void                                    Event_WaitAction( const char *waitForState );
581         void                                    Event_GetCombatNode( void );
582         void                                    Event_EnemyInCombatCone( idEntity *ent, int use_current_enemy_location );
583         void                                    Event_WaitMove( void );
584         void                                    Event_GetJumpVelocity( const idVec3 &pos, float speed, float max_height );
585         void                                    Event_EntityInAttackCone( idEntity *ent );
586         void                                    Event_CanSeeEntity( idEntity *ent );
587         void                                    Event_SetTalkTarget( idEntity *target );
588         void                                    Event_GetTalkTarget( void );
589         void                                    Event_SetTalkState( int state );
590         void                                    Event_EnemyRange( void );
591         void                                    Event_EnemyRange2D( void );
592         void                                    Event_GetEnemy( void );
593         void                                    Event_GetEnemyPos( void );
594         void                                    Event_GetEnemyEyePos( void );
595         void                                    Event_PredictEnemyPos( float time );
596         void                                    Event_CanHitEnemy( void );
597         void                                    Event_CanHitEnemyFromAnim( const char *animname );
598         void                                    Event_CanHitEnemyFromJoint( const char *jointname );
599         void                                    Event_EnemyPositionValid( void );
600         void                                    Event_ChargeAttack( const char *damageDef );
601         void                                    Event_TestChargeAttack( void );
602         void                                    Event_TestAnimMoveTowardEnemy( const char *animname );
603         void                                    Event_TestAnimMove( const char *animname );
604         void                                    Event_TestMoveToPosition( const idVec3 &position );
605         void                                    Event_TestMeleeAttack( void );
606         void                                    Event_TestAnimAttack( const char *animname );
607         void                                    Event_Shrivel( float shirvel_time );
608         void                                    Event_Burn( void );
609         void                                    Event_PreBurn( void );
610         void                                    Event_ClearBurn( void );
611         void                                    Event_SetSmokeVisibility( int num, int on );
612         void                                    Event_NumSmokeEmitters( void );
613         void                                    Event_StopThinking( void );
614         void                                    Event_GetTurnDelta( void );
615         void                                    Event_GetMoveType( void );
616         void                                    Event_SetMoveType( int moveType );
617         void                                    Event_SaveMove( void );
618         void                                    Event_RestoreMove( void );
619         void                                    Event_AllowMovement( float flag );
620         void                                    Event_JumpFrame( void );
621         void                                    Event_EnableClip( void );
622         void                                    Event_DisableClip( void );
623         void                                    Event_EnableGravity( void );
624         void                                    Event_DisableGravity( void );
625         void                                    Event_EnableAFPush( void );
626         void                                    Event_DisableAFPush( void );
627         void                                    Event_SetFlySpeed( float speed );
628         void                                    Event_SetFlyOffset( int offset );
629         void                                    Event_ClearFlyOffset( void );
630         void                                    Event_GetClosestHiddenTarget( const char *type );
631         void                                    Event_GetRandomTarget( const char *type );
632         void                                    Event_TravelDistanceToPoint( const idVec3 &pos );
633         void                                    Event_TravelDistanceToEntity( idEntity *ent );
634         void                                    Event_TravelDistanceBetweenPoints( const idVec3 &source, const idVec3 &dest );
635         void                                    Event_TravelDistanceBetweenEntities( idEntity *source, idEntity *dest );
636         void                                    Event_LookAtEntity( idEntity *ent, float duration );
637         void                                    Event_LookAtEnemy( float duration );
638         void                                    Event_SetJointMod( int allowJointMod );
639         void                                    Event_ThrowMoveable( void );
640         void                                    Event_ThrowAF( void );
641         void                                    Event_SetAngles( idAngles const &ang );
642         void                                    Event_GetAngles( void );
643         void                                    Event_RealKill( void );
644         void                                    Event_Kill( void );
645         void                                    Event_WakeOnFlashlight( int enable );
646         void                                    Event_LocateEnemy( void );
647         void                                    Event_KickObstacles( idEntity *kickEnt, float force );
648         void                                    Event_GetObstacle( void );
649         void                                    Event_PushPointIntoAAS( const idVec3 &pos );
650         void                                    Event_GetTurnRate( void );
651         void                                    Event_SetTurnRate( float rate );
652         void                                    Event_AnimTurn( float angles );
653         void                                    Event_AllowHiddenMovement( int enable );
654         void                                    Event_TriggerParticles( const char *jointName );
655         void                                    Event_FindActorsInBounds( const idVec3 &mins, const idVec3 &maxs );
656         void                                    Event_CanReachPosition( const idVec3 &pos );
657         void                                    Event_CanReachEntity( idEntity *ent );
658         void                                    Event_CanReachEnemy( void );
659         void                                    Event_GetReachableEntityPosition( idEntity *ent );
660 };
661
662 class idCombatNode : public idEntity {
663 public:
664         CLASS_PROTOTYPE( idCombatNode );
665
666                                                 idCombatNode();
667
668         void                            Save( idSaveGame *savefile ) const;
669         void                            Restore( idRestoreGame *savefile );
670
671         void                            Spawn( void );
672         bool                            IsDisabled( void ) const;
673         bool                            EntityInView( idActor *actor, const idVec3 &pos );
674         static void                     DrawDebugInfo( void );
675
676 private:
677         float                           min_dist;
678         float                           max_dist;
679         float                           cone_dist;
680         float                           min_height;
681         float                           max_height;
682         idVec3                          cone_left;
683         idVec3                          cone_right;
684         idVec3                          offset;
685         bool                            disabled;
686
687         void                            Event_Activate( idEntity *activator );
688         void                            Event_MarkUsed( void );
689 };
690
691 #endif /* !__AI_H__ */