mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2026-06-25 10:28:08 +00:00
feat: implement bot name retrieval from botnames.txt
This commit is contained in:
+12
-1
@@ -775,7 +775,18 @@ added()
|
|||||||
*/
|
*/
|
||||||
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 ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1312,6 +1312,50 @@ getWaypointLinesFromFile( filename )
|
|||||||
return result;
|
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
|
Loads waypoints from file
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
bota
|
||||||
|
botb
|
||||||
|
botc
|
||||||
|
botd
|
||||||
|
bote
|
||||||
|
botf
|
||||||
|
botg
|
||||||
|
both
|
||||||
|
boti
|
||||||
|
botj
|
||||||
|
botk
|
||||||
|
botl
|
||||||
|
botm
|
||||||
|
botn
|
||||||
|
boto
|
||||||
|
botp
|
||||||
|
botq
|
||||||
Reference in New Issue
Block a user