| 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 |
#include "../qcommon/q_shared.h" |
| 33 |
#include "l_memory.h" |
| 34 |
#include "l_log.h" |
| 35 |
#include "l_libvar.h" |
| 36 |
#include "l_script.h" |
| 37 |
#include "l_precomp.h" |
| 38 |
#include "l_struct.h" |
| 39 |
#include "aasfile.h" |
| 40 |
#include "botlib.h" |
| 41 |
#include "be_aas.h" |
| 42 |
#include "be_aas_funcs.h" |
| 43 |
#include "be_aas_def.h" |
| 44 |
#include "be_interface.h" |
| 45 |
|
| 46 |
#include "be_ea.h" |
| 47 |
#include "be_ai_weight.h" |
| 48 |
#include "be_ai_goal.h" |
| 49 |
#include "be_ai_move.h" |
| 50 |
#include "be_ai_weap.h" |
| 51 |
#include "be_ai_chat.h" |
| 52 |
#include "be_ai_char.h" |
| 53 |
#include "be_ai_gen.h" |
| 54 |
|
| 55 |
|
| 56 |
botlib_globals_t botlibglobals; |
| 57 |
|
| 58 |
botlib_export_t be_botlib_export; |
| 59 |
botlib_import_t botimport; |
| 60 |
|
| 61 |
int botDeveloper; |
| 62 |
|
| 63 |
int botlibsetup = qfalse; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
int Sys_MilliSeconds(void) |
| 78 |
{ |
| 79 |
return clock() * 1000 / CLOCKS_PER_SEC; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
qboolean ValidClientNumber(int num, char *str) |
| 88 |
{ |
| 89 |
if (num < 0 || num > botlibglobals.maxclients) |
| 90 |
{ |
| 91 |
|
| 92 |
botimport.Print(PRT_ERROR, "%s: invalid client number %d, [0, %d]\n", |
| 93 |
str, num, botlibglobals.maxclients); |
| 94 |
return qfalse; |
| 95 |
} |
| 96 |
return qtrue; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
qboolean ValidEntityNumber(int num, char *str) |
| 105 |
{ |
| 106 |
if (num < 0 || num > botlibglobals.maxentities) |
| 107 |
{ |
| 108 |
botimport.Print(PRT_ERROR, "%s: invalid entity number %d, [0, %d]\n", |
| 109 |
str, num, botlibglobals.maxentities); |
| 110 |
return qfalse; |
| 111 |
} |
| 112 |
return qtrue; |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
qboolean BotLibSetup(char *str) |
| 121 |
{ |
| 122 |
if (!botlibglobals.botlibsetup) |
| 123 |
{ |
| 124 |
botimport.Print(PRT_ERROR, "%s: bot library used before being setup\n", str); |
| 125 |
return qfalse; |
| 126 |
} |
| 127 |
return qtrue; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
int Export_BotLibSetup(void) |
| 137 |
{ |
| 138 |
int errnum; |
| 139 |
|
| 140 |
botDeveloper = LibVarGetValue("bot_developer"); |
| 141 |
memset( &botlibglobals, 0, sizeof(botlibglobals) ); |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
if(botDeveloper) |
| 146 |
{ |
| 147 |
Log_Open("botlib.log"); |
| 148 |
} |
| 149 |
|
| 150 |
botimport.Print(PRT_MESSAGE, "------- BotLib Initialization -------\n"); |
| 151 |
|
| 152 |
botlibglobals.maxclients = (int) LibVarValue("maxclients", "128"); |
| 153 |
botlibglobals.maxentities = (int) LibVarValue("maxentities", "1024"); |
| 154 |
|
| 155 |
errnum = AAS_Setup(); |
| 156 |
if (errnum != BLERR_NOERROR) return errnum; |
| 157 |
errnum = EA_Setup(); |
| 158 |
if (errnum != BLERR_NOERROR) return errnum; |
| 159 |
errnum = BotSetupWeaponAI(); |
| 160 |
if (errnum != BLERR_NOERROR)return errnum; |
| 161 |
errnum = BotSetupGoalAI(); |
| 162 |
if (errnum != BLERR_NOERROR) return errnum; |
| 163 |
errnum = BotSetupChatAI(); |
| 164 |
if (errnum != BLERR_NOERROR) return errnum; |
| 165 |
errnum = BotSetupMoveAI(); |
| 166 |
if (errnum != BLERR_NOERROR) return errnum; |
| 167 |
|
| 168 |
botlibsetup = qtrue; |
| 169 |
botlibglobals.botlibsetup = qtrue; |
| 170 |
|
| 171 |
return BLERR_NOERROR; |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
int Export_BotLibShutdown(void) |
| 180 |
{ |
| 181 |
if (!BotLibSetup("BotLibShutdown")) return BLERR_LIBRARYNOTSETUP; |
| 182 |
#ifndef DEMO |
| 183 |
|
| 184 |
#endif |
| 185 |
|
| 186 |
BotShutdownChatAI(); |
| 187 |
BotShutdownMoveAI(); |
| 188 |
BotShutdownGoalAI(); |
| 189 |
BotShutdownWeaponAI(); |
| 190 |
BotShutdownWeights(); |
| 191 |
BotShutdownCharacters(); |
| 192 |
|
| 193 |
AAS_Shutdown(); |
| 194 |
|
| 195 |
EA_Shutdown(); |
| 196 |
|
| 197 |
LibVarDeAllocAll(); |
| 198 |
|
| 199 |
PC_RemoveAllGlobalDefines(); |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
#ifdef DEBUG |
| 204 |
PrintMemoryLabels(); |
| 205 |
#endif |
| 206 |
|
| 207 |
Log_Shutdown(); |
| 208 |
|
| 209 |
botlibsetup = qfalse; |
| 210 |
botlibglobals.botlibsetup = qfalse; |
| 211 |
|
| 212 |
PC_CheckOpenSourceHandles(); |
| 213 |
|
| 214 |
return BLERR_NOERROR; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
int Export_BotLibVarSet(const char *var_name, const char *value) |
| 223 |
{ |
| 224 |
LibVarSet(var_name, value); |
| 225 |
return BLERR_NOERROR; |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
int Export_BotLibVarGet(const char *var_name, char *value, int size) |
| 234 |
{ |
| 235 |
char *varvalue; |
| 236 |
|
| 237 |
varvalue = LibVarGetString(var_name); |
| 238 |
Q_strncpyz(value, varvalue, size); |
| 239 |
return BLERR_NOERROR; |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
int Export_BotLibStartFrame(float time) |
| 248 |
{ |
| 249 |
if (!BotLibSetup("BotStartFrame")) return BLERR_LIBRARYNOTSETUP; |
| 250 |
return AAS_StartFrame(time); |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
int Export_BotLibLoadMap(const char *mapname) |
| 259 |
{ |
| 260 |
#ifdef DEBUG |
| 261 |
int starttime = Sys_MilliSeconds(); |
| 262 |
#endif |
| 263 |
int errnum; |
| 264 |
|
| 265 |
if (!BotLibSetup("BotLoadMap")) return BLERR_LIBRARYNOTSETUP; |
| 266 |
|
| 267 |
botimport.Print(PRT_MESSAGE, "------------ Map Loading ------------\n"); |
| 268 |
|
| 269 |
errnum = AAS_LoadMap(mapname); |
| 270 |
if (errnum != BLERR_NOERROR) return errnum; |
| 271 |
|
| 272 |
BotInitLevelItems(); |
| 273 |
BotSetBrushModelTypes(); |
| 274 |
|
| 275 |
botimport.Print(PRT_MESSAGE, "-------------------------------------\n"); |
| 276 |
#ifdef DEBUG |
| 277 |
botimport.Print(PRT_MESSAGE, "map loaded in %d msec\n", Sys_MilliSeconds() - starttime); |
| 278 |
#endif |
| 279 |
|
| 280 |
return BLERR_NOERROR; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
int Export_BotLibUpdateEntity(int ent, bot_entitystate_t *state) |
| 289 |
{ |
| 290 |
if (!BotLibSetup("BotUpdateEntity")) return BLERR_LIBRARYNOTSETUP; |
| 291 |
if (!ValidEntityNumber(ent, "BotUpdateEntity")) return BLERR_INVALIDENTITYNUMBER; |
| 292 |
|
| 293 |
return AAS_UpdateEntity(ent, state); |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
void AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir); |
| 302 |
void ElevatorBottomCenter(aas_reachability_t *reach, vec3_t bottomcenter); |
| 303 |
int BotGetReachabilityToGoal(vec3_t origin, int areanum, |
| 304 |
int lastgoalareanum, int lastareanum, |
| 305 |
int *avoidreach, float *avoidreachtimes, int *avoidreachtries, |
| 306 |
bot_goal_t *goal, int travelflags, |
| 307 |
struct bot_avoidspot_s *avoidspots, int numavoidspots, int *flags); |
| 308 |
|
| 309 |
int AAS_PointLight(vec3_t origin, int *red, int *green, int *blue); |
| 310 |
|
| 311 |
int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); |
| 312 |
|
| 313 |
int AAS_Reachability_WeaponJump(int area1num, int area2num); |
| 314 |
|
| 315 |
int BotFuzzyPointReachabilityArea(vec3_t origin); |
| 316 |
|
| 317 |
float BotGapDistance(vec3_t origin, vec3_t hordir, int entnum); |
| 318 |
|
| 319 |
void AAS_FloodAreas(vec3_t origin); |
| 320 |
|
| 321 |
int BotExportTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3) |
| 322 |
{ |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
#ifdef DEBUG |
| 327 |
static int area = -1; |
| 328 |
static int line[2]; |
| 329 |
int newarea, i, highlightarea, flood; |
| 330 |
|
| 331 |
vec3_t eye, forward, right, end, origin; |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
vec3_t mins = {-16, -16, -24}; |
| 342 |
vec3_t maxs = {16, 16, 32}; |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
if (!aasworld.loaded) return 0; |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
for (i = 0; i < 2; i++) if (!line[i]) line[i] = botimport.DebugLineCreate(); |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
highlightarea = LibVarGetValue("bot_highlightarea"); |
| 368 |
if (highlightarea > 0) |
| 369 |
{ |
| 370 |
newarea = highlightarea; |
| 371 |
} |
| 372 |
else |
| 373 |
{ |
| 374 |
VectorCopy(parm2, origin); |
| 375 |
origin[2] += 0.5; |
| 376 |
|
| 377 |
newarea = BotFuzzyPointReachabilityArea(origin); |
| 378 |
} |
| 379 |
|
| 380 |
botimport.Print(PRT_MESSAGE, "\rtravel time to goal (%d) = %d ", botlibglobals.goalareanum, |
| 381 |
AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT)); |
| 382 |
|
| 383 |
if (newarea != area) |
| 384 |
{ |
| 385 |
botimport.Print(PRT_MESSAGE, "origin = %f, %f, %f\n", origin[0], origin[1], origin[2]); |
| 386 |
area = newarea; |
| 387 |
botimport.Print(PRT_MESSAGE, "new area %d, cluster %d, presence type %d\n", |
| 388 |
area, AAS_AreaCluster(area), AAS_PointPresenceType(origin)); |
| 389 |
botimport.Print(PRT_MESSAGE, "area contents: "); |
| 390 |
if (aasworld.areasettings[area].contents & AREACONTENTS_WATER) |
| 391 |
{ |
| 392 |
botimport.Print(PRT_MESSAGE, "water &"); |
| 393 |
} |
| 394 |
if (aasworld.areasettings[area].contents & AREACONTENTS_LAVA) |
| 395 |
{ |
| 396 |
botimport.Print(PRT_MESSAGE, "lava &"); |
| 397 |
} |
| 398 |
if (aasworld.areasettings[area].contents & AREACONTENTS_SLIME) |
| 399 |
{ |
| 400 |
botimport.Print(PRT_MESSAGE, "slime &"); |
| 401 |
} |
| 402 |
if (aasworld.areasettings[area].contents & AREACONTENTS_JUMPPAD) |
| 403 |
{ |
| 404 |
botimport.Print(PRT_MESSAGE, "jump pad &"); |
| 405 |
} |
| 406 |
if (aasworld.areasettings[area].contents & AREACONTENTS_CLUSTERPORTAL) |
| 407 |
{ |
| 408 |
botimport.Print(PRT_MESSAGE, "cluster portal &"); |
| 409 |
} |
| 410 |
if (aasworld.areasettings[area].contents & AREACONTENTS_VIEWPORTAL) |
| 411 |
{ |
| 412 |
botimport.Print(PRT_MESSAGE, "view portal &"); |
| 413 |
} |
| 414 |
if (aasworld.areasettings[area].contents & AREACONTENTS_DONOTENTER) |
| 415 |
{ |
| 416 |
botimport.Print(PRT_MESSAGE, "do not enter &"); |
| 417 |
} |
| 418 |
if (aasworld.areasettings[area].contents & AREACONTENTS_MOVER) |
| 419 |
{ |
| 420 |
botimport.Print(PRT_MESSAGE, "mover &"); |
| 421 |
} |
| 422 |
if (!aasworld.areasettings[area].contents) |
| 423 |
{ |
| 424 |
botimport.Print(PRT_MESSAGE, "empty"); |
| 425 |
} |
| 426 |
botimport.Print(PRT_MESSAGE, "\n"); |
| 427 |
botimport.Print(PRT_MESSAGE, "travel time to goal (%d) = %d\n", botlibglobals.goalareanum, |
| 428 |
AAS_AreaTravelTimeToGoalArea(newarea, origin, botlibglobals.goalareanum, TFL_DEFAULT|TFL_ROCKETJUMP)); |
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
} |
| 443 |
|
| 444 |
flood = LibVarGetValue("bot_flood"); |
| 445 |
if (parm0 & 1) |
| 446 |
{ |
| 447 |
if (flood) |
| 448 |
{ |
| 449 |
AAS_ClearShownPolygons(); |
| 450 |
AAS_ClearShownDebugLines(); |
| 451 |
AAS_FloodAreas(parm2); |
| 452 |
} |
| 453 |
else |
| 454 |
{ |
| 455 |
botlibglobals.goalareanum = newarea; |
| 456 |
VectorCopy(parm2, botlibglobals.goalorigin); |
| 457 |
botimport.Print(PRT_MESSAGE, "new goal %2.1f %2.1f %2.1f area %d\n", |
| 458 |
origin[0], origin[1], origin[2], newarea); |
| 459 |
} |
| 460 |
} |
| 461 |
if (flood) |
| 462 |
return 0; |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
AAS_ClearShownPolygons(); |
| 510 |
AAS_ClearShownDebugLines(); |
| 511 |
AAS_ShowAreaPolygons(newarea, 1, parm0 & 4); |
| 512 |
if (parm0 & 2) AAS_ShowReachableAreas(area); |
| 513 |
else |
| 514 |
{ |
| 515 |
static int lastgoalareanum, lastareanum; |
| 516 |
static int avoidreach[MAX_AVOIDREACH]; |
| 517 |
static float avoidreachtimes[MAX_AVOIDREACH]; |
| 518 |
static int avoidreachtries[MAX_AVOIDREACH]; |
| 519 |
int reachnum, resultFlags; |
| 520 |
bot_goal_t goal; |
| 521 |
aas_reachability_t reach; |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
int curarea; |
| 535 |
vec3_t curorigin; |
| 536 |
|
| 537 |
goal.areanum = botlibglobals.goalareanum; |
| 538 |
VectorCopy(botlibglobals.goalorigin, goal.origin); |
| 539 |
VectorCopy(origin, curorigin); |
| 540 |
curarea = newarea; |
| 541 |
for ( i = 0; i < 100; i++ ) { |
| 542 |
if ( curarea == goal.areanum ) { |
| 543 |
break; |
| 544 |
} |
| 545 |
reachnum = BotGetReachabilityToGoal(curorigin, curarea, |
| 546 |
lastgoalareanum, lastareanum, |
| 547 |
avoidreach, avoidreachtimes, avoidreachtries, |
| 548 |
&goal, TFL_DEFAULT|TFL_FUNCBOB|TFL_ROCKETJUMP, |
| 549 |
NULL, 0, &resultFlags); |
| 550 |
AAS_ReachabilityFromNum(reachnum, &reach); |
| 551 |
AAS_ShowReachability(&reach); |
| 552 |
VectorCopy(reach.end, origin); |
| 553 |
lastareanum = curarea; |
| 554 |
curarea = reach.areanum; |
| 555 |
} |
| 556 |
} |
| 557 |
VectorClear(forward); |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
AngleVectors(parm3, forward, right, NULL); |
| 567 |
|
| 568 |
VectorMA(parm2, 8, right, eye); |
| 569 |
|
| 570 |
eye[2] += 24; |
| 571 |
|
| 572 |
VectorMA(eye, 800, forward, end); |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
#if 0 |
| 609 |
AAS_ClearShownDebugLines(); |
| 610 |
|
| 611 |
bsptrace = AAS_Trace(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); |
| 612 |
if (!line[0]) line[0] = botimport.DebugLineCreate(); |
| 613 |
botimport.DebugLineShow(line[0], eye, bsptrace.endpos, LINECOLOR_YELLOW); |
| 614 |
if (bsptrace.fraction < 1.0) |
| 615 |
{ |
| 616 |
face = AAS_TraceEndFace(&trace); |
| 617 |
if (face) |
| 618 |
{ |
| 619 |
AAS_ShowFace(face - aasworld.faces); |
| 620 |
} |
| 621 |
|
| 622 |
AAS_DrawPlaneCross(bsptrace.endpos, |
| 623 |
bsptrace.plane.normal, |
| 624 |
bsptrace.plane.dist + bsptrace.exp_dist, |
| 625 |
bsptrace.plane.type, LINECOLOR_GREEN); |
| 626 |
if (trace.ent) |
| 627 |
{ |
| 628 |
ent = &aasworld.entities[trace.ent]; |
| 629 |
AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs); |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
bsptrace = AAS_Trace2(eye, mins, maxs, end, 1, MASK_PLAYERSOLID); |
| 634 |
botimport.DebugLineShow(line[1], eye, bsptrace.endpos, LINECOLOR_BLUE); |
| 635 |
if (bsptrace.fraction < 1.0) |
| 636 |
{ |
| 637 |
AAS_DrawPlaneCross(bsptrace.endpos, |
| 638 |
bsptrace.plane.normal, |
| 639 |
bsptrace.plane.dist, |
| 640 |
bsptrace.plane.type, LINECOLOR_RED); |
| 641 |
if (bsptrace.ent) |
| 642 |
{ |
| 643 |
ent = &aasworld.entities[bsptrace.ent]; |
| 644 |
AAS_ShowBoundingBox(ent->origin, ent->mins, ent->maxs); |
| 645 |
} |
| 646 |
} |
| 647 |
#endif |
| 648 |
#endif |
| 649 |
return 0; |
| 650 |
} |
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
static void Init_AAS_Export( aas_export_t *aas ) { |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
aas->AAS_EntityInfo = AAS_EntityInfo; |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
aas->AAS_Initialized = AAS_Initialized; |
| 667 |
aas->AAS_PresenceTypeBoundingBox = AAS_PresenceTypeBoundingBox; |
| 668 |
aas->AAS_Time = AAS_Time; |
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
aas->AAS_PointAreaNum = AAS_PointAreaNum; |
| 673 |
aas->AAS_PointReachabilityAreaIndex = AAS_PointReachabilityAreaIndex; |
| 674 |
aas->AAS_TraceAreas = AAS_TraceAreas; |
| 675 |
aas->AAS_BBoxAreas = AAS_BBoxAreas; |
| 676 |
aas->AAS_AreaInfo = AAS_AreaInfo; |
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
aas->AAS_PointContents = AAS_PointContents; |
| 681 |
aas->AAS_NextBSPEntity = AAS_NextBSPEntity; |
| 682 |
aas->AAS_ValueForBSPEpairKey = AAS_ValueForBSPEpairKey; |
| 683 |
aas->AAS_VectorForBSPEpairKey = AAS_VectorForBSPEpairKey; |
| 684 |
aas->AAS_FloatForBSPEpairKey = AAS_FloatForBSPEpairKey; |
| 685 |
aas->AAS_IntForBSPEpairKey = AAS_IntForBSPEpairKey; |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
aas->AAS_AreaReachability = AAS_AreaReachability; |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
aas->AAS_AreaTravelTimeToGoalArea = AAS_AreaTravelTimeToGoalArea; |
| 694 |
aas->AAS_EnableRoutingArea = AAS_EnableRoutingArea; |
| 695 |
aas->AAS_PredictRoute = AAS_PredictRoute; |
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
aas->AAS_AlternativeRouteGoals = AAS_AlternativeRouteGoals; |
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
aas->AAS_Swimming = AAS_Swimming; |
| 704 |
aas->AAS_PredictClientMovement = AAS_PredictClientMovement; |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
static void Init_EA_Export( ea_export_t *ea ) { |
| 714 |
|
| 715 |
ea->EA_Command = EA_Command; |
| 716 |
ea->EA_Say = EA_Say; |
| 717 |
ea->EA_SayTeam = EA_SayTeam; |
| 718 |
|
| 719 |
ea->EA_Action = EA_Action; |
| 720 |
ea->EA_Gesture = EA_Gesture; |
| 721 |
ea->EA_Talk = EA_Talk; |
| 722 |
ea->EA_Attack = EA_Attack; |
| 723 |
ea->EA_Use = EA_Use; |
| 724 |
ea->EA_Respawn = EA_Respawn; |
| 725 |
ea->EA_Crouch = EA_Crouch; |
| 726 |
ea->EA_MoveUp = EA_MoveUp; |
| 727 |
ea->EA_MoveDown = EA_MoveDown; |
| 728 |
ea->EA_MoveForward = EA_MoveForward; |
| 729 |
ea->EA_MoveBack = EA_MoveBack; |
| 730 |
ea->EA_MoveLeft = EA_MoveLeft; |
| 731 |
ea->EA_MoveRight = EA_MoveRight; |
| 732 |
|
| 733 |
ea->EA_SelectWeapon = EA_SelectWeapon; |
| 734 |
ea->EA_Jump = EA_Jump; |
| 735 |
ea->EA_DelayedJump = EA_DelayedJump; |
| 736 |
ea->EA_Move = EA_Move; |
| 737 |
ea->EA_View = EA_View; |
| 738 |
ea->EA_GetInput = EA_GetInput; |
| 739 |
ea->EA_EndRegular = EA_EndRegular; |
| 740 |
ea->EA_ResetInput = EA_ResetInput; |
| 741 |
} |
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
static void Init_AI_Export( ai_export_t *ai ) { |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
ai->BotLoadCharacter = BotLoadCharacter; |
| 754 |
ai->BotFreeCharacter = BotFreeCharacter; |
| 755 |
ai->Characteristic_Float = Characteristic_Float; |
| 756 |
ai->Characteristic_BFloat = Characteristic_BFloat; |
| 757 |
ai->Characteristic_Integer = Characteristic_Integer; |
| 758 |
ai->Characteristic_BInteger = Characteristic_BInteger; |
| 759 |
ai->Characteristic_String = Characteristic_String; |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
ai->BotAllocChatState = BotAllocChatState; |
| 764 |
ai->BotFreeChatState = BotFreeChatState; |
| 765 |
ai->BotQueueConsoleMessage = BotQueueConsoleMessage; |
| 766 |
ai->BotRemoveConsoleMessage = BotRemoveConsoleMessage; |
| 767 |
ai->BotNextConsoleMessage = BotNextConsoleMessage; |
| 768 |
ai->BotNumConsoleMessages = BotNumConsoleMessages; |
| 769 |
ai->BotInitialChat = BotInitialChat; |
| 770 |
ai->BotNumInitialChats = BotNumInitialChats; |
| 771 |
ai->BotReplyChat = BotReplyChat; |
| 772 |
ai->BotChatLength = BotChatLength; |
| 773 |
ai->BotEnterChat = BotEnterChat; |
| 774 |
ai->BotGetChatMessage = BotGetChatMessage; |
| 775 |
ai->StringContains = StringContains; |
| 776 |
ai->BotFindMatch = BotFindMatch; |
| 777 |
ai->BotMatchVariable = BotMatchVariable; |
| 778 |
ai->UnifyWhiteSpaces = UnifyWhiteSpaces; |
| 779 |
ai->BotReplaceSynonyms = BotReplaceSynonyms; |
| 780 |
ai->BotLoadChatFile = BotLoadChatFile; |
| 781 |
ai->BotSetChatGender = BotSetChatGender; |
| 782 |
ai->BotSetChatName = BotSetChatName; |
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
ai->BotResetGoalState = BotResetGoalState; |
| 787 |
ai->BotResetAvoidGoals = BotResetAvoidGoals; |
| 788 |
ai->BotRemoveFromAvoidGoals = BotRemoveFromAvoidGoals; |
| 789 |
ai->BotPushGoal = BotPushGoal; |
| 790 |
ai->BotPopGoal = BotPopGoal; |
| 791 |
ai->BotEmptyGoalStack = BotEmptyGoalStack; |
| 792 |
ai->BotDumpAvoidGoals = BotDumpAvoidGoals; |
| 793 |
ai->BotDumpGoalStack = BotDumpGoalStack; |
| 794 |
ai->BotGoalName = BotGoalName; |
| 795 |
ai->BotGetTopGoal = BotGetTopGoal; |
| 796 |
ai->BotGetSecondGoal = BotGetSecondGoal; |
| 797 |
ai->BotChooseLTGItem = BotChooseLTGItem; |
| 798 |
ai->BotChooseNBGItem = BotChooseNBGItem; |
| 799 |
ai->BotTouchingGoal = BotTouchingGoal; |
| 800 |
ai->BotItemGoalInVisButNotVisible = BotItemGoalInVisButNotVisible; |
| 801 |
ai->BotGetLevelItemGoal = BotGetLevelItemGoal; |
| 802 |
ai->BotGetNextCampSpotGoal = BotGetNextCampSpotGoal; |
| 803 |
ai->BotGetMapLocationGoal = BotGetMapLocationGoal; |
| 804 |
ai->BotAvoidGoalTime = BotAvoidGoalTime; |
| 805 |
ai->BotSetAvoidGoalTime = BotSetAvoidGoalTime; |
| 806 |
ai->BotInitLevelItems = BotInitLevelItems; |
| 807 |
ai->BotUpdateEntityItems = BotUpdateEntityItems; |
| 808 |
ai->BotLoadItemWeights = BotLoadItemWeights; |
| 809 |
ai->BotFreeItemWeights = BotFreeItemWeights; |
| 810 |
ai->BotInterbreedGoalFuzzyLogic = BotInterbreedGoalFuzzyLogic; |
| 811 |
ai->BotSaveGoalFuzzyLogic = BotSaveGoalFuzzyLogic; |
| 812 |
ai->BotMutateGoalFuzzyLogic = BotMutateGoalFuzzyLogic; |
| 813 |
ai->BotAllocGoalState = BotAllocGoalState; |
| 814 |
ai->BotFreeGoalState = BotFreeGoalState; |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
ai->BotResetMoveState = BotResetMoveState; |
| 819 |
ai->BotMoveToGoal = BotMoveToGoal; |
| 820 |
ai->BotMoveInDirection = BotMoveInDirection; |
| 821 |
ai->BotResetAvoidReach = BotResetAvoidReach; |
| 822 |
ai->BotResetLastAvoidReach = BotResetLastAvoidReach; |
| 823 |
ai->BotReachabilityArea = BotReachabilityArea; |
| 824 |
ai->BotMovementViewTarget = BotMovementViewTarget; |
| 825 |
ai->BotPredictVisiblePosition = BotPredictVisiblePosition; |
| 826 |
ai->BotAllocMoveState = BotAllocMoveState; |
| 827 |
ai->BotFreeMoveState = BotFreeMoveState; |
| 828 |
ai->BotInitMoveState = BotInitMoveState; |
| 829 |
ai->BotAddAvoidSpot = BotAddAvoidSpot; |
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
ai->BotChooseBestFightWeapon = BotChooseBestFightWeapon; |
| 834 |
ai->BotGetWeaponInfo = BotGetWeaponInfo; |
| 835 |
ai->BotLoadWeaponWeights = BotLoadWeaponWeights; |
| 836 |
ai->BotAllocWeaponState = BotAllocWeaponState; |
| 837 |
ai->BotFreeWeaponState = BotFreeWeaponState; |
| 838 |
ai->BotResetWeaponState = BotResetWeaponState; |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
ai->GeneticParentsAndChildSelection = GeneticParentsAndChildSelection; |
| 843 |
} |
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
botlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t *import) { |
| 852 |
assert(import); |
| 853 |
botimport = *import; |
| 854 |
assert(botimport.Print); |
| 855 |
|
| 856 |
Com_Memset( &be_botlib_export, 0, sizeof( be_botlib_export ) ); |
| 857 |
|
| 858 |
if ( apiVersion != BOTLIB_API_VERSION ) { |
| 859 |
botimport.Print( PRT_ERROR, "Mismatched BOTLIB_API_VERSION: expected %i, got %i\n", BOTLIB_API_VERSION, apiVersion ); |
| 860 |
return NULL; |
| 861 |
} |
| 862 |
|
| 863 |
Init_AAS_Export(&be_botlib_export.aas); |
| 864 |
Init_EA_Export(&be_botlib_export.ea); |
| 865 |
Init_AI_Export(&be_botlib_export.ai); |
| 866 |
|
| 867 |
be_botlib_export.BotLibSetup = Export_BotLibSetup; |
| 868 |
be_botlib_export.BotLibShutdown = Export_BotLibShutdown; |
| 869 |
be_botlib_export.BotLibVarSet = Export_BotLibVarSet; |
| 870 |
be_botlib_export.BotLibVarGet = Export_BotLibVarGet; |
| 871 |
|
| 872 |
be_botlib_export.PC_AddGlobalDefine = PC_AddGlobalDefine; |
| 873 |
be_botlib_export.PC_LoadSourceHandle = PC_LoadSourceHandle; |
| 874 |
be_botlib_export.PC_FreeSourceHandle = PC_FreeSourceHandle; |
| 875 |
be_botlib_export.PC_ReadTokenHandle = PC_ReadTokenHandle; |
| 876 |
be_botlib_export.PC_SourceFileAndLine = PC_SourceFileAndLine; |
| 877 |
|
| 878 |
be_botlib_export.BotLibStartFrame = Export_BotLibStartFrame; |
| 879 |
be_botlib_export.BotLibLoadMap = Export_BotLibLoadMap; |
| 880 |
be_botlib_export.BotLibUpdateEntity = Export_BotLibUpdateEntity; |
| 881 |
be_botlib_export.Test = BotExportTest; |
| 882 |
|
| 883 |
return &be_botlib_export; |
| 884 |
} |