| 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_utils.h" |
| 34 |
#include "l_libvar.h" |
| 35 |
#include "l_memory.h" |
| 36 |
#include "l_log.h" |
| 37 |
#include "l_script.h" |
| 38 |
#include "l_precomp.h" |
| 39 |
#include "l_struct.h" |
| 40 |
#include "aasfile.h" |
| 41 |
#include "botlib.h" |
| 42 |
#include "be_aas.h" |
| 43 |
#include "be_aas_funcs.h" |
| 44 |
#include "be_interface.h" |
| 45 |
#include "be_ai_weight.h" |
| 46 |
#include "be_ai_goal.h" |
| 47 |
#include "be_ai_move.h" |
| 48 |
|
| 49 |
|
| 50 |
#ifdef RANDOMIZE |
| 51 |
#define UNDECIDEDFUZZY |
| 52 |
#endif |
| 53 |
#define DROPPEDWEIGHT |
| 54 |
|
| 55 |
#define AVOID_MINIMUM_TIME 10 |
| 56 |
|
| 57 |
#define AVOID_DEFAULT_TIME 30 |
| 58 |
|
| 59 |
#define AVOID_DROPPED_TIME 10 |
| 60 |
|
| 61 |
#define TRAVELTIME_SCALE 0.01 |
| 62 |
|
| 63 |
#define IFL_NOTFREE 1 //not in free for all |
| 64 |
#define IFL_NOTTEAM 2 //not in team play |
| 65 |
#define IFL_NOTSINGLE 4 //not in single player |
| 66 |
#define IFL_NOTBOT 8 //bot should never go for this |
| 67 |
#define IFL_ROAM 16 //bot roam goal |
| 68 |
|
| 69 |
|
| 70 |
typedef struct maplocation_s |
| 71 |
{ |
| 72 |
vec3_t origin; |
| 73 |
int areanum; |
| 74 |
char name[MAX_EPAIRKEY]; |
| 75 |
struct maplocation_s *next; |
| 76 |
} maplocation_t; |
| 77 |
|
| 78 |
|
| 79 |
typedef struct campspot_s |
| 80 |
{ |
| 81 |
vec3_t origin; |
| 82 |
int areanum; |
| 83 |
char name[MAX_EPAIRKEY]; |
| 84 |
float range; |
| 85 |
float weight; |
| 86 |
float wait; |
| 87 |
float random; |
| 88 |
struct campspot_s *next; |
| 89 |
} campspot_t; |
| 90 |
|
| 91 |
|
| 92 |
typedef enum { |
| 93 |
GT_FFA, |
| 94 |
GT_TOURNAMENT, |
| 95 |
GT_SINGLE_PLAYER, |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
GT_TEAM, |
| 100 |
GT_CTF, |
| 101 |
#ifdef MISSIONPACK |
| 102 |
GT_1FCTF, |
| 103 |
GT_OBELISK, |
| 104 |
GT_HARVESTER, |
| 105 |
#endif |
| 106 |
GT_MAX_GAME_TYPE |
| 107 |
} gametype_t; |
| 108 |
|
| 109 |
typedef struct levelitem_s |
| 110 |
{ |
| 111 |
int number; |
| 112 |
int iteminfo; |
| 113 |
int flags; |
| 114 |
float weight; |
| 115 |
vec3_t origin; |
| 116 |
int goalareanum; |
| 117 |
vec3_t goalorigin; |
| 118 |
int entitynum; |
| 119 |
float timeout; |
| 120 |
struct levelitem_s *prev, *next; |
| 121 |
} levelitem_t; |
| 122 |
|
| 123 |
typedef struct iteminfo_s |
| 124 |
{ |
| 125 |
char classname[32]; |
| 126 |
char name[MAX_STRINGFIELD]; |
| 127 |
char model[MAX_STRINGFIELD]; |
| 128 |
int modelindex; |
| 129 |
int type; |
| 130 |
int index; |
| 131 |
float respawntime; |
| 132 |
vec3_t mins; |
| 133 |
vec3_t maxs; |
| 134 |
int number; |
| 135 |
} iteminfo_t; |
| 136 |
|
| 137 |
#define ITEMINFO_OFS(x) (size_t)&(((iteminfo_t *)0)->x) |
| 138 |
|
| 139 |
fielddef_t iteminfo_fields[] = |
| 140 |
{ |
| 141 |
{"name", ITEMINFO_OFS(name), FT_STRING}, |
| 142 |
{"model", ITEMINFO_OFS(model), FT_STRING}, |
| 143 |
{"modelindex", ITEMINFO_OFS(modelindex), FT_INT}, |
| 144 |
{"type", ITEMINFO_OFS(type), FT_INT}, |
| 145 |
{"index", ITEMINFO_OFS(index), FT_INT}, |
| 146 |
{"respawntime", ITEMINFO_OFS(respawntime), FT_FLOAT}, |
| 147 |
{"mins", ITEMINFO_OFS(mins), FT_FLOAT|FT_ARRAY, 3}, |
| 148 |
{"maxs", ITEMINFO_OFS(maxs), FT_FLOAT|FT_ARRAY, 3}, |
| 149 |
{NULL, 0, 0} |
| 150 |
}; |
| 151 |
|
| 152 |
structdef_t iteminfo_struct = |
| 153 |
{ |
| 154 |
sizeof(iteminfo_t), iteminfo_fields |
| 155 |
}; |
| 156 |
|
| 157 |
typedef struct itemconfig_s |
| 158 |
{ |
| 159 |
int numiteminfo; |
| 160 |
iteminfo_t *iteminfo; |
| 161 |
} itemconfig_t; |
| 162 |
|
| 163 |
|
| 164 |
typedef struct bot_goalstate_s |
| 165 |
{ |
| 166 |
struct weightconfig_s *itemweightconfig; |
| 167 |
int *itemweightindex; |
| 168 |
|
| 169 |
int client; |
| 170 |
int lastreachabilityarea; |
| 171 |
|
| 172 |
bot_goal_t goalstack[MAX_GOALSTACK]; |
| 173 |
int goalstacktop; |
| 174 |
|
| 175 |
int avoidgoals[MAX_AVOIDGOALS]; |
| 176 |
float avoidgoaltimes[MAX_AVOIDGOALS]; |
| 177 |
} bot_goalstate_t; |
| 178 |
|
| 179 |
bot_goalstate_t *botgoalstates[MAX_CLIENTS + 1]; |
| 180 |
|
| 181 |
itemconfig_t *itemconfig = NULL; |
| 182 |
|
| 183 |
levelitem_t *levelitemheap = NULL; |
| 184 |
levelitem_t *freelevelitems = NULL; |
| 185 |
levelitem_t *levelitems = NULL; |
| 186 |
int numlevelitems = 0; |
| 187 |
|
| 188 |
maplocation_t *maplocations = NULL; |
| 189 |
|
| 190 |
campspot_t *campspots = NULL; |
| 191 |
|
| 192 |
int g_gametype = 0; |
| 193 |
|
| 194 |
libvar_t *droppedweight = NULL; |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
bot_goalstate_t *BotGoalStateFromHandle(int handle) |
| 203 |
{ |
| 204 |
if (handle <= 0 || handle > MAX_CLIENTS) |
| 205 |
{ |
| 206 |
botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle); |
| 207 |
return NULL; |
| 208 |
} |
| 209 |
if (!botgoalstates[handle]) |
| 210 |
{ |
| 211 |
botimport.Print(PRT_FATAL, "invalid goal state %d\n", handle); |
| 212 |
return NULL; |
| 213 |
} |
| 214 |
return botgoalstates[handle]; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) |
| 223 |
{ |
| 224 |
bot_goalstate_t *p1, *p2, *c; |
| 225 |
|
| 226 |
p1 = BotGoalStateFromHandle(parent1); |
| 227 |
p2 = BotGoalStateFromHandle(parent2); |
| 228 |
c = BotGoalStateFromHandle(child); |
| 229 |
|
| 230 |
if (!p1 || !p2 || !c) |
| 231 |
return; |
| 232 |
|
| 233 |
InterbreedWeightConfigs(p1->itemweightconfig, p2->itemweightconfig, |
| 234 |
c->itemweightconfig); |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
void BotSaveGoalFuzzyLogic(int goalstate, char *filename) |
| 243 |
{ |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
void BotMutateGoalFuzzyLogic(int goalstate, float range) |
| 257 |
{ |
| 258 |
bot_goalstate_t *gs; |
| 259 |
|
| 260 |
gs = BotGoalStateFromHandle(goalstate); |
| 261 |
if (!gs) return; |
| 262 |
EvolveWeightConfig(gs->itemweightconfig); |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
itemconfig_t *LoadItemConfig(char *filename) |
| 271 |
{ |
| 272 |
int max_iteminfo; |
| 273 |
token_t token; |
| 274 |
char path[MAX_QPATH]; |
| 275 |
source_t *source; |
| 276 |
itemconfig_t *ic; |
| 277 |
iteminfo_t *ii; |
| 278 |
|
| 279 |
max_iteminfo = (int) LibVarValue("max_iteminfo", "256"); |
| 280 |
if (max_iteminfo < 0) |
| 281 |
{ |
| 282 |
botimport.Print(PRT_ERROR, "max_iteminfo = %d\n", max_iteminfo); |
| 283 |
max_iteminfo = 256; |
| 284 |
LibVarSet( "max_iteminfo", "256" ); |
| 285 |
} |
| 286 |
|
| 287 |
Q_strncpyz(path, filename, sizeof(path)); |
| 288 |
PC_SetBaseFolder(BOTFILESBASEFOLDER); |
| 289 |
source = LoadSourceFile( path ); |
| 290 |
if( !source ) { |
| 291 |
botimport.Print( PRT_ERROR, "couldn't load %s\n", path ); |
| 292 |
return NULL; |
| 293 |
} |
| 294 |
|
| 295 |
ic = (itemconfig_t *) GetClearedHunkMemory(sizeof(itemconfig_t) + |
| 296 |
max_iteminfo * sizeof(iteminfo_t)); |
| 297 |
ic->iteminfo = (iteminfo_t *) ((char *) ic + sizeof(itemconfig_t)); |
| 298 |
ic->numiteminfo = 0; |
| 299 |
|
| 300 |
while(PC_ReadToken(source, &token)) |
| 301 |
{ |
| 302 |
if (!strcmp(token.string, "iteminfo")) |
| 303 |
{ |
| 304 |
if (ic->numiteminfo >= max_iteminfo) |
| 305 |
{ |
| 306 |
SourceError(source, "more than %d item info defined", max_iteminfo); |
| 307 |
FreeMemory(ic); |
| 308 |
FreeSource(source); |
| 309 |
return NULL; |
| 310 |
} |
| 311 |
ii = &ic->iteminfo[ic->numiteminfo]; |
| 312 |
Com_Memset(ii, 0, sizeof(iteminfo_t)); |
| 313 |
if (!PC_ExpectTokenType(source, TT_STRING, 0, &token)) |
| 314 |
{ |
| 315 |
FreeMemory(ic); |
| 316 |
FreeSource(source); |
| 317 |
return NULL; |
| 318 |
} |
| 319 |
StripDoubleQuotes(token.string); |
| 320 |
Q_strncpyz(ii->classname, token.string, sizeof(ii->classname)); |
| 321 |
if (!ReadStructure(source, &iteminfo_struct, (char *) ii)) |
| 322 |
{ |
| 323 |
FreeMemory(ic); |
| 324 |
FreeSource(source); |
| 325 |
return NULL; |
| 326 |
} |
| 327 |
ii->number = ic->numiteminfo; |
| 328 |
ic->numiteminfo++; |
| 329 |
} |
| 330 |
else |
| 331 |
{ |
| 332 |
SourceError(source, "unknown definition %s", token.string); |
| 333 |
FreeMemory(ic); |
| 334 |
FreeSource(source); |
| 335 |
return NULL; |
| 336 |
} |
| 337 |
} |
| 338 |
FreeSource(source); |
| 339 |
|
| 340 |
if (!ic->numiteminfo) botimport.Print(PRT_WARNING, "no item info loaded\n"); |
| 341 |
botimport.Print(PRT_MESSAGE, "loaded %s\n", path); |
| 342 |
return ic; |
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
int *ItemWeightIndex(weightconfig_t *iwc, itemconfig_t *ic) |
| 352 |
{ |
| 353 |
int *index, i; |
| 354 |
|
| 355 |
|
| 356 |
index = (int *) GetClearedMemory(sizeof(int) * ic->numiteminfo); |
| 357 |
|
| 358 |
for (i = 0; i < ic->numiteminfo; i++) |
| 359 |
{ |
| 360 |
index[i] = FindFuzzyWeight(iwc, ic->iteminfo[i].classname); |
| 361 |
if (index[i] < 0) |
| 362 |
{ |
| 363 |
Log_Write("item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[i].classname); |
| 364 |
} |
| 365 |
} |
| 366 |
return index; |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
void InitLevelItemHeap(void) |
| 375 |
{ |
| 376 |
int i, max_levelitems; |
| 377 |
|
| 378 |
if (levelitemheap) FreeMemory(levelitemheap); |
| 379 |
|
| 380 |
max_levelitems = (int) LibVarValue("max_levelitems", "256"); |
| 381 |
levelitemheap = (levelitem_t *) GetClearedMemory(max_levelitems * sizeof(levelitem_t)); |
| 382 |
|
| 383 |
for (i = 0; i < max_levelitems-1; i++) |
| 384 |
{ |
| 385 |
levelitemheap[i].next = &levelitemheap[i + 1]; |
| 386 |
} |
| 387 |
levelitemheap[max_levelitems-1].next = NULL; |
| 388 |
|
| 389 |
freelevelitems = levelitemheap; |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
levelitem_t *AllocLevelItem(void) |
| 398 |
{ |
| 399 |
levelitem_t *li; |
| 400 |
|
| 401 |
li = freelevelitems; |
| 402 |
if (!li) |
| 403 |
{ |
| 404 |
botimport.Print(PRT_FATAL, "out of level items\n"); |
| 405 |
return NULL; |
| 406 |
} |
| 407 |
|
| 408 |
freelevelitems = freelevelitems->next; |
| 409 |
Com_Memset(li, 0, sizeof(levelitem_t)); |
| 410 |
return li; |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
void FreeLevelItem(levelitem_t *li) |
| 419 |
{ |
| 420 |
li->next = freelevelitems; |
| 421 |
freelevelitems = li; |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
void AddLevelItemToList(levelitem_t *li) |
| 430 |
{ |
| 431 |
if (levelitems) levelitems->prev = li; |
| 432 |
li->prev = NULL; |
| 433 |
li->next = levelitems; |
| 434 |
levelitems = li; |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
void RemoveLevelItemFromList(levelitem_t *li) |
| 443 |
{ |
| 444 |
if (li->prev) li->prev->next = li->next; |
| 445 |
else levelitems = li->next; |
| 446 |
if (li->next) li->next->prev = li->prev; |
| 447 |
} |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
void BotFreeInfoEntities(void) |
| 455 |
{ |
| 456 |
maplocation_t *ml, *nextml; |
| 457 |
campspot_t *cs, *nextcs; |
| 458 |
|
| 459 |
for (ml = maplocations; ml; ml = nextml) |
| 460 |
{ |
| 461 |
nextml = ml->next; |
| 462 |
FreeMemory(ml); |
| 463 |
} |
| 464 |
maplocations = NULL; |
| 465 |
for (cs = campspots; cs; cs = nextcs) |
| 466 |
{ |
| 467 |
nextcs = cs->next; |
| 468 |
FreeMemory(cs); |
| 469 |
} |
| 470 |
campspots = NULL; |
| 471 |
} |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
void BotInitInfoEntities(void) |
| 479 |
{ |
| 480 |
char classname[MAX_EPAIRKEY]; |
| 481 |
maplocation_t *ml; |
| 482 |
campspot_t *cs; |
| 483 |
int ent, numlocations, numcampspots; |
| 484 |
|
| 485 |
BotFreeInfoEntities(); |
| 486 |
|
| 487 |
numlocations = 0; |
| 488 |
numcampspots = 0; |
| 489 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 490 |
{ |
| 491 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 492 |
|
| 493 |
|
| 494 |
if (!strcmp(classname, "target_location")) |
| 495 |
{ |
| 496 |
ml = (maplocation_t *) GetClearedMemory(sizeof(maplocation_t)); |
| 497 |
AAS_VectorForBSPEpairKey(ent, "origin", ml->origin); |
| 498 |
AAS_ValueForBSPEpairKey(ent, "message", ml->name, sizeof(ml->name)); |
| 499 |
ml->areanum = AAS_PointAreaNum(ml->origin); |
| 500 |
ml->next = maplocations; |
| 501 |
maplocations = ml; |
| 502 |
numlocations++; |
| 503 |
} |
| 504 |
|
| 505 |
else if (!strcmp(classname, "info_camp")) |
| 506 |
{ |
| 507 |
cs = (campspot_t *) GetClearedMemory(sizeof(campspot_t)); |
| 508 |
AAS_VectorForBSPEpairKey(ent, "origin", cs->origin); |
| 509 |
|
| 510 |
AAS_ValueForBSPEpairKey(ent, "message", cs->name, sizeof(cs->name)); |
| 511 |
AAS_FloatForBSPEpairKey(ent, "range", &cs->range); |
| 512 |
AAS_FloatForBSPEpairKey(ent, "weight", &cs->weight); |
| 513 |
AAS_FloatForBSPEpairKey(ent, "wait", &cs->wait); |
| 514 |
AAS_FloatForBSPEpairKey(ent, "random", &cs->random); |
| 515 |
cs->areanum = AAS_PointAreaNum(cs->origin); |
| 516 |
if (!cs->areanum) |
| 517 |
{ |
| 518 |
botimport.Print(PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[0], cs->origin[1], cs->origin[2]); |
| 519 |
FreeMemory(cs); |
| 520 |
continue; |
| 521 |
} |
| 522 |
cs->next = campspots; |
| 523 |
campspots = cs; |
| 524 |
|
| 525 |
numcampspots++; |
| 526 |
} |
| 527 |
} |
| 528 |
if (botDeveloper) |
| 529 |
{ |
| 530 |
botimport.Print(PRT_MESSAGE, "%d map locations\n", numlocations); |
| 531 |
botimport.Print(PRT_MESSAGE, "%d camp spots\n", numcampspots); |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
void BotInitLevelItems(void) |
| 541 |
{ |
| 542 |
int i, spawnflags, value; |
| 543 |
char classname[MAX_EPAIRKEY]; |
| 544 |
vec3_t origin, end; |
| 545 |
int ent, goalareanum; |
| 546 |
itemconfig_t *ic; |
| 547 |
levelitem_t *li; |
| 548 |
bsp_trace_t trace; |
| 549 |
|
| 550 |
|
| 551 |
BotInitInfoEntities(); |
| 552 |
|
| 553 |
|
| 554 |
InitLevelItemHeap(); |
| 555 |
levelitems = NULL; |
| 556 |
numlevelitems = 0; |
| 557 |
|
| 558 |
ic = itemconfig; |
| 559 |
if (!ic) return; |
| 560 |
|
| 561 |
|
| 562 |
if (!AAS_Loaded()) return; |
| 563 |
|
| 564 |
|
| 565 |
for (i = 0; i < ic->numiteminfo; i++) |
| 566 |
{ |
| 567 |
if (!ic->iteminfo[i].modelindex) |
| 568 |
{ |
| 569 |
Log_Write("item %s has modelindex 0", ic->iteminfo[i].classname); |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 574 |
{ |
| 575 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 576 |
|
| 577 |
spawnflags = 0; |
| 578 |
AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); |
| 579 |
|
| 580 |
for (i = 0; i < ic->numiteminfo; i++) |
| 581 |
{ |
| 582 |
if (!strcmp(classname, ic->iteminfo[i].classname)) break; |
| 583 |
} |
| 584 |
if (i >= ic->numiteminfo) |
| 585 |
{ |
| 586 |
Log_Write("entity %s unknown item\r\n", classname); |
| 587 |
continue; |
| 588 |
} |
| 589 |
|
| 590 |
if (!AAS_VectorForBSPEpairKey(ent, "origin", origin)) |
| 591 |
{ |
| 592 |
botimport.Print(PRT_ERROR, "item %s without origin\n", classname); |
| 593 |
continue; |
| 594 |
} |
| 595 |
|
| 596 |
goalareanum = 0; |
| 597 |
|
| 598 |
if (spawnflags & 1) |
| 599 |
{ |
| 600 |
|
| 601 |
if (!(AAS_PointContents(origin) & CONTENTS_WATER)) |
| 602 |
{ |
| 603 |
VectorCopy(origin, end); |
| 604 |
end[2] -= 32; |
| 605 |
trace = AAS_Trace(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, end, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP); |
| 606 |
|
| 607 |
if (trace.fraction >= 1) |
| 608 |
{ |
| 609 |
|
| 610 |
goalareanum = AAS_BestReachableFromJumpPadArea(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs); |
| 611 |
Log_Write("item %s reachable from jumppad area %d\r\n", ic->iteminfo[i].classname, goalareanum); |
| 612 |
|
| 613 |
if (!goalareanum) continue; |
| 614 |
} |
| 615 |
} |
| 616 |
} |
| 617 |
|
| 618 |
li = AllocLevelItem(); |
| 619 |
if (!li) return; |
| 620 |
|
| 621 |
li->number = ++numlevelitems; |
| 622 |
li->timeout = 0; |
| 623 |
li->entitynum = 0; |
| 624 |
|
| 625 |
li->flags = 0; |
| 626 |
AAS_IntForBSPEpairKey(ent, "notfree", &value); |
| 627 |
if (value) li->flags |= IFL_NOTFREE; |
| 628 |
AAS_IntForBSPEpairKey(ent, "notteam", &value); |
| 629 |
if (value) li->flags |= IFL_NOTTEAM; |
| 630 |
AAS_IntForBSPEpairKey(ent, "notsingle", &value); |
| 631 |
if (value) li->flags |= IFL_NOTSINGLE; |
| 632 |
AAS_IntForBSPEpairKey(ent, "notbot", &value); |
| 633 |
if (value) li->flags |= IFL_NOTBOT; |
| 634 |
if (!strcmp(classname, "item_botroam")) |
| 635 |
{ |
| 636 |
li->flags |= IFL_ROAM; |
| 637 |
AAS_FloatForBSPEpairKey(ent, "weight", &li->weight); |
| 638 |
} |
| 639 |
|
| 640 |
if (!(spawnflags & 1)) |
| 641 |
{ |
| 642 |
if (!AAS_DropToFloor(origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs)) |
| 643 |
{ |
| 644 |
botimport.Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", |
| 645 |
classname, origin[0], origin[1], origin[2]); |
| 646 |
} |
| 647 |
} |
| 648 |
|
| 649 |
li->iteminfo = i; |
| 650 |
|
| 651 |
VectorCopy(origin, li->origin); |
| 652 |
|
| 653 |
if (goalareanum) |
| 654 |
{ |
| 655 |
li->goalareanum = goalareanum; |
| 656 |
VectorCopy(origin, li->goalorigin); |
| 657 |
} |
| 658 |
else |
| 659 |
{ |
| 660 |
|
| 661 |
li->goalareanum = AAS_BestReachableArea(origin, |
| 662 |
ic->iteminfo[i].mins, ic->iteminfo[i].maxs, |
| 663 |
li->goalorigin); |
| 664 |
if (!li->goalareanum) |
| 665 |
{ |
| 666 |
botimport.Print(PRT_MESSAGE, "%s not reachable for bots at (%1.1f %1.1f %1.1f)\n", |
| 667 |
classname, origin[0], origin[1], origin[2]); |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
AddLevelItemToList(li); |
| 672 |
} |
| 673 |
botimport.Print(PRT_MESSAGE, "found %d level items\n", numlevelitems); |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
void BotGoalName(int number, char *name, int size) |
| 682 |
{ |
| 683 |
levelitem_t *li; |
| 684 |
|
| 685 |
if (!itemconfig) return; |
| 686 |
|
| 687 |
for (li = levelitems; li; li = li->next) |
| 688 |
{ |
| 689 |
if (li->number == number) |
| 690 |
{ |
| 691 |
Q_strncpyz(name, itemconfig->iteminfo[li->iteminfo].name, size); |
| 692 |
return; |
| 693 |
} |
| 694 |
} |
| 695 |
strcpy(name, ""); |
| 696 |
} |
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
void BotResetAvoidGoals(int goalstate) |
| 704 |
{ |
| 705 |
bot_goalstate_t *gs; |
| 706 |
|
| 707 |
gs = BotGoalStateFromHandle(goalstate); |
| 708 |
if (!gs) return; |
| 709 |
Com_Memset(gs->avoidgoals, 0, MAX_AVOIDGOALS * sizeof(int)); |
| 710 |
Com_Memset(gs->avoidgoaltimes, 0, MAX_AVOIDGOALS * sizeof(float)); |
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
void BotDumpAvoidGoals(int goalstate) |
| 719 |
{ |
| 720 |
int i; |
| 721 |
bot_goalstate_t *gs; |
| 722 |
char name[32]; |
| 723 |
|
| 724 |
gs = BotGoalStateFromHandle(goalstate); |
| 725 |
if (!gs) return; |
| 726 |
for (i = 0; i < MAX_AVOIDGOALS; i++) |
| 727 |
{ |
| 728 |
if (gs->avoidgoaltimes[i] >= AAS_Time()) |
| 729 |
{ |
| 730 |
BotGoalName(gs->avoidgoals[i], name, 32); |
| 731 |
Log_Write("avoid goal %s, number %d for %f seconds", name, |
| 732 |
gs->avoidgoals[i], gs->avoidgoaltimes[i] - AAS_Time()); |
| 733 |
} |
| 734 |
} |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
void BotAddToAvoidGoals(bot_goalstate_t *gs, int number, float avoidtime) |
| 743 |
{ |
| 744 |
int i; |
| 745 |
|
| 746 |
for (i = 0; i < MAX_AVOIDGOALS; i++) |
| 747 |
{ |
| 748 |
|
| 749 |
if (gs->avoidgoals[i] == number) |
| 750 |
{ |
| 751 |
gs->avoidgoals[i] = number; |
| 752 |
gs->avoidgoaltimes[i] = AAS_Time() + avoidtime; |
| 753 |
return; |
| 754 |
} |
| 755 |
} |
| 756 |
|
| 757 |
for (i = 0; i < MAX_AVOIDGOALS; i++) |
| 758 |
{ |
| 759 |
|
| 760 |
if (gs->avoidgoaltimes[i] < AAS_Time()) |
| 761 |
{ |
| 762 |
gs->avoidgoals[i] = number; |
| 763 |
gs->avoidgoaltimes[i] = AAS_Time() + avoidtime; |
| 764 |
return; |
| 765 |
} |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
void BotRemoveFromAvoidGoals(int goalstate, int number) |
| 775 |
{ |
| 776 |
int i; |
| 777 |
bot_goalstate_t *gs; |
| 778 |
|
| 779 |
gs = BotGoalStateFromHandle(goalstate); |
| 780 |
if (!gs) return; |
| 781 |
|
| 782 |
for (i = 0; i < MAX_AVOIDGOALS; i++) |
| 783 |
{ |
| 784 |
if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time()) |
| 785 |
{ |
| 786 |
gs->avoidgoaltimes[i] = 0; |
| 787 |
return; |
| 788 |
} |
| 789 |
} |
| 790 |
} |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
float BotAvoidGoalTime(int goalstate, int number) |
| 798 |
{ |
| 799 |
int i; |
| 800 |
bot_goalstate_t *gs; |
| 801 |
|
| 802 |
gs = BotGoalStateFromHandle(goalstate); |
| 803 |
if (!gs) return 0; |
| 804 |
|
| 805 |
for (i = 0; i < MAX_AVOIDGOALS; i++) |
| 806 |
{ |
| 807 |
if (gs->avoidgoals[i] == number && gs->avoidgoaltimes[i] >= AAS_Time()) |
| 808 |
{ |
| 809 |
return gs->avoidgoaltimes[i] - AAS_Time(); |
| 810 |
} |
| 811 |
} |
| 812 |
return 0; |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime) |
| 821 |
{ |
| 822 |
bot_goalstate_t *gs; |
| 823 |
levelitem_t *li; |
| 824 |
|
| 825 |
gs = BotGoalStateFromHandle(goalstate); |
| 826 |
if (!gs) |
| 827 |
return; |
| 828 |
if (avoidtime < 0) |
| 829 |
{ |
| 830 |
if (!itemconfig) |
| 831 |
return; |
| 832 |
|
| 833 |
for (li = levelitems; li; li = li->next) |
| 834 |
{ |
| 835 |
if (li->number == number) |
| 836 |
{ |
| 837 |
avoidtime = itemconfig->iteminfo[li->iteminfo].respawntime; |
| 838 |
if (!avoidtime) |
| 839 |
avoidtime = AVOID_DEFAULT_TIME; |
| 840 |
if (avoidtime < AVOID_MINIMUM_TIME) |
| 841 |
avoidtime = AVOID_MINIMUM_TIME; |
| 842 |
BotAddToAvoidGoals(gs, number, avoidtime); |
| 843 |
return; |
| 844 |
} |
| 845 |
} |
| 846 |
return; |
| 847 |
} |
| 848 |
else |
| 849 |
{ |
| 850 |
BotAddToAvoidGoals(gs, number, avoidtime); |
| 851 |
} |
| 852 |
} |
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
int BotGetLevelItemGoal(int index, char *name, bot_goal_t *goal) |
| 860 |
{ |
| 861 |
levelitem_t *li; |
| 862 |
|
| 863 |
if (!itemconfig) return -1; |
| 864 |
li = levelitems; |
| 865 |
if (index >= 0) |
| 866 |
{ |
| 867 |
for (; li; li = li->next) |
| 868 |
{ |
| 869 |
if (li->number == index) |
| 870 |
{ |
| 871 |
li = li->next; |
| 872 |
break; |
| 873 |
} |
| 874 |
} |
| 875 |
} |
| 876 |
for (; li; li = li->next) |
| 877 |
{ |
| 878 |
|
| 879 |
if (g_gametype == GT_SINGLE_PLAYER) { |
| 880 |
if (li->flags & IFL_NOTSINGLE) continue; |
| 881 |
} |
| 882 |
else if (g_gametype >= GT_TEAM) { |
| 883 |
if (li->flags & IFL_NOTTEAM) continue; |
| 884 |
} |
| 885 |
else { |
| 886 |
if (li->flags & IFL_NOTFREE) continue; |
| 887 |
} |
| 888 |
if (li->flags & IFL_NOTBOT) continue; |
| 889 |
|
| 890 |
if (!Q_stricmp(name, itemconfig->iteminfo[li->iteminfo].name)) |
| 891 |
{ |
| 892 |
goal->areanum = li->goalareanum; |
| 893 |
VectorCopy(li->goalorigin, goal->origin); |
| 894 |
goal->entitynum = li->entitynum; |
| 895 |
VectorCopy(itemconfig->iteminfo[li->iteminfo].mins, goal->mins); |
| 896 |
VectorCopy(itemconfig->iteminfo[li->iteminfo].maxs, goal->maxs); |
| 897 |
goal->number = li->number; |
| 898 |
goal->flags = GFL_ITEM; |
| 899 |
if (li->timeout) goal->flags |= GFL_DROPPED; |
| 900 |
goal->iteminfo = li->iteminfo; |
| 901 |
|
| 902 |
return li->number; |
| 903 |
} |
| 904 |
} |
| 905 |
return -1; |
| 906 |
} |
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
int BotGetMapLocationGoal(char *name, bot_goal_t *goal) |
| 914 |
{ |
| 915 |
maplocation_t *ml; |
| 916 |
vec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8}; |
| 917 |
|
| 918 |
for (ml = maplocations; ml; ml = ml->next) |
| 919 |
{ |
| 920 |
if (!Q_stricmp(ml->name, name)) |
| 921 |
{ |
| 922 |
goal->areanum = ml->areanum; |
| 923 |
VectorCopy(ml->origin, goal->origin); |
| 924 |
goal->entitynum = 0; |
| 925 |
VectorCopy(mins, goal->mins); |
| 926 |
VectorCopy(maxs, goal->maxs); |
| 927 |
goal->number = 0; |
| 928 |
goal->flags = 0; |
| 929 |
goal->iteminfo = 0; |
| 930 |
return qtrue; |
| 931 |
} |
| 932 |
} |
| 933 |
return qfalse; |
| 934 |
} |
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
int BotGetNextCampSpotGoal(int num, bot_goal_t *goal) |
| 942 |
{ |
| 943 |
int i; |
| 944 |
campspot_t *cs; |
| 945 |
vec3_t mins = {-8, -8, -8}, maxs = {8, 8, 8}; |
| 946 |
|
| 947 |
if (num < 0) num = 0; |
| 948 |
i = num; |
| 949 |
for (cs = campspots; cs; cs = cs->next) |
| 950 |
{ |
| 951 |
if (--i < 0) |
| 952 |
{ |
| 953 |
goal->areanum = cs->areanum; |
| 954 |
VectorCopy(cs->origin, goal->origin); |
| 955 |
goal->entitynum = 0; |
| 956 |
VectorCopy(mins, goal->mins); |
| 957 |
VectorCopy(maxs, goal->maxs); |
| 958 |
goal->number = 0; |
| 959 |
goal->flags = 0; |
| 960 |
goal->iteminfo = 0; |
| 961 |
return num+1; |
| 962 |
} |
| 963 |
} |
| 964 |
return 0; |
| 965 |
} |
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
void BotFindEntityForLevelItem(levelitem_t *li) |
| 973 |
{ |
| 974 |
int ent, modelindex; |
| 975 |
itemconfig_t *ic; |
| 976 |
aas_entityinfo_t entinfo; |
| 977 |
vec3_t dir; |
| 978 |
|
| 979 |
ic = itemconfig; |
| 980 |
if (!itemconfig) return; |
| 981 |
for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent)) |
| 982 |
{ |
| 983 |
|
| 984 |
modelindex = AAS_EntityModelindex(ent); |
| 985 |
|
| 986 |
if (!modelindex) continue; |
| 987 |
|
| 988 |
AAS_EntityInfo(ent, &entinfo); |
| 989 |
|
| 990 |
if (entinfo.origin[0] != entinfo.lastvisorigin[0] || |
| 991 |
entinfo.origin[1] != entinfo.lastvisorigin[1] || |
| 992 |
entinfo.origin[2] != entinfo.lastvisorigin[2]) continue; |
| 993 |
|
| 994 |
if (ic->iteminfo[li->iteminfo].modelindex == modelindex) |
| 995 |
{ |
| 996 |
|
| 997 |
VectorSubtract(li->origin, entinfo.origin, dir); |
| 998 |
if (VectorLength(dir) < 30) |
| 999 |
{ |
| 1000 |
|
| 1001 |
li->entitynum = ent; |
| 1002 |
} |
| 1003 |
} |
| 1004 |
} |
| 1005 |
} |
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
#define ET_ITEM 2 |
| 1015 |
|
| 1016 |
void BotUpdateEntityItems(void) |
| 1017 |
{ |
| 1018 |
int ent, i, modelindex; |
| 1019 |
vec3_t dir; |
| 1020 |
levelitem_t *li, *nextli; |
| 1021 |
aas_entityinfo_t entinfo; |
| 1022 |
itemconfig_t *ic; |
| 1023 |
|
| 1024 |
|
| 1025 |
for (li = levelitems; li; li = nextli) |
| 1026 |
{ |
| 1027 |
nextli = li->next; |
| 1028 |
|
| 1029 |
if (li->timeout) |
| 1030 |
{ |
| 1031 |
|
| 1032 |
if (li->timeout < AAS_Time()) |
| 1033 |
{ |
| 1034 |
RemoveLevelItemFromList(li); |
| 1035 |
FreeLevelItem(li); |
| 1036 |
} |
| 1037 |
} |
| 1038 |
} |
| 1039 |
|
| 1040 |
ic = itemconfig; |
| 1041 |
if (!itemconfig) return; |
| 1042 |
|
| 1043 |
for (ent = AAS_NextEntity(0); ent; ent = AAS_NextEntity(ent)) |
| 1044 |
{ |
| 1045 |
if (AAS_EntityType(ent) != ET_ITEM) continue; |
| 1046 |
|
| 1047 |
modelindex = AAS_EntityModelindex(ent); |
| 1048 |
|
| 1049 |
if (!modelindex) continue; |
| 1050 |
|
| 1051 |
AAS_EntityInfo(ent, &entinfo); |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
if (entinfo.origin[0] != entinfo.lastvisorigin[0] || |
| 1057 |
entinfo.origin[1] != entinfo.lastvisorigin[1] || |
| 1058 |
entinfo.origin[2] != entinfo.lastvisorigin[2]) continue; |
| 1059 |
|
| 1060 |
for (li = levelitems; li; li = li->next) |
| 1061 |
{ |
| 1062 |
|
| 1063 |
if (li->entitynum && li->entitynum == ent) |
| 1064 |
{ |
| 1065 |
|
| 1066 |
if (ic->iteminfo[li->iteminfo].modelindex != modelindex) |
| 1067 |
{ |
| 1068 |
|
| 1069 |
RemoveLevelItemFromList(li); |
| 1070 |
FreeLevelItem(li); |
| 1071 |
li = NULL; |
| 1072 |
break; |
| 1073 |
} |
| 1074 |
else |
| 1075 |
{ |
| 1076 |
if (entinfo.origin[0] != li->origin[0] || |
| 1077 |
entinfo.origin[1] != li->origin[1] || |
| 1078 |
entinfo.origin[2] != li->origin[2]) |
| 1079 |
{ |
| 1080 |
VectorCopy(entinfo.origin, li->origin); |
| 1081 |
|
| 1082 |
li->goalareanum = AAS_BestReachableArea(li->origin, |
| 1083 |
ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs, |
| 1084 |
li->goalorigin); |
| 1085 |
} |
| 1086 |
break; |
| 1087 |
} |
| 1088 |
} |
| 1089 |
} |
| 1090 |
if (li) continue; |
| 1091 |
|
| 1092 |
for (li = levelitems; li; li = li->next) |
| 1093 |
{ |
| 1094 |
|
| 1095 |
if (li->entitynum) continue; |
| 1096 |
|
| 1097 |
if (g_gametype == GT_SINGLE_PLAYER) { |
| 1098 |
if (li->flags & IFL_NOTSINGLE) continue; |
| 1099 |
} |
| 1100 |
else if (g_gametype >= GT_TEAM) { |
| 1101 |
if (li->flags & IFL_NOTTEAM) continue; |
| 1102 |
} |
| 1103 |
else { |
| 1104 |
if (li->flags & IFL_NOTFREE) continue; |
| 1105 |
} |
| 1106 |
|
| 1107 |
if (ic->iteminfo[li->iteminfo].modelindex == modelindex) |
| 1108 |
{ |
| 1109 |
|
| 1110 |
VectorSubtract(li->origin, entinfo.origin, dir); |
| 1111 |
if (VectorLength(dir) < 30) |
| 1112 |
{ |
| 1113 |
|
| 1114 |
li->entitynum = ent; |
| 1115 |
|
| 1116 |
if (entinfo.origin[0] != li->origin[0] || |
| 1117 |
entinfo.origin[1] != li->origin[1] || |
| 1118 |
entinfo.origin[2] != li->origin[2]) |
| 1119 |
{ |
| 1120 |
|
| 1121 |
VectorCopy(entinfo.origin, li->origin); |
| 1122 |
|
| 1123 |
li->goalareanum = AAS_BestReachableArea(li->origin, |
| 1124 |
ic->iteminfo[li->iteminfo].mins, ic->iteminfo[li->iteminfo].maxs, |
| 1125 |
li->goalorigin); |
| 1126 |
} |
| 1127 |
#ifdef DEBUG |
| 1128 |
Log_Write("linked item %s to an entity", ic->iteminfo[li->iteminfo].classname); |
| 1129 |
#endif |
| 1130 |
break; |
| 1131 |
} |
| 1132 |
} |
| 1133 |
} |
| 1134 |
if (li) continue; |
| 1135 |
|
| 1136 |
for (i = 0; i < ic->numiteminfo; i++) |
| 1137 |
{ |
| 1138 |
if (ic->iteminfo[i].modelindex == modelindex) |
| 1139 |
{ |
| 1140 |
break; |
| 1141 |
} |
| 1142 |
} |
| 1143 |
|
| 1144 |
if (i >= ic->numiteminfo) continue; |
| 1145 |
|
| 1146 |
li = AllocLevelItem(); |
| 1147 |
|
| 1148 |
if (!li) continue; |
| 1149 |
|
| 1150 |
li->entitynum = ent; |
| 1151 |
|
| 1152 |
li->number = numlevelitems + ent; |
| 1153 |
|
| 1154 |
li->iteminfo = i; |
| 1155 |
|
| 1156 |
VectorCopy(entinfo.origin, li->origin); |
| 1157 |
|
| 1158 |
li->goalareanum = AAS_BestReachableArea(li->origin, |
| 1159 |
ic->iteminfo[i].mins, ic->iteminfo[i].maxs, |
| 1160 |
li->goalorigin); |
| 1161 |
|
| 1162 |
if (AAS_AreaJumpPad(li->goalareanum)) |
| 1163 |
{ |
| 1164 |
FreeLevelItem(li); |
| 1165 |
continue; |
| 1166 |
} |
| 1167 |
|
| 1168 |
|
| 1169 |
li->timeout = AAS_Time() + 30; |
| 1170 |
|
| 1171 |
AddLevelItemToList(li); |
| 1172 |
|
| 1173 |
} |
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
} |
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
void BotDumpGoalStack(int goalstate) |
| 1190 |
{ |
| 1191 |
int i; |
| 1192 |
bot_goalstate_t *gs; |
| 1193 |
char name[32]; |
| 1194 |
|
| 1195 |
gs = BotGoalStateFromHandle(goalstate); |
| 1196 |
if (!gs) return; |
| 1197 |
for (i = 1; i <= gs->goalstacktop; i++) |
| 1198 |
{ |
| 1199 |
BotGoalName(gs->goalstack[i].number, name, 32); |
| 1200 |
Log_Write("%d: %s", i, name); |
| 1201 |
} |
| 1202 |
} |
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
void BotPushGoal(int goalstate, bot_goal_t *goal) |
| 1210 |
{ |
| 1211 |
bot_goalstate_t *gs; |
| 1212 |
|
| 1213 |
gs = BotGoalStateFromHandle(goalstate); |
| 1214 |
if (!gs) return; |
| 1215 |
if (gs->goalstacktop >= MAX_GOALSTACK-1) |
| 1216 |
{ |
| 1217 |
botimport.Print(PRT_ERROR, "goal heap overflow\n"); |
| 1218 |
BotDumpGoalStack(goalstate); |
| 1219 |
return; |
| 1220 |
} |
| 1221 |
gs->goalstacktop++; |
| 1222 |
Com_Memcpy(&gs->goalstack[gs->goalstacktop], goal, sizeof(bot_goal_t)); |
| 1223 |
} |
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
void BotPopGoal(int goalstate) |
| 1231 |
{ |
| 1232 |
bot_goalstate_t *gs; |
| 1233 |
|
| 1234 |
gs = BotGoalStateFromHandle(goalstate); |
| 1235 |
if (!gs) return; |
| 1236 |
if (gs->goalstacktop > 0) gs->goalstacktop--; |
| 1237 |
} |
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
void BotEmptyGoalStack(int goalstate) |
| 1245 |
{ |
| 1246 |
bot_goalstate_t *gs; |
| 1247 |
|
| 1248 |
gs = BotGoalStateFromHandle(goalstate); |
| 1249 |
if (!gs) return; |
| 1250 |
gs->goalstacktop = 0; |
| 1251 |
} |
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
int BotGetTopGoal(int goalstate, bot_goal_t *goal) |
| 1259 |
{ |
| 1260 |
bot_goalstate_t *gs; |
| 1261 |
|
| 1262 |
gs = BotGoalStateFromHandle(goalstate); |
| 1263 |
if (!gs) return qfalse; |
| 1264 |
if (!gs->goalstacktop) return qfalse; |
| 1265 |
Com_Memcpy(goal, &gs->goalstack[gs->goalstacktop], sizeof(bot_goal_t)); |
| 1266 |
return qtrue; |
| 1267 |
} |
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
int BotGetSecondGoal(int goalstate, bot_goal_t *goal) |
| 1275 |
{ |
| 1276 |
bot_goalstate_t *gs; |
| 1277 |
|
| 1278 |
gs = BotGoalStateFromHandle(goalstate); |
| 1279 |
if (!gs) return qfalse; |
| 1280 |
if (gs->goalstacktop <= 1) return qfalse; |
| 1281 |
Com_Memcpy(goal, &gs->goalstack[gs->goalstacktop-1], sizeof(bot_goal_t)); |
| 1282 |
return qtrue; |
| 1283 |
} |
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags) |
| 1292 |
{ |
| 1293 |
int areanum, t, weightnum; |
| 1294 |
float weight, bestweight, avoidtime; |
| 1295 |
iteminfo_t *iteminfo; |
| 1296 |
itemconfig_t *ic; |
| 1297 |
levelitem_t *li, *bestitem; |
| 1298 |
bot_goal_t goal; |
| 1299 |
bot_goalstate_t *gs; |
| 1300 |
|
| 1301 |
gs = BotGoalStateFromHandle(goalstate); |
| 1302 |
if (!gs) |
| 1303 |
return qfalse; |
| 1304 |
if (!gs->itemweightconfig) |
| 1305 |
return qfalse; |
| 1306 |
|
| 1307 |
areanum = BotReachabilityArea(origin, gs->client); |
| 1308 |
|
| 1309 |
if (!areanum || !AAS_AreaReachability(areanum)) |
| 1310 |
{ |
| 1311 |
|
| 1312 |
areanum = gs->lastreachabilityarea; |
| 1313 |
} |
| 1314 |
|
| 1315 |
gs->lastreachabilityarea = areanum; |
| 1316 |
|
| 1317 |
if (!areanum) |
| 1318 |
return qfalse; |
| 1319 |
|
| 1320 |
ic = itemconfig; |
| 1321 |
if (!itemconfig) |
| 1322 |
return qfalse; |
| 1323 |
|
| 1324 |
bestweight = 0; |
| 1325 |
bestitem = NULL; |
| 1326 |
Com_Memset(&goal, 0, sizeof(bot_goal_t)); |
| 1327 |
|
| 1328 |
for (li = levelitems; li; li = li->next) |
| 1329 |
{ |
| 1330 |
if (g_gametype == GT_SINGLE_PLAYER) { |
| 1331 |
if (li->flags & IFL_NOTSINGLE) |
| 1332 |
continue; |
| 1333 |
} |
| 1334 |
else if (g_gametype >= GT_TEAM) { |
| 1335 |
if (li->flags & IFL_NOTTEAM) |
| 1336 |
continue; |
| 1337 |
} |
| 1338 |
else { |
| 1339 |
if (li->flags & IFL_NOTFREE) |
| 1340 |
continue; |
| 1341 |
} |
| 1342 |
if (li->flags & IFL_NOTBOT) |
| 1343 |
continue; |
| 1344 |
|
| 1345 |
if (!li->goalareanum) |
| 1346 |
continue; |
| 1347 |
|
| 1348 |
if (!li->entitynum && !(li->flags & IFL_ROAM)) |
| 1349 |
continue; |
| 1350 |
|
| 1351 |
iteminfo = &ic->iteminfo[li->iteminfo]; |
| 1352 |
weightnum = gs->itemweightindex[iteminfo->number]; |
| 1353 |
if (weightnum < 0) |
| 1354 |
continue; |
| 1355 |
|
| 1356 |
#ifdef UNDECIDEDFUZZY |
| 1357 |
weight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum); |
| 1358 |
#else |
| 1359 |
weight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum); |
| 1360 |
#endif |
| 1361 |
#ifdef DROPPEDWEIGHT |
| 1362 |
|
| 1363 |
if (li->timeout) |
| 1364 |
weight += droppedweight->value; |
| 1365 |
#endif |
| 1366 |
|
| 1367 |
if (li->flags & IFL_ROAM) weight *= li->weight; |
| 1368 |
|
| 1369 |
if (weight > 0) |
| 1370 |
{ |
| 1371 |
|
| 1372 |
t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags); |
| 1373 |
|
| 1374 |
if (t > 0) |
| 1375 |
{ |
| 1376 |
|
| 1377 |
avoidtime = BotAvoidGoalTime(goalstate, li->number); |
| 1378 |
if (avoidtime - t * 0.009 > 0) |
| 1379 |
continue; |
| 1380 |
|
| 1381 |
weight /= (float) t * TRAVELTIME_SCALE; |
| 1382 |
|
| 1383 |
if (weight > bestweight) |
| 1384 |
{ |
| 1385 |
bestweight = weight; |
| 1386 |
bestitem = li; |
| 1387 |
} |
| 1388 |
} |
| 1389 |
} |
| 1390 |
} |
| 1391 |
|
| 1392 |
if (!bestitem) |
| 1393 |
{ |
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
return qfalse; |
| 1417 |
} |
| 1418 |
|
| 1419 |
iteminfo = &ic->iteminfo[bestitem->iteminfo]; |
| 1420 |
VectorCopy(bestitem->goalorigin, goal.origin); |
| 1421 |
VectorCopy(iteminfo->mins, goal.mins); |
| 1422 |
VectorCopy(iteminfo->maxs, goal.maxs); |
| 1423 |
goal.areanum = bestitem->goalareanum; |
| 1424 |
goal.entitynum = bestitem->entitynum; |
| 1425 |
goal.number = bestitem->number; |
| 1426 |
goal.flags = GFL_ITEM; |
| 1427 |
if (bestitem->timeout) |
| 1428 |
goal.flags |= GFL_DROPPED; |
| 1429 |
if (bestitem->flags & IFL_ROAM) |
| 1430 |
goal.flags |= GFL_ROAM; |
| 1431 |
goal.iteminfo = bestitem->iteminfo; |
| 1432 |
|
| 1433 |
if (bestitem->timeout) |
| 1434 |
{ |
| 1435 |
avoidtime = AVOID_DROPPED_TIME; |
| 1436 |
} |
| 1437 |
else |
| 1438 |
{ |
| 1439 |
avoidtime = iteminfo->respawntime; |
| 1440 |
if (!avoidtime) |
| 1441 |
avoidtime = AVOID_DEFAULT_TIME; |
| 1442 |
if (avoidtime < AVOID_MINIMUM_TIME) |
| 1443 |
avoidtime = AVOID_MINIMUM_TIME; |
| 1444 |
} |
| 1445 |
|
| 1446 |
BotAddToAvoidGoals(gs, bestitem->number, avoidtime); |
| 1447 |
|
| 1448 |
BotPushGoal(goalstate, &goal); |
| 1449 |
|
| 1450 |
return qtrue; |
| 1451 |
} |
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, |
| 1459 |
bot_goal_t *ltg, float maxtime) |
| 1460 |
{ |
| 1461 |
int areanum, t, weightnum, ltg_time; |
| 1462 |
float weight, bestweight, avoidtime; |
| 1463 |
iteminfo_t *iteminfo; |
| 1464 |
itemconfig_t *ic; |
| 1465 |
levelitem_t *li, *bestitem; |
| 1466 |
bot_goal_t goal; |
| 1467 |
bot_goalstate_t *gs; |
| 1468 |
|
| 1469 |
gs = BotGoalStateFromHandle(goalstate); |
| 1470 |
if (!gs) |
| 1471 |
return qfalse; |
| 1472 |
if (!gs->itemweightconfig) |
| 1473 |
return qfalse; |
| 1474 |
|
| 1475 |
areanum = BotReachabilityArea(origin, gs->client); |
| 1476 |
|
| 1477 |
if (!areanum || !AAS_AreaReachability(areanum)) |
| 1478 |
{ |
| 1479 |
|
| 1480 |
areanum = gs->lastreachabilityarea; |
| 1481 |
} |
| 1482 |
|
| 1483 |
gs->lastreachabilityarea = areanum; |
| 1484 |
|
| 1485 |
if (!areanum) |
| 1486 |
return qfalse; |
| 1487 |
|
| 1488 |
if (ltg) ltg_time = AAS_AreaTravelTimeToGoalArea(areanum, origin, ltg->areanum, travelflags); |
| 1489 |
else ltg_time = 99999; |
| 1490 |
|
| 1491 |
ic = itemconfig; |
| 1492 |
if (!itemconfig) |
| 1493 |
return qfalse; |
| 1494 |
|
| 1495 |
bestweight = 0; |
| 1496 |
bestitem = NULL; |
| 1497 |
Com_Memset(&goal, 0, sizeof(bot_goal_t)); |
| 1498 |
|
| 1499 |
for (li = levelitems; li; li = li->next) |
| 1500 |
{ |
| 1501 |
if (g_gametype == GT_SINGLE_PLAYER) { |
| 1502 |
if (li->flags & IFL_NOTSINGLE) |
| 1503 |
continue; |
| 1504 |
} |
| 1505 |
else if (g_gametype >= GT_TEAM) { |
| 1506 |
if (li->flags & IFL_NOTTEAM) |
| 1507 |
continue; |
| 1508 |
} |
| 1509 |
else { |
| 1510 |
if (li->flags & IFL_NOTFREE) |
| 1511 |
continue; |
| 1512 |
} |
| 1513 |
if (li->flags & IFL_NOTBOT) |
| 1514 |
continue; |
| 1515 |
|
| 1516 |
if (!li->goalareanum) |
| 1517 |
continue; |
| 1518 |
|
| 1519 |
if (!li->entitynum && !(li->flags & IFL_ROAM)) |
| 1520 |
continue; |
| 1521 |
|
| 1522 |
iteminfo = &ic->iteminfo[li->iteminfo]; |
| 1523 |
weightnum = gs->itemweightindex[iteminfo->number]; |
| 1524 |
if (weightnum < 0) |
| 1525 |
continue; |
| 1526 |
|
| 1527 |
#ifdef UNDECIDEDFUZZY |
| 1528 |
weight = FuzzyWeightUndecided(inventory, gs->itemweightconfig, weightnum); |
| 1529 |
#else |
| 1530 |
weight = FuzzyWeight(inventory, gs->itemweightconfig, weightnum); |
| 1531 |
#endif |
| 1532 |
#ifdef DROPPEDWEIGHT |
| 1533 |
|
| 1534 |
if (li->timeout) |
| 1535 |
weight += droppedweight->value; |
| 1536 |
#endif |
| 1537 |
|
| 1538 |
if (li->flags & IFL_ROAM) weight *= li->weight; |
| 1539 |
|
| 1540 |
if (weight > 0) |
| 1541 |
{ |
| 1542 |
|
| 1543 |
t = AAS_AreaTravelTimeToGoalArea(areanum, origin, li->goalareanum, travelflags); |
| 1544 |
|
| 1545 |
if (t > 0 && t < maxtime) |
| 1546 |
{ |
| 1547 |
|
| 1548 |
avoidtime = BotAvoidGoalTime(goalstate, li->number); |
| 1549 |
if (avoidtime - t * 0.009 > 0) |
| 1550 |
continue; |
| 1551 |
|
| 1552 |
weight /= (float) t * TRAVELTIME_SCALE; |
| 1553 |
|
| 1554 |
if (weight > bestweight) |
| 1555 |
{ |
| 1556 |
t = 0; |
| 1557 |
if (ltg && !li->timeout) |
| 1558 |
{ |
| 1559 |
|
| 1560 |
t = AAS_AreaTravelTimeToGoalArea(li->goalareanum, li->goalorigin, ltg->areanum, travelflags); |
| 1561 |
} |
| 1562 |
|
| 1563 |
if (t <= ltg_time) |
| 1564 |
{ |
| 1565 |
bestweight = weight; |
| 1566 |
bestitem = li; |
| 1567 |
} |
| 1568 |
} |
| 1569 |
} |
| 1570 |
} |
| 1571 |
} |
| 1572 |
|
| 1573 |
if (!bestitem) |
| 1574 |
return qfalse; |
| 1575 |
|
| 1576 |
iteminfo = &ic->iteminfo[bestitem->iteminfo]; |
| 1577 |
VectorCopy(bestitem->goalorigin, goal.origin); |
| 1578 |
VectorCopy(iteminfo->mins, goal.mins); |
| 1579 |
VectorCopy(iteminfo->maxs, goal.maxs); |
| 1580 |
goal.areanum = bestitem->goalareanum; |
| 1581 |
goal.entitynum = bestitem->entitynum; |
| 1582 |
goal.number = bestitem->number; |
| 1583 |
goal.flags = GFL_ITEM; |
| 1584 |
if (bestitem->timeout) |
| 1585 |
goal.flags |= GFL_DROPPED; |
| 1586 |
if (bestitem->flags & IFL_ROAM) |
| 1587 |
goal.flags |= GFL_ROAM; |
| 1588 |
goal.iteminfo = bestitem->iteminfo; |
| 1589 |
|
| 1590 |
if (bestitem->timeout) |
| 1591 |
{ |
| 1592 |
avoidtime = AVOID_DROPPED_TIME; |
| 1593 |
} |
| 1594 |
else |
| 1595 |
{ |
| 1596 |
avoidtime = iteminfo->respawntime; |
| 1597 |
if (!avoidtime) |
| 1598 |
avoidtime = AVOID_DEFAULT_TIME; |
| 1599 |
if (avoidtime < AVOID_MINIMUM_TIME) |
| 1600 |
avoidtime = AVOID_MINIMUM_TIME; |
| 1601 |
} |
| 1602 |
|
| 1603 |
BotAddToAvoidGoals(gs, bestitem->number, avoidtime); |
| 1604 |
|
| 1605 |
BotPushGoal(goalstate, &goal); |
| 1606 |
|
| 1607 |
return qtrue; |
| 1608 |
} |
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
|
| 1613 |
|
| 1614 |
|
| 1615 |
int BotTouchingGoal(vec3_t origin, bot_goal_t *goal) |
| 1616 |
{ |
| 1617 |
int i; |
| 1618 |
vec3_t boxmins, boxmaxs; |
| 1619 |
vec3_t absmins, absmaxs; |
| 1620 |
vec3_t safety_maxs = {0, 0, 0}; |
| 1621 |
vec3_t safety_mins = {0, 0, 0}; |
| 1622 |
|
| 1623 |
AAS_PresenceTypeBoundingBox(PRESENCE_NORMAL, boxmins, boxmaxs); |
| 1624 |
VectorSubtract(goal->mins, boxmaxs, absmins); |
| 1625 |
VectorSubtract(goal->maxs, boxmins, absmaxs); |
| 1626 |
VectorAdd(absmins, goal->origin, absmins); |
| 1627 |
VectorAdd(absmaxs, goal->origin, absmaxs); |
| 1628 |
|
| 1629 |
VectorSubtract(absmaxs, safety_maxs, absmaxs); |
| 1630 |
VectorSubtract(absmins, safety_mins, absmins); |
| 1631 |
|
| 1632 |
for (i = 0; i < 3; i++) |
| 1633 |
{ |
| 1634 |
if (origin[i] < absmins[i] || origin[i] > absmaxs[i]) return qfalse; |
| 1635 |
} |
| 1636 |
return qtrue; |
| 1637 |
} |
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal) |
| 1645 |
{ |
| 1646 |
aas_entityinfo_t entinfo; |
| 1647 |
bsp_trace_t trace; |
| 1648 |
vec3_t middle; |
| 1649 |
|
| 1650 |
if (!(goal->flags & GFL_ITEM)) return qfalse; |
| 1651 |
|
| 1652 |
VectorAdd(goal->mins, goal->mins, middle); |
| 1653 |
VectorScale(middle, 0.5, middle); |
| 1654 |
VectorAdd(goal->origin, middle, middle); |
| 1655 |
|
| 1656 |
trace = AAS_Trace(eye, NULL, NULL, middle, viewer, CONTENTS_SOLID); |
| 1657 |
|
| 1658 |
if (trace.fraction >= 1) |
| 1659 |
{ |
| 1660 |
|
| 1661 |
|
| 1662 |
if (goal->entitynum <= 0) |
| 1663 |
return qfalse; |
| 1664 |
|
| 1665 |
|
| 1666 |
AAS_EntityInfo(goal->entitynum, &entinfo); |
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
if (entinfo.ltime < AAS_Time() - 0.5) |
| 1671 |
return qtrue; |
| 1672 |
} |
| 1673 |
return qfalse; |
| 1674 |
} |
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
void BotResetGoalState(int goalstate) |
| 1682 |
{ |
| 1683 |
bot_goalstate_t *gs; |
| 1684 |
|
| 1685 |
gs = BotGoalStateFromHandle(goalstate); |
| 1686 |
if (!gs) return; |
| 1687 |
Com_Memset(gs->goalstack, 0, MAX_GOALSTACK * sizeof(bot_goal_t)); |
| 1688 |
gs->goalstacktop = 0; |
| 1689 |
BotResetAvoidGoals(goalstate); |
| 1690 |
} |
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
int BotLoadItemWeights(int goalstate, char *filename) |
| 1698 |
{ |
| 1699 |
bot_goalstate_t *gs; |
| 1700 |
|
| 1701 |
gs = BotGoalStateFromHandle(goalstate); |
| 1702 |
if (!gs) return BLERR_CANNOTLOADITEMWEIGHTS; |
| 1703 |
|
| 1704 |
gs->itemweightconfig = ReadWeightConfig(filename); |
| 1705 |
if (!gs->itemweightconfig) |
| 1706 |
{ |
| 1707 |
botimport.Print(PRT_FATAL, "couldn't load weights\n"); |
| 1708 |
return BLERR_CANNOTLOADITEMWEIGHTS; |
| 1709 |
} |
| 1710 |
|
| 1711 |
if (!itemconfig) return BLERR_CANNOTLOADITEMWEIGHTS; |
| 1712 |
|
| 1713 |
gs->itemweightindex = ItemWeightIndex(gs->itemweightconfig, itemconfig); |
| 1714 |
|
| 1715 |
return BLERR_NOERROR; |
| 1716 |
} |
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
void BotFreeItemWeights(int goalstate) |
| 1724 |
{ |
| 1725 |
bot_goalstate_t *gs; |
| 1726 |
|
| 1727 |
gs = BotGoalStateFromHandle(goalstate); |
| 1728 |
if (!gs) return; |
| 1729 |
if (gs->itemweightconfig) FreeWeightConfig(gs->itemweightconfig); |
| 1730 |
if (gs->itemweightindex) FreeMemory(gs->itemweightindex); |
| 1731 |
} |
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
int BotAllocGoalState(int client) |
| 1739 |
{ |
| 1740 |
int i; |
| 1741 |
|
| 1742 |
for (i = 1; i <= MAX_CLIENTS; i++) |
| 1743 |
{ |
| 1744 |
if (!botgoalstates[i]) |
| 1745 |
{ |
| 1746 |
botgoalstates[i] = GetClearedMemory(sizeof(bot_goalstate_t)); |
| 1747 |
botgoalstates[i]->client = client; |
| 1748 |
return i; |
| 1749 |
} |
| 1750 |
} |
| 1751 |
return 0; |
| 1752 |
} |
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
void BotFreeGoalState(int handle) |
| 1760 |
{ |
| 1761 |
if (handle <= 0 || handle > MAX_CLIENTS) |
| 1762 |
{ |
| 1763 |
botimport.Print(PRT_FATAL, "goal state handle %d out of range\n", handle); |
| 1764 |
return; |
| 1765 |
} |
| 1766 |
if (!botgoalstates[handle]) |
| 1767 |
{ |
| 1768 |
botimport.Print(PRT_FATAL, "invalid goal state handle %d\n", handle); |
| 1769 |
return; |
| 1770 |
} |
| 1771 |
BotFreeItemWeights(handle); |
| 1772 |
FreeMemory(botgoalstates[handle]); |
| 1773 |
botgoalstates[handle] = NULL; |
| 1774 |
} |
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
int BotSetupGoalAI(void) |
| 1782 |
{ |
| 1783 |
char *filename; |
| 1784 |
|
| 1785 |
|
| 1786 |
g_gametype = LibVarValue("g_gametype", "0"); |
| 1787 |
|
| 1788 |
filename = LibVarString("itemconfig", "items.c"); |
| 1789 |
|
| 1790 |
itemconfig = LoadItemConfig(filename); |
| 1791 |
if (!itemconfig) |
| 1792 |
{ |
| 1793 |
botimport.Print(PRT_FATAL, "couldn't load item config\n"); |
| 1794 |
return BLERR_CANNOTLOADITEMCONFIG; |
| 1795 |
} |
| 1796 |
|
| 1797 |
droppedweight = LibVar("droppedweight", "1000"); |
| 1798 |
|
| 1799 |
return BLERR_NOERROR; |
| 1800 |
} |
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
void BotShutdownGoalAI(void) |
| 1808 |
{ |
| 1809 |
int i; |
| 1810 |
|
| 1811 |
if (itemconfig) FreeMemory(itemconfig); |
| 1812 |
itemconfig = NULL; |
| 1813 |
if (levelitemheap) FreeMemory(levelitemheap); |
| 1814 |
levelitemheap = NULL; |
| 1815 |
freelevelitems = NULL; |
| 1816 |
levelitems = NULL; |
| 1817 |
numlevelitems = 0; |
| 1818 |
|
| 1819 |
BotFreeInfoEntities(); |
| 1820 |
|
| 1821 |
for (i = 1; i <= MAX_CLIENTS; i++) |
| 1822 |
{ |
| 1823 |
if (botgoalstates[i]) |
| 1824 |
{ |
| 1825 |
BotFreeGoalState(i); |
| 1826 |
} |
| 1827 |
} |
| 1828 |
} |