always use curly braces

This commit is contained in:
ineed bots
2023-12-19 19:24:07 -06:00
parent 9e2025e86a
commit 4aba1289f2
5 changed files with 572 additions and 10 deletions

View File

@@ -10,82 +10,132 @@ init()
level.bw_version = "z0.1";
if ( getdvar( "bots_main" ) == "" )
{
setdvar( "bots_main", true );
}
if ( !getdvarint( "bots_main" ) )
{
return;
}
if ( !wait_for_builtins() )
{
println( "FATAL: NO BUILT-INS FOR BOTS" );
}
thread load_waypoints();
thread hook_callbacks();
if ( getdvar( "bots_main_GUIDs" ) == "" )
setdvar( "bots_main_GUIDs", "" ); //guids of players who will be given host powers, comma seperated
{
setdvar( "bots_main_GUIDs", "" ); //guids of players who will be given host powers, comma seperated
}
if ( getdvar( "bots_main_firstIsHost" ) == "" )
setdvar( "bots_main_firstIsHost", false ); //first player to connect is a host
{
setdvar( "bots_main_firstIsHost", false ); //first player to connect is a host
}
if ( getdvar( "bots_main_waitForHostTime" ) == "" )
setdvar( "bots_main_waitForHostTime", 10.0 ); //how long to wait to wait for the host player
{
setdvar( "bots_main_waitForHostTime", 10.0 ); //how long to wait to wait for the host player
}
if ( getdvar( "bots_main_kickBotsAtEnd" ) == "" )
setdvar( "bots_main_kickBotsAtEnd", false ); //kicks the bots at game end
{
setdvar( "bots_main_kickBotsAtEnd", false ); //kicks the bots at game end
}
if ( getdvar( "bots_manage_add" ) == "" )
setdvar( "bots_manage_add", 0 ); //amount of bots to add to the game
{
setdvar( "bots_manage_add", 0 ); //amount of bots to add to the game
}
if ( getdvar( "bots_manage_fill" ) == "" )
setdvar( "bots_manage_fill", 0 ); //amount of bots to maintain
{
setdvar( "bots_manage_fill", 0 ); //amount of bots to maintain
}
if ( getdvar( "bots_manage_fill_mode" ) == "" )
setdvar( "bots_manage_fill_mode", 0 ); //fill mode, 0 adds everyone, 1 just bots, 2 maintains at maps, 3 is 2 with 1
{
setdvar( "bots_manage_fill_mode", 0 ); //fill mode, 0 adds everyone, 1 just bots, 2 maintains at maps, 3 is 2 with 1
}
if ( getdvar( "bots_manage_fill_kick" ) == "" )
setdvar( "bots_manage_fill_kick", false ); //kick bots if too many
{
setdvar( "bots_manage_fill_kick", false ); //kick bots if too many
}
if ( getdvar( "bots_skill" ) == "" )
setdvar( "bots_skill", 0 ); //0 is random, 1 is easy 7 is hard, 8 is custom, 9 is completely random
{
setdvar( "bots_skill", 0 ); //0 is random, 1 is easy 7 is hard, 8 is custom, 9 is completely random
}
if ( getdvar( "bots_skill_hard" ) == "" )
setdvar( "bots_skill_hard", 0 ); //amount of hard bots on axis team
{
setdvar( "bots_skill_hard", 0 ); //amount of hard bots on axis team
}
if ( getdvar( "bots_skill_med" ) == "" )
{
setdvar( "bots_skill_med", 0 );
}
if ( getdvar( "bots_loadout_rank" ) == "" ) // what rank the bots should be around, -1 is around the players, 0 is all random
{
setdvar( "bots_loadout_rank", -1 );
}
if ( getdvar( "bots_loadout_prestige" ) == "" ) // what pretige the bots will be, -1 is the players, -2 is random
{
setdvar( "bots_loadout_prestige", -1 );
}
if ( getdvar( "bots_play_move" ) == "" ) //bots move
{
setdvar( "bots_play_move", true );
}
if ( getdvar( "bots_play_knife" ) == "" ) //bots knife
{
setdvar( "bots_play_knife", true );
}
if ( getdvar( "bots_play_fire" ) == "" ) //bots fire
{
setdvar( "bots_play_fire", true );
}
if ( getdvar( "bots_play_nade" ) == "" ) //bots grenade
{
setdvar( "bots_play_nade", true );
}
if ( getdvar( "bots_play_ads" ) == "" ) //bot ads
{
setdvar( "bots_play_ads", true );
}
if ( getdvar( "bots_play_aim" ) == "" )
{
setdvar( "bots_play_aim", true );
}
if ( getdvar( "bots_t8_mode" ) == "" )
{
setdvar( "bots_t8_mode", false );
}
if ( getdvar( "bots_play_opendoors" ) == "" )
{
setdvar( "bots_play_opendoors", true );
}
if ( !isdefined( game[ "botWarfare" ] ) )
{
game[ "botWarfare" ] = true;
}
level.bots_minsprintdistance = 315;
level.bots_minsprintdistance *= level.bots_minsprintdistance;
@@ -133,12 +183,16 @@ handleBots()
level addBots();
while ( !isdefined( level.intermission ) || !level.intermission )
{
wait 0.05;
}
setdvar( "bots_manage_add", getBotArray().size );
if ( !getdvarint( "bots_main_kickBotsAtEnd" ) )
{
return;
}
bots = getBotArray();
@@ -258,7 +312,9 @@ connected()
self endon( "disconnect" );
if ( !isdefined( self.pers[ "bot_host" ] ) )
{
self thread doHostCheck();
}
level.players[ level.players.size ] = self;
self thread onDisconnectAll();
@@ -266,7 +322,9 @@ connected()
self thread onSpawnedAll();
if ( !self is_bot() )
{
return;
}
if ( !isdefined( self.pers[ "isBot" ] ) )
{
@@ -307,25 +365,39 @@ watchBotDebugEvent()
big_str = "Bot Warfare debug: " + self.playername + ": " + msg;
if ( isdefined( str ) && isstring( str ) )
{
big_str += ", " + str;
}
if ( isdefined( b ) && isstring( b ) )
{
big_str += ", " + b;
}
if ( isdefined( c ) && isstring( c ) )
{
big_str += ", " + c;
}
if ( isdefined( d ) && isstring( d ) )
{
big_str += ", " + d;
}
if ( isdefined( e ) && isstring( e ) )
{
big_str += ", " + e;
}
if ( isdefined( f ) && isstring( f ) )
{
big_str += ", " + f;
}
if ( isdefined( g ) && isstring( g ) )
{
big_str += ", " + g;
}
BotBuiltinPrintConsole( big_str );
}
@@ -383,10 +455,14 @@ diffBots_loop()
player = level.players[ i ];
if ( !isdefined( player.pers[ "team" ] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( hard < var_hard )
{
@@ -399,7 +475,9 @@ diffBots_loop()
player.pers[ "bots" ][ "skill" ][ "base" ] = 4;
}
else
{
player.pers[ "bots" ][ "skill" ][ "base" ] = 1;
}
}
}
else if ( var_skill != 0 && var_skill != 9 )
@@ -411,7 +489,9 @@ diffBots_loop()
player = level.players[ i ];
if ( !player is_bot() )
{
continue;
}
player.pers[ "bots" ][ "skill" ][ "base" ] = var_skill;
}
@@ -443,7 +523,9 @@ addBots_loop()
setdvar( "bots_manage_add", 0 );
if ( botsToAdd > 4 )
{
botsToAdd = 4;
}
for ( ; botsToAdd > 0; botsToAdd-- )
{
@@ -455,7 +537,9 @@ addBots_loop()
fillMode = getdvarint( "bots_manage_fill_mode" );
if ( fillMode == 2 || fillMode == 3 )
{
setdvar( "bots_manage_fill", getGoodMapAmount() );
}
fillAmount = getdvarint( "bots_manage_fill" );
@@ -469,24 +553,34 @@ addBots_loop()
player = level.players[ i ];
if ( player is_bot() )
{
bots++;
}
else
{
players++;
}
}
amount = bots;
if ( fillMode == 0 || fillMode == 2 )
{
amount += players;
}
if ( amount < fillAmount )
{
setdvar( "bots_manage_add", 1 );
}
else if ( amount > fillAmount && getdvarint( "bots_manage_fill_kick" ) )
{
tempBot = getBotToKick();
if ( isdefined( tempBot ) )
{
BotBuiltinCmdExec( "clientkick " + tempBot getentitynumber() );
}
}
}