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