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.

119 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef AI_BEHAVIOR_FUNCTANK_H
  7. #define AI_BEHAVIOR_FUNCTANK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "simtimer.h"
  12. #include "ai_behavior.h"
  13. #include "func_tank.h"
  14. #define AI_FUNCTANK_BEHAVIOR_BUSYTIME 10.0f
  15. enum
  16. {
  17. FUNCTANK_SENTENCE_MOVE_TO_MOUNT = SENTENCE_BASE_BEHAVIOR_INDEX,
  18. FUNCTANK_SENTENCE_JUST_MOUNTED,
  19. FUNCTANK_SENTENCE_SCAN_FOR_ENEMIES,
  20. FUNCTANK_SENTENCE_DISMOUNTING,
  21. };
  22. //-----------------------------------------------------------------------------
  23. // Purpose:
  24. //-----------------------------------------------------------------------------
  25. class CAI_FuncTankBehavior : public CAI_SimpleBehavior
  26. {
  27. DECLARE_CLASS( CAI_FuncTankBehavior, CAI_SimpleBehavior );
  28. DEFINE_CUSTOM_SCHEDULE_PROVIDER;
  29. DECLARE_DATADESC();
  30. public:
  31. // Contructor/Deconstructor
  32. CAI_FuncTankBehavior();
  33. ~CAI_FuncTankBehavior();
  34. void UpdateOnRemove();
  35. // Identifier
  36. const char *GetName() { return "FuncTank"; }
  37. // Schedule
  38. bool CanSelectSchedule();
  39. void BeginScheduleSelection();
  40. void EndScheduleSelection();
  41. void PrescheduleThink();
  42. Activity NPC_TranslateActivity( Activity activity );
  43. // Conditions:
  44. virtual void GatherConditions();
  45. enum
  46. {
  47. SCHED_MOVE_TO_FUNCTANK = BaseClass::NEXT_SCHEDULE,
  48. SCHED_FIRE_FUNCTANK,
  49. SCHED_SCAN_WITH_FUNCTANK,
  50. SCHED_FAIL_MOVE_TO_FUNCTANK,
  51. };
  52. // Tasks
  53. void StartTask( const Task_t *pTask );
  54. void RunTask( const Task_t *pTask );
  55. enum
  56. {
  57. TASK_GET_PATH_TO_FUNCTANK = BaseClass::NEXT_TASK,
  58. TASK_FACE_FUNCTANK,
  59. TASK_HOLSTER_WEAPON,
  60. TASK_FIRE_FUNCTANK,
  61. TASK_SCAN_LEFT_FUNCTANK,
  62. TASK_SCAN_RIGHT_FUNCTANK,
  63. TASK_FORGET_ABOUT_FUNCTANK,
  64. TASK_FUNCTANK_ANNOUNCE_SCAN,
  65. };
  66. enum
  67. {
  68. COND_FUNCTANK_DISMOUNT = BaseClass::NEXT_CONDITION,
  69. NEXT_CONDITION,
  70. };
  71. // Combat.
  72. CBaseEntity *BestEnemy( void );
  73. void Event_Killed( const CTakeDamageInfo &info );
  74. bool HasFuncTank( void ) { return ( m_hFuncTank != NULL ); }
  75. void SetFuncTank( CHandle<CFuncTank> hFuncTank );
  76. CFuncTank *GetFuncTank() { return m_hFuncTank; }
  77. void AimGun( void );
  78. void Dismount( void );
  79. int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  80. // Time.
  81. void SetBusy( float flTime ) { m_flBusyTime = flTime; }
  82. bool IsBusy( void ) { return ( gpGlobals->curtime < m_flBusyTime ); }
  83. bool IsMounted( void ) { return m_bMounted; }
  84. private:
  85. // Schedule
  86. int SelectSchedule();
  87. private:
  88. CHandle<CFuncTank> m_hFuncTank;
  89. bool m_bMounted;
  90. float m_flBusyTime;
  91. bool m_bSpottedPlayerOutOfCover;
  92. };
  93. #endif // AI_BEHAVIOR_FUNCTANK_H