AI.h 24 KB

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