#include "../game/q_shared.h"
#include "l_log.h"
#include "l_memory.h"
#include "l_utils.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_libvar.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "../game/be_ai_char.h"
Include dependency graph for be_ai_char.c:

Go to the source code of this file.
Data Structures | |
| struct | bot_character_s |
| struct | bot_characteristic_s |
| union | cvalue |
Defines | |
| #define | CT_FLOAT 2 |
| #define | CT_INTEGER 1 |
| #define | CT_STRING 3 |
| #define | DEFAULT_CHARACTER "bots/default_c.c" |
| #define | MAX_CHARACTERISTICS 80 |
Typedefs | |
| typedef bot_character_s | bot_character_t |
| typedef bot_characteristic_s | bot_characteristic_t |
Functions | |
| bot_character_t * | BotCharacterFromHandle (int handle) |
| void | BotDefaultCharacteristics (bot_character_t *ch, bot_character_t *defaultch) |
| void | BotDumpCharacter (bot_character_t *ch) |
| int | BotFindCachedCharacter (char *charfile, float skill) |
| void | BotFreeCharacter (int handle) |
| void | BotFreeCharacter2 (int handle) |
| void | BotFreeCharacterStrings (bot_character_t *ch) |
| int | BotInterpolateCharacters (int handle1, int handle2, float desiredskill) |
| int | BotLoadCachedCharacter (char *charfile, float skill, int reload) |
| int | BotLoadCharacter (char *charfile, float skill) |
| bot_character_t * | BotLoadCharacterFromFile (char *charfile, int skill) |
| int | BotLoadCharacterSkill (char *charfile, float skill) |
| void | BotShutdownCharacters (void) |
| float | Characteristic_BFloat (int character, int index, float min, float max) |
| int | Characteristic_BInteger (int character, int index, int min, int max) |
| float | Characteristic_Float (int character, int index) |
| int | Characteristic_Integer (int character, int index) |
| void | Characteristic_String (int character, int index, char *buf, int size) |
| int | CheckCharacteristicIndex (int character, int index) |
Variables | |
| bot_character_t * | botcharacters [MAX_CLIENTS+1] |
|
|
Definition at line 50 of file be_ai_char.c. Referenced by BotDumpCharacter(), and BotInterpolateCharacters(). |
|
|
Definition at line 49 of file be_ai_char.c. Referenced by BotDumpCharacter(). |
|
|
Definition at line 51 of file be_ai_char.c. Referenced by BotDumpCharacter(). |
|
|
Definition at line 53 of file be_ai_char.c. Referenced by BotLoadCachedCharacter(), and BotLoadCharacterSkill(). |
|
|
Definition at line 47 of file be_ai_char.c. Referenced by BotInterpolateCharacters(), and BotLoadCharacterFromFile(). |
|
|
|
Referenced by BotInterpolateCharacters(), and BotLoadCharacterFromFile(). |
|
|
Definition at line 85 of file be_ai_char.c. References bot_character_t, botcharacters, botimport, and PRT_FATAL. Referenced by BotInterpolateCharacters(), Characteristic_BFloat(), Characteristic_BInteger(), Characteristic_Float(), Characteristic_Integer(), Characteristic_String(), and CheckCharacteristicIndex(). 00086 {
00087 if (handle <= 0 || handle > MAX_CLIENTS)
00088 {
00089 botimport.Print(PRT_FATAL, "character handle %d out of range\n", handle);
00090 return NULL;
00091 } //end if
00092 if (!botcharacters[handle])
00093 {
00094 botimport.Print(PRT_FATAL, "invalid character %d\n", handle);
00095 return NULL;
00096 } //end if
00097 return botcharacters[handle];
00098 } //end of the function BotCharacterFromHandle
|
|
||||||||||||
|
Definition at line 180 of file be_ai_char.c. References cvalue::_float, bot_character_t, bot_character_s::c, ch, GetMemory(), i, cvalue::integer, strcpy(), cvalue::string, strlen(), bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by BotLoadCharacterSkill(). 00181 {
00182 int i;
00183
00184 for (i = 0; i < MAX_CHARACTERISTICS; i++)
00185 {
00186 if (ch->c[i].type) continue;
00187 //
00188 if (defaultch->c[i].type == CT_FLOAT)
00189 {
00190 ch->c[i].type = CT_FLOAT;
00191 ch->c[i].value._float = defaultch->c[i].value._float;
00192 } //end if
00193 else if (defaultch->c[i].type == CT_INTEGER)
00194 {
00195 ch->c[i].type = CT_INTEGER;
00196 ch->c[i].value.integer = defaultch->c[i].value.integer;
00197 } //end else if
00198 else if (defaultch->c[i].type == CT_STRING)
00199 {
00200 ch->c[i].type = CT_STRING;
00201 ch->c[i].value.string = (char *) GetMemory(strlen(defaultch->c[i].value.string)+1);
00202 strcpy(ch->c[i].value.string, defaultch->c[i].value.string);
00203 } //end else if
00204 } //end for
00205 } //end of the function BotDefaultCharacteristics
|
Here is the call graph for this function:

|
|
Definition at line 105 of file be_ai_char.c. References cvalue::_float, bot_character_t, bot_character_s::c, ch, CT_FLOAT, CT_INTEGER, CT_STRING, bot_character_s::filename, i, cvalue::integer, Log_Write(), bot_character_s::skill, cvalue::string, bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by BotLoadCharacter(). 00106 {
00107 int i;
00108
00109 Log_Write("%s", ch->filename);
00110 Log_Write("skill %d\n", ch->skill);
00111 Log_Write("{\n");
00112 for (i = 0; i < MAX_CHARACTERISTICS; i++)
00113 {
00114 switch(ch->c[i].type)
00115 {
00116 case CT_INTEGER: Log_Write(" %4d %d\n", i, ch->c[i].value.integer); break;
00117 case CT_FLOAT: Log_Write(" %4d %f\n", i, ch->c[i].value._float); break;
00118 case CT_STRING: Log_Write(" %4d %s\n", i, ch->c[i].value.string); break;
00119 } //end case
00120 } //end for
00121 Log_Write("}\n");
00122 } //end of the function BotDumpCharacter
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 362 of file be_ai_char.c. References botcharacters, fabs(), and strcmp(). Referenced by BotLoadCachedCharacter(), and BotLoadCharacter(). 00363 {
00364 int handle;
00365
00366 for (handle = 1; handle <= MAX_CLIENTS; handle++)
00367 {
00368 if ( !botcharacters[handle] ) continue;
00369 if ( strcmp( botcharacters[handle]->filename, charfile ) == 0 &&
00370 (skill < 0 || fabs(botcharacters[handle]->skill - skill) < 0.01) )
00371 {
00372 return handle;
00373 } //end if
00374 } //end for
00375 return 0;
00376 } //end of the function BotFindCachedCharacter
|
Here is the call graph for this function:

|
|
Definition at line 169 of file be_ai_char.c. References BotFreeCharacter2(), and LibVarGetValue(). 00170 {
00171 if (!LibVarGetValue("bot_reloadcharacters")) return;
00172 BotFreeCharacter2(handle);
00173 } //end of the function BotFreeCharacter
|
Here is the call graph for this function:

|
|
Definition at line 147 of file be_ai_char.c. References botcharacters, BotFreeCharacterStrings(), botimport, FreeMemory(), and PRT_FATAL. Referenced by BotFreeCharacter(), and BotShutdownCharacters(). 00148 {
00149 if (handle <= 0 || handle > MAX_CLIENTS)
00150 {
00151 botimport.Print(PRT_FATAL, "character handle %d out of range\n", handle);
00152 return;
00153 } //end if
00154 if (!botcharacters[handle])
00155 {
00156 botimport.Print(PRT_FATAL, "invalid character %d\n", handle);
00157 return;
00158 } //end if
00159 BotFreeCharacterStrings(botcharacters[handle]);
00160 FreeMemory(botcharacters[handle]);
00161 botcharacters[handle] = NULL;
00162 } //end of the function BotFreeCharacter2
|
Here is the call graph for this function:

|
|
Definition at line 129 of file be_ai_char.c. References bot_character_t, bot_character_s::c, ch, FreeMemory(), i, cvalue::string, bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by BotFreeCharacter2(), and BotLoadCharacterFromFile(). 00130 {
00131 int i;
00132
00133 for (i = 0; i < MAX_CHARACTERISTICS; i++)
00134 {
00135 if (ch->c[i].type == CT_STRING)
00136 {
00137 FreeMemory(ch->c[i].value.string);
00138 } //end if
00139 } //end for
00140 } //end of the function BotFreeCharacterStrings
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 516 of file be_ai_char.c. References cvalue::_float, bot_character_t, bot_characteristic_t, BotCharacterFromHandle(), botcharacters, bot_character_s::c, CT_FLOAT, bot_character_s::filename, GetClearedMemory(), GetMemory(), i, cvalue::integer, MAX_CHARACTERISTICS, bot_character_s::skill, strcpy(), cvalue::string, strlen(), bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by BotLoadCharacter(). 00517 {
00518 bot_character_t *ch1, *ch2, *out;
00519 int i, handle;
00520 float scale;
00521
00522 ch1 = BotCharacterFromHandle(handle1);
00523 ch2 = BotCharacterFromHandle(handle2);
00524 if (!ch1 || !ch2)
00525 return 0;
00526 //find a free spot for a character
00527 for (handle = 1; handle <= MAX_CLIENTS; handle++)
00528 {
00529 if (!botcharacters[handle]) break;
00530 } //end for
00531 if (handle > MAX_CLIENTS) return 0;
00532 out = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) +
00533 MAX_CHARACTERISTICS * sizeof(bot_characteristic_t));
00534 out->skill = desiredskill;
00535 strcpy(out->filename, ch1->filename);
00536 botcharacters[handle] = out;
00537
00538 scale = (float) (desiredskill - ch1->skill) / (ch2->skill - ch1->skill);
00539 for (i = 0; i < MAX_CHARACTERISTICS; i++)
00540 {
00541 //
00542 if (ch1->c[i].type == CT_FLOAT && ch2->c[i].type == CT_FLOAT)
00543 {
00544 out->c[i].type = CT_FLOAT;
00545 out->c[i].value._float = ch1->c[i].value._float +
00546 (ch2->c[i].value._float - ch1->c[i].value._float) * scale;
00547 } //end if
00548 else if (ch1->c[i].type == CT_INTEGER)
00549 {
00550 out->c[i].type = CT_INTEGER;
00551 out->c[i].value.integer = ch1->c[i].value.integer;
00552 } //end else if
00553 else if (ch1->c[i].type == CT_STRING)
00554 {
00555 out->c[i].type = CT_STRING;
00556 out->c[i].value.string = (char *) GetMemory(strlen(ch1->c[i].value.string)+1);
00557 strcpy(out->c[i].value.string, ch1->c[i].value.string);
00558 } //end else if
00559 } //end for
00560 return handle;
00561 } //end of the function BotInterpolateCharacters
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 383 of file be_ai_char.c. References bot_character_t, botcharacters, BotFindCachedCharacter(), botimport, BotLoadCharacterFromFile(), ch, DEFAULT_CHARACTER, PRT_MESSAGE, PRT_WARNING, bot_character_s::skill, and Sys_MilliSeconds(). Referenced by BotLoadCharacterSkill(). 00384 {
00385 int handle, cachedhandle, intskill;
00386 bot_character_t *ch = NULL;
00387 #ifdef DEBUG
00388 int starttime;
00389
00390 starttime = Sys_MilliSeconds();
00391 #endif //DEBUG
00392
00393 //find a free spot for a character
00394 for (handle = 1; handle <= MAX_CLIENTS; handle++)
00395 {
00396 if (!botcharacters[handle]) break;
00397 } //end for
00398 if (handle > MAX_CLIENTS) return 0;
00399 //try to load a cached character with the given skill
00400 if (!reload)
00401 {
00402 cachedhandle = BotFindCachedCharacter(charfile, skill);
00403 if (cachedhandle)
00404 {
00405 botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", skill, charfile);
00406 return cachedhandle;
00407 } //end if
00408 } //end else
00409 //
00410 intskill = (int) (skill + 0.5);
00411 //try to load the character with the given skill
00412 ch = BotLoadCharacterFromFile(charfile, intskill);
00413 if (ch)
00414 {
00415 botcharacters[handle] = ch;
00416 //
00417 botimport.Print(PRT_MESSAGE, "loaded skill %d from %s\n", intskill, charfile);
00418 #ifdef DEBUG
00419 if (bot_developer)
00420 {
00421 botimport.Print(PRT_MESSAGE, "skill %d loaded in %d msec from %s\n", intskill, Sys_MilliSeconds() - starttime, charfile);
00422 } //end if
00423 #endif //DEBUG
00424 return handle;
00425 } //end if
00426 //
00427 botimport.Print(PRT_WARNING, "couldn't find skill %d in %s\n", intskill, charfile);
00428 //
00429 if (!reload)
00430 {
00431 //try to load a cached default character with the given skill
00432 cachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, skill);
00433 if (cachedhandle)
00434 {
00435 botimport.Print(PRT_MESSAGE, "loaded cached default skill %d from %s\n", intskill, charfile);
00436 return cachedhandle;
00437 } //end if
00438 } //end if
00439 //try to load the default character with the given skill
00440 ch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, intskill);
00441 if (ch)
00442 {
00443 botcharacters[handle] = ch;
00444 botimport.Print(PRT_MESSAGE, "loaded default skill %d from %s\n", intskill, charfile);
00445 return handle;
00446 } //end if
00447 //
00448 if (!reload)
00449 {
00450 //try to load a cached character with any skill
00451 cachedhandle = BotFindCachedCharacter(charfile, -1);
00452 if (cachedhandle)
00453 {
00454 botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", botcharacters[cachedhandle]->skill, charfile);
00455 return cachedhandle;
00456 } //end if
00457 } //end if
00458 //try to load a character with any skill
00459 ch = BotLoadCharacterFromFile(charfile, -1);
00460 if (ch)
00461 {
00462 botcharacters[handle] = ch;
00463 botimport.Print(PRT_MESSAGE, "loaded skill %f from %s\n", ch->skill, charfile);
00464 return handle;
00465 } //end if
00466 //
00467 if (!reload)
00468 {
00469 //try to load a cached character with any skill
00470 cachedhandle = BotFindCachedCharacter(DEFAULT_CHARACTER, -1);
00471 if (cachedhandle)
00472 {
00473 botimport.Print(PRT_MESSAGE, "loaded cached default skill %f from %s\n", botcharacters[cachedhandle]->skill, charfile);
00474 return cachedhandle;
00475 } //end if
00476 } //end if
00477 //try to load a character with any skill
00478 ch = BotLoadCharacterFromFile(DEFAULT_CHARACTER, -1);
00479 if (ch)
00480 {
00481 botcharacters[handle] = ch;
00482 botimport.Print(PRT_MESSAGE, "loaded default skill %f from %s\n", ch->skill, charfile);
00483 return handle;
00484 } //end if
00485 //
00486 botimport.Print(PRT_WARNING, "couldn't load any skill from %s\n", charfile);
00487 //couldn't load any character
00488 return 0;
00489 } //end of the function BotLoadCachedCharacter
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 568 of file be_ai_char.c. References botcharacters, BotDumpCharacter(), BotFindCachedCharacter(), botimport, BotInterpolateCharacters(), BotLoadCharacterSkill(), and PRT_MESSAGE. 00569 {
00570 int firstskill, secondskill, handle;
00571
00572 //make sure the skill is in the valid range
00573 if (skill < 1.0) skill = 1.0;
00574 else if (skill > 5.0) skill = 5.0;
00575 //skill 1, 4 and 5 should be available in the character files
00576 if (skill == 1.0 || skill == 4.0 || skill == 5.0)
00577 {
00578 return BotLoadCharacterSkill(charfile, skill);
00579 } //end if
00580 //check if there's a cached skill
00581 handle = BotFindCachedCharacter(charfile, skill);
00582 if (handle)
00583 {
00584 botimport.Print(PRT_MESSAGE, "loaded cached skill %f from %s\n", skill, charfile);
00585 return handle;
00586 } //end if
00587 if (skill < 4.0)
00588 {
00589 //load skill 1 and 4
00590 firstskill = BotLoadCharacterSkill(charfile, 1);
00591 if (!firstskill) return 0;
00592 secondskill = BotLoadCharacterSkill(charfile, 4);
00593 if (!secondskill) return firstskill;
00594 } //end if
00595 else
00596 {
00597 //load skill 4 and 5
00598 firstskill = BotLoadCharacterSkill(charfile, 4);
00599 if (!firstskill) return 0;
00600 secondskill = BotLoadCharacterSkill(charfile, 5);
00601 if (!secondskill) return firstskill;
00602 } //end else
00603 //interpolate between the two skills
00604 handle = BotInterpolateCharacters(firstskill, secondskill, skill);
00605 if (!handle) return 0;
00606 //write the character to the log file
00607 BotDumpCharacter(botcharacters[handle]);
00608 //
00609 return handle;
00610 } //end of the function BotLoadCharacter
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 212 of file be_ai_char.c. References cvalue::_float, bot_character_t, bot_characteristic_t, BOTFILESBASEFOLDER, BotFreeCharacterStrings(), botimport, bot_character_s::c, ch, bot_character_s::filename, token_s::floatvalue, FreeMemory(), FreeSource(), GetClearedMemory(), GetMemory(), cvalue::integer, token_s::intvalue, LoadSourceFile(), MAX_CHARACTERISTICS, PC_ExpectAnyToken(), PC_ExpectTokenString(), PC_ExpectTokenType(), PC_ReadToken(), PC_SetBaseFolder(), PRT_ERROR, bot_character_s::skill, source, source_t, SourceError(), strcmp(), strcpy(), cvalue::string, token_s::string, StripDoubleQuotes(), strlen(), token_s::subtype, token, token_t, TT_NUMBER, bot_characteristic_s::type, token_s::type, and bot_characteristic_s::value. Referenced by BotLoadCachedCharacter(). 00213 {
00214 int indent, index, foundcharacter;
00215 bot_character_t *ch;
00216 source_t *source;
00217 token_t token;
00218
00219 foundcharacter = qfalse;
00220 //a bot character is parsed in two phases
00221 PC_SetBaseFolder(BOTFILESBASEFOLDER);
00222 source = LoadSourceFile(charfile);
00223 if (!source)
00224 {
00225 botimport.Print(PRT_ERROR, "counldn't load %s\n", charfile);
00226 return NULL;
00227 } //end if
00228 ch = (bot_character_t *) GetClearedMemory(sizeof(bot_character_t) +
00229 MAX_CHARACTERISTICS * sizeof(bot_characteristic_t));
00230 strcpy(ch->filename, charfile);
00231 while(PC_ReadToken(source, &token))
00232 {
00233 if (!strcmp(token.string, "skill"))
00234 {
00235 if (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token))
00236 {
00237 FreeSource(source);
00238 BotFreeCharacterStrings(ch);
00239 FreeMemory(ch);
00240 return NULL;
00241 } //end if
00242 if (!PC_ExpectTokenString(source, "{"))
00243 {
00244 FreeSource(source);
00245 BotFreeCharacterStrings(ch);
00246 FreeMemory(ch);
00247 return NULL;
00248 } //end if
00249 //if it's the correct skill
00250 if (skill < 0 || token.intvalue == skill)
00251 {
00252 foundcharacter = qtrue;
00253 ch->skill = token.intvalue;
00254 while(PC_ExpectAnyToken(source, &token))
00255 {
00256 if (!strcmp(token.string, "}")) break;
00257 if (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER))
00258 {
00259 SourceError(source, "expected integer index, found %s\n", token.string);
00260 FreeSource(source);
00261 BotFreeCharacterStrings(ch);
00262 FreeMemory(ch);
00263 return NULL;
00264 } //end if
00265 index = token.intvalue;
00266 if (index < 0 || index > MAX_CHARACTERISTICS)
00267 {
00268 SourceError(source, "characteristic index out of range [0, %d]\n", MAX_CHARACTERISTICS);
00269 FreeSource(source);
00270 BotFreeCharacterStrings(ch);
00271 FreeMemory(ch);
00272 return NULL;
00273 } //end if
00274 if (ch->c[index].type)
00275 {
00276 SourceError(source, "characteristic %d already initialized\n", index);
00277 FreeSource(source);
00278 BotFreeCharacterStrings(ch);
00279 FreeMemory(ch);
00280 return NULL;
00281 } //end if
00282 if (!PC_ExpectAnyToken(source, &token))
00283 {
00284 FreeSource(source);
00285 BotFreeCharacterStrings(ch);
00286 FreeMemory(ch);
00287 return NULL;
00288 } //end if
00289 if (token.type == TT_NUMBER)
00290 {
00291 if (token.subtype & TT_FLOAT)
00292 {
00293 ch->c[index].value._float = token.floatvalue;
00294 ch->c[index].type = CT_FLOAT;
00295 } //end if
00296 else
00297 {
00298 ch->c[index].value.integer = token.intvalue;
00299 ch->c[index].type = CT_INTEGER;
00300 } //end else
00301 } //end if
00302 else if (token.type == TT_STRING)
00303 {
00304 StripDoubleQuotes(token.string);
00305 ch->c[index].value.string = GetMemory(strlen(token.string)+1);
00306 strcpy(ch->c[index].value.string, token.string);
00307 ch->c[index].type = CT_STRING;
00308 } //end else if
00309 else
00310 {
00311 SourceError(source, "expected integer, float or string, found %s\n", token.string);
00312 FreeSource(source);
00313 BotFreeCharacterStrings(ch);
00314 FreeMemory(ch);
00315 return NULL;
00316 } //end else
00317 } //end if
00318 break;
00319 } //end if
00320 else
00321 {
00322 indent = 1;
00323 while(indent)
00324 {
00325 if (!PC_ExpectAnyToken(source, &token))
00326 {
00327 FreeSource(source);
00328 BotFreeCharacterStrings(ch);
00329 FreeMemory(ch);
00330 return NULL;
00331 } //end if
00332 if (!strcmp(token.string, "{")) indent++;
00333 else if (!strcmp(token.string, "}")) indent--;
00334 } //end while
00335 } //end else
00336 } //end if
00337 else
00338 {
00339 SourceError(source, "unknown definition %s\n", token.string);
00340 FreeSource(source);
00341 BotFreeCharacterStrings(ch);
00342 FreeMemory(ch);
00343 return NULL;
00344 } //end else
00345 } //end while
00346 FreeSource(source);
00347 //
00348 if (!foundcharacter)
00349 {
00350 BotFreeCharacterStrings(ch);
00351 FreeMemory(ch);
00352 return NULL;
00353 } //end if
00354 return ch;
00355 } //end of the function BotLoadCharacterFromFile
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 496 of file be_ai_char.c. References botcharacters, BotDefaultCharacteristics(), BotLoadCachedCharacter(), ch, DEFAULT_CHARACTER, LibVarGetValue(), and qfalse. Referenced by BotLoadCharacter(). 00497 {
00498 int ch, defaultch;
00499
00500 defaultch = BotLoadCachedCharacter(DEFAULT_CHARACTER, skill, qfalse);
00501 ch = BotLoadCachedCharacter(charfile, skill, LibVarGetValue("bot_reloadcharacters"));
00502
00503 if (defaultch && ch)
00504 {
00505 BotDefaultCharacteristics(botcharacters[ch], botcharacters[defaultch]);
00506 } //end if
00507
00508 return ch;
00509 } //end of the function BotLoadCharacterSkill
|
Here is the call graph for this function:

|
|
Definition at line 778 of file be_ai_char.c. References botcharacters, and BotFreeCharacter2(). Referenced by Export_BotLibShutdown(). 00779 {
00780 int handle;
00781
00782 for (handle = 1; handle <= MAX_CLIENTS; handle++)
00783 {
00784 if (botcharacters[handle])
00785 {
00786 BotFreeCharacter2(handle);
00787 } //end if
00788 } //end for
00789 } //end of the function BotShutdownCharacters
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 673 of file be_ai_char.c. References bot_character_t, BotCharacterFromHandle(), botimport, ch, Characteristic_Float(), max, min, PRT_ERROR, and value. 00674 {
00675 float value;
00676 bot_character_t *ch;
00677
00678 ch = BotCharacterFromHandle(character);
00679 if (!ch) return 0;
00680 if (min > max)
00681 {
00682 botimport.Print(PRT_ERROR, "cannot bound characteristic %d between %f and %f\n", index, min, max);
00683 return 0;
00684 } //end if
00685 value = Characteristic_Float(character, index);
00686 if (value < min) return min;
00687 if (value > max) return max;
00688 return value;
00689 } //end of the function Characteristic_BFloat
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 727 of file be_ai_char.c. References bot_character_t, BotCharacterFromHandle(), botimport, ch, Characteristic_Integer(), max, min, PRT_ERROR, and value. 00728 {
00729 int value;
00730 bot_character_t *ch;
00731
00732 ch = BotCharacterFromHandle(character);
00733 if (!ch) return 0;
00734 if (min > max)
00735 {
00736 botimport.Print(PRT_ERROR, "cannot bound characteristic %d between %d and %d\n", index, min, max);
00737 return 0;
00738 } //end if
00739 value = Characteristic_Integer(character, index);
00740 if (value < min) return min;
00741 if (value > max) return max;
00742 return value;
00743 } //end of the function Characteristic_BInteger
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 641 of file be_ai_char.c. References cvalue::_float, bot_character_t, BotCharacterFromHandle(), botimport, bot_character_s::c, ch, CheckCharacteristicIndex(), cvalue::integer, PRT_ERROR, bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by Characteristic_BFloat(). 00642 {
00643 bot_character_t *ch;
00644
00645 ch = BotCharacterFromHandle(character);
00646 if (!ch) return 0;
00647 //check if the index is in range
00648 if (!CheckCharacteristicIndex(character, index)) return 0;
00649 //an integer will be converted to a float
00650 if (ch->c[index].type == CT_INTEGER)
00651 {
00652 return (float) ch->c[index].value.integer;
00653 } //end if
00654 //floats are just returned
00655 else if (ch->c[index].type == CT_FLOAT)
00656 {
00657 return ch->c[index].value._float;
00658 } //end else if
00659 //cannot convert a string pointer to a float
00660 else
00661 {
00662 botimport.Print(PRT_ERROR, "characteristic %d is not a float\n", index);
00663 return 0;
00664 } //end else if
00665 // return 0;
00666 } //end of the function Characteristic_Float
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 696 of file be_ai_char.c. References cvalue::_float, bot_character_t, BotCharacterFromHandle(), botimport, bot_character_s::c, ch, CheckCharacteristicIndex(), cvalue::integer, PRT_ERROR, bot_characteristic_s::type, and bot_characteristic_s::value. Referenced by Characteristic_BInteger(). 00697 {
00698 bot_character_t *ch;
00699
00700 ch = BotCharacterFromHandle(character);
00701 if (!ch) return 0;
00702 //check if the index is in range
00703 if (!CheckCharacteristicIndex(character, index)) return 0;
00704 //an integer will just be returned
00705 if (ch->c[index].type == CT_INTEGER)
00706 {
00707 return ch->c[index].value.integer;
00708 } //end if
00709 //floats are casted to integers
00710 else if (ch->c[index].type == CT_FLOAT)
00711 {
00712 return (int) ch->c[index].value._float;
00713 } //end else if
00714 else
00715 {
00716 botimport.Print(PRT_ERROR, "characteristic %d is not a integer\n", index);
00717 return 0;
00718 } //end else if
00719 // return 0;
00720 } //end of the function Characteristic_Integer
|
Here is the call graph for this function:
