codemp/game/be_ai_move.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2000 Id Software, Inc.
00002 //
00003 
00004 /*****************************************************************************
00005  * name:                be_ai_move.h
00006  *
00007  * desc:                movement AI
00008  *
00009  * $Archive: /source/code/botlib/be_ai_move.h $
00010  * $Author: osman $ 
00011  * $Revision: 1.4 $
00012  * $Modtime: 10/05/99 3:32p $
00013  * $Date: 2003/03/15 23:44:00 $
00014  *
00015  *****************************************************************************/
00016 
00017 //movement types
00018 #define MOVE_WALK                                               1
00019 #define MOVE_CROUCH                                             2
00020 #define MOVE_JUMP                                               4
00021 #define MOVE_GRAPPLE                                    8
00022 #define MOVE_ROCKETJUMP                                 16
00023 #define MOVE_BFGJUMP                                    32
00024 //move flags
00025 #define MFL_BARRIERJUMP                                 1               //bot is performing a barrier jump
00026 #define MFL_ONGROUND                                    2               //bot is in the ground
00027 #define MFL_SWIMMING                                    4               //bot is swimming
00028 #define MFL_AGAINSTLADDER                               8               //bot is against a ladder
00029 #define MFL_WATERJUMP                                   16              //bot is waterjumping
00030 #define MFL_TELEPORTED                                  32              //bot is being teleported
00031 #define MFL_GRAPPLEPULL                                 64              //bot is being pulled by the grapple
00032 #define MFL_ACTIVEGRAPPLE                               128             //bot is using the grapple hook
00033 #define MFL_GRAPPLERESET                                256             //bot has reset the grapple
00034 #define MFL_WALK                                                512             //bot should walk slowly
00035 // move result flags
00036 #define MOVERESULT_MOVEMENTVIEW                 1               //bot uses view for movement
00037 #define MOVERESULT_SWIMVIEW                             2               //bot uses view for swimming
00038 #define MOVERESULT_WAITING                              4               //bot is waiting for something
00039 #define MOVERESULT_MOVEMENTVIEWSET              8               //bot has set the view in movement code
00040 #define MOVERESULT_MOVEMENTWEAPON               16              //bot uses weapon for movement
00041 #define MOVERESULT_ONTOPOFOBSTACLE              32              //bot is ontop of obstacle
00042 #define MOVERESULT_ONTOPOF_FUNCBOB              64              //bot is ontop of a func_bobbing
00043 #define MOVERESULT_ONTOPOF_ELEVATOR             128             //bot is ontop of an elevator (func_plat)
00044 #define MOVERESULT_BLOCKEDBYAVOIDSPOT   256             //bot is blocked by an avoid spot
00045 //
00046 #define MAX_AVOIDREACH                                  1
00047 #define MAX_AVOIDSPOTS                                  32
00048 // avoid spot types
00049 #define AVOID_CLEAR                                             0               //clear all avoid spots
00050 #define AVOID_ALWAYS                                    1               //avoid always
00051 #define AVOID_DONTBLOCK                                 2               //never totally block
00052 // restult types
00053 #define RESULTTYPE_ELEVATORUP                   1               //elevator is up
00054 #define RESULTTYPE_WAITFORFUNCBOBBING   2               //waiting for func bobbing to arrive
00055 #define RESULTTYPE_BADGRAPPLEPATH               4               //grapple path is obstructed
00056 #define RESULTTYPE_INSOLIDAREA                  8               //stuck in solid area, this is bad
00057 
00058 //structure used to initialize the movement state
00059 //the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate
00060 typedef struct bot_initmove_s
00061 {
00062         vec3_t origin;                          //origin of the bot
00063         vec3_t velocity;                        //velocity of the bot
00064         vec3_t viewoffset;                      //view offset
00065         int entitynum;                          //entity number of the bot
00066         int client;                                     //client number of the bot
00067         float thinktime;                        //time the bot thinks
00068         int presencetype;                       //presencetype of the bot
00069         vec3_t viewangles;                      //view angles of the bot
00070         int or_moveflags;                       //values ored to the movement flags
00071 } bot_initmove_t;
00072 
00073 //NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set
00074 typedef struct bot_moveresult_s
00075 {
00076         int failure;                            //true if movement failed all together
00077         int type;                                       //failure or blocked type
00078         int blocked;                            //true if blocked by an entity
00079         int blockentity;                        //entity blocking the bot
00080         int traveltype;                         //last executed travel type
00081         int flags;                                      //result flags
00082         int weapon;                                     //weapon used for movement
00083         vec3_t movedir;                         //movement direction
00084         vec3_t ideal_viewangles;        //ideal viewangles for the movement
00085 } bot_moveresult_t;
00086 
00087 // bk001204: from code/botlib/be_ai_move.c
00088 // TTimo 04/12/2001 was moved here to avoid dup defines
00089 typedef struct bot_avoidspot_s
00090 {
00091         vec3_t origin;
00092         float radius;
00093         int type;
00094 } bot_avoidspot_t;
00095 
00096 //resets the whole move state
00097 void BotResetMoveState(int movestate);
00098 //moves the bot to the given goal
00099 void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags);
00100 //moves the bot in the specified direction using the specified type of movement
00101 int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
00102 //reset avoid reachability
00103 void BotResetAvoidReach(int movestate);
00104 //resets the last avoid reachability
00105 void BotResetLastAvoidReach(int movestate);
00106 //returns a reachability area if the origin is in one
00107 int BotReachabilityArea(vec3_t origin, int client);
00108 //view target based on movement
00109 int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);
00110 //predict the position of a player based on movement towards a goal
00111 int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target);
00112 //returns the handle of a newly allocated movestate
00113 int BotAllocMoveState(void);
00114 //frees the movestate with the given handle
00115 void BotFreeMoveState(int handle);
00116 //initialize movement state before performing any movement
00117 void BotInitMoveState(int handle, bot_initmove_t *initmove);
00118 //add a spot to avoid (if type == AVOID_CLEAR all spots are removed)
00119 void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
00120 //must be called every map change
00121 void BotSetBrushModelTypes(void);
00122 //setup movement AI
00123 int BotSetupMoveAI(void);
00124 //shutdown movement AI
00125 void BotShutdownMoveAI(void);
00126