1 ///////////////////////////////////////////////////////////////////////
2 //
3 //  ACE - Quake II Bot Base Code
4 //
5 //  Version 1.0
6 //
7 //  This file is Copyright(c), Steve Yeager 1998, All Rights Reserved
8 //
9 //
10 //	All other files are Copyright(c) Id Software, Inc.
11 //
12 //	Please see liscense.txt in the source directory for the copyright
13 //	information regarding those files belonging to Id Software, Inc.
14 //
15 //	Should you decide to release a modified version of ACE, you MUST
16 //	include the following text (minus the BEGIN and END lines) in the
17 //	documentation for your modification.
18 //
19 //	--- BEGIN ---
20 //
21 //	The ACE Bot is a product of Steve Yeager, and is available from
22 //	the ACE Bot homepage, at http://www.axionfx.com/ace.
23 //
24 //	This program is a modification of the ACE Bot, and is therefore
25 //	in NO WAY supported by Steve Yeager.
26 
27 //	This program MUST NOT be sold in ANY form. If you have paid for
28 //	this product, you should contact Steve Yeager immediately, via
29 //	the ACE Bot homepage.
30 //
31 //	--- END ---
32 //
33 //	I, Steve Yeager, hold no responsibility for any harm caused by the
34 //	use of this source code, especially to small children and animals.
35 //  It is provided as-is with no implied warranty or support.
36 //
37 //  I also wish to thank and acknowledge the great work of others
38 //  that has helped me to develop this code.
39 //
40 //  John Cricket    - For ideas and swapping code.
41 //  Ryan Feltrin    - For ideas and swapping code.
42 //  SABIN           - For showing how to do true client based movement.
43 //  BotEpidemic     - For keeping us up to date.
44 //  Telefragged.com - For giving ACE a home.
45 //  Microsoft       - For giving us such a wonderful crash free OS.
46 //  id              - Need I say more.
47 //
48 //  And to all the other testers, pathers, and players and people
49 //  who I can't remember who the heck they were, but helped out.
50 //
51 ///////////////////////////////////////////////////////////////////////
52 
53 ///////////////////////////////////////////////////////////////////////
54 //
55 //  acebot.h - Main header file for ACEBOT
56 //
57 //
58 ///////////////////////////////////////////////////////////////////////
59 
60 #ifndef _ACEBOT_H
61 #define _ACEBOT_H
62 
63 #if !defined BOT_GAMEDATA
64 #define BOT_GAMEDATA "botinfo"
65 #endif
66 
67 // Only 100 allowed for now (probably never be enough edicts for 'em
68 #define MAX_BOTS 100
69 
70 // Platform states
71 #define	STATE_TOP			0
72 #define	STATE_BOTTOM		1
73 #define STATE_UP			2
74 #define STATE_DOWN			3
75 
76 // Maximum nodes
77 #define MAX_NODES 1000
78 
79 // Link types
80 #define INVALID -1
81 
82 // Node types
83 #define NODE_MOVE 0
84 #define NODE_LADDER 1
85 #define NODE_PLATFORM 2
86 #define NODE_TELEPORTER 3
87 #define NODE_ITEM 4
88 #define NODE_WATER 5
89 #define NODE_GRAPPLE 6
90 #define NODE_JUMP 7
91 #define NODE_REDBASE 8
92 #define NODE_BLUEBASE 9
93 #define NODE_DEFEND 10
94 #define NODE_ALL 99 // For selecting all nodes
95 
96 // Density setting for nodes
97 #define NODE_DENSITY 256
98 
99 // Bot state types
100 #define STATE_STAND 0
101 #define STATE_MOVE 1
102 #define STATE_ATTACK 2
103 #define STATE_WANDER 3
104 #define STATE_FLEE 4
105 
106 #define MOVE_LEFT 0
107 #define MOVE_RIGHT 1
108 #define MOVE_FORWARD 2
109 #define MOVE_BACK 3
110 
111 // Item defines (got this list from somewhere??....so thanks to whoever created it)
112 #define ITEMLIST_NULLINDEX			0
113 #define ITEMLIST_BODYARMOR			1
114 #define ITEMLIST_COMBATARMOR		2
115 #define ITEMLIST_JACKETARMOR		3
116 #define ITEMLIST_ARMORSHARD			4
117 
118 #define ITEMLIST_GRAPPLE            7
119 
120 #define ITEMLIST_BLASTER			8
121 #define ITEMLIST_SHOTGUN			9
122 #define ITEMLIST_SUPERSHOTGUN		10
123 #define ITEMLIST_CHAINGUN			11
124 #define ITEMLIST_GRENADES			12
125 #define ITEMLIST_ROCKETLAUNCHER		13
126 #define ITEMLIST_HYPERBLASTER		14
127 #define ITEMLIST_RAILGUN			15
128 #define ITEMLIST_BFG10K				16
129 
130 #define ITEMLIST_SHELLS				17
131 #define ITEMLIST_BULLETS			18
132 #define ITEMLIST_CELLS				19
133 #define ITEMLIST_ROCKETS			20
134 #define ITEMLIST_SLUGS				21
135 #define ITEMLIST_QUADDAMAGE			22
136 #define ITEMLIST_INVULNERABILITY	23
137 #define ITEMLIST_ADRENALINE			24
138 #define ITEMLIST_HEALTH				25
139 
140 // new for ctf
141 #define ITEMLIST_FLAG1              26
142 #define ITEMLIST_FLAG2              27
143 #define ITEMLIST_HASTE				28
144 #define ITEMLIST_SPROING			29
145 
146 // my additions
147 #define ITEMLIST_HEALTH_SMALL		30
148 #define ITEMLIST_HEALTH_MEDIUM		31
149 #define ITEMLIST_HEALTH_LARGE		32
150 #define ITEMLIST_BOT				33
151 #define ITEMLIST_PLAYER				34
152 #define ITEMLIST_HEALTH_MEGA        35
153 
154 //vehicles
155 #define ITEMLIST_BOMBER				36
156 #define ITEMLIST_STRAFER			37
157 #define ITEMLIST_DEATHBALL			38
158 #define ITEMLIST_HOVER				39
159 
160 //mind eraser
161 #define ITEMLIST_MINDERASER			40
162 
163 // Special CONTENT mask for acebots, so they can detect and climb ladders
164 // replaces MASK_OPAQUE defined in game/q_shared.h
165 #define BOTMASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA|CONTENTS_LADDER)
166 
167 // Node structure
168 typedef struct node_s
169 {
170 	vec3_t origin; // Using Id's representation
171 	int type;   // type of node
172 
173 } node_t;
174 
175 typedef struct item_table_s
176 {
177 	int item;
178 	float weight;
179 	edict_t *ent;
180 	int node;
181 
182 } item_table_t;
183 
184 // Bot config structure
185 struct botvals_s
186 {
187 	int skill;
188 	char faveweap[64];
189 	float weapacc[10];
190 	float awareness;
191 	char		chatmsg1[128];
192 	char		chatmsg2[128];
193 	char		chatmsg3[128];
194 	char		chatmsg4[128];
195 	char		chatmsg5[128];
196 	char		chatmsg6[128];
197 	char		chatmsg7[128];
198 	char		chatmsg8[128];
199 } botvals;
200 
201 extern edict_t *players[MAX_CLIENTS];		// pointers to all players in the game
202 
203 // extern decs
204 edict_t *node_showents[MAX_NODES]; //ents created by shownode
205 extern node_t nodes[MAX_NODES];
206 extern item_table_t item_table[MAX_EDICTS];
207 extern qboolean debug_mode;
208 extern int bot_numnodes;
209 extern int num_items;
210 extern int num_bots;
211 
212 // id Function Protos I need
213 void     LookAtKiller (edict_t *self, edict_t *inflictor, edict_t *attacker);
214 void     ClientObituary (edict_t *self, edict_t *inflictor, edict_t *attacker);
215 void     TossClientWeapon (edict_t *self);
216 void     ClientThink (edict_t *ent, usercmd_t *ucmd);
217 void     SelectSpawnPoint (edict_t *ent, vec3_t origin, vec3_t angles);
218 void     ClientUserinfoChanged (edict_t *ent, char *userinfo, int whereFrom);
219 void     CopyToBodyQue (edict_t *ent);
220 
221 qboolean ClientConnect (edict_t *ent, char *userinfo);
222 
223 void     Use_Plat (edict_t *ent, edict_t *other, edict_t *activator);
224 
225 // acebot_ai.c protos
226 void     ACEAI_Think (edict_t *self);
227 void     ACEAI_PickLongRangeGoal(edict_t *self);
228 void     ACEAI_PickShortRangeGoal(edict_t *self);
229 qboolean ACEAI_FindEnemy(edict_t *self);
230 void     ACEAI_ChooseWeapon(edict_t *self);
231 qboolean ACEAI_CheckShot(edict_t *self);
232 
233 // acebot_cmds.c protos
234 qboolean ACECM_Commands(edict_t *ent);
235 void     ACECM_Store();
236 
237 // acebot_items.c protos
238 qboolean ACEIT_IsVisible(edict_t *self, vec3_t goal);
239 qboolean ACEIT_IsReachable(edict_t *self,vec3_t goal);
240 qboolean ACEIT_ChangeWeapon (edict_t *ent, gitem_t *item);
241 qboolean ACEIT_CanUseArmor (gitem_t *item, edict_t *other);
242 float	 ACEIT_ItemNeed(edict_t *self, int item);
243 int		 ACEIT_ClassnameToIndex(char *classname);
244 void     ACEIT_BuildItemNodeTable (qboolean rebuild);
245 
246 // acebot_movement.c protos
247 qboolean ACEMV_SpecialMove(edict_t *self,usercmd_t *ucmd);
248 void     ACEMV_Move(edict_t *self, usercmd_t *ucmd);
249 void     ACEMV_Attack (edict_t *self, usercmd_t *ucmd);
250 void     ACEMV_Wander (edict_t *self, usercmd_t *ucmd);
251 
252 // acebot_nodes.c protos
253 int      ACEND_FindCost(int from, int to);
254 int      ACEND_FindCloseReachableNode(edict_t *self, int dist, int type);
255 int      ACEND_FindClosestReachableNode(edict_t *self, int range, int type);
256 void     ACEND_SetGoal(edict_t *self, int goal_node);
257 qboolean ACEND_FollowPath(edict_t *self);
258 void     ACEND_GrapFired(edict_t *self);
259 qboolean ACEND_CheckForLadder(edict_t *self);
260 void     ACEND_PathMap(edict_t *self);
261 void     ACEND_InitNodes(void);
262 void     ACEND_ShowNode(int node);
263 void     ACEND_DrawPath();
264 void     ACEND_ShowPath(edict_t *self, int goal_node);
265 int      ACEND_AddNode(edict_t *self, int type);
266 void     ACEND_UpdateNodeEdge(int from, int to);
267 void     ACEND_RemoveNodeEdge(edict_t *self, int from, int to);
268 void     ACEND_ResolveAllPaths();
269 void     ACEND_SaveNodes();
270 void     ACEND_LoadNodes();
271 
272 // acebot_spawn.c protos
273 void     ACESP_UpdateBots(void);
274 void	 ACESP_SaveBots();
275 void	 ACESP_LoadBots(edict_t *ent);
276 int		 ACESP_FindBotNum(void);
277 edict_t *ACESP_FindBot(const char *name);
278 void	 ACESP_KickBot(edict_t *bot);
279 void     ACESP_HoldSpawn(edict_t *self);
280 void     ACESP_PutClientInServer (edict_t *bot, qboolean respawn);
281 void     ACESP_Respawn (edict_t *self);
282 edict_t *ACESP_FindFreeClient (void);
283 void     ACESP_SetName(edict_t *bot, char *name, char *skin, char *userinfo );
284 qboolean ACESP_SpawnBot (char *name, char *skin, char *userinfo);
285 void     ACESP_ReAddBots();
286 void     ACESP_RemoveBot(char *name);
287 void	 safe_cprintf (edict_t *ent, int printlevel, char *fmt, ...);
288 void     safe_centerprintf (edict_t *ent, char *fmt, ...);
289 void     safe_bprintf (int printlevel, char *fmt, ...);
290 void     debug_printf (char *fmt, ...);
291 #endif
292