Bot names can now be customized per mod via botnames.cfg
This commit is contained in:
parent
17444f24d5
commit
6ad3ae8e9c
1 changed files with 39 additions and 4 deletions
|
@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "bot.h"
|
||||
|
||||
globot_t globot; // This struct is used to store global stuff that aint client specific
|
||||
|
||||
qboolean qUsesBotnames;
|
||||
int iMaxBotnames;
|
||||
char cBotName[32][16]; // eukara - 32 names max, 16 characters per name
|
||||
/*
|
||||
======
|
||||
Random
|
||||
|
@ -178,7 +180,7 @@ TODO: Read and parse names from a file
|
|||
*/
|
||||
char *PickBotName (int r)
|
||||
{
|
||||
if (r == 1) return "windshield wiper";
|
||||
if (r == 1) return "windshield wiper";
|
||||
else if (r == 2) return "nosefart";
|
||||
else if (r == 3) return "WILDEBEEST";
|
||||
else if (r == 4) return "Human";
|
||||
|
@ -234,7 +236,7 @@ void BotConnect (client_t *client, int ClientNo, int color, char *name)
|
|||
bot->bot.isbot = true; // And yes this is a bot
|
||||
bot->bot.Active = true; // and hes active
|
||||
bot->bot.enemy = bot; // Now why is he chasing himself?
|
||||
bot->bot.connecttime = sv.time;
|
||||
bot->bot.connecttime = sv.time;
|
||||
bot->bot.ClientNo = ClientNo; // Now we get a clientnumber
|
||||
|
||||
randombot = ceil (RandomRange (0, 15));
|
||||
|
@ -247,7 +249,12 @@ void BotConnect (client_t *client, int ClientNo, int color, char *name)
|
|||
if (name[0] != '0')
|
||||
strcpy (client->name, name);
|
||||
else
|
||||
strcpy (client->name, PickBotName (randombot));
|
||||
{
|
||||
if(qUsesBotnames == true && cBotName[randombot])
|
||||
strcpy (client->name, cBotName[randombot]);
|
||||
else
|
||||
strcpy (client->name, PickBotName (randombot));
|
||||
}
|
||||
|
||||
if (color != 666)
|
||||
{
|
||||
|
@ -734,7 +741,35 @@ the command "addbot" from the console
|
|||
*/
|
||||
void Bot_Init (void)
|
||||
{
|
||||
char name[256];
|
||||
Cmd_AddCommand ("addbot", NextFreeClient);
|
||||
Cmd_AddCommand ("addburp", NextFreeLoser);
|
||||
|
||||
// eukara - loading botnames start
|
||||
printf("Looking for botnames.cfg...\n");
|
||||
sprintf (name, "%s/botnames.cfg", com_gamedir);
|
||||
FILE *fd = fopen(name,"r");
|
||||
|
||||
if (fd == NULL)
|
||||
{
|
||||
printf("No bot definition file found.\n");
|
||||
qUsesBotnames = false;
|
||||
return;
|
||||
}
|
||||
|
||||
qUsesBotnames = true;
|
||||
iMaxBotnames = 0;
|
||||
// id is OK as os
|
||||
while ((fscanf(fd, "%16[^\n]\n", cBotName[iMaxBotnames]) == 1) && !feof(fd)) { // only load 16 chars...
|
||||
printf("Found botname %d...\n",iMaxBotnames);
|
||||
iMaxBotnames++;
|
||||
}
|
||||
|
||||
if(iMaxBotnames < svs.maxclients) // Just to be safe.
|
||||
{
|
||||
printf("Not enough bot names in botnames.cfg\n");
|
||||
qUsesBotnames = false;
|
||||
}
|
||||
// eukara - loading botnames end
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue