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
1 changed files with 7 additions and 14 deletions

View File

@ -274,6 +274,11 @@ int G_SelectRandomBotInfo( int team ) {
int count, bestCount;
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;
bestCount = MAX_CLIENTS;
for ( n = 0; n < g_numBots ; n++ ) {
@ -312,26 +317,14 @@ G_AddRandomBot
===============
*/
void G_AddRandomBot( int team ) {
int n;
char *value, netname[36], *teamstr;
char *teamstr;
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" );
if (team == TEAM_RED) teamstr = "red";
else if (team == TEAM_BLUE) teamstr = "blue";
else teamstr = "free";
Q_strncpyz(netname, value, sizeof(netname));
Q_CleanStr(netname);
trap_SendConsoleCommand( EXEC_INSERT, va("addbot %s %f %s %i\n", netname, skill, teamstr, 0) );
trap_SendConsoleCommand( EXEC_INSERT, va("addbot random %f %s %i\n", skill, teamstr, 0) );
}
/*