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.

140 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Base class for many flying NPCs
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "ai_basenpc_flyer_new.h"
  9. #include "ai_route.h"
  10. #include "ai_navigator.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. #define FLYER_ROUTE_REBUILD_TIME 3.0 // Time between route rebuilds
  14. // NOTE: Never instantiate ai_base_npc_flyer_new directly!!
  15. //IMPLEMENT_CUSTOM_AI( ai_base_npc_flyer_new, CAI_BaseNPCFlyerNew);
  16. //------------------------------------------------------------------------------
  17. // Purpose :
  18. // Input :
  19. // Output :
  20. //------------------------------------------------------------------------------
  21. CAI_BaseNPCFlyerNew::CAI_BaseNPCFlyerNew()
  22. {
  23. }
  24. //------------------------------------------------------------------------------
  25. // Used to set up a flyer
  26. //------------------------------------------------------------------------------
  27. void CAI_BaseNPCFlyerNew::SpawnFlyer()
  28. {
  29. SetNavType( NAV_FLY );
  30. AddFlag( FL_FLY );
  31. SetMoveType( MOVETYPE_STEP );
  32. CapabilitiesAdd( bits_CAP_MOVE_FLY );
  33. }
  34. /*
  35. void CAI_BaseNPCFlyerNew::InitCustomSchedules(void)
  36. {
  37. INIT_CUSTOM_AI(CAI_BaseNPCFlyerNew);
  38. ADD_CUSTOM_CONDITION(CAI_BaseNPCFlyerNew, COND_FLYER_MOVE_BLOCKED);
  39. ADD_CUSTOM_CONDITION(CAI_BaseNPCFlyerNew, COND_FLYER_MOVE_IMPOSSIBLE);
  40. }
  41. */
  42. //------------------------------------------------------------------------------
  43. // Should be called during Select Schedule (BLEAH!)
  44. //------------------------------------------------------------------------------
  45. void CAI_BaseNPCFlyerNew::ClearFlyerConditions(void)
  46. {
  47. // ClearCondition( COND_FLYER_MOVE_BLOCKED );
  48. // ClearCondition( COND_FLYER_MOVE_IMPOSSIBLE );
  49. }
  50. //------------------------------------------------------------------------------
  51. // Purpose :
  52. // Input :
  53. // Output :
  54. //------------------------------------------------------------------------------
  55. float CAI_BaseNPCFlyerNew::MinGroundDist(void)
  56. {
  57. return 0;
  58. }
  59. //-----------------------------------------------------------------------------
  60. // Sets the ground speed appropriately:
  61. //-----------------------------------------------------------------------------
  62. float CAI_BaseNPCFlyerNew::GetIdealSpeed( ) const
  63. {
  64. return m_flSpeed;
  65. }
  66. //------------------------------------------------------------------------------
  67. // Purpose :
  68. // Input :
  69. // Output :
  70. //------------------------------------------------------------------------------
  71. void CAI_BaseNPCFlyerNew::StartTask( const Task_t *pTask )
  72. {
  73. switch (pTask->iTask)
  74. {
  75. // Activity is just idle (have no run)
  76. case TASK_RUN_PATH:
  77. {
  78. GetNavigator()->SetMovementActivity(ACT_IDLE);
  79. TaskComplete();
  80. break;
  81. }
  82. // Don't check for run/walk activity
  83. case TASK_SCRIPT_RUN_TO_TARGET:
  84. case TASK_SCRIPT_WALK_TO_TARGET:
  85. {
  86. if (GetTarget() == NULL)
  87. {
  88. TaskFail(FAIL_NO_TARGET);
  89. }
  90. else
  91. {
  92. if (!GetNavigator()->SetGoal( GOALTYPE_TARGETENT ) )
  93. {
  94. TaskFail(FAIL_NO_ROUTE);
  95. GetNavigator()->ClearGoal();
  96. }
  97. }
  98. TaskComplete();
  99. break;
  100. }
  101. default:
  102. {
  103. BaseClass::StartTask(pTask);
  104. }
  105. break;
  106. }
  107. }
  108. //-----------------------------------------------------------------------------
  109. // Purpose:
  110. //-----------------------------------------------------------------------------
  111. void CAI_BaseNPCFlyerNew::RunTask( const Task_t *pTask )
  112. {
  113. BaseClass::RunTask(pTask);
  114. }