From 27bd26254c50d519258805d0ffcba10bb636d6d5 Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Sat, 13 Jun 2026 11:40:54 +0100 Subject: [PATCH] feat: implement bot name retrieval from botnames.txt --- maps/mp/bots/_bot.gsc | 13 ++++++++++- maps/mp/bots/_bot_utility.gsc | 44 +++++++++++++++++++++++++++++++++++ scriptdata/botnames.txt | 17 ++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 scriptdata/botnames.txt diff --git a/maps/mp/bots/_bot.gsc b/maps/mp/bots/_bot.gsc index 4092545..2331e97 100644 --- a/maps/mp/bots/_bot.gsc +++ b/maps/mp/bots/_bot.gsc @@ -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 ) ) { diff --git a/maps/mp/bots/_bot_utility.gsc b/maps/mp/bots/_bot_utility.gsc index b484f97..c85613e 100644 --- a/maps/mp/bots/_bot_utility.gsc +++ b/maps/mp/bots/_bot_utility.gsc @@ -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 */ diff --git a/scriptdata/botnames.txt b/scriptdata/botnames.txt new file mode 100644 index 0000000..13287b1 --- /dev/null +++ b/scriptdata/botnames.txt @@ -0,0 +1,17 @@ +bota +botb +botc +botd +bote +botf +botg +both +boti +botj +botk +botl +botm +botn +boto +botp +botq \ No newline at end of file