be_ai_move.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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_move.h
  21. *
  22. * desc: movement AI
  23. *
  24. * $Archive: /source/code/botlib/be_ai_move.h $
  25. *
  26. *****************************************************************************/
  27. //movement types
  28. #define MOVE_WALK 1
  29. #define MOVE_CROUCH 2
  30. #define MOVE_JUMP 4
  31. #define MOVE_GRAPPLE 8
  32. #define MOVE_ROCKETJUMP 16
  33. #define MOVE_BFGJUMP 32
  34. //move flags
  35. #define MFL_BARRIERJUMP 1 //bot is performing a barrier jump
  36. #define MFL_ONGROUND 2 //bot is in the ground
  37. #define MFL_SWIMMING 4 //bot is swimming
  38. #define MFL_AGAINSTLADDER 8 //bot is against a ladder
  39. #define MFL_WATERJUMP 16 //bot is waterjumping
  40. #define MFL_TELEPORTED 32 //bot is being teleported
  41. #define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple
  42. #define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook
  43. #define MFL_GRAPPLERESET 256 //bot has reset the grapple
  44. #define MFL_WALK 512 //bot should walk slowly
  45. // move result flags
  46. #define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement
  47. #define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming
  48. #define MOVERESULT_WAITING 4 //bot is waiting for something
  49. #define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code
  50. #define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement
  51. #define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle
  52. #define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing
  53. #define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat)
  54. #define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot
  55. //
  56. #define MAX_AVOIDREACH 1
  57. #define MAX_AVOIDSPOTS 32
  58. // avoid spot types
  59. #define AVOID_CLEAR 0 //clear all avoid spots
  60. #define AVOID_ALWAYS 1 //avoid always
  61. #define AVOID_DONTBLOCK 2 //never totally block
  62. // restult types
  63. #define RESULTTYPE_ELEVATORUP 1 //elevator is up
  64. #define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive
  65. #define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed
  66. #define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad
  67. //structure used to initialize the movement state
  68. //the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate
  69. typedef struct bot_initmove_s
  70. {
  71. vec3_t origin; //origin of the bot
  72. vec3_t velocity; //velocity of the bot
  73. vec3_t viewoffset; //view offset
  74. int entitynum; //entity number of the bot
  75. int client; //client number of the bot
  76. float thinktime; //time the bot thinks
  77. int presencetype; //presencetype of the bot
  78. vec3_t viewangles; //view angles of the bot
  79. int or_moveflags; //values ored to the movement flags
  80. } bot_initmove_t;
  81. //NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set
  82. typedef struct bot_moveresult_s
  83. {
  84. int failure; //true if movement failed all together
  85. int type; //failure or blocked type
  86. int blocked; //true if blocked by an entity
  87. int blockentity; //entity blocking the bot
  88. int traveltype; //last executed travel type
  89. int flags; //result flags
  90. int weapon; //weapon used for movement
  91. vec3_t movedir; //movement direction
  92. vec3_t ideal_viewangles; //ideal viewangles for the movement
  93. } bot_moveresult_t;
  94. // bk001204: from code/botlib/be_ai_move.c
  95. // TTimo 04/12/2001 was moved here to avoid dup defines
  96. typedef struct bot_avoidspot_s
  97. {
  98. vec3_t origin;
  99. float radius;
  100. int type;
  101. } bot_avoidspot_t;
  102. //resets the whole move state
  103. void BotResetMoveState(int movestate);
  104. //moves the bot to the given goal
  105. void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags);
  106. //moves the bot in the specified direction using the specified type of movement
  107. int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
  108. //reset avoid reachability
  109. void BotResetAvoidReach(int movestate);
  110. //resets the last avoid reachability
  111. void BotResetLastAvoidReach(int movestate);
  112. //returns a reachability area if the origin is in one
  113. int BotReachabilityArea(vec3_t origin, int client);
  114. //view target based on movement
  115. int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);
  116. //predict the position of a player based on movement towards a goal
  117. int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target);
  118. //returns the handle of a newly allocated movestate
  119. int BotAllocMoveState(void);
  120. //frees the movestate with the given handle
  121. void BotFreeMoveState(int handle);
  122. //initialize movement state before performing any movement
  123. void BotInitMoveState(int handle, bot_initmove_t *initmove);
  124. //add a spot to avoid (if type == AVOID_CLEAR all spots are removed)
  125. void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
  126. //must be called every map change
  127. void BotSetBrushModelTypes(void);
  128. //setup movement AI
  129. int BotSetupMoveAI(void);
  130. //shutdown movement AI
  131. void BotShutdownMoveAI(void);