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