codemp/game/ai_main.h File Reference

#include "bg_saga.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Data Structures

struct  bot_state_s
struct  botattachment_s
struct  boteventtracker_s
struct  botskills_s
struct  nodeobject_s

Defines

#define DEFAULT_FORCEPOWERS   "5-1-000000000000000000"
#define MAX_CHAT_BUFFER_SIZE   8192
#define MAX_CHAT_LINE_SIZE   128
#define TABLE_BRANCH_DISTANCE   32
#define MAX_NODETABLE_SIZE   16384
#define MAX_LOVED_ONES   4
#define MAX_ATTACHMENT_NAME   64
#define MAX_FORCE_INFO_SIZE   2048
#define WPFLAG_JUMP   0x00000010
#define WPFLAG_DUCK   0x00000020
#define WPFLAG_NOVIS   0x00000400
#define WPFLAG_SNIPEORCAMPSTAND   0x00000800
#define WPFLAG_WAITFORFUNC   0x00001000
#define WPFLAG_SNIPEORCAMP   0x00002000
#define WPFLAG_ONEWAY_FWD   0x00004000
#define WPFLAG_ONEWAY_BACK   0x00008000
#define WPFLAG_GOALPOINT   0x00010000
#define WPFLAG_RED_FLAG   0x00020000
#define WPFLAG_BLUE_FLAG   0x00040000
#define WPFLAG_SIEGE_REBELOBJ   0x00080000
#define WPFLAG_SIEGE_IMPERIALOBJ   0x00100000
#define WPFLAG_NOMOVEFUNC   0x00200000
#define WPFLAG_CALCULATED   0x00400000
#define WPFLAG_NEVERONEWAY   0x00800000
#define LEVELFLAG_NOPOINTPREDICTION   1
#define LEVELFLAG_IGNOREINFALLBACK   2
#define LEVELFLAG_IMUSTNTRUNAWAY   4
#define WP_KEEP_FLAG_DIST   128
#define BWEAPONRANGE_MELEE   1
#define BWEAPONRANGE_MID   2
#define BWEAPONRANGE_LONG   3
#define BWEAPONRANGE_SABER   4
#define MELEE_ATTACK_RANGE   256
#define SABER_ATTACK_RANGE   128
#define MAX_CHICKENWUSS_TIME   10000
#define BOT_RUN_HEALTH   40
#define BOT_WPTOUCH_DISTANCE   32
#define ENEMY_FORGET_MS   10000
#define BOT_PLANT_DISTANCE   256
#define BOT_PLANT_INTERVAL   15000
#define BOT_PLANT_BLOW_DISTANCE   256
#define BOT_MAX_WEAPON_GATHER_TIME   1000
#define BOT_MAX_WEAPON_CHASE_TIME   15000
#define BOT_MAX_WEAPON_CHASE_CTF   5000
#define BOT_MIN_SIEGE_GOAL_SHOOT   1024
#define BOT_MIN_SIEGE_GOAL_TRAVEL   128
#define BASE_GUARD_DISTANCE   256
#define BASE_FLAGWAIT_DISTANCE   256
#define BASE_GETENEMYFLAG_DISTANCE   256
#define BOT_FLAG_GET_DISTANCE   256
#define BOT_SABER_THROW_RANGE   800
#define FloatTime()   floattime

Typedefs

typedef botattachment_s botattachment_t
typedef nodeobject_s nodeobject_t
typedef boteventtracker_s boteventtracker_t
typedef botskills_s botskills_t
typedef bot_state_s bot_state_t

Enumerations

enum  bot_ctf_state_t {
  CTFSTATE_NONE, CTFSTATE_ATTACKER, CTFSTATE_DEFENDER, CTFSTATE_RETRIEVAL,
  CTFSTATE_GUARDCARRIER, CTFSTATE_GETFLAGHOME, CTFSTATE_MAXCTFSTATES
}
enum  bot_siege_state_t { SIEGESTATE_NONE, SIEGESTATE_ATTACKER, SIEGESTATE_DEFENDER, SIEGESTATE_MAXSIEGESTATES }
enum  bot_teamplay_state_t {
  TEAMPLAYSTATE_NONE, TEAMPLAYSTATE_FOLLOWING, TEAMPLAYSTATE_ASSISTING, TEAMPLAYSTATE_REGROUP,
  TEAMPLAYSTATE_MAXTPSTATES
}

Functions

void * B_TempAlloc (int size)
void B_TempFree (int size)
void * B_Alloc (int size)
void B_Free (void *ptr)
void BotResetState (bot_state_t *bs)
int NumBots (void)
void BotUtilizePersonality (bot_state_t *bs)
int BotDoChat (bot_state_t *bs, char *section, int always)
void StandardBotAI (bot_state_t *bs, float thinktime)
void BotWaypointRender (void)
int OrgVisibleBox (vec3_t org1, vec3_t mins, vec3_t maxs, vec3_t org2, int ignore)
int BotIsAChickenWuss (bot_state_t *bs)
int GetNearestVisibleWP (vec3_t org, int ignore)
int GetBestIdleGoal (bot_state_t *bs)
char * ConcatArgs (int start)

Variables

vmCvar_t bot_forcepowers
vmCvar_t bot_forgimmick
vmCvar_t bot_honorableduelacceptance
vmCvar_t bot_attachments
vmCvar_t bot_camp
vmCvar_t bot_wp_info
vmCvar_t bot_wp_edit
vmCvar_t bot_wp_clearweight
vmCvar_t bot_wp_distconnect
vmCvar_t bot_wp_visconnect
wpobject_tflagRed
wpobject_toFlagRed
wpobject_tflagBlue
wpobject_toFlagBlue
gentity_teFlagRed
gentity_teFlagBlue
char gBotChatBuffer [MAX_CLIENTS][MAX_CHAT_BUFFER_SIZE]
float gWPRenderTime
float gDeactivated
float gBotEdit
int gWPRenderedFrame
wpobject_tgWPArray [MAX_WPARRAY_SIZE]
int gWPNum
int gLastPrintedIndex
nodeobject_t nodetable [MAX_NODETABLE_SIZE]
int nodenum
int gLevelFlags
float floattime


Define Documentation

#define BASE_FLAGWAIT_DISTANCE   256
 

Definition at line 74 of file ai_main.h.

Referenced by BotGetFlagHome().

#define BASE_GETENEMYFLAG_DISTANCE   256
 

Definition at line 75 of file ai_main.h.

Referenced by BotGetEnemyFlag().

#define BASE_GUARD_DISTANCE   256
 

Definition at line 73 of file ai_main.h.

Referenced by BotDefendFlag().

#define BOT_FLAG_GET_DISTANCE   256
 

Definition at line 77 of file ai_main.h.

Referenced by CTFFlagMovement().

#define BOT_MAX_WEAPON_CHASE_CTF   5000
 

Definition at line 68 of file ai_main.h.

Referenced by CTFTakesPriority().

#define BOT_MAX_WEAPON_CHASE_TIME   15000
 

Definition at line 66 of file ai_main.h.

Referenced by SiegeTakesPriority().

#define BOT_MAX_WEAPON_GATHER_TIME   1000
 

Definition at line 65 of file ai_main.h.

Referenced by CTFTakesPriority(), and SiegeTakesPriority().

#define BOT_MIN_SIEGE_GOAL_SHOOT   1024
 

Definition at line 70 of file ai_main.h.

Referenced by Siege_TargetClosestObjective().

#define BOT_MIN_SIEGE_GOAL_TRAVEL   128
 

Definition at line 71 of file ai_main.h.

Referenced by Siege_TargetClosestObjective().

#define BOT_PLANT_BLOW_DISTANCE   256
 

Definition at line 63 of file ai_main.h.

Referenced by BotCheckDetPacks().

#define BOT_PLANT_DISTANCE   256
 

Definition at line 61 of file ai_main.h.

Referenced by StandardBotAI().

#define BOT_PLANT_INTERVAL   15000
 

Definition at line 62 of file ai_main.h.

Referenced by StandardBotAI().

#define BOT_RUN_HEALTH   40
 

Definition at line 55 of file ai_main.h.

Referenced by BotIsAChickenWuss().

#define BOT_SABER_THROW_RANGE   800
 

Definition at line 79 of file ai_main.h.

Referenced by StandardBotAI().

#define BOT_WPTOUCH_DISTANCE   32
 

Definition at line 56 of file ai_main.h.

Referenced by StandardBotAI().

#define BWEAPONRANGE_LONG   3
 

Definition at line 48 of file ai_main.h.

Referenced by BotGetWeaponRange(), GetIdealDestination(), and StandardBotAI().

#define BWEAPONRANGE_MELEE   1
 

Definition at line 46 of file ai_main.h.

Referenced by BotGetWeaponRange(), BotIsAChickenWuss(), BotTrace_Jump(), CombatBotAI(), GetIdealDestination(), Siege_TargetClosestObjective(), and StandardBotAI().

#define BWEAPONRANGE_MID   2
 

Definition at line 47 of file ai_main.h.

Referenced by BotGetWeaponRange(), GetIdealDestination(), and StandardBotAI().

#define BWEAPONRANGE_SABER   4
 

Definition at line 49 of file ai_main.h.

Referenced by BotGetWeaponRange(), BotIsAChickenWuss(), BotTrace_Jump(), CombatBotAI(), GetIdealDestination(), Siege_TargetClosestObjective(), and StandardBotAI().

#define DEFAULT_FORCEPOWERS   "5-1-000000000000000000"
 

Definition at line 3 of file ai_main.h.

#define ENEMY_FORGET_MS   10000
 

Definition at line 57 of file ai_main.h.

Referenced by BotDamageNotification(), GetNearestBadThing(), and StandardBotAI().

 
#define FloatTime  )     floattime
 

Definition at line 411 of file ai_main.h.

Referenced by BotAIRegularUpdate(), and BotAISetupClient().

#define LEVELFLAG_IGNOREINFALLBACK   2
 

Definition at line 41 of file ai_main.h.

Referenced by PassStandardEnemyChecks().

#define LEVELFLAG_IMUSTNTRUNAWAY   4
 

Definition at line 42 of file ai_main.h.

Referenced by BotIsAChickenWuss().

#define LEVELFLAG_NOPOINTPREDICTION   1
 

Definition at line 40 of file ai_main.h.

Referenced by LoadPath_ThisLevel(), and StandardBotAI().

#define MAX_ATTACHMENT_NAME   64
 

Definition at line 18 of file ai_main.h.

#define MAX_CHAT_BUFFER_SIZE   8192
 

Definition at line 10 of file ai_main.h.

Referenced by BotDoChat(), BotUtilizePersonality(), and ReadChatGroups().

#define MAX_CHAT_LINE_SIZE   128
 

Definition at line 12 of file ai_main.h.

Referenced by BotDoChat().

#define MAX_CHICKENWUSS_TIME   10000
 

Definition at line 53 of file ai_main.h.

Referenced by BotIsAChickenWuss().

#define MAX_FORCE_INFO_SIZE   2048
 

Definition at line 20 of file ai_main.h.

#define MAX_LOVED_ONES   4
 

Definition at line 17 of file ai_main.h.

Referenced by ParseEmotionalAttachments().

#define MAX_NODETABLE_SIZE   16384
 

Definition at line 15 of file ai_main.h.

Referenced by ConnectTrail(), and G_RMGPathing().

#define MELEE_ATTACK_RANGE   256
 

Definition at line 51 of file ai_main.h.

Referenced by CombatBotAI(), and StandardBotAI().

#define SABER_ATTACK_RANGE   128
 

Definition at line 52 of file ai_main.h.

Referenced by CombatBotAI(), and StandardBotAI().

#define TABLE_BRANCH_DISTANCE   32
 

Definition at line 14 of file ai_main.h.

Referenced by ConnectTrail().

#define WP_KEEP_FLAG_DIST   128
 

Definition at line 44 of file ai_main.h.

Referenced by GetNewFlagPoint().

#define WPFLAG_BLUE_FLAG   0x00040000
 

Definition at line 32 of file ai_main.h.

Referenced by CreateNewWP_FromObject(), FlagObjects(), GetFlagStr(), PassWayCheck(), and StandardBotAI().

#define WPFLAG_CALCULATED   0x00400000
 

Definition at line 37 of file ai_main.h.

Referenced by ConnectTrail(), and RepairPaths().

#define WPFLAG_DUCK   0x00000020
 

Definition at line 23 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), and WPConstantRoutine().

#define WPFLAG_GOALPOINT   0x00010000
 

Definition at line 30 of file ai_main.h.

Referenced by AcceptBotCommand(), CalculateWeightGoals(), GetBestIdleGoal(), and GetFlagStr().

#define WPFLAG_JUMP   0x00000010
 

Definition at line 22 of file ai_main.h.

Referenced by AcceptBotCommand(), CalculateJumpRoutes(), GetFlagStr(), RepairPaths(), WPConstantRoutine(), and WPTouchRoutine().

#define WPFLAG_NEVERONEWAY   0x00800000
 

Definition at line 38 of file ai_main.h.

Referenced by ConnectTrail(), and G_RMGPathing().

#define WPFLAG_NOMOVEFUNC   0x00200000
 

Definition at line 35 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), StandardBotAI(), and WPTouchRoutine().

#define WPFLAG_NOVIS   0x00000400
 

Definition at line 24 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), RepairPaths(), and StandardBotAI().

#define WPFLAG_ONEWAY_BACK   0x00008000
 

Definition at line 29 of file ai_main.h.

Referenced by AcceptBotCommand(), ConnectTrail(), GetFlagStr(), OpposingEnds(), PassWayCheck(), and TotalTrailDistance().

#define WPFLAG_ONEWAY_FWD   0x00004000
 

Definition at line 28 of file ai_main.h.

Referenced by AcceptBotCommand(), ConnectTrail(), GetFlagStr(), OpposingEnds(), PassWayCheck(), and TotalTrailDistance().

#define WPFLAG_RED_FLAG   0x00020000
 

Definition at line 31 of file ai_main.h.

Referenced by CreateNewWP_FromObject(), FlagObjects(), GetFlagStr(), PassWayCheck(), and StandardBotAI().

#define WPFLAG_SIEGE_IMPERIALOBJ   0x00100000
 

Definition at line 34 of file ai_main.h.

Referenced by CalculateSiegeGoals(), GetFlagStr(), and SiegeTakesPriority().

#define WPFLAG_SIEGE_REBELOBJ   0x00080000
 

Definition at line 33 of file ai_main.h.

Referenced by CalculateSiegeGoals(), GetFlagStr(), and SiegeTakesPriority().

#define WPFLAG_SNIPEORCAMP   0x00002000
 

Definition at line 27 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), and WPTouchRoutine().

#define WPFLAG_SNIPEORCAMPSTAND   0x00000800
 

Definition at line 25 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), and WPTouchRoutine().

#define WPFLAG_WAITFORFUNC   0x00001000
 

Definition at line 26 of file ai_main.h.

Referenced by AcceptBotCommand(), GetFlagStr(), and StandardBotAI().


Typedef Documentation

typedef struct bot_state_s bot_state_t
 

Referenced by AltFiring(), Bot_SetForcedMovement(), BotAI(), BotAimLeading(), BotAimOffsetGoalAngles(), BotAISetupClient(), BotAIShutdownClient(), BotCanHear(), BotChangeViewAngles(), BotCheckDetPacks(), BotCTFGuardDuty(), BotDamageNotification(), BotDeathNotify(), BotDefendFlag(), BotDoChat(), BotDoTeamplayAI(), BotFallbackNavigation(), BotGetEnemyFlag(), BotGetFlagBack(), BotGetFlagHome(), BotGetWeaponRange(), BotGuardFlagCarrier(), BotHasAssociated(), BotIsAChickenWuss(), BotLovedOneDied(), BotReplyGreetings(), BotReportStatus(), BotResetState(), BotScanForLeader(), BotSelectChoiceWeapon(), BotSelectIdealWeapon(), BotSelectMelee(), BotStraightTPOrderCheck(), BotSurfaceNear(), BotTrace_Duck(), BotTrace_Jump(), BotTrace_Strafe(), BotTryAnotherWeapon(), BotUpdateInput(), BotUseInventoryItem(), BotUtilizePersonality(), BotWeaponCanLead(), BotWeaponSelectable(), CheckForFriendInLOF(), CheckForShorterRoutes(), CombatBotAI(), CommanderBotAI(), CommanderBotCTFAI(), CommanderBotSiegeAI(), CommanderBotTeamplayAI(), CTFFlagMovement(), CTFTakesPriority(), GetBestIdleGoal(), GetIdealDestination(), GetLoveLevel(), GetNearestBadThing(), JMTakesPriority(), KeepAltFromFiring(), KeepPrimFromFiring(), MeleeCombatHandling(), MoveTowardIdealAngles(), ParseEmotionalAttachments(), PassLovedOneCheck(), PassStandardEnemyChecks(), PassWayCheck(), PrimFiring(), ReadChatGroups(), SaberCombatHandling(), ScanForEnemies(), ShouldSecondaryFire(), Siege_CountDefenders(), Siege_CountTeammates(), Siege_DefendFromAttackers(), Siege_TargetClosestObjective(), SiegeTakesPriority(), StandardBotAI(), StrafeTracing(), TotalTrailDistance(), WaitingForNow(), WPConstantRoutine(), and WPTouchRoutine().

typedef struct botattachment_s botattachment_t
 

typedef struct boteventtracker_s boteventtracker_t
 

typedef struct botskills_s botskills_t
 

typedef struct nodeobject_s nodeobject_t
 


Enumeration Type Documentation

enum bot_ctf_state_t
 

Enumeration values:
CTFSTATE_NONE 
CTFSTATE_ATTACKER 
CTFSTATE_DEFENDER 
CTFSTATE_RETRIEVAL 
CTFSTATE_GUARDCARRIER 
CTFSTATE_GETFLAGHOME 
CTFSTATE_MAXCTFSTATES 

Definition at line 81 of file ai_main.h.

enum bot_siege_state_t
 

Enumeration values:
SIEGESTATE_NONE 
SIEGESTATE_ATTACKER 
SIEGESTATE_DEFENDER 
SIEGESTATE_MAXSIEGESTATES 

Definition at line 92 of file ai_main.h.

enum bot_teamplay_state_t
 

Enumeration values:
TEAMPLAYSTATE_NONE 
TEAMPLAYSTATE_FOLLOWING 
TEAMPLAYSTATE_ASSISTING 
TEAMPLAYSTATE_REGROUP 
TEAMPLAYSTATE_MAXTPSTATES 

Definition at line 100 of file ai_main.h.


Function Documentation

void* B_Alloc int  size  ) 
 

Definition at line 25 of file ai_util.c.

References BG_Alloc(), G_Printf(), and NULL.

Referenced by BotAISetupClient(), CreateNewWP(), CreateNewWP_FromObject(), CreateNewWP_InsertUnder(), CreateNewWP_InTrail(), and TransferWPData().

00026 {
00027 #ifdef BOT_ZMALLOC
00028         void *ptr = NULL;
00029         int i = 0;
00030 
00031 #ifdef BOTMEMTRACK
00032         int free = 0;
00033         int used = 0;
00034 
00035         while (i < MAX_BALLOC)
00036         {
00037                 if (!BAllocList[i])
00038                 {
00039                         free++;
00040                 }
00041                 else
00042                 {
00043                         used++;
00044                 }
00045 
00046                 i++;
00047         }
00048 
00049         G_Printf("Allocations used: %i\nFree allocation slots: %i\n", used, free);
00050 
00051         i = 0;
00052 #endif
00053 
00054         ptr = trap_BotGetMemoryGame(size);
00055 
00056         while (i < MAX_BALLOC)
00057         {
00058                 if (!BAllocList[i])
00059                 {
00060                         BAllocList[i] = ptr;
00061                         break;
00062                 }
00063                 i++;
00064         }
00065 
00066         if (i == MAX_BALLOC)
00067         {
00068                 //If this happens we'll have to rely on this chunk being freed manually with B_Free, which it hopefully will be
00069 #ifdef DEBUG
00070                 G_Printf("WARNING: MAXIMUM B_ALLOC ALLOCATIONS EXCEEDED\n");
00071 #endif
00072         }
00073 
00074         return ptr;
00075 #else
00076 
00077         return BG_Alloc(size);
00078 
00079 #endif
00080 }

void B_Free void *  ptr  ) 
 

Definition at line 82 of file ai_util.c.

References G_Printf(), and NULL.

00083 {
00084 #ifdef BOT_ZMALLOC
00085         int i = 0;
00086 
00087 #ifdef BOTMEMTRACK
00088         int free = 0;
00089         int used = 0;
00090 
00091         while (i < MAX_BALLOC)
00092         {
00093                 if (!BAllocList[i])
00094                 {
00095                         free++;
00096                 }
00097                 else
00098                 {
00099                         used++;
00100                 }
00101 
00102                 i++;
00103         }
00104 
00105         G_Printf("Allocations used: %i\nFree allocation slots: %i\n", used, free);
00106 
00107         i = 0;
00108 #endif
00109 
00110         while (i < MAX_BALLOC)
00111         {
00112                 if (BAllocList[i] == ptr)
00113                 {
00114                         BAllocList[i] = NULL;
00115                         break;
00116                 }
00117 
00118                 i++;
00119         }
00120 
00121         if (i == MAX_BALLOC)
00122         {
00123                 //Likely because the limit was exceeded and we're now freeing the chunk manually as we hoped would happen
00124 #ifdef DEBUG
00125                 G_Printf("WARNING: Freeing allocation which is not in the allocation structure\n");
00126 #endif
00127         }
00128 
00129         trap_BotFreeMemoryGame(ptr);
00130 #endif
00131 }

void* B_TempAlloc int  size  ) 
 

Definition at line 14 of file ai_util.c.

References BG_TempAlloc().

Referenced by BotDoChat(), BotUtilizePersonality(), GetFlagStr(), LoadPathData(), and SavePathData().

00015 {
00016         return BG_TempAlloc(size);
00017 }

void B_TempFree int  size  ) 
 

Definition at line 19 of file ai_util.c.

References BG_TempFree().

Referenced by BotDoChat(), BotUtilizePersonality(), BotWaypointRender(), LoadPathData(), and SavePathData().

00020 {
00021         BG_TempFree(size);
00022 }

int BotDoChat bot_state_t bs,
char *  section,
int  always
 

Definition at line 328 of file ai_util.c.

References B_TempAlloc(), B_TempFree(), bot_state_t, bot_state_s::canChat, bot_state_s::chatAltObject, bot_state_s::chatFrequency, bot_state_s::chatObject, bot_state_s::chatTeam, bot_state_s::chatTime, bot_state_s::chatTime_stored, bot_state_s::client, gentity_s::client, bot_state_s::currentChat, bot_state_s::doChat, gBotChatBuffer, gentity_t, GetValueGroup(), level, MAX_CHAT_BUFFER_SIZE, MAX_CHAT_LINE_SIZE, clientPersistant_t::netname, NULL, gclient_s::pers, Q_irand(), strcmp(), strlen(), level_locals_t::time, and trap_Cvar_VariableIntegerValue().

Referenced by BotAISetupClient(), BotLovedOneDied(), BotOrder(), BotReplyGreetings(), and StandardBotAI().

00329 {
00330         char *chatgroup;
00331         int rVal;
00332         int inc_1;
00333         int inc_2;
00334         int inc_n;
00335         int lines;
00336         int checkedline;
00337         int getthisline;
00338         gentity_t *cobject;
00339 
00340         if (!bs->canChat)
00341         {
00342                 return 0;
00343         }
00344 
00345         if (bs->doChat)
00346         { //already have a chat scheduled
00347                 return 0;
00348         }
00349 
00350         if (trap_Cvar_VariableIntegerValue("se_language"))
00351         { //no chatting unless English.
00352                 return 0;
00353         }
00354 
00355         if (Q_irand(1, 10) > bs->chatFrequency && !always)
00356         {
00357                 return 0;
00358         }
00359 
00360         bs->chatTeam = 0;
00361 
00362         chatgroup = (char *)B_TempAlloc(MAX_CHAT_BUFFER_SIZE);
00363 
00364         rVal = GetValueGroup(gBotChatBuffer[bs->client], section, chatgroup);
00365 
00366         if (!rVal) //the bot has no group defined for the specified chat event
00367         {
00368                 B_TempFree(MAX_CHAT_BUFFER_SIZE); //chatgroup
00369                 return 0;
00370         }
00371 
00372         inc_1 = 0;
00373         inc_2 = 2;
00374 
00375         while (chatgroup[inc_2] && chatgroup[inc_2] != '\0')
00376         {
00377                 if (chatgroup[inc_2] != 13 && chatgroup[inc_2] != 9)
00378                 {
00379                         chatgroup[inc_1] = chatgroup[inc_2];
00380                         inc_1++;
00381                 }
00382                 inc_2++;
00383         }
00384         chatgroup[inc_1] = '\0';
00385 
00386         inc_1 = 0;
00387 
00388         lines = 0;
00389 
00390         while (chatgroup[inc_1] && chatgroup[inc_1] != '\0')
00391         {
00392                 if (chatgroup[inc_1] == '\n')
00393                 {
00394                         lines++;
00395                 }
00396                 inc_1++;
00397         }
00398 
00399         if (!lines)
00400         {
00401                 B_TempFree(MAX_CHAT_BUFFER_SIZE); //chatgroup
00402                 return 0;
00403         }
00404 
00405         getthisline = Q_irand(0, (lines+1));
00406 
00407         if (getthisline < 1)
00408         {
00409                 getthisline = 1;
00410         }
00411         if (getthisline > lines)
00412         {
00413                 getthisline = lines;
00414         }
00415 
00416         checkedline = 1;
00417 
00418         inc_1 = 0;
00419 
00420         while (checkedline != getthisline)
00421         {
00422                 if (chatgroup[inc_1] && chatgroup[inc_1] != '\0')
00423                 {
00424                         if (chatgroup[inc_1] == '\n')
00425                         {
00426                                 inc_1++;
00427                                 checkedline++;
00428                         }
00429                 }
00430 
00431                 if (checkedline == getthisline)
00432                 {
00433                         break;
00434                 }
00435 
00436                 inc_1++;
00437         }
00438 
00439         //we're at the starting position of the desired line here
00440         inc_2 = 0;
00441 
00442         while (chatgroup[inc_1] != '\n')
00443         {
00444                 chatgroup[inc_2] = chatgroup[inc_1];
00445                 inc_2++;
00446                 inc_1++;
00447         }
00448         chatgroup[inc_2] = '\0';
00449 
00450         //trap_EA_Say(bs->client, chatgroup);
00451         inc_1 = 0;
00452         inc_2 = 0;
00453 
00454         if (strlen(chatgroup) > MAX_CHAT_LINE_SIZE)
00455         {
00456                 B_TempFree(MAX_CHAT_BUFFER_SIZE); //chatgroup
00457                 return 0;
00458         }
00459 
00460         while (chatgroup[inc_1])
00461         {
00462                 if (chatgroup[inc_1] == '%' && chatgroup[inc_1+1] != '%')
00463                 {
00464                         inc_1++;
00465 
00466                         if (chatgroup[inc_1] == 's' && bs->chatObject)
00467                         {
00468                                 cobject = bs->chatObject;
00469                         }
00470                         else if (chatgroup[inc_1] == 'a' && bs->chatAltObject)
00471                         {
00472                                 cobject = bs->chatAltObject;
00473                         }
00474                         else
00475                         {
00476                                 cobject = NULL;
00477                         }
00478 
00479                         if (cobject && cobject->client)
00480                         {
00481                                 inc_n = 0;
00482 
00483                                 while (cobject->client->pers.netname[inc_n])
00484                                 {
00485                                         bs->currentChat[inc_2] = cobject->client->pers.netname[inc_n];
00486                                         inc_2++;
00487                                         inc_n++;
00488                                 }
00489                                 inc_2--; //to make up for the auto-increment below
00490                         }
00491                 }
00492                 else
00493                 {
00494                         bs->currentChat[inc_2] = chatgroup[inc_1];
00495                 }
00496                 inc_2++;
00497                 inc_1++;
00498         }
00499         bs->currentChat[inc_2] = '\0';
00500 
00501         if (strcmp(section, "GeneralGreetings") == 0)
00502         {
00503                 bs->doChat = 2;
00504         }
00505         else
00506         {
00507                 bs->doChat = 1;
00508         }
00509         bs->chatTime_stored = (strlen(bs->currentChat)*45)+Q_irand(1300, 1500);
00510         bs->chatTime = level.time + bs->chatTime_stored;
00511 
00512         B_TempFree(MAX_CHAT_BUFFER_SIZE); //chatgroup
00513 
00514         return 1;
00515 }

int BotIsAChickenWuss bot_state_t bs  ) 
 

Definition at line 2301 of file ai_main.c.

References BOT_RUN_HEALTH, bot_state_t, BotGetWeaponRange(), BWEAPONRANGE_MELEE, BWEAPONRANGE_SABER, bot_state_s::chickenWussCalculationTime, bot_state_s::client, gentity_s::client, bot_state_s::cur_ps, bot_state_s::currentEnemy, playerState_s::electrifyTime, playerState_s::fd, forcedata_s::forcePowersActive, FP_RAGE, bot_state_s::frame_Enemy_Len, g_entities, g_gametype, gLevelFlags, GT_CTF, GT_JEDIMASTER, GT_SINGLE_PLAYER, gentity_s::health, vmCvar_t::integer, playerState_s::isJediMaster, level, LEVELFLAG_IMUSTNTRUNAWAY, MAX_CHICKENWUSS_TIME, playerState_s::powerups, gclient_s::ps, PW_BLUEFLAG, PW_REDFLAG, bot_state_s::saberSpecialist, level_locals_t::time, playerState_s::weapon, WP_BRYAR_PISTOL, WP_ROCKET_LAUNCHER, and WP_SABER.

Referenced by GetIdealDestination(), and WPTouchRoutine().

02302 {
02303         int bWRange;
02304 
02305         if (gLevelFlags & LEVELFLAG_IMUSTNTRUNAWAY)
02306         { //The level says we mustn't run away!
02307                 return 0;
02308         }
02309 
02310         if (g_gametype.integer == GT_SINGLE_PLAYER)
02311         { //"coop" (not really)
02312                 return 0;
02313         }
02314 
02315         if (g_gametype.integer == GT_JEDIMASTER && !bs->cur_ps.isJediMaster)
02316         { //Then you may know no fear.
02317                 //Well, unless he's strong.
02318                 if (bs->currentEnemy && bs->currentEnemy->client &&
02319                         bs->currentEnemy->client->ps.isJediMaster &&
02320                         bs->currentEnemy->health > 40 &&
02321                         bs->cur_ps.weapon < WP_ROCKET_LAUNCHER)
02322                 { //explosive weapons are most effective against the Jedi Master
02323                         goto jmPass;
02324                 }
02325                 return 0;
02326         }
02327 
02328         if (g_gametype.integer == GT_CTF && bs->currentEnemy && bs->currentEnemy->client)
02329         {
02330                 if (bs->currentEnemy->client->ps.powerups[PW_REDFLAG] ||
02331                         bs->currentEnemy->client->ps.powerups[PW_BLUEFLAG])
02332                 { //don't be afraid of flag carriers, they must die!
02333                         return 0;
02334                 }
02335         }
02336 
02337 jmPass:
02338         if (bs->chickenWussCalculationTime > level.time)
02339         {
02340                 return 2; //don't want to keep going between two points...
02341         }
02342 
02343         if (bs->cur_ps.fd.forcePowersActive & (1 << FP_RAGE))
02344         { //don't run while raging
02345                 return 0;
02346         }
02347 
02348         if (g_gametype.integer == GT_JEDIMASTER && !bs->cur_ps.isJediMaster)
02349         { //be frightened of the jedi master? I guess in this case.
02350                 return 1;
02351         }
02352 
02353         bs->chickenWussCalculationTime = level.time + MAX_CHICKENWUSS_TIME;
02354 
02355         if (g_entities[bs->client].health < BOT_RUN_HEALTH)
02356         { //we're low on health, let's get away
02357                 return 1;
02358         }
02359 
02360         bWRange = BotGetWeaponRange(bs);
02361 
02362         if (bWRange == BWEAPONRANGE_MELEE || bWRange == BWEAPONRANGE_SABER)
02363         {
02364                 if (bWRange != BWEAPONRANGE_SABER || !bs->saberSpecialist)
02365                 { //run away if we're using melee, or if we're using a saber and not a "saber specialist"
02366                         return 1;
02367                 }
02368         }
02369 
02370         if (bs->cur_ps.weapon == WP_BRYAR_PISTOL)
02371         { //the bryar is a weak weapon, so just try to find a new one if it's what you're having to use
02372                 return 1;
02373         }
02374 
02375         if (bs->currentEnemy && bs->currentEnemy->client &&
02376                 bs->currentEnemy->client->ps.weapon == WP_SABER &&
02377                 bs->frame_Enemy_Len < 512 && bs->cur_ps.weapon != WP_SABER)
02378         { //if close to an enemy with a saber and not using a saber, then try to back off
02379                 return 1;
02380         }
02381 
02382         if ((level.time-bs->cur_ps.electrifyTime) < 16000)
02383         { //lightning is dangerous.
02384                 return 1;
02385         }
02386 
02387         //didn't run, reset the timer
02388         bs->chickenWussCalculationTime = 0;
02389 
02390         return 0;
02391 }

void BotResetState bot_state_t bs  ) 
 

Definition at line 924 of file ai_main.c.

References bot_settings_t, bot_state_t, bot_state_s::client, client, bot_state_s::cur_ps, bot_state_s::entergame_time, bot_state_s::entitynum, bot_state_s::gs, bot_state_s::inuse, memcpy(), memset(), bot_state_s::ms, playerState_t, bot_state_s::settings, trap_BotResetAvoidGoals(), trap_BotResetAvoidReach(), trap_BotResetGoalState(), trap_BotResetMoveState(), trap_BotResetWeaponState(), and bot_state_s::ws.

Referenced by BotAILoadMap().

00924                                     {
00925         int client, entitynum, inuse;
00926         int movestate, goalstate, weaponstate;
00927         bot_settings_t settings;
00928         playerState_t ps;                                                       //current player state
00929         float entergame_time;
00930 
00931         //save some things that should not be reset here
00932         memcpy(&settings, &bs->settings, sizeof(bot_settings_t));
00933         memcpy(&ps, &bs->cur_ps, sizeof(playerState_t));
00934         inuse = bs->inuse;
00935         client = bs->client;
00936         entitynum = bs->entitynum;
00937         movestate = bs->ms;
00938         goalstate = bs->gs;
00939         weaponstate = bs->