Added custom bot names

This commit is contained in:
Your Name 2020-09-10 14:34:14 -06:00
parent d18a4e6ffd
commit 557bdfefd1
5 changed files with 73 additions and 7 deletions

5
.gitignore vendored
View File

@ -13,3 +13,8 @@
!/main_shared/maps/mp/gametypes/_callbacksetup.gsx !/main_shared/maps/mp/gametypes/_callbacksetup.gsx
main_shared/maps/mp/gametypes/_globallogic.gsx main_shared/maps/mp/gametypes/_globallogic.gsx
main_shared/maps/mp/gametypes/_hardpoints.gsx main_shared/maps/mp/gametypes/_hardpoints.gsx
!/main/
/main/*
!/main/botnames.txt
!/main/waypoints/

View File

@ -1,6 +0,0 @@
a
b
c
d
e
f

26
main/botnames.txt Normal file
View File

@ -0,0 +1,26 @@
bota
botb
botc
botd
bote
botf
botg
both
boti
botj
botk
botl
botm
botn
boto
botp
botq
botr
bots
bott
botu
botv
botw
botx
boty
botz

View File

@ -315,7 +315,14 @@ connected()
*/ */
add_bot() add_bot()
{ {
bot = addtestclient(); name = getABotName();
bot = undefined;
if (isDefined(name) && name.size >= 3)
bot = addtestclient(name);
else
bot = addtestclient();
if (isdefined(bot)) if (isdefined(bot))
{ {

View File

@ -652,6 +652,40 @@ parseTokensIntoWaypoint(tokens)
return waypoint; return waypoint;
} }
getABotName()
{
if (!isDefined(level.bot_names))
{
level.bot_names = [];
level.bot_name_cursor = 0;
filename = "botnames.txt";
if (FS_TestFile(filename))
{
f = FS_FOpen(filename, "read");
name = FS_ReadLine(f);
while (isDefined(name) && name != "")
{
level.bot_names[level.bot_names.size] = name;
name = FS_ReadLine(f);
}
FS_FClose(f);
}
}
if (!level.bot_names.size)
return undefined;
name = level.bot_names[level.bot_name_cursor % level.bot_names.size];
level.bot_name_cursor++;
return name;
}
readWpsFromFile(mapname) readWpsFromFile(mapname)
{ {
waypoints = []; waypoints = [];