| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
|
| 24 |
/***************************************************************************** |
| 25 |
* name: be_ai_move.h |
| 26 |
* |
| 27 |
* desc: movement AI |
| 28 |
* |
| 29 |
* $Archive: /source/code/botlib/be_ai_move.h $ |
| 30 |
* |
| 31 |
*****************************************************************************/ |
| 32 |
|
| 33 |
//movement types |
| 34 |
#define MOVE_WALK 1 |
| 35 |
#define MOVE_CROUCH 2 |
| 36 |
#define MOVE_JUMP 4 |
| 37 |
#define MOVE_GRAPPLE 8 |
| 38 |
#define MOVE_ROCKETJUMP 16 |
| 39 |
#define MOVE_BFGJUMP 32 |
| 40 |
//move flags |
| 41 |
#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump |
| 42 |
#define MFL_ONGROUND 2 //bot is in the ground |
| 43 |
#define MFL_SWIMMING 4 //bot is swimming |
| 44 |
#define MFL_AGAINSTLADDER 8 //bot is against a ladder |
| 45 |
#define MFL_WATERJUMP 16 //bot is waterjumping |
| 46 |
#define MFL_TELEPORTED 32 //bot is being teleported |
| 47 |
#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple |
| 48 |
#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook |
| 49 |
#define MFL_GRAPPLERESET 256 //bot has reset the grapple |
| 50 |
#define MFL_WALK 512 //bot should walk slowly |
| 51 |
// move result flags |
| 52 |
#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement |
| 53 |
#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming |
| 54 |
#define MOVERESULT_WAITING 4 //bot is waiting for something |
| 55 |
#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code |
| 56 |
#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement |
| 57 |
#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle |
| 58 |
#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing |
| 59 |
#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat) |
| 60 |
#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot |
| 61 |
// |
| 62 |
#define MAX_AVOIDREACH 1 |
| 63 |
#define MAX_AVOIDSPOTS 32 |
| 64 |
// avoid spot types |
| 65 |
#define AVOID_CLEAR 0 //clear all avoid spots |
| 66 |
#define AVOID_ALWAYS 1 //avoid always |
| 67 |
#define AVOID_DONTBLOCK 2 //never totally block |
| 68 |
// restult types |
| 69 |
#define RESULTTYPE_ELEVATORUP 1 //elevator is up |
| 70 |
#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive |
| 71 |
#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed |
| 72 |
#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad |
| 73 |
|
| 74 |
//structure used to initialize the movement state |
| 75 |
//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate |
| 76 |
typedef struct bot_initmove_s |
| 77 |
{ |
| 78 |
vec3_t origin; //origin of the bot |
| 79 |
vec3_t velocity; //velocity of the bot |
| 80 |
vec3_t viewoffset; //view offset |
| 81 |
int entitynum; //entity number of the bot |
| 82 |
int client; //client number of the bot |
| 83 |
float thinktime; //time the bot thinks |
| 84 |
int presencetype; //presencetype of the bot |
| 85 |
vec3_t viewangles; //view angles of the bot |
| 86 |
int or_moveflags; //values ored to the movement flags |
| 87 |
} bot_initmove_t; |
| 88 |
|
| 89 |
//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set |
| 90 |
typedef struct bot_moveresult_s |
| 91 |
{ |
| 92 |
int failure; //true if movement failed all together |
| 93 |
int type; //failure or blocked type |
| 94 |
int blocked; //true if blocked by an entity |
| 95 |
int blockentity; //entity blocking the bot |
| 96 |
int traveltype; //last executed travel type |
| 97 |
int flags; //result flags |
| 98 |
int weapon; //weapon used for movement |
| 99 |
vec3_t movedir; //movement direction |
| 100 |
vec3_t ideal_viewangles; //ideal viewangles for the movement |
| 101 |
} bot_moveresult_t; |
| 102 |
|
| 103 |
#define bot_moveresult_t_cleared(x) bot_moveresult_t (x) = {0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}} |
| 104 |
|
| 105 |
typedef struct bot_avoidspot_s |
| 106 |
{ |
| 107 |
vec3_t origin; |
| 108 |
float radius; |
| 109 |
int type; |
| 110 |
} bot_avoidspot_t; |
| 111 |
|
| 112 |
//resets the whole move state |
| 113 |
void BotResetMoveState(int movestate); |
| 114 |
//moves the bot to the given goal |
| 115 |
void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags); |
| 116 |
//moves the bot in the specified direction using the specified type of movement |
| 117 |
int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type); |
| 118 |
//reset avoid reachability |
| 119 |
void BotResetAvoidReach(int movestate); |
| 120 |
//resets the last avoid reachability |
| 121 |
void BotResetLastAvoidReach(int movestate); |
| 122 |
//returns a reachability area if the origin is in one |
| 123 |
int BotReachabilityArea(vec3_t origin, int client); |
| 124 |
//view target based on movement |
| 125 |
int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target); |
| 126 |
//predict the position of a player based on movement towards a goal |
| 127 |
int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target); |
| 128 |
//returns the handle of a newly allocated movestate |
| 129 |
int BotAllocMoveState(void); |
| 130 |
//frees the movestate with the given handle |
| 131 |
void BotFreeMoveState(int handle); |
| 132 |
//initialize movement state before performing any movement |
| 133 |
void BotInitMoveState(int handle, bot_initmove_t *initmove); |
| 134 |
//add a spot to avoid (if type == AVOID_CLEAR all spots are removed) |
| 135 |
void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type); |
| 136 |
//must be called every map change |
| 137 |
void BotSetBrushModelTypes(void); |
| 138 |
//setup movement AI |
| 139 |
int BotSetupMoveAI(void); |
| 140 |
//shutdown movement AI |
| 141 |
void BotShutdownMoveAI(void); |
| 142 |
|