forked from Bots-United/jk_botti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.h
379 lines (293 loc) · 8.14 KB
/
bot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
//
// JK_Botti - be more human!
//
// bot.h
//
#ifndef BOT_H
#define BOT_H
#include <ctype.h>
#include "safe_snprintf.h"
// Manual branch optimization for GCC 3.0.0 and newer
#if !defined(__GNUC__) || __GNUC__ < 3
#define likely(x) (x)
#define unlikely(x) (x)
#else
#define likely(x) __builtin_expect((long int)!!(x), true)
#define unlikely(x) __builtin_expect((long int)!!(x), false)
#endif
//
#define JKASSERT(_x_) \
do { if (unlikely(!!(_x_))) UTIL_AssertConsolePrintf(#_x_, __FILE__, __LINE__); } while(0)
// stuff for Win32 vs. Linux builds
#ifdef __linux__
#define Sleep sleep
#define stricmp strcasecmp
#define strcmpi strcasecmp
#define strnicmp strncasecmp
typedef int BOOL;
#endif
// for detecting submods
#define SUBMOD_HLDM 0
#define SUBMOD_SEVS 1
#define SUBMOD_BUBBLEMOD 2
#define SUBMOD_XDM 3
#define SUBMOD_OP4 4
// global defines
#define PLAYER_SEARCH_RADIUS (64 - 4.0)
// define a new bit flag for bot identification
#define FL_THIRDPARTYBOT (1 << 27)
// teamplay_gamerules.h
#define MAX_TEAMNAME_LENGTH 16
#define MAX_TEAMS 32
#define TEAMPLAY_TEAMLISTLENGTH (MAX_TEAMS*MAX_TEAMNAME_LENGTH)
#define LADDER_UNKNOWN 0
#define LADDER_UP 1
#define LADDER_DOWN 2
#define WANDER_LEFT 1
#define WANDER_RIGHT 2
#define RESPAWN_IDLE 1
#define RESPAWN_NEED_TO_RESPAWN 2
#define RESPAWN_IS_RESPAWNING 3
// waypoint goal types
#define WPT_GOAL_NONE 0
#define WPT_GOAL_HEALTH 1
#define WPT_GOAL_ARMOR 2
#define WPT_GOAL_WEAPON 3
#define WPT_GOAL_AMMO 4
#define WPT_GOAL_ITEM 5
#define WPT_GOAL_LOCATION 8
#define WPT_GOAL_TRACK_SOUND 9
#define WPT_GOAL_ENEMY 10
// instant damage (from cbase.h)
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far
#define DMG_SHOCK (1 << 8) // electric shock
#define DMG_DROWN (1 << 14) // Drowning
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define BOT_SKIN_LEN MAX_TEAMNAME_LENGTH
#define BOT_NAME_LEN 32
#define MAX_BOT_CHAT 100
typedef struct
{
int index;
char * skin;
char * name;
int skill;
int top_color;
int bottom_color;
} cfg_bot_record_t;
typedef struct breakable_list_s
{
qboolean inuse;
struct breakable_list_s * next;
qboolean material_breakable;
edict_t *pEdict;
} breakable_list_t;
typedef struct
{
int iId; // weapon ID
int iClip; // amount of ammo in the clip
int iAmmo1; // amount of ammo in primary reserve
int iAmmo2; // amount of ammo in secondary reserve
} bot_current_weapon_t;
typedef struct
{
qboolean is_used;
int userid;
int cfg_bot_index;
edict_t *pEdict;
qboolean need_to_initialize;
char name[BOT_NAME_LEN];
char skin[BOT_SKIN_LEN];
int bot_skill;
int weapon_skill;
float f_recoil;
float f_kick_time;
float f_create_time;
float f_frame_time;
float f_bot_spawn_time;
int chat_percent;
int taunt_percent;
int whine_percent;
int endgame_percent;
int chat_tag_percent;
int chat_drop_percent;
int chat_swap_percent;
int chat_lower_percent;
double connect_time;
double stay_time;
qboolean b_on_ground;
qboolean b_on_ladder;
qboolean b_in_water;
qboolean b_ducking;
qboolean b_has_enough_ammo_for_good_weapon;
qboolean b_low_health;
int eagle_secondary_state;
// things from pev in CBasePlayer...
float idle_angle;
float idle_angle_time;
float blinded_time;
float bot_think_time;
float f_last_think_time;
float msecdel;
float msecval;
float f_max_speed;
float f_prev_speed;
float f_speed_check_time;
Vector v_prev_origin;
float f_find_item;
edict_t *pBotPickupItem;
int ladder_dir;
float f_start_use_ladder_time;
float f_end_use_ladder_time;
qboolean waypoint_top_of_ladder;
float f_wall_check_time;
float f_wall_on_right;
float f_wall_on_left;
float f_dont_avoid_wall_time;
float f_look_for_waypoint_time;
float f_jump_time;
float f_drop_check_time;
int wander_dir;
qboolean b_not_maxspeed;
float f_move_direction;
float f_strafe_direction; // 0 = none, negative = left, positive = right
float f_strafe_time;
float f_exit_water_time;
Vector waypoint_origin;
float f_waypoint_time;
int curr_waypoint_index;
int prev_waypoint_index[5];
float f_random_waypoint_time;
int waypoint_goal;
float f_waypoint_goal_time;
float prev_waypoint_distance;
int wpt_goal_type;
edict_t *pTrackSoundEdict; // used when wpt_goal_type == WPT_GOAL_TRACK_SOUND
float f_track_sound_time; // how long we track sound?
#define EXCLUDE_POINTS_COUNT 10
int exclude_points[EXCLUDE_POINTS_COUNT+1]; // ten item locations + 1 null
float f_last_item_found;
edict_t *pBotEnemy;
float f_bot_see_enemy_time;
Vector v_bot_see_enemy_origin;
float f_next_find_visible_sound_enemy_time;
float f_last_time_attacked;
edict_t *killer_edict;
qboolean b_bot_say;
float f_bot_say;
char bot_say_msg[256];
float f_bot_chat_time;
qboolean b_bot_endgame;
float f_duck_time;
float f_random_jump_time;
float f_random_jump_duck_time;
float f_random_jump_duck_end;
float f_random_duck_time;
int prev_random_type;
qboolean b_longjump;
float f_combat_longjump;
qboolean b_combat_longjump;
float f_longjump_time;
qboolean b_longjump_do_jump;
float f_sniper_aim_time;
float f_shoot_time;
float f_primary_charging;
float f_secondary_charging;
int charging_weapon_id;
float f_grenade_search_time;
float f_grenade_found_time;
int current_weapon_index;
float current_opt_distance;
float f_move_speed;
float f_pause_time;
float f_pause_look_time;
float f_sound_update_time;
qboolean b_see_tripmine;
qboolean b_shoot_tripmine;
Vector v_tripmine;
edict_t *tripmine_edict;
qboolean b_use_health_station;
float f_use_health_time;
qboolean b_use_HEV_station;
float f_use_HEV_time;
qboolean b_use_button;
float f_use_button_time;
qboolean b_lift_moving;
Vector v_use_target;
int logo_percent;
qboolean b_spray_logo;
float f_spray_logo_time;
char logo_name[16];
int top_color;
int bottom_color;
float f_reaction_target_time; // time when enemy targeting starts
float f_weaponchange_time;
float f_current_hearing_sensitivity;
qboolean b_set_special_shoot_angle;
float f_special_shoot_angle;
bot_current_weapon_t current_weapon; // one current weapon for each bot
int m_rgAmmo[MAX_AMMO_SLOTS]; // total ammo amounts (1 array for each bot)
// for counting msec effency
float total_frame_time;
float total_msecval;
int total_counter;
} bot_t;
#define MAX_TEAMS 32
#define MAX_TEAMNAME_LENGTH 16
#define MAX_FLAGS 5
typedef struct {
edict_t *edict;
int team_no;
} FLAG_S;
#define MAX_BACKPACKS 100
typedef struct {
edict_t *edict;
int armor; // 0=none
int health; // 0=none
int ammo; // 0=none
int team; // 0=all, 1=Blue, 2=Red, 3=Yellow, 4=Green
} BACKPACK_S;
#define MAX_SKINS 200
typedef struct
{
qboolean skin_used;
char model_name[32];
char bot_name[32];
} skin_t;
typedef struct
{
qboolean can_modify;
char text[81];
} bot_chat_t;
typedef struct
{
char identification[4]; // should be WAD2 (or 2DAW) or WAD3 (or 3DAW)
int numlumps;
int infotableofs;
} wadinfo_t;
typedef struct
{
int filepos;
int disksize;
int size; // uncompressed
char type;
char compression;
char pad1, pad2;
char name[16]; // must be null terminated
} lumpinfo_t;
extern bot_t bots[32];
extern int submod_id;
extern int m_spriteTexture;
//void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
#include "util.h"
#include "bot_func.h"
#include "bot_inline_funcs.h"
#endif // BOT_H