00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #define BOTLIB_API_VERSION 2
00033
00034 struct aas_clientmove_s;
00035 struct aas_entityinfo_s;
00036 struct aas_areainfo_s;
00037 struct aas_altroutegoal_s;
00038 struct aas_predictroute_s;
00039 struct bot_consolemessage_s;
00040 struct bot_match_s;
00041 struct bot_goal_s;
00042 struct bot_moveresult_s;
00043 struct bot_initmove_s;
00044 struct weaponinfo_s;
00045
00046 #define BOTFILESBASEFOLDER "botfiles"
00047
00048 #define LINECOLOR_NONE -1
00049 #define LINECOLOR_RED 1//0xf2f2f0f0L
00050 #define LINECOLOR_GREEN 2//0xd0d1d2d3L
00051 #define LINECOLOR_BLUE 3//0xf3f3f1f1L
00052 #define LINECOLOR_YELLOW 4//0xdcdddedfL
00053 #define LINECOLOR_ORANGE 5//0xe0e1e2e3L
00054
00055
00056 #define PRT_MESSAGE 1
00057 #define PRT_WARNING 2
00058 #define PRT_ERROR 3
00059 #define PRT_FATAL 4
00060 #define PRT_EXIT 5
00061
00062
00063 #define CMS_NORMAL 0
00064 #define CMS_CHAT 1
00065
00066
00067 #define BLERR_NOERROR 0 //no error
00068 #define BLERR_LIBRARYNOTSETUP 1 //library not setup
00069 #define BLERR_INVALIDENTITYNUMBER 2 //invalid entity number
00070 #define BLERR_NOAASFILE 3 //no AAS file available
00071 #define BLERR_CANNOTOPENAASFILE 4 //cannot open AAS file
00072 #define BLERR_WRONGAASFILEID 5 //incorrect AAS file id
00073 #define BLERR_WRONGAASFILEVERSION 6 //incorrect AAS file version
00074 #define BLERR_CANNOTREADAASLUMP 7 //cannot read AAS file lump
00075 #define BLERR_CANNOTLOADICHAT 8 //cannot load initial chats
00076 #define BLERR_CANNOTLOADITEMWEIGHTS 9 //cannot load item weights
00077 #define BLERR_CANNOTLOADITEMCONFIG 10 //cannot load item config
00078 #define BLERR_CANNOTLOADWEAPONWEIGHTS 11 //cannot load weapon weights
00079 #define BLERR_CANNOTLOADWEAPONCONFIG 12 //cannot load weapon config
00080
00081
00082 #define ACTION_ATTACK 0x0000001
00083 #define ACTION_USE 0x0000002
00084 #define ACTION_RESPAWN 0x0000008
00085 #define ACTION_JUMP 0x0000010
00086 #define ACTION_MOVEUP 0x0000020
00087 #define ACTION_CROUCH 0x0000080
00088 #define ACTION_MOVEDOWN 0x0000100
00089 #define ACTION_MOVEFORWARD 0x0000200
00090 #define ACTION_MOVEBACK 0x0000800
00091 #define ACTION_MOVELEFT 0x0001000
00092 #define ACTION_MOVERIGHT 0x0002000
00093 #define ACTION_DELAYEDJUMP 0x0008000
00094 #define ACTION_TALK 0x0010000
00095 #define ACTION_GESTURE 0x0020000
00096 #define ACTION_WALK 0x0080000
00097 #define ACTION_AFFIRMATIVE 0x0100000
00098 #define ACTION_NEGATIVE 0x0200000
00099 #define ACTION_GETFLAG 0x0800000
00100 #define ACTION_GUARDBASE 0x1000000
00101 #define ACTION_PATROL 0x2000000
00102 #define ACTION_FOLLOWME 0x8000000
00103
00104
00105 typedef struct bot_input_s
00106 {
00107 float thinktime;
00108 vec3_t dir;
00109 float speed;
00110 vec3_t viewangles;
00111 int actionflags;
00112 int weapon;
00113 } bot_input_t;
00114
00115 #ifndef BSPTRACE
00116
00117 #define BSPTRACE
00118
00119
00120 typedef struct bsp_surface_s
00121 {
00122 char name[16];
00123 int flags;
00124 int value;
00125 } bsp_surface_t;
00126
00127
00128
00129 typedef struct bsp_trace_s
00130 {
00131 qboolean allsolid;
00132 qboolean startsolid;
00133 float fraction;
00134 vec3_t endpos;
00135 cplane_t plane;
00136 float exp_dist;
00137 int sidenum;
00138 bsp_surface_t surface;
00139 int contents;
00140 int ent;
00141 } bsp_trace_t;
00142
00143 #endif // BSPTRACE
00144
00145
00146 typedef struct bot_entitystate_s
00147 {
00148 int type;
00149 int flags;
00150 vec3_t origin;
00151 vec3_t angles;
00152 vec3_t old_origin;
00153 vec3_t mins;
00154 vec3_t maxs;
00155 int groundent;
00156 int solid;
00157 int modelindex;
00158 int modelindex2;
00159 int frame;
00160 int event;
00161 int eventParm;
00162 int powerups;
00163 int weapon;
00164 int legsAnim;
00165 int torsoAnim;
00166 } bot_entitystate_t;
00167
00168
00169 typedef struct botlib_import_s
00170 {
00171
00172 void (QDECL *Print)(int type, char *fmt, ...);
00173
00174 void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);
00175
00176 void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask);
00177
00178 int (*PointContents)(vec3_t point);
00179
00180 int (*inPVS)(vec3_t p1, vec3_t p2);
00181
00182 char *(*BSPEntityData)(void);
00183
00184 void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
00185
00186 void (*BotClientCommand)(int client, char *command);
00187
00188 void *(*GetMemory)(int size);
00189 void (*FreeMemory)(void *ptr);
00190 int (*AvailableMemory)(void);
00191 void *(*HunkAlloc)(int size);
00192
00193 int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode );
00194 int (*FS_Read)( void *buffer, int len, fileHandle_t f );
00195 int (*FS_Write)( const void *buffer, int len, fileHandle_t f );
00196 void (*FS_FCloseFile)( fileHandle_t f );
00197 int (*FS_Seek)( fileHandle_t f, long offset, int origin );
00198
00199 int (*DebugLineCreate)(void);
00200 void (*DebugLineDelete)(int line);
00201 void (*DebugLineShow)(int line, vec3_t start, vec3_t end, int color);
00202
00203 int (*DebugPolygonCreate)(int color, int numPoints, vec3_t *points);
00204 void (*DebugPolygonDelete)(int id);
00205 } botlib_import_t;
00206
00207 typedef struct aas_export_s
00208 {
00209
00210
00211
00212 void (*AAS_EntityInfo)(int entnum, struct aas_entityinfo_s *info);
00213
00214
00215
00216 int (*AAS_Initialized)(void);
00217 void (*AAS_PresenceTypeBoundingBox)(int presencetype, vec3_t mins, vec3_t maxs);
00218 float (*AAS_Time)(void);
00219
00220
00221
00222 int (*AAS_PointAreaNum)(vec3_t point);
00223 int (*AAS_PointReachabilityAreaIndex)( vec3_t point );
00224 int (*AAS_TraceAreas)(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
00225 int (*AAS_BBoxAreas)(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
00226 int (*AAS_AreaInfo)( int areanum, struct aas_areainfo_s *info );
00227
00228
00229
00230 int (*AAS_PointContents)(vec3_t point);
00231 int (*AAS_NextBSPEntity)(int ent);
00232 int (*AAS_ValueForBSPEpairKey)(int ent, char *key, char *value, int size);
00233 int (*AAS_VectorForBSPEpairKey)(int ent, char *key, vec3_t v);
00234 int (*AAS_FloatForBSPEpairKey)(int ent, char *key, float *value);
00235 int (*AAS_IntForBSPEpairKey)(int ent, char *key, int *value);
00236
00237
00238
00239 int (*AAS_AreaReachability)(int areanum);
00240
00241
00242
00243 int (*AAS_AreaTravelTimeToGoalArea)(int areanum, vec3_t origin, int goalareanum, int travelflags);
00244 int (*AAS_EnableRoutingArea)(int areanum, int enable);
00245 int (*AAS_PredictRoute)(struct aas_predictroute_s *route, int areanum, vec3_t origin,
00246 int goalareanum, int travelflags, int maxareas, int maxtime,
00247 int stopevent, int stopcontents, int stoptfl, int stopareanum);
00248
00249
00250
00251 int (*AAS_AlternativeRouteGoals)(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
00252 struct aas_altroutegoal_s *altroutegoals, int maxaltroutegoals,
00253 int type);
00254
00255
00256
00257 int (*AAS_Swimming)(vec3_t origin);
00258 int (*AAS_PredictClientMovement)(struct aas_clientmove_s *move,
00259 int entnum, vec3_t origin,
00260 int presencetype, int onground,
00261 vec3_t velocity, vec3_t cmdmove,
00262 int cmdframes,
00263 int maxframes, float frametime,
00264 int stopevent, int stopareanum, int visualize);
00265 } aas_export_t;
00266
00267 typedef struct ea_export_s
00268 {
00269
00270 void (*EA_Command)(int client, char *command );
00271 void (*EA_Say)(int client, char *str);
00272 void (*EA_SayTeam)(int client, char *str);
00273
00274 void (*EA_Action)(int client, int action);
00275 void (*EA_Gesture)(int client);
00276 void (*EA_Talk)(int client);
00277 void (*EA_Attack)(int client);
00278 void (*EA_Use)(int client);
00279 void (*EA_Respawn)(int client);
00280 void (*EA_MoveUp)(int client);
00281 void (*EA_MoveDown)(int client);
00282 void (*EA_MoveForward)(int client);
00283 void (*EA_MoveBack)(int client);
00284 void (*EA_MoveLeft)(int client);
00285 void (*EA_MoveRight)(int client);
00286 void (*EA_Crouch)(int client);
00287
00288 void (*EA_SelectWeapon)(int client, int weapon);
00289 void (*EA_Jump)(int client);
00290 void (*EA_DelayedJump)(int client);
00291 void (*EA_Move)(int client, vec3_t dir, float speed);
00292 void (*EA_View)(int client, vec3_t viewangles);
00293
00294 void (*EA_EndRegular)(int client, float thinktime);
00295 void (*EA_GetInput)(int client, float thinktime, bot_input_t *input);
00296 void (*EA_ResetInput)(int client);
00297 } ea_export_t;
00298
00299 typedef struct ai_export_s
00300 {
00301
00302
00303
00304 int (*BotLoadCharacter)(char *charfile, float skill);
00305 void (*BotFreeCharacter)(int character);
00306 float (*Characteristic_Float)(int character, int index);
00307 float (*Characteristic_BFloat)(int character, int index, float min, float max);
00308 int (*Characteristic_Integer)(int character, int index);
00309 int (*Characteristic_BInteger)(int character, int index, int min, int max);
00310 void (*Characteristic_String)(int character, int index, char *buf, int size);
00311
00312
00313
00314 int (*BotAllocChatState)(void);
00315 void (*BotFreeChatState)(int handle);
00316 void (*BotQueueConsoleMessage)(int chatstate, int type, char *message);
00317 void (*BotRemoveConsoleMessage)(int chatstate, int handle);
00318 int (*BotNextConsoleMessage)(int chatstate, struct bot_consolemessage_s *cm);
00319 int (*BotNumConsoleMessages)(int chatstate);
00320 void (*BotInitialChat)(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
00321 int (*BotNumInitialChats)(int chatstate, char *type);
00322 int (*BotReplyChat)(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
00323 int (*BotChatLength)(int chatstate);
00324 void (*BotEnterChat)(int chatstate, int client, int sendto);
00325 void (*BotGetChatMessage)(int chatstate, char *buf, int size);
00326 int (*StringContains)(char *str1, char *str2, int casesensitive);
00327 int (*BotFindMatch)(char *str, struct bot_match_s *match, unsigned long int context);
00328 void (*BotMatchVariable)(struct bot_match_s *match, int variable, char *buf, int size);
00329 void (*UnifyWhiteSpaces)(char *string);
00330 void (*BotReplaceSynonyms)(char *string, unsigned long int context);
00331 int (*BotLoadChatFile)(int chatstate, char *chatfile, char *chatname);
00332 void (*BotSetChatGender)(int chatstate, int gender);
00333 void (*BotSetChatName)(int chatstate, char *name, int client);
00334
00335
00336
00337 void (*BotResetGoalState)(int goalstate);
00338 void (*BotResetAvoidGoals)(int goalstate);
00339 void (*BotRemoveFromAvoidGoals)(int goalstate, int number);
00340 void (*BotPushGoal)(int goalstate, struct bot_goal_s *goal);
00341 void (*BotPopGoal)(int goalstate);
00342 void (*BotEmptyGoalStack)(int goalstate);
00343 void (*BotDumpAvoidGoals)(int goalstate);
00344 void (*BotDumpGoalStack)(int goalstate);
00345 void (*BotGoalName)(int number, char *name, int size);
00346 int (*BotGetTopGoal)(int goalstate, struct bot_goal_s *goal);
00347 int (*BotGetSecondGoal)(int goalstate, struct bot_goal_s *goal);
00348 int (*BotChooseLTGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags);
00349 int (*BotChooseNBGItem)(int goalstate, vec3_t origin, int *inventory, int travelflags,
00350 struct bot_goal_s *ltg, float maxtime);
00351 int (*BotTouchingGoal)(vec3_t origin, struct bot_goal_s *goal);
00352 int (*BotItemGoalInVisButNotVisible)(int viewer, vec3_t eye, vec3_t viewangles, struct bot_goal_s *goal);
00353 int (*BotGetLevelItemGoal)(int index, char *classname, struct bot_goal_s *goal);
00354 int (*BotGetNextCampSpotGoal)(int num, struct bot_goal_s *goal);
00355 int (*BotGetMapLocationGoal)(char *name, struct bot_goal_s *goal);
00356 float (*BotAvoidGoalTime)(int goalstate, int number);
00357 void (*BotSetAvoidGoalTime)(int goalstate, int number, float avoidtime);
00358 void (*BotInitLevelItems)(void);
00359 void (*BotUpdateEntityItems)(void);
00360 int (*BotLoadItemWeights)(int goalstate, char *filename);
00361 void (*BotFreeItemWeights)(int goalstate);
00362 void (*BotInterbreedGoalFuzzyLogic)(int parent1, int parent2, int child);
00363 void (*BotSaveGoalFuzzyLogic)(int goalstate, char *filename);
00364 void (*BotMutateGoalFuzzyLogic)(int goalstate, float range);
00365 int (*BotAllocGoalState)(int client);
00366 void (*BotFreeGoalState)(int handle);
00367
00368
00369
00370 void (*BotResetMoveState)(int movestate);
00371 void (*BotMoveToGoal)(struct bot_moveresult_s *result, int movestate, struct bot_goal_s *goal, int travelflags);
00372 int (*BotMoveInDirection)(int movestate, vec3_t dir, float speed, int type);
00373 void (*BotResetAvoidReach)(int movestate);
00374 void (*BotResetLastAvoidReach)(int movestate);
00375 int (*BotReachabilityArea)(vec3_t origin, int testground);
00376 int (*BotMovementViewTarget)(int movestate, struct bot_goal_s *goal, int travelflags, float lookahead, vec3_t target);
00377 int (*BotPredictVisiblePosition)(vec3_t origin, int areanum, struct bot_goal_s *goal, int travelflags, vec3_t target);
00378 int (*BotAllocMoveState)(void);
00379 void (*BotFreeMoveState)(int handle);
00380 void (*BotInitMoveState)(int handle, struct bot_initmove_s *initmove);
00381 void (*BotAddAvoidSpot)(int movestate, vec3_t origin, float radius, int type);
00382
00383
00384
00385 int (*BotChooseBestFightWeapon)(int weaponstate, int *inventory);
00386 void (*BotGetWeaponInfo)(int weaponstate, int weapon, struct weaponinfo_s *weaponinfo);
00387 int (*BotLoadWeaponWeights)(int weaponstate, char *filename);
00388 int (*BotAllocWeaponState)(void);
00389 void (*BotFreeWeaponState)(int weaponstate);
00390 void (*BotResetWeaponState)(int weaponstate);
00391
00392
00393
00394 int (*GeneticParentsAndChildSelection)(int numranks, float *ranks, int *parent1, int *parent2, int *child);
00395 } ai_export_t;
00396
00397
00398 typedef struct botlib_export_s
00399 {
00400
00401 aas_export_t aas;
00402
00403 ea_export_t ea;
00404
00405 ai_export_t ai;
00406
00407 int (*BotLibSetup)(void);
00408
00409 int (*BotLibShutdown)(void);
00410
00411 int (*BotLibVarSet)(char *var_name, char *value);
00412
00413 int (*BotLibVarGet)(char *var_name, char *value, int size);
00414
00415
00416 int (*PC_AddGlobalDefine)(char *string);
00417 int (*PC_LoadSourceHandle)(const char *filename);
00418 int (*PC_FreeSourceHandle)(int handle);
00419 int (*PC_ReadTokenHandle)(int handle, pc_token_t *pc_token);
00420 int (*PC_SourceFileAndLine)(int handle, char *filename, int *line);
00421
00422
00423 int (*BotLibStartFrame)(float time);
00424
00425 int (*BotLibLoadMap)(const char *mapname);
00426
00427 int (*BotLibUpdateEntity)(int ent, bot_entitystate_t *state);
00428
00429 int (*Test)(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);
00430 } botlib_export_t;
00431
00432
00433 botlib_export_t *GetBotLibAPI( int apiVersion, botlib_import_t *import );
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516