feat: implement bot name retrieval from botnames.txt

This commit is contained in:
Michael Oliver
2026-06-13 11:40:54 +01:00
committed by mo
parent e7f1a90440
commit 27bd26254c
3 changed files with 73 additions and 1 deletions
+12 -1
View File
@@ -775,7 +775,18 @@ added()
*/
add_bot()
{
bot = addtestclient();
name = getABotName();
bot = undefined;
if ( isdefined( name ) && name.size >= 3 )
{
bot = addtestclient( name );
}
else
{
bot = addtestclient();
}
if ( isdefined( bot ) )
{
+44
View File
@@ -1312,6 +1312,50 @@ getWaypointLinesFromFile( filename )
return result;
}
/*
Returns a bot's name to be used. Reads from botnames.txt
*/
getABotName()
{
if ( !isdefined( level.bot_names ) )
{
level.bot_names = [];
if ( getdvar( "temp_dvar_bot_name_cursor" ) == "" )
{
setdvar( "temp_dvar_bot_name_cursor", 0 );
}
filename = "botnames.txt";
if ( BotBuiltinFileExists( filename ) )
{
openResult = BotBuiltinOpenFile( filename, "read" );
if ( openResult > 0 )
{
for ( line = BotBuiltinReadStream(); isdefined( line ); line = BotBuiltinReadStream() )
{
level.bot_names[ level.bot_names.size ] = line;
}
BotBuiltinCloseFile();
}
}
}
if ( !level.bot_names.size )
{
return undefined;
}
cur = getdvarint( "temp_dvar_bot_name_cursor" );
name = level.bot_names[ cur % level.bot_names.size ];
setdvar( "temp_dvar_bot_name_cursor", cur + 1 );
return name;
}
/*
Loads waypoints from file
*/
+17
View File
@@ -0,0 +1,17 @@
bota
botb
botc
botd
bote
botf
botg
both
boti
botj
botk
botl
botm
botn
boto
botp
botq