Counter Strike : Global Offensive Source Code
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.

152 lines
3.4 KiB

  1. //========== Copyright � 2008, Valve Corporation, All rights reserved. ========
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef AI_BEHAVIOR_FIGHTFROMCOVER_H
  7. #define AI_BEHAVIOR_FIGHTFROMCOVER_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #include "ai_goalentity.h"
  12. #include "ai_behavior.h"
  13. //-----------------------------------------------------------------------------
  14. //
  15. //-----------------------------------------------------------------------------
  16. class CAI_FightFromCoverGoal : public CAI_GoalEntity
  17. {
  18. DECLARE_CLASS( CAI_FightFromCoverGoal, CAI_GoalEntity );
  19. public:
  20. CAI_FightFromCoverGoal();
  21. const Vector &GetFrontPosition();
  22. const Vector &GetFrontDirection();
  23. const QAngle &GetFrontAngles();
  24. virtual void OnActivate();
  25. virtual void OnDeactivate();
  26. virtual void EnableGoal( CAI_BaseNPC *pAI );
  27. virtual void DisableGoal( CAI_BaseNPC *pAI );
  28. void FrontThink();
  29. virtual void ResolveNames();
  30. void InputSetDirectionalMarker( inputdata_t &inputdata );
  31. void BeginMovingFront();
  32. void EndMovingFront();
  33. int DrawDebugTextOverlays();
  34. string_t m_DirectionalMarker;
  35. string_t m_GenericHintType;
  36. EHANDLE m_hDirectionalMarker;
  37. float m_WidthZone;
  38. float m_LengthZone;
  39. float m_HeightZone;
  40. float m_BiasZone;
  41. Vector m_vFront;
  42. Vector m_vDir;
  43. DECLARE_DATADESC();
  44. };
  45. //-----------------------------------------------------------------------------
  46. //
  47. //-----------------------------------------------------------------------------
  48. class CAI_FightFromCoverBehavior : public CAI_SimpleBehavior
  49. {
  50. DECLARE_CLASS( CAI_FightFromCoverBehavior, CAI_SimpleBehavior );
  51. DECLARE_DATADESC();
  52. DEFINE_CUSTOM_SCHEDULE_PROVIDER;
  53. public:
  54. CAI_FightFromCoverBehavior();
  55. void SetGoal( CAI_FightFromCoverGoal *pGoal );
  56. void ClearGoal();
  57. private:
  58. struct Animation_t
  59. {
  60. Animation_t() { Reset(); }
  61. void Reset() { bActivity = true; id = ACT_INVALID; }
  62. bool bActivity;
  63. int id;
  64. };
  65. void OnRestore() { UpdateAnimationsFromHint(); }
  66. void GatherConditions();
  67. bool CanSelectSchedule();
  68. int SelectSchedule();
  69. void StartTask( const Task_t *pTask );
  70. void RunTask( const Task_t *pTask );
  71. bool StartAnimationTask( const Animation_t &animation, bool bReset = false, Activity defaultActivity = ACT_IDLE );
  72. bool FValidateHintType ( CAI_Hint *pHint );
  73. static bool HintSearchFilter( void *pContext, CAI_Hint *pCandidate );
  74. bool IsPointInZone( const Vector &v );
  75. void OnUpdateShotRegulator();
  76. void UpdateAnimationsFromHint();
  77. bool GetAnimation( CScriptScope &scope, const char *pszKey, Animation_t *pAnimation );
  78. enum
  79. {
  80. // Schedules
  81. SCHED_FFC_RUN_TO_HINT = BaseClass::NEXT_SCHEDULE,
  82. SCHED_FFC_HOLD_COVER,
  83. SCHED_FFC_PEEK,
  84. SCHED_FFC_HOLD_PEEK,
  85. SCHED_FFC_RELOAD,
  86. SCHED_FFC_ATTACK,
  87. NEXT_SCHEDULE,
  88. // Tasks
  89. TASK_FFC_GET_PATH_TO_HINT = BaseClass::NEXT_TASK,
  90. TASK_FFC_COVER,
  91. TASK_FFC_PEEK,
  92. TASK_FFC_ATTACK,
  93. NEXT_TASK = BaseClass::NEXT_TASK,
  94. // Conditions
  95. COND_FFC_HINT_CHANGE = BaseClass::NEXT_CONDITION,
  96. NEXT_CONDITION,
  97. };
  98. virtual const char *GetName() { return "FightFromCover"; }
  99. CHandle<CAI_FightFromCoverGoal> m_hGoal;
  100. CAI_MoveMonitor m_FrontMoveMonitor;
  101. CSimpleSimTimer m_FrontTimer;
  102. Animation_t m_EntryAnim;
  103. Animation_t m_MoveAnim;
  104. Animation_t m_CoverAnim;
  105. Animation_t m_ReloadAnim;
  106. Animation_t m_PeekAnim;
  107. Animation_t m_ShootAnim;
  108. Animation_t m_ExitAnim;
  109. };
  110. #endif // AI_BEHAVIOR_FIGHTFROMCOVER_H