Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

be_ai_weap.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  projectileinfo_s
struct  weaponinfo_s

Defines

#define DAMAGETYPE_IMPACT   1
#define DAMAGETYPE_RADIAL   2
#define DAMAGETYPE_VISIBLE   4
#define PFL_RETURN   2
#define PFL_WINDOWDAMAGE   1
#define WFL_FIRERELEASED   1

Typedefs

typedef projectileinfo_s projectileinfo_t
typedef weaponinfo_s weaponinfo_t

Functions

int BotAllocWeaponState (void)
int BotChooseBestFightWeapon (int weaponstate, int *inventory)
void BotFreeWeaponState (int weaponstate)
void BotGetWeaponInfo (int weaponstate, int weapon, weaponinfo_t *weaponinfo)
int BotLoadWeaponWeights (int weaponstate, char *filename)
void BotResetWeaponState (int weaponstate)
int BotSetupWeaponAI (void)
void BotShutdownWeaponAI (void)


Define Documentation

#define DAMAGETYPE_IMPACT   1
 

Definition at line 39 of file be_ai_weap.h.

#define DAMAGETYPE_RADIAL   2
 

Definition at line 40 of file be_ai_weap.h.

#define DAMAGETYPE_VISIBLE   4
 

Definition at line 41 of file be_ai_weap.h.

#define PFL_RETURN   2
 

Definition at line 35 of file be_ai_weap.h.

#define PFL_WINDOWDAMAGE   1
 

Definition at line 34 of file be_ai_weap.h.

#define WFL_FIRERELEASED   1
 

Definition at line 37 of file be_ai_weap.h.


Typedef Documentation

typedef struct projectileinfo_s projectileinfo_t
 

Referenced by LoadWeaponConfig().

typedef struct weaponinfo_s weaponinfo_t
 

Referenced by BotAimAtEnemy(), BotCheckAttack(), BotGetWeaponInfo(), and LoadWeaponConfig().


Function Documentation

int BotAllocWeaponState void   ) 
 

Definition at line 462 of file be_ai_weap.c.

References bot_weaponstate_t, botweaponstates, GetClearedMemory(), and i.

00463 {
00464     int i;
00465 
00466     for (i = 1; i <= MAX_CLIENTS; i++)
00467     {
00468         if (!botweaponstates[i])
00469         {
00470             botweaponstates[i] = GetClearedMemory(sizeof(bot_weaponstate_t));
00471             return i;
00472         } //end if
00473     } //end for
00474     return 0;
00475 } //end of the function BotAllocWeaponState

Here is the call graph for this function:

int BotChooseBestFightWeapon int  weaponstate,
int *  inventory
 

Definition at line 404 of file be_ai_weap.c.

References bot_weaponstate_t, BotWeaponStateFromHandle(), FuzzyWeight(), i, weaponconfig_s::numweapons, weaponinfo_s::valid, weaponconfig_t, weaponconfig_s::weaponinfo, bot_weaponstate_s::weaponweightconfig, and bot_weaponstate_s::weaponweightindex.

00405 {
00406     int i, index, bestweapon;
00407     float weight, bestweight;
00408     weaponconfig_t *wc;
00409     bot_weaponstate_t *ws;
00410 
00411     ws = BotWeaponStateFromHandle(weaponstate);
00412     if (!ws) return 0;
00413     wc = weaponconfig;
00414     if (!weaponconfig) return 0;
00415 
00416     //if the bot has no weapon weight configuration
00417     if (!ws->weaponweightconfig) return 0;
00418 
00419     bestweight = 0;
00420     bestweapon = 0;
00421     for (i = 0; i < wc->numweapons; i++)
00422     {
00423         if (!wc->weaponinfo[i].valid) continue;
00424         index = ws->weaponweightindex[i];
00425         if (index < 0) continue;
00426         weight = FuzzyWeight(inventory, ws->weaponweightconfig, index);
00427         if (weight > bestweight)
00428         {
00429             bestweight = weight;
00430             bestweapon = i;
00431         } //end if
00432     } //end for
00433     return bestweapon;
00434 } //end of the function BotChooseBestFightWeapon

Here is the call graph for this function:

void BotFreeWeaponState int  weaponstate  ) 
 

Definition at line 482 of file be_ai_weap.c.

References BotFreeWeaponWeights(), botimport, botweaponstates, FreeMemory(), and PRT_FATAL.

Referenced by BotShutdownWeaponAI().

00483 {
00484     if (handle <= 0 || handle > MAX_CLIENTS)
00485     {
00486         botimport.Print(PRT_FATAL, "move state handle %d out of range\n", handle);
00487         return;
00488     } //end if
00489     if (!botweaponstates[handle])
00490     {
00491         botimport.Print(PRT_FATAL, "invalid move state %d\n", handle);
00492         return;
00493     } //end if
00494     BotFreeWeaponWeights(handle);
00495     FreeMemory(botweaponstates[handle]);
00496     botweaponstates[handle] = NULL;
00497 } //end of the function BotFreeWeaponState

Here is the call graph for this function:

void BotGetWeaponInfo int  weaponstate,
int  weapon,
weaponinfo_t weaponinfo
 

Definition at line 388 of file be_ai_weap.c.

References bot_weaponstate_t, BotValidWeaponNumber(), BotWeaponStateFromHandle(), Com_Memcpy(), weaponconfig, weaponconfig_s::weaponinfo, and weaponinfo_t.

00389 {
00390     bot_weaponstate_t *ws;
00391 
00392     if (!BotValidWeaponNumber(weapon)) return;
00393     ws = BotWeaponStateFromHandle(weaponstate);
00394     if (!ws) return;
00395     if (!weaponconfig) return;
00396     Com_Memcpy(weaponinfo, &weaponconfig->weaponinfo[weapon], sizeof(weaponinfo_t));
00397 } //end of the function BotGetWeaponInfo

Here is the call graph for this function:

int BotLoadWeaponWeights int  weaponstate,
char *  filename
 

Definition at line 364 of file be_ai_weap.c.

References bot_weaponstate_t, BotFreeWeaponWeights(), botimport, BotWeaponStateFromHandle(), PRT_FATAL, ReadWeightConfig(), weaponconfig, bot_weaponstate_s::weaponweightconfig, WeaponWeightIndex(), and bot_weaponstate_s::weaponweightindex.

00365 {
00366     bot_weaponstate_t *ws;
00367 
00368     ws = BotWeaponStateFromHandle(weaponstate);
00369     if (!ws) return BLERR_CANNOTLOADWEAPONWEIGHTS;
00370     BotFreeWeaponWeights(weaponstate);
00371     //
00372     ws->weaponweightconfig = ReadWeightConfig(filename);
00373     if (!ws->weaponweightconfig)
00374     {
00375         botimport.Print(PRT_FATAL, "couldn't load weapon config %s\n", filename);
00376         return BLERR_CANNOTLOADWEAPONWEIGHTS;
00377     } //end if
00378     if (!weaponconfig) return BLERR_CANNOTLOADWEAPONCONFIG;
00379     ws->weaponweightindex = WeaponWeightIndex(ws->weaponweightconfig, weaponconfig);
00380     return BLERR_NOERROR;
00381 } //end of the function BotLoadWeaponWeights

Here is the call graph for this function:

void BotResetWeaponState int  weaponstate  ) 
 

Definition at line 441 of file be_ai_weap.c.

References bot_weaponstate_t, BotWeaponStateFromHandle(), bot_weaponstate_s::weaponweightconfig, and bot_weaponstate_s::weaponweightindex.

00442 {
00443     struct weightconfig_s *weaponweightconfig;
00444     int *weaponweightindex;
00445     bot_weaponstate_t *ws;
00446 
00447     ws = BotWeaponStateFromHandle(weaponstate);
00448     if (!ws) return;
00449     weaponweightconfig = ws->weaponweightconfig;
00450     weaponweightindex = ws->weaponweightindex;
00451 
00452     //Com_Memset(ws, 0, sizeof(bot_weaponstate_t));
00453     ws->weaponweightconfig = weaponweightconfig;
00454     ws->weaponweightindex = weaponweightindex;
00455 } //end of the function BotResetWeaponState

Here is the call graph for this function:

int BotSetupWeaponAI void   ) 
 

Definition at line 504 of file be_ai_weap.c.

References botimport, file, LibVarString(), LoadWeaponConfig(), PRT_FATAL, and weaponconfig.

Referenced by Export_BotLibSetup().

00505 {
00506     char *file;
00507 
00508     file = LibVarString("weaponconfig", "weapons.c");
00509     weaponconfig = LoadWeaponConfig(file);
00510     if (!weaponconfig)
00511     {
00512         botimport.Print(PRT_FATAL, "couldn't load the weapon config\n");
00513         return BLERR_CANNOTLOADWEAPONCONFIG;
00514     } //end if
00515 
00516 #ifdef DEBUG_AI_WEAP
00517     DumpWeaponConfig(weaponconfig);
00518 #endif //DEBUG_AI_WEAP
00519     //
00520     return BLERR_NOERROR;
00521 } //end of the function BotSetupWeaponAI

Here is the call graph for this function:

void BotShutdownWeaponAI void   ) 
 

Definition at line 528 of file be_ai_weap.c.

References BotFreeWeaponState(), botweaponstates, FreeMemory(), i, and weaponconfig.

Referenced by Export_BotLibShutdown().

00529 {
00530     int i;
00531 
00532     if (weaponconfig) FreeMemory(weaponconfig);
00533     weaponconfig = NULL;
00534 
00535     for (i = 1; i <= MAX_CLIENTS; i++)
00536     {
00537         if (botweaponstates[i])
00538         {
00539             BotFreeWeaponState(i);
00540         } //end if
00541     } //end for
00542 } //end of the function BotShutdownWeaponAI

Here is the call graph for this function:


Generated on Thu Aug 25 13:46:21 2005 for Quake III Arena by  doxygen 1.3.9.1