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.

229 lines
9.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Sets up the tasks for default AI.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "stringregistry.h"
  9. #include "ai_basenpc.h"
  10. #include "ai_task.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. const char * g_ppszTaskFailureText[] =
  14. {
  15. "No failure", // NO_TASK_FAILURE
  16. "No Target", // FAIL_NO_TARGET
  17. "Weapon owned by someone else", // FAIL_WEAPON_OWNED
  18. "Weapon/Item doesn't exist", // FAIL_ITEM_NO_FIND
  19. "No hint node", // FAIL_NO_HINT_NODE
  20. "Schedule not found", // FAIL_SCHEDULE_NOT_FOUND
  21. "Don't have an enemy", // FAIL_NO_ENEMY
  22. "Found no backaway node", // FAIL_NO_BACKAWAY_NODE
  23. "Couldn't find cover", // FAIL_NO_COVER
  24. "Couldn't find flank", // FAIL_NO_FLANK
  25. "Couldn't find shoot position", // FAIL_NO_SHOOT
  26. "Don't have a route", // FAIL_NO_ROUTE
  27. "Don't have a route: no goal", // FAIL_NO_ROUTE_GOAL
  28. "Don't have a route: blocked", // FAIL_NO_ROUTE_BLOCKED
  29. "Don't have a route: illegal move", // FAIL_NO_ROUTE_ILLEGAL
  30. "Couldn't walk to target", // FAIL_NO_WALK
  31. "Node already locked", // FAIL_ALREADY_LOCKED
  32. "No sound present", // FAIL_NO_SOUND
  33. "No scent present", // FAIL_NO_SCENT
  34. "Bad activity", // FAIL_BAD_ACTIVITY
  35. "No goal entity", // FAIL_NO_GOAL
  36. "No player", // FAIL_NO_PLAYER
  37. "Can't reach any nodes", // FAIL_NO_REACHABLE_NODE
  38. "No AI Network to Use", // FAIL_NO_AI_NETWORK
  39. "Bad position to Target", // FAIL_BAD_POSITION
  40. "Route Destination No Longer Valid", // FAIL_BAD_PATH_GOAL
  41. "Stuck on top of something", // FAIL_STUCK_ONTOP
  42. "Item has been taken", // FAIL_ITEM_TAKEN
  43. "Too frozen", // FAIL_FROZEN
  44. };
  45. const char *TaskFailureToString( AI_TaskFailureCode_t code )
  46. {
  47. const char *pszResult;
  48. if ( code < 0 || code >= NUM_FAIL_CODES )
  49. pszResult = (const char *)code;
  50. else
  51. pszResult = g_ppszTaskFailureText[code];
  52. return pszResult;
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose: Given and task name, return the task ID
  56. //-----------------------------------------------------------------------------
  57. int CAI_BaseNPC::GetTaskID(const char* taskName)
  58. {
  59. return GetSchedulingSymbols()->TaskSymbolToId( taskName );
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose: Initialize the task name string registry
  63. // Input :
  64. // Output :
  65. //-----------------------------------------------------------------------------
  66. void CAI_BaseNPC::InitDefaultTaskSR(void)
  67. {
  68. #define ADD_DEF_TASK( name ) idSpace.AddTask(#name, name, "CAI_BaseNPC" )
  69. CAI_ClassScheduleIdSpace &idSpace = CAI_BaseNPC::AccessClassScheduleIdSpaceDirect();
  70. ADD_DEF_TASK( TASK_INVALID );
  71. ADD_DEF_TASK( TASK_ANNOUNCE_ATTACK );
  72. ADD_DEF_TASK( TASK_RESET_ACTIVITY );
  73. ADD_DEF_TASK( TASK_WAIT );
  74. ADD_DEF_TASK( TASK_WAIT_FACE_ENEMY );
  75. ADD_DEF_TASK( TASK_WAIT_FACE_ENEMY_RANDOM );
  76. ADD_DEF_TASK( TASK_WAIT_PVS );
  77. ADD_DEF_TASK( TASK_SUGGEST_STATE );
  78. ADD_DEF_TASK( TASK_TARGET_PLAYER );
  79. ADD_DEF_TASK( TASK_SCRIPT_WALK_TO_TARGET );
  80. ADD_DEF_TASK( TASK_SCRIPT_RUN_TO_TARGET );
  81. ADD_DEF_TASK( TASK_SCRIPT_CUSTOM_MOVE_TO_TARGET );
  82. ADD_DEF_TASK( TASK_MOVE_TO_TARGET_RANGE );
  83. ADD_DEF_TASK( TASK_MOVE_TO_GOAL_RANGE );
  84. ADD_DEF_TASK( TASK_MOVE_AWAY_PATH );
  85. ADD_DEF_TASK( TASK_GET_PATH_AWAY_FROM_BEST_SOUND );
  86. ADD_DEF_TASK( TASK_SET_GOAL );
  87. ADD_DEF_TASK( TASK_GET_PATH_TO_GOAL );
  88. ADD_DEF_TASK( TASK_GET_PATH_TO_ENEMY );
  89. ADD_DEF_TASK( TASK_GET_PATH_TO_ENEMY_LKP );
  90. ADD_DEF_TASK( TASK_GET_CHASE_PATH_TO_ENEMY );
  91. ADD_DEF_TASK( TASK_GET_PATH_TO_ENEMY_LKP_LOS );
  92. ADD_DEF_TASK( TASK_GET_PATH_TO_RANGE_ENEMY_LKP_LOS );
  93. ADD_DEF_TASK( TASK_GET_PATH_TO_ENEMY_CORPSE );
  94. ADD_DEF_TASK( TASK_GET_PATH_TO_PLAYER );
  95. ADD_DEF_TASK( TASK_GET_PATH_TO_ENEMY_LOS );
  96. ADD_DEF_TASK( TASK_GET_FLANK_ARC_PATH_TO_ENEMY_LOS );
  97. ADD_DEF_TASK( TASK_GET_FLANK_RADIUS_PATH_TO_ENEMY_LOS );
  98. ADD_DEF_TASK( TASK_GET_PATH_TO_TARGET );
  99. ADD_DEF_TASK( TASK_GET_PATH_TO_TARGET_WEAPON );
  100. ADD_DEF_TASK( TASK_GET_PATH_OFF_OF_NPC );
  101. ADD_DEF_TASK( TASK_CREATE_PENDING_WEAPON );
  102. ADD_DEF_TASK( TASK_GET_PATH_TO_HINTNODE );
  103. ADD_DEF_TASK( TASK_STORE_LASTPOSITION );
  104. ADD_DEF_TASK( TASK_CLEAR_LASTPOSITION );
  105. ADD_DEF_TASK( TASK_STORE_POSITION_IN_SAVEPOSITION );
  106. ADD_DEF_TASK( TASK_STORE_BESTSOUND_IN_SAVEPOSITION );
  107. ADD_DEF_TASK( TASK_STORE_BESTSOUND_REACTORIGIN_IN_SAVEPOSITION );
  108. ADD_DEF_TASK( TASK_REACT_TO_COMBAT_SOUND );
  109. ADD_DEF_TASK( TASK_STORE_ENEMY_POSITION_IN_SAVEPOSITION );
  110. ADD_DEF_TASK( TASK_GET_PATH_TO_COMMAND_GOAL );
  111. ADD_DEF_TASK( TASK_MARK_COMMAND_GOAL_POS );
  112. ADD_DEF_TASK( TASK_CLEAR_COMMAND_GOAL );
  113. ADD_DEF_TASK( TASK_GET_PATH_TO_LASTPOSITION );
  114. ADD_DEF_TASK( TASK_GET_PATH_TO_SAVEPOSITION );
  115. ADD_DEF_TASK( TASK_GET_PATH_TO_SAVEPOSITION_LOS );
  116. ADD_DEF_TASK( TASK_GET_PATH_TO_BESTSOUND );
  117. ADD_DEF_TASK( TASK_GET_PATH_TO_BESTSCENT );
  118. ADD_DEF_TASK( TASK_GET_PATH_TO_RANDOM_NODE );
  119. ADD_DEF_TASK( TASK_RUN_PATH );
  120. ADD_DEF_TASK( TASK_WALK_PATH );
  121. ADD_DEF_TASK( TASK_WALK_PATH_TIMED );
  122. ADD_DEF_TASK( TASK_WALK_PATH_WITHIN_DIST );
  123. ADD_DEF_TASK( TASK_RUN_PATH_WITHIN_DIST );
  124. ADD_DEF_TASK( TASK_WALK_PATH_FOR_UNITS );
  125. ADD_DEF_TASK( TASK_RUN_PATH_FOR_UNITS );
  126. ADD_DEF_TASK( TASK_RUN_PATH_FLEE );
  127. ADD_DEF_TASK( TASK_RUN_PATH_TIMED );
  128. ADD_DEF_TASK( TASK_STRAFE_PATH );
  129. ADD_DEF_TASK( TASK_CLEAR_MOVE_WAIT );
  130. ADD_DEF_TASK( TASK_SMALL_FLINCH );
  131. ADD_DEF_TASK( TASK_BIG_FLINCH );
  132. ADD_DEF_TASK( TASK_DEFER_DODGE );
  133. ADD_DEF_TASK( TASK_FACE_IDEAL );
  134. ADD_DEF_TASK( TASK_FACE_REASONABLE );
  135. ADD_DEF_TASK( TASK_FACE_PATH );
  136. ADD_DEF_TASK( TASK_FACE_PLAYER );
  137. ADD_DEF_TASK( TASK_FACE_ENEMY );
  138. ADD_DEF_TASK( TASK_FACE_HINTNODE );
  139. ADD_DEF_TASK( TASK_PLAY_HINT_ACTIVITY );
  140. ADD_DEF_TASK( TASK_FACE_TARGET );
  141. ADD_DEF_TASK( TASK_FACE_LASTPOSITION );
  142. ADD_DEF_TASK( TASK_FACE_SAVEPOSITION );
  143. ADD_DEF_TASK( TASK_FACE_AWAY_FROM_SAVEPOSITION );
  144. ADD_DEF_TASK( TASK_SET_IDEAL_YAW_TO_CURRENT );
  145. ADD_DEF_TASK( TASK_RANGE_ATTACK1 );
  146. ADD_DEF_TASK( TASK_RANGE_ATTACK2 );
  147. ADD_DEF_TASK( TASK_MELEE_ATTACK1 );
  148. ADD_DEF_TASK( TASK_MELEE_ATTACK2 );
  149. ADD_DEF_TASK( TASK_RELOAD );
  150. ADD_DEF_TASK( TASK_SPECIAL_ATTACK1 );
  151. ADD_DEF_TASK( TASK_SPECIAL_ATTACK2 );
  152. ADD_DEF_TASK( TASK_FIND_HINTNODE );
  153. ADD_DEF_TASK( TASK_CLEAR_HINTNODE );
  154. ADD_DEF_TASK( TASK_FIND_LOCK_HINTNODE );
  155. ADD_DEF_TASK( TASK_LOCK_HINTNODE );
  156. ADD_DEF_TASK( TASK_SOUND_ANGRY );
  157. ADD_DEF_TASK( TASK_SOUND_DEATH );
  158. ADD_DEF_TASK( TASK_SOUND_IDLE );
  159. ADD_DEF_TASK( TASK_SOUND_WAKE );
  160. ADD_DEF_TASK( TASK_SOUND_PAIN );
  161. ADD_DEF_TASK( TASK_SOUND_DIE );
  162. ADD_DEF_TASK( TASK_SPEAK_SENTENCE );
  163. ADD_DEF_TASK( TASK_WAIT_FOR_SPEAK_FINISH );
  164. ADD_DEF_TASK( TASK_SET_ACTIVITY );
  165. ADD_DEF_TASK( TASK_RANDOMIZE_FRAMERATE );
  166. ADD_DEF_TASK( TASK_SET_SCHEDULE );
  167. ADD_DEF_TASK( TASK_SET_FAIL_SCHEDULE );
  168. ADD_DEF_TASK( TASK_SET_TOLERANCE_DISTANCE );
  169. ADD_DEF_TASK( TASK_SET_ROUTE_SEARCH_TIME );
  170. ADD_DEF_TASK( TASK_CLEAR_FAIL_SCHEDULE );
  171. ADD_DEF_TASK( TASK_PLAY_SEQUENCE );
  172. ADD_DEF_TASK( TASK_PLAY_PRIVATE_SEQUENCE );
  173. ADD_DEF_TASK( TASK_PLAY_PRIVATE_SEQUENCE_FACE_ENEMY );
  174. ADD_DEF_TASK( TASK_PLAY_SEQUENCE_FACE_ENEMY );
  175. ADD_DEF_TASK( TASK_PLAY_SEQUENCE_FACE_TARGET );
  176. ADD_DEF_TASK( TASK_FIND_COVER_FROM_BEST_SOUND );
  177. ADD_DEF_TASK( TASK_FIND_COVER_FROM_ENEMY );
  178. ADD_DEF_TASK( TASK_FIND_LATERAL_COVER_FROM_ENEMY );
  179. ADD_DEF_TASK( TASK_FIND_BACKAWAY_FROM_SAVEPOSITION );
  180. ADD_DEF_TASK( TASK_FIND_NODE_COVER_FROM_ENEMY );
  181. ADD_DEF_TASK( TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY );
  182. ADD_DEF_TASK( TASK_FIND_FAR_NODE_COVER_FROM_ENEMY );
  183. ADD_DEF_TASK( TASK_FIND_COVER_FROM_ORIGIN );
  184. ADD_DEF_TASK( TASK_DIE );
  185. ADD_DEF_TASK( TASK_WAIT_FOR_SCRIPT );
  186. ADD_DEF_TASK( TASK_PUSH_SCRIPT_ARRIVAL_ACTIVITY );
  187. ADD_DEF_TASK( TASK_PLAY_SCRIPT );
  188. ADD_DEF_TASK( TASK_PLAY_SCRIPT_POST_IDLE );
  189. ADD_DEF_TASK( TASK_ENABLE_SCRIPT );
  190. ADD_DEF_TASK( TASK_PLANT_ON_SCRIPT );
  191. ADD_DEF_TASK( TASK_FACE_SCRIPT );
  192. ADD_DEF_TASK( TASK_PLAY_SCENE );
  193. ADD_DEF_TASK( TASK_WAIT_RANDOM );
  194. ADD_DEF_TASK( TASK_WAIT_INDEFINITE );
  195. ADD_DEF_TASK( TASK_STOP_MOVING );
  196. ADD_DEF_TASK( TASK_TURN_LEFT );
  197. ADD_DEF_TASK( TASK_TURN_RIGHT );
  198. ADD_DEF_TASK( TASK_REMEMBER );
  199. ADD_DEF_TASK( TASK_FORGET );
  200. ADD_DEF_TASK( TASK_WAIT_FOR_MOVEMENT );
  201. ADD_DEF_TASK( TASK_WAIT_FOR_MOVEMENT_STEP );
  202. ADD_DEF_TASK( TASK_WAIT_UNTIL_NO_DANGER_SOUND );
  203. ADD_DEF_TASK( TASK_WEAPON_FIND );
  204. ADD_DEF_TASK( TASK_WEAPON_PICKUP );
  205. ADD_DEF_TASK( TASK_WEAPON_RUN_PATH );
  206. ADD_DEF_TASK( TASK_WEAPON_CREATE );
  207. ADD_DEF_TASK( TASK_ITEM_RUN_PATH );
  208. ADD_DEF_TASK( TASK_ITEM_PICKUP );
  209. ADD_DEF_TASK( TASK_USE_SMALL_HULL );
  210. ADD_DEF_TASK( TASK_FALL_TO_GROUND );
  211. ADD_DEF_TASK( TASK_WANDER );
  212. ADD_DEF_TASK( TASK_FREEZE );
  213. ADD_DEF_TASK( TASK_GATHER_CONDITIONS );
  214. ADD_DEF_TASK( TASK_IGNORE_OLD_ENEMIES );
  215. ADD_DEF_TASK( TASK_DEBUG_BREAK );
  216. ADD_DEF_TASK( TASK_ADD_HEALTH );
  217. ADD_DEF_TASK( TASK_GET_PATH_TO_INTERACTION_PARTNER );
  218. ADD_DEF_TASK( TASK_PRE_SCRIPT );
  219. }