be_ai_goal.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. //
  19. /*****************************************************************************
  20. * name: be_ai_goal.h
  21. *
  22. * desc: goal AI
  23. *
  24. * $Archive: /source/code/botlib/be_ai_goal.h $
  25. *
  26. *****************************************************************************/
  27. #define MAX_AVOIDGOALS 256
  28. #define MAX_GOALSTACK 8
  29. #define GFL_NONE 0
  30. #define GFL_ITEM 1
  31. #define GFL_ROAM 2
  32. #define GFL_DROPPED 4
  33. //a bot goal
  34. typedef struct bot_goal_s
  35. {
  36. vec3_t origin; //origin of the goal
  37. int areanum; //area number of the goal
  38. vec3_t mins, maxs; //mins and maxs of the goal
  39. int entitynum; //number of the goal entity
  40. int number; //goal number
  41. int flags; //goal flags
  42. int iteminfo; //item information
  43. } bot_goal_t;
  44. //reset the whole goal state, but keep the item weights
  45. void BotResetGoalState(int goalstate);
  46. //reset avoid goals
  47. void BotResetAvoidGoals(int goalstate);
  48. //remove the goal with the given number from the avoid goals
  49. void BotRemoveFromAvoidGoals(int goalstate, int number);
  50. //push a goal onto the goal stack
  51. void BotPushGoal(int goalstate, bot_goal_t *goal);
  52. //pop a goal from the goal stack
  53. void BotPopGoal(int goalstate);
  54. //empty the bot's goal stack
  55. void BotEmptyGoalStack(int goalstate);
  56. //dump the avoid goals
  57. void BotDumpAvoidGoals(int goalstate);
  58. //dump the goal stack
  59. void BotDumpGoalStack(int goalstate);
  60. //get the name name of the goal with the given number
  61. void BotGoalName(int number, char *name, int size);
  62. //get the top goal from the stack
  63. int BotGetTopGoal(int goalstate, bot_goal_t *goal);
  64. //get the second goal on the stack
  65. int BotGetSecondGoal(int goalstate, bot_goal_t *goal);
  66. //choose the best long term goal item for the bot
  67. int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
  68. //choose the best nearby goal item for the bot
  69. //the item may not be further away from the current bot position than maxtime
  70. //also the travel time from the nearby goal towards the long term goal may not
  71. //be larger than the travel time towards the long term goal from the current bot position
  72. int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags,
  73. bot_goal_t *ltg, float maxtime);
  74. //returns true if the bot touches the goal
  75. int BotTouchingGoal(vec3_t origin, bot_goal_t *goal);
  76. //returns true if the goal should be visible but isn't
  77. int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal);
  78. //search for a goal for the given classname, the index can be used
  79. //as a start point for the search when multiple goals are available with that same classname
  80. int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal);
  81. //get the next camp spot in the map
  82. int BotGetNextCampSpotGoal(int num, bot_goal_t *goal);
  83. //get the map location with the given name
  84. int BotGetMapLocationGoal(char *name, bot_goal_t *goal);
  85. //returns the avoid goal time
  86. float BotAvoidGoalTime(int goalstate, int number);
  87. //set the avoid goal time
  88. void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
  89. //initializes the items in the level
  90. void BotInitLevelItems(void);
  91. //regularly update dynamic entity items (dropped weapons, flags etc.)
  92. void BotUpdateEntityItems(void);
  93. //interbreed the goal fuzzy logic
  94. void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
  95. //save the goal fuzzy logic to disk
  96. void BotSaveGoalFuzzyLogic(int goalstate, char *filename);
  97. //mutate the goal fuzzy logic
  98. void BotMutateGoalFuzzyLogic(int goalstate, float range);
  99. //loads item weights for the bot
  100. int BotLoadItemWeights(int goalstate, char *filename);
  101. //frees the item weights of the bot
  102. void BotFreeItemWeights(int goalstate);
  103. //returns the handle of a newly allocated goal state
  104. int BotAllocGoalState(int client);
  105. //free the given goal state
  106. void BotFreeGoalState(int handle);
  107. //setup the goal AI
  108. int BotSetupGoalAI(void);
  109. //shut down the goal AI
  110. void BotShutdownGoalAI(void);