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.

106 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef AI_BEHAVIOR_POLICE_H
  7. #define AI_BEHAVIOR_POLICE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "ai_behavior.h"
  12. #include "ai_goal_police.h"
  13. #include "ai_sentence.h"
  14. #define PATROL_RADIUS_RATIO 2.0f
  15. #define POLICE_MAX_WARNINGS 4
  16. class CAI_PolicingBehavior : public CAI_SimpleBehavior
  17. {
  18. DECLARE_CLASS( CAI_PolicingBehavior, CAI_SimpleBehavior );
  19. public:
  20. DECLARE_DATADESC();
  21. CAI_PolicingBehavior();
  22. enum
  23. {
  24. // Schedules
  25. SCHED_POLICE_RETURN_FROM_HARASS = BaseClass::NEXT_SCHEDULE,
  26. SCHED_POLICE_WARN_TARGET,
  27. SCHED_POLICE_HARASS_TARGET,
  28. SCHED_POLICE_SUPPRESS_TARGET,
  29. SCHED_POLICE_FACE_ALONG_GOAL,
  30. SCHED_POLICE_TRACK_TARGET,
  31. NEXT_SCHEDULE,
  32. // Tasks
  33. TASK_POLICE_GET_PATH_TO_HARASS_GOAL = BaseClass::NEXT_TASK,
  34. TASK_POLICE_GET_PATH_TO_POLICE_GOAL,
  35. TASK_POLICE_FACE_ALONG_GOAL,
  36. TASK_POLICE_ANNOUNCE_HARASS,
  37. NEXT_TASK,
  38. // Conditions
  39. COND_POLICE_TARGET_TOO_CLOSE_HARASS = BaseClass::NEXT_CONDITION,
  40. COND_POLICE_TARGET_TOO_CLOSE_SUPPRESS,
  41. NEXT_CONDITION,
  42. };
  43. virtual const char *GetName() { return "Policing"; }
  44. void Enable( CAI_PoliceGoal *pGoal );
  45. void Disable( void );
  46. bool CanSelectSchedule( void );
  47. void BuildScheduleTestBits( void );
  48. bool IsEnabled( void ) { return m_bEnabled; }
  49. bool TargetIsHostile( void );
  50. bool ShouldKnockOutTarget( CBaseEntity *pTarget );
  51. void KnockOutTarget( CBaseEntity *pTarget );
  52. int SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode );
  53. CBaseEntity *GetGoalTarget( void );
  54. private:
  55. void HostSpeakSentence( const char *pSentence, SentencePriority_t nSoundPriority, SentenceCriteria_t nCriteria );
  56. int TranslateSchedule( int scheduleType );
  57. int SelectSchedule( void );
  58. int SelectSuppressSchedule( void );
  59. int SelectHarassSchedule( void );
  60. Activity NPC_TranslateActivity( Activity newActivity );
  61. void GatherConditions( void );
  62. bool OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval );
  63. void StartTask( const Task_t *pTask );
  64. void RunTask( const Task_t *pTask );
  65. void AnnouncePolicing( void );
  66. void HostSetBatonState( bool state );
  67. bool HostBatonIsOn( void );
  68. void SetTargetHostileDuration( float time );
  69. bool MaintainGoalPosition( void );
  70. protected:
  71. bool m_bEnabled;
  72. bool m_bStartPolicing;
  73. float m_flNextHarassTime;
  74. float m_flAggressiveTime;
  75. int m_nNumWarnings;
  76. bool m_bTargetIsHostile;
  77. float m_flTargetHostileTime;
  78. CHandle<CAI_PoliceGoal> m_hPoliceGoal;
  79. DEFINE_CUSTOM_SCHEDULE_PROVIDER;
  80. };
  81. #endif // AI_BEHAVIOR_POLICE_H