Debian Codegraph @

code/game/ai_main.h

raw
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: ai_main.h
26 *
27 * desc: Quake3 bot AI
28 *
29 * $Archive: /source/code/botai/ai_chat.c $
30 *
31 *****************************************************************************/
32
33 //#define DEBUG
34 #define CTF
35
36 #define MAX_ITEMS 256
37 //bot flags
38 #define BFL_STRAFERIGHT 1 //strafe to the right
39 #define BFL_ATTACKED 2 //bot has attacked last ai frame
40 #define BFL_ATTACKJUMPED 4 //bot jumped during attack last frame
41 #define BFL_AIMATENEMY 8 //bot aimed at the enemy this frame
42 #define BFL_AVOIDRIGHT 16 //avoid obstacles by going to the right
43 #define BFL_IDEALVIEWSET 32 //bot has ideal view angles set
44 #define BFL_FIGHTSUICIDAL 64 //bot is in a suicidal fight
45 //long term goal types
46 #define LTG_TEAMHELP 1 //help a team mate
47 #define LTG_TEAMACCOMPANY 2 //accompany a team mate
48 #define LTG_DEFENDKEYAREA 3 //defend a key area
49 #define LTG_GETFLAG 4 //get the enemy flag
50 #define LTG_RUSHBASE 5 //rush to the base
51 #define LTG_RETURNFLAG 6 //return the flag
52 #define LTG_CAMP 7 //camp somewhere
53 #define LTG_CAMPORDER 8 //ordered to camp somewhere
54 #define LTG_PATROL 9 //patrol
55 #define LTG_GETITEM 10 //get an item
56 #define LTG_KILL 11 //kill someone
57 #define LTG_HARVEST 12 //harvest skulls
58 #define LTG_ATTACKENEMYBASE 13 //attack the enemy base
59 #define LTG_MAKELOVE_UNDER 14
60 #define LTG_MAKELOVE_ONTOP 15
61 //Long term DD goals
62 #define LTG_POINTA 16 //Take/Defend point A
63 #define LTG_POINTB 17 //Take/Defend point B
64 //Long term DD goals
65 #define LTG_DOMROAM 18 //Go for a non taken point.
66 #define LTG_DOMHOLD 19 //Pick a point and hold it.
67 //some goal dedication times
68 #define TEAM_HELP_TIME 60 //1 minute teamplay help time
69 #define TEAM_ACCOMPANY_TIME 600 //10 minutes teamplay accompany time
70 #define TEAM_DEFENDKEYAREA_TIME 600 //10 minutes ctf defend base time
71 #define TEAM_CAMP_TIME 600 //10 minutes camping time
72 #define TEAM_PATROL_TIME 600 //10 minutes patrolling time
73 #define TEAM_LEAD_TIME 600 //10 minutes taking the lead
74 #define TEAM_GETITEM_TIME 60 //1 minute
75 #define TEAM_KILL_SOMEONE 180 //3 minute to kill someone
76 #define TEAM_ATTACKENEMYBASE_TIME 600 //10 minutes
77 #define TEAM_HARVEST_TIME 120 //2 minutes
78 #define CTF_GETFLAG_TIME 600 //10 minutes ctf get flag time
79 #define CTF_RUSHBASE_TIME 120 //2 minutes ctf rush base time
80 #define CTF_RETURNFLAG_TIME 180 //3 minutes to return the flag
81 #define CTF_ROAM_TIME 60 //1 minute ctf roam time
82 //Time for Double Domination tasks
83 #define DD_POINTA 600
84 #define DD_POINTB 600
85 //patrol flags
86 #define PATROL_LOOP 1
87 #define PATROL_REVERSE 2
88 #define PATROL_BACK 4
89 //teamplay task preference
90 #define TEAMTP_DEFENDER 1
91 #define TEAMTP_ATTACKER 2
92 //CTF strategy
93 #define CTFS_AGRESSIVE 1
94 //copied from the aas file header
95 #define PRESENCE_NONE 1
96 #define PRESENCE_NORMAL 2
97 #define PRESENCE_CROUCH 4
98 //
99 #define MAX_PROXMINES 64
100
101 //check points
102 typedef struct bot_waypoint_s
103 {
104 int inuse;
105 char name[32];
106 bot_goal_t goal;
107 struct bot_waypoint_s *next, *prev;
108 } bot_waypoint_t;
109
110 #define MAX_ACTIVATESTACK 8
111 #define MAX_ACTIVATEAREAS 32
112
113 typedef struct bot_activategoal_s
114 {
115 int inuse;
116 bot_goal_t goal; //goal to activate (buttons etc.)
117 float time; //time to activate something
118 float start_time; //time starting to activate something
119 float justused_time; //time the goal was used
120 int shoot; //true if bot has to shoot to activate
121 int weapon; //weapon to be used for activation
122 vec3_t target; //target to shoot at to activate something
123 vec3_t origin; //origin of the blocking entity to activate
124 int areas[MAX_ACTIVATEAREAS]; //routing areas disabled by blocking entity
125 int numareas; //number of disabled routing areas
126 int areasdisabled; //true if the areas are disabled for the routing
127 struct bot_activategoal_s *next; //next activate goal on stack
128 } bot_activategoal_t;
129
130 //bot state
131 typedef struct bot_state_s
132 {
133 int inuse; //true if this state is used by a bot client
134 int botthink_residual; //residual for the bot thinks
135 int client; //client number of the bot
136 int entitynum; //entity number of the bot
137 playerState_t cur_ps; //current player state
138 int last_eFlags; //last ps flags
139 usercmd_t lastucmd; //usercmd from last frame
140 int entityeventTime[1024]; //last entity event time
141 //
142 bot_settings_t settings; //several bot settings
143 int (*ainode)(struct bot_state_s *bs); //current AI node
144 float thinktime; //time the bot thinks this frame
145 vec3_t origin; //origin of the bot
146 vec3_t velocity; //velocity of the bot
147 int presencetype; //presence type of the bot
148 vec3_t eye; //eye coordinates of the bot
149 int areanum; //the number of the area the bot is in
150 int inventory[MAX_ITEMS]; //string with items amounts the bot has
151 int tfl; //the travel flags the bot uses
152 int flags; //several flags
153 int respawn_wait; //wait until respawned
154 int lasthealth; //health value previous frame
155 int lastkilledplayer; //last killed player
156 int lastkilledby; //player that last killed this bot
157 int botdeathtype; //the death type of the bot
158 int enemydeathtype; //the death type of the enemy
159 int botsuicide; //true when the bot suicides
160 int enemysuicide; //true when the enemy of the bot suicides
161 int setupcount; //true when the bot has just been setup
162 int map_restart; //true when the map is being restarted
163 int entergamechat; //true when the bot used an enter game chat
164 int num_deaths; //number of time this bot died
165 int num_kills; //number of kills of this bot
166 int revenge_enemy; //the revenge enemy
167 int revenge_kills; //number of kills the enemy made
168 int lastframe_health; //health value the last frame
169 int lasthitcount; //number of hits last frame
170 int chatto; //chat to all or team
171 float walker; //walker charactertic
172 float ltime; //local bot time
173 float entergame_time; //time the bot entered the game
174 float ltg_time; //long term goal time
175 float nbg_time; //nearby goal time
176 float respawn_time; //time the bot takes to respawn
177 float respawnchat_time; //time the bot started a chat during respawn
178 float chase_time; //time the bot will chase the enemy
179 float enemyvisible_time; //time the enemy was last visible
180 float check_time; //time to check for nearby items
181 float stand_time; //time the bot is standing still
182 float lastchat_time; //time the bot last selected a chat
183 float kamikaze_time; //time to check for kamikaze usage
184 float invulnerability_time; //time to check for invulnerability usage
185 float standfindenemy_time; //time to find enemy while standing
186 float attackstrafe_time; //time the bot is strafing in one dir
187 float attackcrouch_time; //time the bot will stop crouching
188 float attackchase_time; //time the bot chases during actual attack
189 float attackjump_time; //time the bot jumped during attack
190 float enemysight_time; //time before reacting to enemy
191 float enemydeath_time; //time the enemy died
192 float enemyposition_time; //time the position and velocity of the enemy were stored
193 float defendaway_time; //time away while defending
194 float defendaway_range; //max travel time away from defend area
195 float rushbaseaway_time; //time away from rushing to the base
196 float attackaway_time; //time away from attacking the enemy base
197 float harvestaway_time; //time away from harvesting
198 float ctfroam_time; //time the bot is roaming in ctf
199 float killedenemy_time; //time the bot killed the enemy
200 float arrive_time; //time arrived (at companion)
201 float lastair_time; //last time the bot had air
202 float teleport_time; //last time the bot teleported
203 float camp_time; //last time camped
204 float camp_range; //camp range
205 float weaponchange_time; //time the bot started changing weapons
206 float firethrottlewait_time; //amount of time to wait
207 float firethrottleshoot_time; //amount of time to shoot
208 float notblocked_time; //last time the bot was not blocked
209 float blockedbyavoidspot_time; //time blocked by an avoid spot
210 float predictobstacles_time; //last time the bot predicted obstacles
211 int predictobstacles_goalareanum; //last goal areanum the bot predicted obstacles for
212 vec3_t aimtarget;
213 vec3_t enemyvelocity; //enemy velocity 0.5 secs ago during battle
214 vec3_t enemyorigin; //enemy origin 0.5 secs ago during battle
215 //
216 int kamikazebody; //kamikaze body
217 int proxmines[MAX_PROXMINES];
218 int numproxmines;
219 //
220 int character; //the bot character
221 int ms; //move state of the bot
222 int gs; //goal state of the bot
223 int cs; //chat state of the bot
224 int ws; //weapon state of the bot
225 //
226 int enemy; //enemy entity number
227 int lastenemyareanum; //last reachability area the enemy was in
228 vec3_t lastenemyorigin; //last origin of the enemy in the reachability area
229 int weaponnum; //current weapon number
230 vec3_t viewangles; //current view angles
231 vec3_t ideal_viewangles; //ideal view angles
232 vec3_t viewanglespeed;
233 //
234 int ltgtype; //long term goal type
235 // team goals
236 int teammate; //team mate involved in this team goal
237 int decisionmaker; //player who decided to go for this goal
238 int ordered; //true if ordered to do something
239 float order_time; //time ordered to do something
240 int owndecision_time; //time the bot made it's own decision
241 bot_goal_t teamgoal; //the team goal
242 bot_goal_t altroutegoal; //alternative route goal
243 float reachedaltroutegoal_time; //time the bot reached the alt route goal
244 float teammessage_time; //time to message team mates what the bot is doing
245 float teamgoal_time; //time to stop helping team mate
246 float teammatevisible_time; //last time the team mate was NOT visible
247 int teamtaskpreference; //team task preference
248 // last ordered team goal
249 int lastgoal_decisionmaker;
250 int lastgoal_ltgtype;
251 int lastgoal_teammate;
252 bot_goal_t lastgoal_teamgoal;
253 // for leading team mates
254 int lead_teammate; //team mate the bot is leading
255 bot_goal_t lead_teamgoal; //team goal while leading
256 float lead_time; //time leading someone
257 float leadvisible_time; //last time the team mate was visible
258 float leadmessage_time; //last time a messaged was sent to the team mate
259 float leadbackup_time; //time backing up towards team mate
260 //
261 char teamleader[32]; //netname of the team leader
262 float askteamleader_time; //time asked for team leader
263 float becometeamleader_time; //time the bot will become the team leader
264 float teamgiveorders_time; //time to give team orders
265 float lastflagcapture_time; //last time a flag was captured
266 int numteammates; //number of team mates
267 int redflagstatus; //0 = at base, 1 = not at base
268 int blueflagstatus; //0 = at base, 1 = not at base
269 int neutralflagstatus; //0 = at base, 1 = our team has flag, 2 = enemy team has flag, 3 = enemy team dropped the flag
270 int flagstatuschanged; //flag status changed
271 int forceorders; //true if forced to give orders
272 int flagcarrier; //team mate carrying the enemy flag
273 int ctfstrategy; //ctf strategy
274 char subteam[32]; //sub team name
275 float formation_dist; //formation team mate intervening space
276 char formation_teammate[16]; //netname of the team mate the bot uses for relative positioning
277 float formation_angle; //angle relative to the formation team mate
278 vec3_t formation_dir; //the direction the formation is moving in
279 vec3_t formation_origin; //origin the bot uses for relative positioning
280 bot_goal_t formation_goal; //formation goal
281
282 bot_activategoal_t *activatestack; //first activate goal on the stack
283 bot_activategoal_t activategoalheap[MAX_ACTIVATESTACK]; //activate goal heap
284
285 bot_waypoint_t *checkpoints; //check points
286 bot_waypoint_t *patrolpoints; //patrol points
287 bot_waypoint_t *curpatrolpoint; //current patrol point the bot is going for
288 int patrolflags; //patrol flags
289 } bot_state_t;
290
291 //resets the whole bot state
292 void BotResetState(bot_state_t *bs);
293 //returns the number of bots in the game
294 int NumBots(void);
295 //returns info about the entity
296 void BotEntityInfo(int entnum, aas_entityinfo_t *info);
297
298 extern float floattime;
299 #define FloatTime() floattime
300
301 // from the game source
302 void QDECL BotAI_Print(int type, char *fmt, ...);
303 void QDECL QDECL BotAI_BotInitialChat( bot_state_t *bs, char *type, ... );
304 void BotAI_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);
305 int BotAI_GetClientState( int clientNum, playerState_t *state );
306 int BotAI_GetEntityState( int entityNum, entityState_t *state );
307 int BotAI_GetSnapshotEntity( int clientNum, int sequence, entityState_t *state );
308 int BotTeamLeader(bot_state_t *bs);