t4 refactor

This commit is contained in:
ineed bots
2025-05-22 18:51:26 -06:00
parent 3e08ac900d
commit b8597ee810
4 changed files with 56 additions and 5 deletions

View File

@@ -36,7 +36,7 @@ init()
if ( getdvar( "bots_main_firstIsHost" ) == "" )
{
setdvar( "bots_main_firstIsHost", true ); // first player to connect is a host
setdvar( "bots_main_firstIsHost", false ); // first player to connect is a host
}
if ( getdvar( "bots_main_waitForHostTime" ) == "" )

View File

@@ -170,6 +170,39 @@ BotBuiltinWriteLine( fh, contents )
}
}
/*
*/
BotBuiltinCmdExec( what )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "cmdexec" ] ) )
{
[[ level.bot_builtins[ "cmdexec" ] ]]( what );
}
}
/*
*/
BotBuiltinNotifyOnPlayerCommand( cmd, notif )
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "notifyonplayercommand" ] ) )
{
self [[ level.bot_builtins[ "notifyonplayercommand" ] ]]( cmd, notif );
}
}
/*
waw doesnt have
*/
BotBuiltinIsHost()
{
if ( isdefined( level.bot_builtins ) && isdefined( level.bot_builtins[ "ishost" ] ) )
{
return self [[ level.bot_builtins[ "ishost" ] ]]();
}
return false;
}
/*
Returns if player is the host
*/
@@ -222,7 +255,7 @@ doHostCheck()
}
}
if ( !result )
if ( !self BotBuiltinIsHost() && !result )
{
return;
}

View File

@@ -25,10 +25,10 @@ init()
if ( !getdvarint( "developer" ) )
{
setdvar( "developer_script", 1 );
setdvar( "developer", 1 );
setdvar( "developer", 2 );
setdvar( "sv_mapRotation", "map " + getdvar( "mapname" ) );
exitlevel( false );
BotBuiltinCmdExec( "devmap " + getdvar( "mapname" ) );
return;
}
setdvar( "bots_main", 0 );

View File

@@ -12,6 +12,24 @@ init()
level.bot_builtins[ "fs_fclose" ] = ::do_fs_fclose;
level.bot_builtins[ "fs_readline" ] = ::do_fs_readline;
level.bot_builtins[ "fs_writeline" ] = ::do_fs_writeline;
level.bot_builtins[ "notifyonplayercommand" ] = ::do_notifyonplayercommand;
level.bot_builtins[ "cmdexec" ] = ::do_cmdexec;
level.bot_builtins[ "ishost" ] = ::do_ishost;
}
do_notifyonplayercommand( a, b )
{
self notifyonplayercommand( a, b );
}
do_cmdexec( a )
{
cmdexec( a );
}
do_ishost()
{
return self ishost();
}
do_printconsole( s )