codemp/game/ai_main.c File Reference

#include "g_local.h"
#include "q_shared.h"
#include "botlib.h"
#include "be_aas.h"
#include "be_ea.h"
#include "be_ai_char.h"
#include "be_ai_chat.h"
#include "be_ai_gen.h"
#include "be_ai_goal.h"
#include "be_ai_move.h"
#include "be_ai_weap.h"
#include "ai_main.h"
#include "w_saber.h"
#include "chars.h"
#include "inv.h"
#include "syn.h"

Go to the source code of this file.

Defines

#define MAX_PATH   144
#define BOT_THINK_TIME   0
#define BOT_STRAFE_AVOIDANCE
#define STRAFEAROUND_RIGHT   1
#define STRAFEAROUND_LEFT   2

Functions

void BotStraightTPOrderCheck (gentity_t *ent, int ordernum, bot_state_t *bs)
void BotSelectWeapon (int client, int weapon)
void BotReportStatus (bot_state_t *bs)
void BotOrder (gentity_t *ent, int clientnum, int ordernum)
int BotMindTricked (int botClient, int enemyClient)
int BotGetWeaponRange (bot_state_t *bs)
int PassLovedOneCheck (bot_state_t *bs, gentity_t *ent)
void ExitLevel (void)
void QDECL BotAI_Print (int type, char *fmt,...)
qboolean WP_ForcePowerUsable (gentity_t *self, forcePowers_t forcePower)
int IsTeamplay (void)
int BotAI_GetClientState (int clientNum, playerState_t *state)
int BotAI_GetEntityState (int entityNum, entityState_t *state)
int BotAI_GetSnapshotEntity (int clientNum, int sequence, entityState_t *state)
void BotEntityInfo (int entnum, aas_entityinfo_t *info)
int NumBots (void)
float AngleDifference (float ang1, float ang2)
float BotChangeViewAngle (float angle, float ideal_angle, float speed)
void BotChangeViewAngles (bot_state_t *bs, float thinktime)
void BotInputToUserCommand (bot_input_t *bi, usercmd_t *ucmd, int delta_angles[3], int time, int useTime)
void BotUpdateInput (bot_state_t *bs, int time, int elapsed_time)
void BotAIRegularUpdate (void)
void RemoveColorEscapeSequences (char *text)
int BotAI (int client, float thinktime)
void BotScheduleBotThink (void)
int PlayersInGame (void)
int BotAISetupClient (int client, struct bot_settings_s *settings, qboolean restart)
int BotAIShutdownClient (int client, qboolean restart)
void BotResetState (bot_state_t *bs)
int BotAILoadMap (int restart)
int OrgVisible (vec3_t org1, vec3_t org2, int ignore)
int WPOrgVisible (gentity_t *bot, vec3_t org1, vec3_t org2, int ignore)
int OrgVisibleBox (vec3_t org1, vec3_t mins, vec3_t maxs, vec3_t org2, int ignore)
int CheckForFunc (vec3_t org, int ignore)
qboolean BotPVSCheck (const vec3_t p1, const vec3_t p2)
int GetNearestVisibleWP (vec3_t org, int ignore)
int PassWayCheck (bot_state_t *bs, int windex)
float TotalTrailDistance (int start, int end, bot_state_t *bs)
void CheckForShorterRoutes (bot_state_t *bs, int newwpindex)
void WPConstantRoutine (bot_state_t *bs)
qboolean BotCTFGuardDuty (bot_state_t *bs)
void WPTouchRoutine (bot_state_t *bs)
void MoveTowardIdealAngles (bot_state_t *bs)
int BotTrace_Strafe (bot_state_t *bs, vec3_t traceto)
int BotTrace_Jump (bot_state_t *bs, vec3_t traceto)
int BotTrace_Duck (bot_state_t *bs, vec3_t traceto)
int PassStandardEnemyChecks (bot_state_t *bs, gentity_t *en)
void BotDamageNotification (gclient_t *bot, gentity_t *attacker)
int BotCanHear (bot_state_t *bs, gentity_t *en, float endist)
void UpdateEventTracker (void)
int InFieldOfVision (vec3_t viewangles, float fov, vec3_t angles)
qboolean G_ThereIsAMaster (void)
int ScanForEnemies (bot_state_t *bs)
int WaitingForNow (bot_state_t *bs, vec3_t goalpos)
int BotIsAChickenWuss (bot_state_t *bs)
gentity_tGetNearestBadThing (bot_state_t *bs)
int BotDefendFlag (bot_state_t *bs)
int BotGetEnemyFlag (bot_state_t *bs)
int BotGetFlagBack (bot_state_t *bs)
int BotGuardFlagCarrier (bot_state_t *bs)
int BotGetFlagHome (bot_state_t *bs)
void GetNewFlagPoint (wpobject_t *wp, gentity_t *flagEnt, int team)
int CTFTakesPriority (bot_state_t *bs)
int EntityVisibleBox (vec3_t org1, vec3_t mins, vec3_t maxs, vec3_t org2, int ignore, int ignore2)
int Siege_TargetClosestObjective (bot_state_t *bs, int flag)
void Siege_DefendFromAttackers (bot_state_t *bs)
int Siege_CountDefenders (bot_state_t *bs)
int Siege_CountTeammates (bot_state_t *bs)
int SiegeTakesPriority (bot_state_t *bs)
int JMTakesPriority (bot_state_t *bs)
int BotHasAssociated (bot_state_t *bs, wpobject_t *wp)
int GetBestIdleGoal (bot_state_t *bs)
void GetIdealDestination (bot_state_t *bs)
void CommanderBotCTFAI (bot_state_t *bs)
void CommanderBotSiegeAI (bot_state_t *bs)
void BotDoTeamplayAI (bot_state_t *bs)
void CommanderBotTeamplayAI (bot_state_t *bs)
void CommanderBotAI (bot_state_t *bs)
void MeleeCombatHandling (bot_state_t *bs)
void SaberCombatHandling (bot_state_t *bs)
float BotWeaponCanLead (bot_state_t *bs)
void BotAimLeading (bot_state_t *bs, vec3_t headlevel, float leadAmount)
void BotAimOffsetGoalAngles (bot_state_t *bs)
int ShouldSecondaryFire (bot_state_t *bs)
int CombatBotAI (bot_state_t *bs, float thinktime)
int BotFallbackNavigation (bot_state_t *bs)
int BotTryAnotherWeapon (bot_state_t *bs)
qboolean BotWeaponSelectable (bot_state_t *bs, int weapon)
int BotSelectIdealWeapon (bot_state_t *bs)
int BotSelectChoiceWeapon (bot_state_t *bs, int weapon, int doselection)
int BotSelectMelee (bot_state_t *bs)
int GetLoveLevel (bot_state_t *bs, bot_state_t *love)
void BotLovedOneDied (bot_state_t *bs, bot_state_t *loved, int lovelevel)
void BotDeathNotify (bot_state_t *bs)
void StrafeTracing (bot_state_t *bs)
int PrimFiring (bot_state_t *bs)
int KeepPrimFromFiring (bot_state_t *bs)
int AltFiring (bot_state_t *bs)
int KeepAltFromFiring (bot_state_t *bs)
gentity_tCheckForFriendInLOF (bot_state_t *bs)
void BotScanForLeader (bot_state_t *bs)
void BotReplyGreetings (bot_state_t *bs)
void CTFFlagMovement (bot_state_t *bs)
void BotCheckDetPacks (bot_state_t *bs)
int BotUseInventoryItem (bot_state_t *bs)
int BotSurfaceNear (bot_state_t *bs)
int BotWeaponBlockable (int weapon)
void Cmd_EngageDuel_f (gentity_t *ent)
void Cmd_ToggleSaber_f (gentity_t *ent)
void Bot_SetForcedMovement (int bot, int forward, int right, int up)
void StandardBotAI (bot_state_t *bs, float thinktime)
int BotAIStartFrame (int time)
int BotAISetup (int restart)
int BotAIShutdown (int restart)

Variables

bot_state_tbotstates [MAX_CLIENTS]
int numbots
float floattime
float regularupdate_time
int rebel_attackers
int imperial_attackers
boteventtracker_t gBotEventTracker [MAX_CLIENTS]
vmCvar_t bot_forcepowers
vmCvar_t bot_forgimmick
vmCvar_t bot_honorableduelacceptance
vmCvar_t bot_pvstype
vmCvar_t bot_normgpath
vmCvar_t bot_getinthecarrr
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_tdroppedRedFlag
gentity_teFlagBlue
gentity_tdroppedBlueFlag
char * ctfStateNames []
char * ctfStateDescriptions []
char * siegeStateDescriptions []
char * teamplayStateDescriptions []
int gUpdateVars = 0


Define Documentation

#define BOT_STRAFE_AVOIDANCE
 

Definition at line 1548 of file ai_main.c.

#define BOT_THINK_TIME   0
 

Definition at line 43 of file ai_main.c.

Referenced by BotAIStartFrame(), and BotScheduleBotThink().

#define MAX_PATH   144
 

Definition at line 41 of file ai_main.c.

#define STRAFEAROUND_LEFT   2
 

Definition at line 1552 of file ai_main.c.

Referenced by BotTrace_Strafe(), and StandardBotAI().

#define STRAFEAROUND_RIGHT   1
 

Definition at line 1551 of file ai_main.c.

Referenced by BotTrace_Strafe(), and StandardBotAI().


Function Documentation

int AltFiring bot_state_t bs  ) 
 

Definition at line 5502 of file ai_main.c.

References bot_state_t, bot_state_s::cur_ps, bot_state_s::doAltAttack, WEAPON_CHARGING_ALT, and playerState_s::weaponstate.

Referenced by StandardBotAI().

05503 {
05504         if (bs->cur_ps.weaponstate != WEAPON_CHARGING_ALT &&
05505                 bs->doAltAttack)
05506         {
05507                 return 1;
05508         }
05509 
05510         if (bs->cur_ps.weaponstate == WEAPON_CHARGING_ALT &&
05511                 !bs->doAltAttack)
05512         {
05513                 return 1;
05514         }
05515 
05516         return 0;
05517 }

float AngleDifference float  ang1,
float  ang2
 

Definition at line 425 of file ai_main.c.

Referenced by BotChangeViewAngles(), and BotTrace_Strafe().

00425                                               {
00426         float diff;
00427 
00428         diff = ang1 - ang2;
00429         if (ang1 > ang2) {
00430                 if (diff > 180.0) diff -= 360.0;
00431         }
00432         else {
00433                 if (diff < -180.0) diff += 360.0;
00434         }
00435         return diff;
00436 }

void Bot_SetForcedMovement int  bot,
int  forward,
int  right,
int  up
 

Definition at line 5883 of file ai_main.c.

References bot_state_t, botstates, bot_state_s::forceMove_Forward, bot_state_s::forceMove_Right, and bot_state_s::forceMove_Up.

Referenced by ClientCommand().

05884 {
05885         bot_state_t *bs;
05886 
05887         bs = botstates[bot];
05888 
05889         if (!bs)
05890         { //not a bot
05891                 return;
05892         }
05893 
05894         if (forward != -1)
05895         {
05896                 if (bs->forceMove_Forward)
05897                 {
05898                         bs->forceMove_Forward = 0;
05899                 }
05900                 else
05901                 {
05902                         bs->forceMove_Forward = forward;
05903                 }
05904         }
05905         if (right != -1)
05906         {
05907                 if (bs->forceMove_Right)
05908                 {
05909                         bs->forceMove_Right = 0;
05910                 }
05911                 else
05912                 {
05913                         bs->forceMove_Right = right;
05914                 }
05915         }
05916         if (up != -1)
05917         {
05918                 if (bs->forceMove_Up)
05919                 {
05920                         bs->forceMove_Up = 0;
05921                 }
05922                 else
05923                 {
05924                         bs->forceMove_Up = up;
05925                 }
05926         }
05927 }

int BotAI int  client,
float  thinktime
 

Definition at line 696 of file ai_main.c.

References AngleMod(), bot_state_t, BotAI_GetClientState(), BotAI_Print(), botstates, client, Com_Printf(), bot_state_s::cur_ps, playerState_s::delta_angles, bot_state_s::eye, vmCvar_t::integer, bot_state_s::inuse, bot_state_s::ltime, bot_state_s::origin, playerState_s::origin, PRT_FATAL, Q_stricmp(), qfalse, qtrue, RemoveColorEscapeSequences(), SHORT2ANGLE, StandardBotAI(), strchr(), bot_state_s::thinktime, trap_BotGetServerCommand(), trap_Cvar_Update(), trap_EA_ResetInput(), trap_Milliseconds(), VectorCopy, bot_state_s::viewangles, and playerState_s::viewheight.

Referenced by BotAIStartFrame().

00696                                        {
00697         bot_state_t *bs;
00698         char buf[1024], *args;
00699         int j;
00700 #ifdef _DEBUG
00701         int start = 0;
00702         int end = 0;
00703 #endif
00704 
00705         trap_EA_ResetInput(client);
00706         //
00707         bs = botstates[client];
00708         if (!bs || !bs->inuse) {
00709                 BotAI_Print(PRT_FATAL, "BotAI: client %d is not setup\n", client);
00710                 return qfalse;
00711         }
00712 
00713         //retrieve the current client state
00714         BotAI_GetClientState( client, &bs->cur_ps );
00715 
00716         //retrieve any waiting server commands
00717         while( trap_BotGetServerCommand(client, buf, sizeof(buf)) ) {
00718                 //have buf point to the command and args to the command arguments
00719                 args = strchr( buf, ' ');
00720                 if (!args) continue;
00721                 *args++ = '\0';
00722 
00723                 //remove color espace sequences from the arguments
00724                 RemoveColorEscapeSequences( args );
00725 
00726                 if (!Q_stricmp(buf, "cp "))
00727                         { /*CenterPrintf*/ }
00728                 else if (!Q_stricmp(buf, "cs"))
00729                         { /*ConfigStringModified*/ }
00730                 else if (!Q_stricmp(buf, "scores"))
00731                         { /*FIXME: parse scores?*/ }
00732                 else if (!Q_stricmp(buf, "clientLevelShot"))
00733                         { /*ignore*/ }
00734         }
00735         //add the delta angles to the bot's current view angles
00736         for (j = 0; j < 3; j++) {
00737                 bs->viewangles[j] = AngleMod(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
00738         }
00739         //increase the local time of the bot
00740         bs->ltime += thinktime;
00741         //
00742         bs->thinktime = thinktime;
00743         //origin of the bot
00744         VectorCopy(bs->cur_ps.origin, bs->origin);
00745         //eye coordinates of the bot
00746         VectorCopy(bs->cur_ps.origin, bs->eye);
00747         bs->eye[2] += bs->cur_ps.viewheight;
00748         //get the area the bot is in
00749 
00750 #ifdef _DEBUG
00751         start = trap_Milliseconds();
00752 #endif
00753         StandardBotAI(bs, thinktime);
00754 #ifdef _DEBUG
00755         end = trap_Milliseconds();
00756 
00757         trap_Cvar_Update(&bot_debugmessages);
00758 
00759         if (bot_debugmessages.integer)
00760         {
00761                 Com_Printf("Single AI frametime: %i\n", (end - start));
00762         }
00763 #endif
00764 
00765         //subtract the delta angles
00766         for (j = 0; j < 3; j++) {
00767                 bs->viewangles[j] = AngleMod(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
00768         }
00769         //everything was ok
00770         return qtrue;
00771 }

int BotAI_GetClientState int  clientNum,
playerState_t state
 

Definition at line 351 of file ai_main.c.

References gentity_s::client, g_entities, gentity_t, gentity_s::inuse, memcpy(), playerState_t, gclient_s::ps, qfalse, and qtrue.

Referenced by BotAI().

00351                                                                 {
00352         gentity_t       *ent;
00353 
00354         ent = &g_entities[clientNum];
00355         if ( !ent->inuse ) {
00356                 return qfalse;
00357         }
00358         if ( !ent->client ) {
00359                 return qfalse;
00360         }
00361 
00362         memcpy( state, &ent->client->ps, sizeof(playerState_t) );
00363         return qtrue;
00364 }

int BotAI_GetEntityState int  entityNum,
entityState_t state
 

Definition at line 371 of file ai_main.c.

References entityState_t, g_entities, gentity_t, gentity_s::inuse, entityShared_t::linked, memcpy(), memset(), qfalse, qtrue, gentity_s::r, gentity_s::s, SVF_NOCLIENT, and entityShared_t::svFlags.

Referenced by BotAI_GetSnapshotEntity().

00371                                                                 {
00372         gentity_t       *ent;
00373 
00374         ent = &g_entities[entityNum];
00375         memset( state, 0, sizeof(entityState_t) );
00376         if (!ent->inuse) return qfalse;
00377         if (!ent->r.linked) return qfalse;
00378         if (ent->r.svFlags & SVF_NOCLIENT) return qfalse;
00379         memcpy( state, &ent->s, sizeof(entityState_t) );
00380         return qtrue;
00381 }

int BotAI_GetSnapshotEntity int  clientNum,
int  sequence,
entityState_t state
 

Definition at line 388 of file ai_main.c.

References BotAI_GetEntityState(), entityState_t, memset(), and trap_BotGetSnapshotEntity().

00388                                                                                  {
00389         int             entNum;
00390 
00391         entNum = trap_BotGetSnapshotEntity( clientNum, sequence );
00392         if ( entNum == -1 ) {
00393                 memset(state, 0, sizeof(entityState_t));
00394                 return -1;
00395         }
00396 
00397         BotAI_GetEntityState( entNum, state );
00398 
00399         return sequence + 1;
00400 }

void QDECL BotAI_Print int  type,
char *  fmt,
... 
 

Definition at line 332 of file ai_main.c.

References QDECL.

Referenced by BotAI(), and BotAISetupClient().

00332 { return; }

int BotAILoadMap int  restart  ) 
 

Definition at line 966 of file ai_main.c.

References BotResetState(), botstates, bot_state_s::inuse, MAX_CLIENTS, qtrue, and bot_state_s::setupcount.

Referenced by G_InitGame().

00966                                 {
00967         int                     i;
00968 
00969         for (i = 0; i < MAX_CLIENTS; i++) {
00970                 if (botstates[i] && botstates[i]->inuse) {
00971                         BotResetState( botstates[i] );
00972                         botstates[i]->setupcount = 4;
00973                 }
00974         }
00975 
00976         return qtrue;
00977 }

void BotAimLeading bot_state_t bs,
vec3_t  headlevel,
float  leadAmount
 

Definition at line 4607 of file ai_main.c.

References bot_state_t, gentity_s::client, bot_state_s::currentEnemy, bot_state_s::eye, bot_state_s::frame_Enemy_Len, bot_state_s::goalAngles, gclient_s::ps, vec3_t, vectoangles(), VectorCopy, VectorNormalize(), VectorSubtract, and playerState_s::velocity.

Referenced by StandardBotAI().

04608 {
04609         int x;
04610         vec3_t predictedSpot;
04611         vec3_t movementVector;
04612         vec3_t a, ang;
04613         float vtotal;
04614 
04615         if (!bs->currentEnemy ||
04616                 !bs->currentEnemy->client)
04617         {
04618                 return;
04619         }
04620 
04621         if (!bs->frame_Enemy_Len)
04622         {
04623                 return;
04624         }
04625 
04626         vtotal = 0;
04627 
04628         if (bs->currentEnemy->client->ps.velocity[0] < 0)
04629         {
04630                 vtotal += -bs->currentEnemy->client->ps.velocity[0];
04631         }
04632         else
04633         {
04634                 vtotal += bs->currentEnemy->client->ps.velocity[0];
04635         }
04636 
04637         if (bs->currentEnemy->client->ps.velocity[1] < 0)
04638         {
04639                 vtotal += -bs->currentEnemy->client->ps.velocity[1];
04640         }
04641         else
04642         {
04643                 vtotal += bs->currentEnemy->client->ps.velocity[1];
04644         }
04645 
04646         if (bs->currentEnemy->client->ps.velocity[2] < 0)
04647         {
04648                 vtotal += -bs->currentEnemy->client->ps.velocity[2];
04649         }
04650         else
04651         {
04652                 vtotal += bs->currentEnemy->client->ps.velocity[2];
04653         }
04654 
04655         //G_Printf("Leadin target with a velocity total of %f\n", vtotal);
04656 
04657         VectorCopy(bs->currentEnemy->client->ps.velocity, movementVector);
04658 
04659         VectorNormalize(movementVector);
04660 
04661         x = bs->frame_Enemy_Len*leadAmount; //hardly calculated with an exact science, but it works
04662 
04663         if (vtotal > 400)
04664         {
04665                 vtotal = 400;
04666         }
04667 
04668         if (vtotal)
04669         {
04670                 x = (bs->frame_Enemy_Len*0.9)*leadAmount*(vtotal*0.0012); //hardly calculated with an exact science, but it works
04671         }
04672         else
04673         {
04674                 x = (bs->frame_Enemy_Len*0.9)*leadAmount; //hardly calculated with an exact science, but it works
04675         }
04676 
04677         predictedSpot[0] = headlevel[0] + (movementVector[0]*x);
04678         predictedSpot[1] = headlevel[1] + (movementVector[1]*x);
04679         predictedSpot[2] = headlevel[2] + (movementVector[2]*x);
04680 
04681         VectorSubtract(predictedSpot, bs->eye, a);
04682         vectoangles(a, ang);
04683         VectorCopy(ang, bs->goalAngles);
04684 }

void BotAimOffsetGoalAngles bot_state_t bs  ) 
 

Definition at line 4687 of file ai_main.c.

References botskills_s::accuracy, bot_state_s::aimOffsetAmtPitch, bot_state_s::aimOffsetAmtYaw, bot_state_s::aimOffsetTime, bot_state_t, BotMindTricked(), bot_state_s::client, bot_state_s::currentEnemy, bot_state_s::frame_Enemy_Vis, g_entities, bot_state_s::goalAngles, level, entityState_s::number, botskills_s::perfectaim, PITCH, entityState_s::pos, rand(), bot_state_s::revengeEnemy, bot_state_s::revengeHateLevel, gentity_s::s, bot_state_s::settings, bot_settings_s::skill, bot_state_s::skills, level_locals_t::time, trajectory_t::trDelta, and YAW.

Referenced by StandardBotAI().

04688 {
04689         int i;
04690         float accVal;
04691         i = 0;
04692 
04693         if (bs->skills.perfectaim)
04694         {
04695                 return;
04696         }
04697 
04698         if (bs->aimOffsetTime > level.time)
04699         {
04700                 if (bs->aimOffsetAmtYaw)
04701                 {
04702                         bs->goalAngles[YAW] += bs->aimOffsetAmtYaw;
04703                 }
04704 
04705                 if (bs->aimOffsetAmtPitch)
04706                 {
04707                         bs->goalAngles[PITCH] += bs->aimOffsetAmtPitch;
04708                 }
04709                 
04710                 while (i <= 2)
04711                 {
04712                         if (bs->goalAngles[i] > 360)
04713                         {
04714                                 bs->goalAngles[i] -= 360;
04715                         }
04716 
04717                         if (bs->goalAngles[i] < 0)
04718                         {
04719                                 bs->goalAngles[i] += 360;
04720                         }
04721 
04722                         i++;
04723                 }
04724                 return;
04725         }
04726 
04727         accVal = bs->skills.accuracy/bs->settings.skill;
04728 
04729         if (bs->currentEnemy && BotMindTricked(bs->client, bs->currentEnemy->s.number))
04730         { //having to judge where they are by hearing them, so we should be quite inaccurate here
04731                 accVal *= 7;
04732 
04733                 if (accVal < 30)
04734                 {
04735                         accVal = 30;
04736                 }
04737         }
04738 
04739         if (bs->revengeEnemy && bs->revengeHateLevel &&
04740                 bs->currentEnemy == bs->revengeEnemy)
04741         { //bot becomes more skilled as anger level raises
04742                 accVal = accVal/bs->revengeHateLevel;
04743         }
04744 
04745         if (bs->currentEnemy && bs->frame_Enemy_Vis)
04746         { //assume our goal is aiming at the enemy, seeing as he's visible and all
04747                 if (!bs->currentEnemy->s.pos.trDelta[0] &&
04748                         !bs->currentEnemy->s.pos.trDelta[1] &&
04749                         !bs->currentEnemy->s.pos.trDelta[2])
04750                 {
04751                         accVal = 0; //he's not even moving, so he shouldn't really be hard to hit.
04752                 }
04753                 else
04754                 {
04755                         accVal += accVal*0.25; //if he's moving he's this much harder to hit
04756                 }
04757 
04758                 if (g_entities[bs->client].s.pos.trDelta[0] ||
04759                         g_entities[bs->client].s.pos.trDelta[1] ||
04760                         g_entities[bs->client].s.pos.trDelta[2])
04761                 {
04762                         accVal += accVal*0.15; //make it somewhat harder to aim if we're moving also
04763                 }
04764         }
04765 
04766         if (accVal > 90)
04767         {
04768                 accVal = 90;
04769         }
04770         if (accVal < 1)
04771         {
04772                 accVal = 0;
04773         }
04774 
04775         if (!accVal)
04776         {
04777                 bs->aimOffsetAmtYaw = 0;
04778                 bs->aimOffsetAmtPitch = 0;
04779                 return;
04780         }
04781 
04782         if (rand()%10 <= 5)
04783         {
04784                 bs->aimOffsetAmtYaw = rand()%(int)accVal;
04785         }
04786         else
04787         {
04788                 bs->aimOffsetAmtYaw = -(rand()%(int)accVal);
04789         }
04790 
04791         if (rand()%10 <= 5)
04792         {
04793                 bs->aimOffsetAmtPitch = rand()%(int)accVal;
04794         }
04795         else
04796         {
04797                 bs->aimOffsetAmtPitch = -(rand()%(int)accVal);
04798         }
04799 
04800         bs->aimOffsetTime = level.time + rand()%500 + 200;
04801 }

void BotAIRegularUpdate void   ) 
 

Definition at line 662 of file ai_main.c.

References FloatTime, regularupdate_time, and trap_BotUpdateEntityItems().

00662                               {
00663         if (regularupdate_time < FloatTime()) {
00664                 trap_BotUpdateEntityItems();
00665                 regularupdate_time = FloatTime() + 0.3;
00666         }
00667 }

int BotAISetup int  restart  ) 
 

Definition at line 7575 of file ai_main.c.

References bot_attachments, bot_camp, bot_forcepowers, bot_forgimmick, bot_getinthecarrr, bot_honorableduelacceptance, bot_pvstype, bot_wp_clearweight, bot_wp_distconnect, bot_wp_edit, bot_wp_info, bot_wp_visconnect, botstates, CVAR_CHEAT, memset(), qfalse, qtrue, trap_BotLibSetup(), trap_Cvar_Register(), and trap_Cvar_Update().

Referenced by G_InitGame().

07575                               {
07576         //rww - new bot cvars..
07577         trap_Cvar_Register(&bot_forcepowers, "bot_forcepowers", "1", CVAR_CHEAT);
07578         trap_Cvar_Register(&bot_forgimmick, "bot_forgimmick", "0", CVAR_CHEAT);
07579         trap_Cvar_Register(&bot_honorableduelacceptance, "bot_honorableduelacceptance", "0", CVAR_CHEAT);
07580         trap_Cvar_Register(&bot_pvstype, "bot_pvstype", "1", CVAR_CHEAT);
07581 #ifndef FINAL_BUILD
07582         trap_Cvar_Register(&bot_getinthecarrr, "bot_getinthecarrr", "0", 0);
07583 #endif
07584 
07585 #ifdef _DEBUG
07586         trap_Cvar_Register(&bot_nogoals, "bot_nogoals", "0", CVAR_CHEAT);
07587         trap_Cvar_Register(&bot_debugmessages, "bot_debugmessages", "0", CVAR_CHEAT);
07588 #endif
07589 
07590         trap_Cvar_Register(&bot_attachments, "bot_attachments", "1", 0);
07591         trap_Cvar_Register(&bot_camp, "bot_camp", "1", 0);
07592 
07593         trap_Cvar_Register(&bot_wp_info, "bot_wp_info", "1", 0);
07594         trap_Cvar_Register(&bot_wp_edit, "bot_wp_edit", "0", CVAR_CHEAT);
07595         trap_Cvar_Register(&bot_wp_clearweight, "bot_wp_clearweight", "1", 0);
07596         trap_Cvar_Register(&bot_wp_distconnect, "bot_wp_distconnect", "1", 0);
07597         trap_Cvar_Register(&bot_wp_visconnect, "bot_wp_visconnect", "1", 0);
07598 
07599         trap_Cvar_Update(&bot_forcepowers);
07600         //end rww
07601 
07602         //if the game is restarted for a tournament
07603         if (restart) {
07604                 return qtrue;
07605         }
07606 
07607         //initialize the bot states
07608         memset( botstates, 0, sizeof(botstates) );
07609 
07610         if (!trap_BotLibSetup())
07611         {
07612                 return qfalse; //wts?!
07613         }
07614 
07615         return qtrue;
07616 }

int BotAISetupClient int  client,
struct bot_settings_s settings,
qboolean  restart
 

Definition at line 819 of file ai_main.c.

References B_Alloc(), bot_settings_t, bot_state_t, BotAI_Print(), BotDoChat(), BotScheduleBotThink(), botstates, BotUtilizePersonality(), bot_state_s::botWeaponWeights, client, bot_state_s::client, bot_state_s::entergame_time, bot_state_s::entitynum, FloatTime, g_gametype, bot_state_s::gs, GT_DUEL, GT_POWERDUEL, vmCvar_t::integer, bot_state_s::inuse, memcpy(), memset(), bot_state_s::ms, numbots, PlayersInGame(), PRT_FATAL, qfalse, qtrue, bot_state_s::settings, bot_state_s::setupcount, trap_BotAllocGoalState(), trap_BotAllocMoveState(), trap_BotAllocWeaponState(), WP_BLASTER, WP_BOWCASTER, WP_BRYAR_PISTOL, WP_DEMP2, WP_DET_PACK, WP_DISRUPTOR, WP_FLECHETTE, WP_MELEE, WP_NONE, WP_REPEATER, WP_ROCKET_LAUNCHER, WP_SABER, WP_STUN_BATON, WP_THERMAL, WP_TRIP_MINE, and bot_state_s::ws.

Referenced by G_BotConnect().

00819                                                                                     {
00820         bot_state_t *bs;
00821 
00822         if (!botstates[client]) botstates[client] = (bot_state_t *) B_Alloc(sizeof(bot_state_t)); //G_Alloc(sizeof(bot_state_t));
00823                                                                                                                                                           //rww - G_Alloc bad! B_Alloc good.
00824 
00825         memset(botstates[client], 0, sizeof(bot_state_t));
00826 
00827         bs = botstates[client];
00828 
00829         if (bs && bs->inuse) {
00830                 BotAI_Print(PRT_FATAL, "BotAISetupClient: client %d already setup\n", client);
00831                 return qfalse;
00832         }
00833 
00834         memcpy(&bs->settings, settings, sizeof(bot_settings_t));
00835 
00836         bs->client = client; //need to know the client number before doing personality stuff
00837 
00838         //initialize weapon weight defaults..
00839         bs->botWeaponWeights[WP_NONE] = 0;
00840         bs->botWeaponWeights[WP_STUN_BATON] = 1;
00841         bs->botWeaponWeights[WP_SABER] = 10;
00842         bs->botWeaponWeights[WP_BRYAR_PISTOL] = 11;
00843         bs->botWeaponWeights[WP_BLASTER] = 12;
00844         bs->botWeaponWeights[WP_DISRUPTOR] = 13;
00845         bs->botWeaponWeights[WP_BOWCASTER] = 14;
00846         bs->botWeaponWeights[WP_REPEATER] = 15;
00847         bs->botWeaponWeights[WP_DEMP2] = 16;
00848         bs->botWeaponWeights[WP_FLECHETTE] = 17;
00849         bs->botWeaponWeights[WP_ROCKET_LAUNCHER] = 18;
00850         bs->botWeaponWeights[WP_THERMAL] = 14;
00851         bs->botWeaponWeights[WP_TRIP_MINE] = 0;
00852         bs->botWeaponWeights[WP_DET_PACK] = 0;
00853         bs->botWeaponWeights[WP_MELEE] = 1;
00854 
00855         BotUtilizePersonality(bs);
00856 
00857         if (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL)
00858         {
00859                 bs->botWeaponWeights[WP_SABER] = 13;
00860         }
00861 
00862         //allocate a goal state
00863         bs->gs = trap_BotAllocGoalState(client);
00864 
00865         //allocate a weapon state
00866         bs->ws = trap_BotAllocWeaponState();
00867 
00868         bs->inuse = qtrue;
00869         bs->entitynum = client;
00870         bs->setupcount = 4;
00871         bs->entergame_time = FloatTime();
00872         bs->ms = trap_BotAllocMoveState();
00873         numbots++;
00874 
00875         //NOTE: reschedule the bot thinking
00876         BotScheduleBotThink();
00877 
00878         if (PlayersInGame())
00879         { //don't talk to yourself
00880                 BotDoChat(bs, "GeneralGreetings", 0);
00881         }
00882 
00883         return qtrue;
00884 }

int BotAIShutdown int  restart  ) 
 

Definition at line 7623 of file ai_main.c.

References BotAIShutdownClient(), botstates, client, bot_state_s::inuse, MAX_CLIENTS, qtrue, and trap_BotLibShutdown().

Referenced by G_ShutdownGame().

07623                                  {
07624 
07625         int i;
07626 
07627         //if the game is restarted for a tournament
07628         if ( restart ) {
07629                 //shutdown all the bots in the botlib
07630                 for (i = 0; i < MAX_CLIENTS; i++) {
07631                         if (botstates[i] && botstates[i]->inuse) {
07632                                 BotAIShutdownClient(botstates[i]->client, restart);
07633                         }
07634                 }
07635                 //don't shutdown the bot library
07636         }
07637         else {
07638                 trap_BotLibShutdown();
07639         }
07640         return qtrue;
07641 }

int BotAIShutdownClient int  client,
qboolean  restart
 

Definition at line 891 of file ai_main.c.

References bot_state_t, botstates, client, bot_state_s::gs, bot_state_s::inuse, memset(), bot_state_s::ms, numbots, qfalse, qtrue, trap_BotFreeGoalState(), trap_BotFreeMoveState(), trap_BotFreeWeaponState(), and bot_state_s::ws.

Referenced by BotAIShutdown(), and ClientDisconnect().

00891                                                       {
00892         bot_state_t *bs;
00893 
00894         bs = botstates[client];
00895         if (!bs || !bs->inuse) {
00896                 //BotAI_Print(PRT_ERROR, "BotAIShutdownClient: client %d already shutdown\n", client);
00897                 return qfalse;
00898         }
00899 
00900         trap_BotFreeMoveState(bs->ms);
00901         //free the goal state`                  
00902         trap_BotFreeGoalState(bs->gs);
00903         //free the weapon weights
00904         trap_BotFreeWeaponState(bs->ws);
00905         //
00906         //clear the bot state
00907         memset(bs, 0, sizeof(bot_state_t));
00908         //set the inuse flag to qfalse
00909         bs->inuse = qfalse;
00910         //there's one bot less
00911         numbots--;
00912         //everything went ok
00913         return qtrue;
00914 }

int BotAIStartFrame int  time  ) 
 

Definition at line 7492 of file ai_main.c.

References bot_attachments, bot_camp, bot_forgimmick, bot_getinthecarrr, bot_honorableduelacceptance, bot_pvstype, BOT_THINK_TIME, bot_wp_info, BotAI(), BotScheduleBotThink(), botstates, bot_state_s::botthink_residual, BotUpdateInput(), BotWaypointRender(), gentity_s::client, client, CON_CONNECTED, clientPersistant_t::connected, G_CheckBotSpawn(),