[ioquake3] 17/50: Don't pick duplicate random bots until all bot types are added
Simon McVittie
smcv at debian.org
Sun Jul 23 21:55:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit cabc32362c1093320ce4b03d939df2deabba020a
Author: Zack Middleton <zack at cloemail.com>
Date: Thu Jun 29 17:51:30 2017 -0500
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.
---
code/game/g_bot.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/code/game/g_bot.c b/code/game/g_bot.c
index bda1f7d..66c9ae3 100644
--- a/code/game/g_bot.c
+++ b/code/game/g_bot.c
@@ -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) );
}
/*
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list