Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef NPC_CONTROLLER_H
  9. #define NPC_CONTROLLER_H
  10. #pragma once
  11. #include "ai_basenpc_flyer.h"
  12. class CSprite;
  13. class CNPC_Controller;
  14. enum
  15. {
  16. TASK_CONTROLLER_CHASE_ENEMY = LAST_SHARED_TASK,
  17. TASK_CONTROLLER_STRAFE,
  18. TASK_CONTROLLER_TAKECOVER,
  19. TASK_CONTROLLER_FAIL,
  20. };
  21. enum
  22. {
  23. SCHED_CONTROLLER_CHASE_ENEMY = LAST_SHARED_SCHEDULE,
  24. SCHED_CONTROLLER_STRAFE,
  25. SCHED_CONTROLLER_TAKECOVER,
  26. SCHED_CONTROLLER_FAIL,
  27. };
  28. class CControllerNavigator : public CAI_ComponentWithOuter<CNPC_Controller, CAI_Navigator>
  29. {
  30. typedef CAI_ComponentWithOuter<CNPC_Controller, CAI_Navigator> BaseClass;
  31. public:
  32. CControllerNavigator( CNPC_Controller *pOuter )
  33. : BaseClass( pOuter )
  34. {
  35. }
  36. bool ActivityIsLocomotive( Activity activity ) { return true; }
  37. };
  38. class CNPC_Controller : public CAI_BaseFlyingBot
  39. {
  40. public:
  41. DECLARE_CLASS( CNPC_Controller, CAI_BaseFlyingBot );
  42. DEFINE_CUSTOM_AI;
  43. DECLARE_DATADESC();
  44. void Spawn( void );
  45. void Precache( void );
  46. float MaxYawSpeed( void ) { return 120.0f; }
  47. Class_T Classify ( void ) { return CLASS_ALIEN_MILITARY; }
  48. void HandleAnimEvent( animevent_t *pEvent );
  49. void RunAI( void );
  50. int RangeAttack1Conditions ( float flDot, float flDist ); // balls
  51. int RangeAttack2Conditions ( float flDot, float flDist ); // head
  52. int MeleeAttack1Conditions ( float flDot, float flDist ) { return COND_NONE; }
  53. int MeleeAttack2Conditions ( float flDot, float flDist ) { return COND_NONE; }
  54. int TranslateSchedule( int scheduleType );
  55. void StartTask ( const Task_t *pTask );
  56. void RunTask ( const Task_t *pTask );
  57. void Stop( void );
  58. bool OverridePathMove( float flInterval );
  59. bool OverrideMove( float flInterval );
  60. void MoveToTarget( float flInterval, const Vector &vecMoveTarget );
  61. void SetActivity ( Activity NewActivity );
  62. bool ShouldAdvanceRoute( float flWaypointDist );
  63. int LookupFloat( );
  64. friend class CControllerNavigator;
  65. CAI_Navigator *CreateNavigator()
  66. {
  67. return new CControllerNavigator( this );
  68. }
  69. bool ShouldGib( const CTakeDamageInfo &info );
  70. bool HasAlienGibs( void ) { return true; }
  71. bool HasHumanGibs( void ) { return false; }
  72. float m_flNextFlinch;
  73. float m_flShootTime;
  74. float m_flShootEnd;
  75. void PainSound( void );
  76. void AlertSound( void );
  77. void IdleSound( void );
  78. void AttackSound( void );
  79. void DeathSound( void );
  80. static const char *pAttackSounds[];
  81. static const char *pIdleSounds[];
  82. static const char *pAlertSounds[];
  83. static const char *pPainSounds[];
  84. static const char *pDeathSounds[];
  85. int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  86. void Event_Killed( const CTakeDamageInfo &info );
  87. CSprite *m_pBall[2]; // hand balls
  88. int m_iBall[2]; // how bright it should be
  89. float m_iBallTime[2]; // when it should be that color
  90. int m_iBallCurrent[2]; // current brightness
  91. Vector m_vecEstVelocity;
  92. Vector m_velocity;
  93. bool m_fInCombat;
  94. void SetSequence( int nSequence );
  95. };
  96. class CNPC_ControllerHeadBall : public CAI_BaseNPC
  97. {
  98. public:
  99. DECLARE_CLASS( CNPC_ControllerHeadBall, CAI_BaseNPC );
  100. DECLARE_DATADESC();
  101. void Spawn( void );
  102. void Precache( void );
  103. void EXPORT HuntThink( void );
  104. void EXPORT KillThink( void );
  105. void EXPORT BounceTouch( CBaseEntity *pOther );
  106. void MovetoTarget( Vector vecTarget );
  107. int m_iTrail;
  108. int m_flNextAttack;
  109. float m_flSpawnTime;
  110. Vector m_vecIdeal;
  111. EHANDLE m_hOwner;
  112. CSprite *m_pSprite;
  113. };
  114. class CNPC_ControllerZapBall : public CAI_BaseNPC
  115. {
  116. public:
  117. DECLARE_CLASS( CNPC_ControllerHeadBall, CAI_BaseNPC );
  118. DECLARE_DATADESC();
  119. void Spawn( void );
  120. void Precache( void );
  121. void EXPORT AnimateThink( void );
  122. void EXPORT ExplodeTouch( CBaseEntity *pOther );
  123. void Kill( void );
  124. EHANDLE m_hOwner;
  125. float m_flSpawnTime;
  126. CSprite *m_pSprite;
  127. };
  128. #endif //NPC_CONTROLLER_H