[iortcw] 39/89: All: Make 'addbot random' command select a random bot info
Simon McVittie
smcv at debian.org
Fri Sep 8 10:44:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to tag 1.51b
in repository iortcw.
commit 86168c61bbb0539163c17e0cf7970ea4a88161cc
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date: Wed Jul 19 11:47:18 2017 -0400
All: Make 'addbot random' command select a random bot info
---
MP/code/game/g_bot.c | 66 ++++++++++++++++++++++++++++++++++++++--------------
SP/code/game/g_bot.c | 62 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 96 insertions(+), 32 deletions(-)
diff --git a/MP/code/game/g_bot.c b/MP/code/game/g_bot.c
index 524b4b8..6da033d 100644
--- a/MP/code/game/g_bot.c
+++ b/MP/code/game/g_bot.c
@@ -500,8 +500,10 @@ qboolean G_BotConnect( int clientNum, qboolean restart ) {
G_AddBot
===============
*/
-static void G_AddBot( const char *name, float skill, const char *team, int delay ) {
- int clientNum;
+static void G_AddBot( const char *name, int skill, const char *team, int delay ) {
+ int clientNum;
+ int teamNum;
+ int botinfoNum;
char *botinfo;
char *key;
char *s;
@@ -517,8 +519,50 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
return;
}
+ // set default team
+ if( !team || !*team ) {
+ if( g_gametype.integer >= GT_TEAM ) {
+ if( PickTeam(clientNum) == TEAM_RED) {
+ team = "red";
+ }
+ else {
+ team = "blue";
+ }
+ }
+ else {
+ team = "free";
+ }
+ }
+
// get the botinfo from bots.txt
- botinfo = G_GetBotInfoByName( name );
+ if ( Q_stricmp( name, "random" ) == 0 ) {
+ if ( Q_stricmp( team, "red" ) == 0 || Q_stricmp( team, "r" ) == 0 ) {
+ teamNum = TEAM_RED;
+ }
+ else if ( Q_stricmp( team, "blue" ) == 0 || Q_stricmp( team, "b" ) == 0 ) {
+ teamNum = TEAM_BLUE;
+ }
+ else if ( !Q_stricmp( team, "spectator" ) || !Q_stricmp( team, "s" ) ) {
+ teamNum = TEAM_SPECTATOR;
+ }
+ else {
+ teamNum = TEAM_FREE;
+ }
+
+ botinfoNum = G_SelectRandomBotInfo( teamNum );
+
+ if ( botinfoNum < 0 ) {
+ G_Printf( S_COLOR_YELLOW "WARNING: Cannot add random bot: all bot types in use on team '%s'.\n", team );
+ trap_BotFreeClient( clientNum );
+ return;
+ }
+
+ botinfo = G_GetBotInfoByNumber( botinfoNum );
+ }
+ else {
+ botinfo = G_GetBotInfoByName( name );
+ }
+
if ( !botinfo ) {
G_Printf( S_COLOR_RED "Error: Bot '%s' not defined\n", name );
trap_BotFreeClient( clientNum );
@@ -535,7 +579,8 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
Info_SetValueForKey( userinfo, "name", botname );
Info_SetValueForKey( userinfo, "rate", "25000" );
Info_SetValueForKey( userinfo, "snaps", "20" );
- Info_SetValueForKey( userinfo, "skill", va("%.2f", skill) );
+ Info_SetValueForKey( userinfo, "skill", va("%i", skill) );
+ Info_SetValueForKey( userinfo, "teampref", team );
if ( skill == 1 ) {
Info_SetValueForKey( userinfo, "handicap", "50" );
@@ -574,19 +619,6 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
}
Info_SetValueForKey( userinfo, "characterfile", s );
- if ( !team || !*team ) {
- if ( g_gametype.integer == GT_TEAM || g_gametype.integer == GT_CTF ) {
- if ( PickTeam( clientNum ) == TEAM_RED ) {
- team = "red";
- } else {
- team = "blue";
- }
- } else {
- team = "red";
- }
- }
- Info_SetValueForKey( userinfo, "teampref", team );
-
// register the userinfo
trap_SetUserinfo( clientNum, userinfo );
diff --git a/SP/code/game/g_bot.c b/SP/code/game/g_bot.c
index 814cb7a..d32d5f4 100644
--- a/SP/code/game/g_bot.c
+++ b/SP/code/game/g_bot.c
@@ -502,7 +502,9 @@ G_AddBot
===============
*/
static void G_AddBot( const char *name, int skill, const char *team, int delay ) {
- int clientNum;
+ int clientNum;
+ int teamNum;
+ int botinfoNum;
char *botinfo;
char *key;
char *s;
@@ -518,8 +520,50 @@ static void G_AddBot( const char *name, int skill, const char *team, int delay )
return;
}
+ // set default team
+ if( !team || !*team ) {
+ if( g_gametype.integer >= GT_TEAM ) {
+ if( PickTeam(clientNum) == TEAM_RED) {
+ team = "red";
+ }
+ else {
+ team = "blue";
+ }
+ }
+ else {
+ team = "free";
+ }
+ }
+
// get the botinfo from bots.txt
- botinfo = G_GetBotInfoByName( name );
+ if ( Q_stricmp( name, "random" ) == 0 ) {
+ if ( Q_stricmp( team, "red" ) == 0 || Q_stricmp( team, "r" ) == 0 ) {
+ teamNum = TEAM_RED;
+ }
+ else if ( Q_stricmp( team, "blue" ) == 0 || Q_stricmp( team, "b" ) == 0 ) {
+ teamNum = TEAM_BLUE;
+ }
+ else if ( !Q_stricmp( team, "spectator" ) || !Q_stricmp( team, "s" ) ) {
+ teamNum = TEAM_SPECTATOR;
+ }
+ else {
+ teamNum = TEAM_FREE;
+ }
+
+ botinfoNum = G_SelectRandomBotInfo( teamNum );
+
+ if ( botinfoNum < 0 ) {
+ G_Printf( S_COLOR_YELLOW "WARNING: Cannot add random bot: all bot types in use on team '%s'.\n", team );
+ trap_BotFreeClient( clientNum );
+ return;
+ }
+
+ botinfo = G_GetBotInfoByNumber( botinfoNum );
+ }
+ else {
+ botinfo = G_GetBotInfoByName( name );
+ }
+
if ( !botinfo ) {
G_Printf( S_COLOR_RED "Error: Bot '%s' not defined\n", name );
trap_BotFreeClient( clientNum );
@@ -537,6 +581,7 @@ static void G_AddBot( const char *name, int skill, const char *team, int delay )
Info_SetValueForKey( userinfo, "rate", "25000" );
Info_SetValueForKey( userinfo, "snaps", "20" );
Info_SetValueForKey( userinfo, "skill", va( "%i", skill ) );
+ Info_SetValueForKey( userinfo, "teampref", team );
if ( skill == 1 ) {
Info_SetValueForKey( userinfo, "handicap", "50" );
@@ -575,19 +620,6 @@ static void G_AddBot( const char *name, int skill, const char *team, int delay )
}
Info_SetValueForKey( userinfo, "characterfile", s );
- if ( !team || !*team ) {
- if ( g_gametype.integer == GT_TEAM || g_gametype.integer == GT_CTF ) {
- if ( PickTeam( clientNum ) == TEAM_RED ) {
- team = "red";
- } else {
- team = "blue";
- }
- } else {
- team = "red";
- }
- }
- Info_SetValueForKey( userinfo, "teampref", team );
-
// register the userinfo
trap_SetUserinfo( clientNum, userinfo );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list