Don't pick duplicate random bots until all bot types are added

Don't add the same bot to multiple teams until there are as many
bots on the server as there are bot types.

Previously each team would have unique bots until all bot types
were added to the team but other teams may have the same bot. Now
there will not be any duplicate bots until there are more bots than
bot types.

Now Quake 3 (32 bot types) in 16 vs 16 bot CTF will not contain
duplicate bot types. (You have to increase memory in code/game/
g_mem.c in order to add 32 bots though.)

I had to change G_AddRandomBot() to use 'addbot random' or else the
same bot could be added to red and blue teams. The bot was selected
and stored in console command buffer so game doesn't know not to
select the bot again.
This commit is contained in:
Zack Middleton 2017-06-29 17:51:30 -05:00
parent 0999aff28d
commit cabc32362c

View file

@ -274,6 +274,11 @@ int G_SelectRandomBotInfo( int team ) {
int count, bestCount; int count, bestCount;
char *value; char *value;
// don't add duplicate bots to the server if there are less bots than bot types
if ( team != -1 && G_CountBotPlayersByName( NULL, -1 ) < g_numBots ) {
team = -1;
}
num = 0; num = 0;
bestCount = MAX_CLIENTS; bestCount = MAX_CLIENTS;
for ( n = 0; n < g_numBots ; n++ ) { for ( n = 0; n < g_numBots ; n++ ) {
@ -312,26 +317,14 @@ G_AddRandomBot
=============== ===============
*/ */
void G_AddRandomBot( int team ) { void G_AddRandomBot( int team ) {
int n; char *teamstr;
char *value, netname[36], *teamstr;
float skill; float skill;
n = G_SelectRandomBotInfo( team );
if ( n < 0 ) {
// no bot info available
return;
}
value = Info_ValueForKey( g_botInfos[n], "name" );
skill = trap_Cvar_VariableValue( "g_spSkill" ); skill = trap_Cvar_VariableValue( "g_spSkill" );
if (team == TEAM_RED) teamstr = "red"; if (team == TEAM_RED) teamstr = "red";
else if (team == TEAM_BLUE) teamstr = "blue"; else if (team == TEAM_BLUE) teamstr = "blue";
else teamstr = "free"; else teamstr = "free";
Q_strncpyz(netname, value, sizeof(netname)); trap_SendConsoleCommand( EXEC_INSERT, va("addbot random %f %s %i\n", skill, teamstr, 0) );
Q_CleanStr(netname);
trap_SendConsoleCommand( EXEC_INSERT, va("addbot %s %f %s %i\n", netname, skill, teamstr, 0) );
} }
/* /*