curly braces

This commit is contained in:
ineed bots
2023-12-22 01:28:59 -06:00
parent 6921651ab0
commit 8ec1385d18
7 changed files with 2774 additions and 4 deletions

View File

@@ -18,127 +18,207 @@ init()
level.bw_VERSION = "2.1.0";
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
}
if ( getDvar( "bots_main_firstIsHost" ) == "" )
{
setDvar( "bots_main_firstIsHost", false ); //first play 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
}
if ( getDvar( "bots_main_kickBotsAtEnd" ) == "" )
{
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
}
if ( getDvar( "bots_manage_fill" ) == "" )
{
setDvar( "bots_manage_fill", 0 ); //amount of bots to maintain
}
if ( getDvar( "bots_manage_fill_spec" ) == "" )
{
setDvar( "bots_manage_fill_spec", true ); //to count for fill if player is on spec team
}
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
}
if ( getDvar( "bots_manage_fill_kick" ) == "" )
{
setDvar( "bots_manage_fill_kick", false ); //kick bots if too many
}
if ( getDvar( "bots_team" ) == "" )
{
setDvar( "bots_team", "autoassign" ); //which team for bots to join
}
if ( getDvar( "bots_team_amount" ) == "" )
{
setDvar( "bots_team_amount", 0 ); //amount of bots on axis team
}
if ( getDvar( "bots_team_force" ) == "" )
{
setDvar( "bots_team_force", false ); //force bots on team
}
if ( getDvar( "bots_team_mode" ) == "" )
{
setDvar( "bots_team_mode", 0 ); //counts just bots when 1
}
if ( getDvar( "bots_skill" ) == "" )
{
setDvar( "bots_skill", 0 ); //0 is random, 1 is easy 7 is hard, 8 is custom, 9 is completely random
}
if ( getDvar( "bots_skill_axis_hard" ) == "" )
{
setDvar( "bots_skill_axis_hard", 0 ); //amount of hard bots on axis team
}
if ( getDvar( "bots_skill_axis_med" ) == "" )
{
setDvar( "bots_skill_axis_med", 0 );
}
if ( getDvar( "bots_skill_allies_hard" ) == "" )
{
setDvar( "bots_skill_allies_hard", 0 );
}
if ( getDvar( "bots_skill_allies_med" ) == "" )
{
setDvar( "bots_skill_allies_med", 0 );
}
if ( getDvar( "bots_skill_min" ) == "" )
{
setDvar( "bots_skill_min", 1 );
}
if ( getDvar( "bots_skill_max" ) == "" )
{
setDvar( "bots_skill_max", 7 );
}
if ( getDvar( "bots_loadout_reasonable" ) == "" ) //filter out the bad 'guns' and perks
{
setDvar( "bots_loadout_reasonable", false );
}
if ( getDvar( "bots_loadout_allow_op" ) == "" ) //allows jug, marty and laststand
{
setDvar( "bots_loadout_allow_op", true );
}
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_take_carepackages" ) == "" ) //bots take carepackages
{
setDvar( "bots_play_take_carepackages", true );
}
if ( getDvar( "bots_play_obj" ) == "" ) //bots play the obj
{
setDvar( "bots_play_obj", true );
}
if ( getDvar( "bots_play_camp" ) == "" ) //bots camp and follow
{
setDvar( "bots_play_camp", true );
}
if ( getDvar( "bots_play_jumpdrop" ) == "" ) //bots jump and dropshot
{
setDvar( "bots_play_jumpdrop", true );
}
if ( getDvar( "bots_play_target_other" ) == "" ) //bot target non play ents (vehicles)
{
setDvar( "bots_play_target_other", true );
}
if ( getDvar( "bots_play_killstreak" ) == "" ) //bot use killstreaks
{
setDvar( "bots_play_killstreak", true );
}
if ( getDvar( "bots_play_ads" ) == "" ) //bot ads
{
setDvar( "bots_play_ads", true );
}
if ( getDvar( "bots_play_aim" ) == "" )
{
setDvar( "bots_play_aim", true );
}
if ( !isDefined( game["botWarfare"] ) )
{
game["botWarfare"] = true;
}
level.defuseObject = undefined;
level.bots_smokeList = List();
@@ -212,12 +292,16 @@ handleBots()
level addBots();
while ( !level.intermission )
{
wait 0.05;
}
setDvar( "bots_manage_add", getBotArray().size );
if ( !getDvarInt( "bots_main_kickBotsAtEnd" ) )
{
return;
}
bots = getBotArray();
@@ -279,7 +363,9 @@ fixGamemodes()
if ( isDefined( level.bombZones ) && level.gametype == "sd" )
{
for ( i = 0; i < level.bombZones.size; i++ )
{
level.bombZones[i].onUse = ::onUsePlantObjectFix;
}
break;
}
@@ -317,9 +403,13 @@ fixDem()
bombzone = level.bombZones[i];
if ( isDefined( bombzone.trigger.trigger_off ) )
{
bombzone.bombExploded = true;
}
else
{
bombzone.bombExploded = undefined;
}
}
wait 0.05;
@@ -345,14 +435,18 @@ fixKoth()
for ( i = level.radios.size - 1; i >= 0; i-- )
{
if ( level.radioObject != level.radios[i].gameobject )
{
continue;
}
level.radio = level.radios[i];
break;
}
while ( isDefined( level.radioObject ) && level.radio.gameobject == level.radioObject )
{
wait 0.05;
}
}
}
@@ -368,7 +462,9 @@ addNotifyOnAirdrops_loop()
airdrop = dropCrates[i];
if ( isDefined( airdrop.doingPhysics ) )
{
continue;
}
airdrop.doingPhysics = true;
airdrop thread doNotifyOnAirdrop();
@@ -398,7 +494,9 @@ doNotifyOnAirdrop()
self.doingPhysics = false;
if ( isDefined( self.owner ) )
{
self.owner notify( "crate_physics_done" );
}
self thread onCarepackageCaptured();
}
@@ -452,23 +550,33 @@ watchScrabler_loop()
player = level.players[i];
if ( !player _HasPerk( "specialty_localjammer" ) || !isReallyAlive( player ) )
{
continue;
}
if ( player isEMPed() )
{
continue;
}
for ( h = level.players.size - 1; h >= 0; h-- )
{
player2 = level.players[h];
if ( player2 == player )
{
continue;
}
if ( level.teamBased && player2.team == player.team )
{
continue;
}
if ( DistanceSquared( player2.origin, player.origin ) > 256 * 256 )
{
continue;
}
player2.bot_isScrambled = true;
}
@@ -506,10 +614,14 @@ connected()
self endon( "disconnect" );
if ( !isDefined( self.pers["bot_host"] ) )
{
self thread doHostCheck();
}
if ( !self is_bot() )
{
return;
}
if ( !isDefined( self.pers["isBot"] ) )
{
@@ -550,25 +662,39 @@ watchBotDebugEvent()
big_str = "Bot Warfare debug: " + self.name + ": " + 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 );
}
@@ -630,10 +756,14 @@ diffBots_loop()
player = level.players[i];
if ( !isDefined( player.pers["team"] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( player.pers["team"] == "axis" )
{
@@ -648,7 +778,9 @@ diffBots_loop()
player.pers["bots"]["skill"]["base"] = 4;
}
else
{
player.pers["bots"]["skill"]["base"] = 1;
}
}
else if ( player.pers["team"] == "allies" )
{
@@ -663,7 +795,9 @@ diffBots_loop()
player.pers["bots"]["skill"]["base"] = 4;
}
else
{
player.pers["bots"]["skill"]["base"] = 1;
}
}
}
}
@@ -676,7 +810,9 @@ diffBots_loop()
player = level.players[i];
if ( !player is_bot() )
{
continue;
}
player.pers["bots"]["skill"]["base"] = var_skill;
}
@@ -691,7 +827,9 @@ diffBots_loop()
player = level.players[i];
if ( !player is_bot() )
{
continue;
}
player.pers["bots"]["skill"]["base"] = int( clamp( player.pers["bots"]["skill"]["base"], min_diff, max_diff ) );
}
@@ -730,21 +868,31 @@ teamBots_loop()
player = level.players[i];
if ( !isDefined( player.pers["team"] ) )
{
continue;
}
if ( player is_bot() )
{
if ( player.pers["team"] == "allies" )
{
alliesbots++;
}
else if ( player.pers["team"] == "axis" )
{
axisbots++;
}
}
else
{
if ( player.pers["team"] == "allies" )
{
alliesplayers++;
}
else if ( player.pers["team"] == "axis" )
{
axisplayers++;
}
}
}
@@ -768,7 +916,9 @@ teamBots_loop()
toTeam = "axis";
if ( axis > allies )
{
toTeam = "allies";
}
}
}
@@ -781,20 +931,32 @@ teamBots_loop()
player = level.players[i];
if ( !isDefined( player.pers["team"] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( player.pers["team"] == toTeam )
{
continue;
}
if ( toTeam == "allies" )
{
player thread [[level.allies]]();
}
else if ( toTeam == "axis" )
{
player thread [[level.axis]]();
}
else
{
player thread [[level.spectator]]();
}
break;
}
@@ -810,10 +972,14 @@ teamBots_loop()
player = level.players[i];
if ( !isDefined( player.pers["team"] ) )
{
continue;
}
if ( !player is_bot() )
{
continue;
}
if ( player.pers["team"] == "axis" )
{
@@ -864,7 +1030,9 @@ addBots_loop()
SetDvar( "bots_manage_add", 0 );
if ( botsToAdd > 64 )
{
botsToAdd = 64;
}
for ( ; botsToAdd > 0; botsToAdd-- )
{
@@ -876,7 +1044,9 @@ addBots_loop()
fillMode = getDVarInt( "bots_manage_fill_mode" );
if ( fillMode == 2 || fillMode == 3 )
{
setDvar( "bots_manage_fill", getGoodMapAmount() );
}
fillAmount = getDvarInt( "bots_manage_fill" );
@@ -891,11 +1061,17 @@ addBots_loop()
player = level.players[i];
if ( player is_bot() )
{
bots++;
}
else if ( !isDefined( player.pers["team"] ) || ( player.pers["team"] != "axis" && player.pers["team"] != "allies" ) )
{
spec++;
}
else
{
players++;
}
}
if ( !randomInt( 999 ) )
@@ -918,15 +1094,23 @@ addBots_loop()
player = level.players[i];
if ( player is_bot() )
{
continue;
}
if ( !isDefined( player.pers["team"] ) )
{
continue;
}
if ( player.pers["team"] == "axis" )
{
axisplayers++;
}
else if ( player.pers["team"] == "allies" )
{
alliesplayers++;
}
}
result = fillAmount - abs( axisplayers - alliesplayers ) + bots;
@@ -934,11 +1118,17 @@ addBots_loop()
if ( players == 0 )
{
if ( bots < fillAmount )
{
result = fillAmount - 1;
}
else if ( bots > fillAmount )
{
result = fillAmount + 1;
}
else
{
result = fillAmount;
}
}
bots = result;
@@ -947,19 +1137,27 @@ addBots_loop()
amount = bots;
if ( fillMode == 0 || fillMode == 2 )
{
amount += players;
}
if ( getDVarInt( "bots_manage_fill_spec" ) )
{
amount += spec;
}
if ( amount < fillAmount )
{
setDvar( "bots_manage_add", 1 );
}
else if ( amount > fillAmount && getDvarInt( "bots_manage_fill_kick" ) )
{
tempBot = getBotToKick();
if ( isDefined( tempBot ) )
{
kick( tempBot getEntityNumber(), "EXE_PLAYERKICKED" );
}
}
}
@@ -992,14 +1190,20 @@ onGrenadeFire()
self waittill ( "grenade_fire", grenade, weaponName );
if ( !isDefined( grenade ) )
{
continue;
}
grenade.name = weaponName;
if ( weaponName == "smoke_grenade_mp" )
{
grenade thread AddToSmokeList();
}
else if ( isSubStr( weaponName, "frag_" ) )
{
grenade thread AddToFragList( self );
}
}
}