From 6993ba227f7471cd4e7e6062706bf45ad4f20efa Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 4 Jan 2024 15:43:23 -0600 Subject: [PATCH] fill empty lines --- .astylerc | 14 +- .editorconfig | 2 +- scripts/mp/bots.gsc | 655 ++++++++++++++++++++++---------------------- 3 files changed, 338 insertions(+), 333 deletions(-) diff --git a/.astylerc b/.astylerc index c0e7be1..6c2ea21 100644 --- a/.astylerc +++ b/.astylerc @@ -1,21 +1,27 @@ # try to mimic the original gsc provided +# ghc mode=c style=allman -indent=tab +indent=force-tab=2 lineend=windows pad-oper pad-paren-in pad-header - -# delete-empty-lines +# pad-brackets # adds outer bracket spaces... only want inner spaces +fill-empty-lines +squeeze-lines=2 +squeeze-ws +break-one-line-headers +add-braces +remove-comment-prefix break-blocks -# remove-braces indent-switches indent-cases indent-after-parens +indent-col1-comments remove-comment-prefix diff --git a/.editorconfig b/.editorconfig index bb97c78..be8eb14 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true indent_style = tab indent_size = 2 charset = latin1 -trim_trailing_whitespace = true +trim_trailing_whitespace = false insert_final_newline = true [*.md] diff --git a/scripts/mp/bots.gsc b/scripts/mp/bots.gsc index 2e26641..dcfe4d6 100644 --- a/scripts/mp/bots.gsc +++ b/scripts/mp/bots.gsc @@ -15,22 +15,22 @@ main() { level.bw_version = "1.1.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" ); } - + // fix bot grenade launcher usage BotBuiltinReplaceFunc( BotBuiltinGetFunction( "maps/mp/bots/_bot_combat", "bot_should_hip_fire" ), ::bot_should_hip_fire_replaced ); } @@ -44,116 +44,116 @@ init() { return; } - + if ( !wait_for_builtins() ) { println( "FATAL: NO BUILT-INS FOR BOTS" ); } - + 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_kickBotsAtEnd" ) == "" ) { setdvar( "bots_main_kickBotsAtEnd", false ); // kicks the bots at game end (dedis hang with bots on map rotate) } - + if ( getdvar( "bots_main_waitForHostTime" ) == "" ) { setdvar( "bots_main_waitForHostTime", 10.0 ); // how long to wait to wait for the host player } - + 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_skill" ) == "" ) // alias for bot_difficulty { setdvar( "bots_skill", "" ); } - + 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_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_nade" ) == "" ) { setdvar( "bots_play_nade", true ); } - + if ( getdvar( "bots_play_aim" ) == "" ) { setdvar( "bots_play_aim", true ); } - + if ( getdvar( "bots_play_jumpdrop" ) == "" ) // bots jump and dropshot { setdvar( "bots_play_jumpdrop", true ); } - + if ( !isdefined( game[ "botWarfare" ] ) ) { game[ "botWarfare" ] = true; } - + thread fixGamemodes(); - + thread onPlayerConnect(); - + thread handleBots(); } @@ -164,12 +164,12 @@ bot_should_hip_fire_replaced() { weapon = self getcurrentweapon(); class = weaponclass( weapon ); - + if ( class == "grenade" ) { return 1; } - + func = BotBuiltinGetFunction( "maps/mp/bots/_bot_combat", "bot_should_hip_fire" ); BotBuiltinDisableDetourOnce( func ); return self [[ func ]](); @@ -181,7 +181,7 @@ bot_should_hip_fire_replaced() fixGamemodes() { wait 0.25; - + if ( level.gametype == "sd" ) { level.bot_gametype = ::bot_sd_think; @@ -196,25 +196,25 @@ handleBots() thread diffBots(); thread teamBots(); addBots(); - + while ( !level.intermission ) { wait 0.05; } - + setdvar( "bots_manage_add", getBotArray().size ); - + if ( !getdvarint( "bots_main_kickBotsAtEnd" ) ) { return; } - + bots = getBotArray(); - + for ( i = 0; i < bots.size; i++ ) { bot = bots[ i ]; - + if ( isdefined( bot ) ) { kick( bot getentitynumber() ); @@ -230,15 +230,15 @@ diffBots() for ( ;; ) { wait 1.5; - + // we dont use 'bots_skill' so that we can still use the .menu dvar - + if ( getdvar( "bots_skill" ) != "" ) { setdvar( "bot_difficulty", getdvar( "bots_skill" ) ); setdvar( "bots_skill", "" ); } - + bot_set_difficulty( getdvarint( "bot_difficulty" ) ); } } @@ -329,7 +329,7 @@ bot_set_difficulty( difficulty ) { return; } - + setdvar( "bot_MinDeathTime", "500" ); setdvar( "bot_MaxDeathTime", "1000" ); setdvar( "bot_MinFireTime", "600" ); @@ -354,7 +354,7 @@ bot_set_difficulty( difficulty ) setdvar( "bot_MeleeDist", "70" ); setdvar( "bot_YawSpeed", "1.2" ); } - + if ( level.gametype == "oic" && difficulty == 3 ) { setdvar( "bot_MinReactionTime", "400" ); @@ -362,24 +362,24 @@ bot_set_difficulty( difficulty ) setdvar( "bot_MinAdsTime", "1000" ); setdvar( "bot_MaxAdsTime", "2000" ); } - + if ( ( difficulty == 2 || difficulty == 3 ) && level.gametype == "oic" ) { setdvar( "bot_Sprintdistance", "256" ); } - + if ( !getdvarint( "bots_play_nade" ) ) { setdvar( "bot_AllowGrenades", "0" ); } - + if ( !getdvarint( "bots_play_aim" ) ) { setdvar( "bot_YawSpeed", "0" ); setdvar( "bot_PitchUp", "0" ); setdvar( "bot_PitchDown", "0" ); } - + setdvar( "bot_difficulty", difficulty ); level.bot_difficulty = undefined; level maps\mp\bots\_bot::bot_get_difficulty(); @@ -392,18 +392,18 @@ teamBots_loop() { teamAmount = getdvarint( "bots_team_amount" ); toTeam = getdvar( "bots_team" ); - + alliesbots = 0; alliesplayers = 0; axisbots = 0; axisplayers = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) ) { if ( player is_bot() ) @@ -430,16 +430,16 @@ teamBots_loop() } } } - + allies = alliesbots; axis = axisbots; - + if ( !getdvarint( "bots_team_mode" ) ) { allies += alliesplayers; axis += axisplayers; } - + if ( toTeam != "custom" ) { if ( getdvarint( "bots_team_force" ) ) @@ -449,22 +449,22 @@ teamBots_loop() if ( abs( axis - allies ) > 1 ) { toTeam = "axis"; - + if ( axis > allies ) { toTeam = "allies"; } } } - + if ( toTeam != "autoassign" ) { playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) && player is_bot() && ( player.pers[ "team" ] != toTeam ) ) { if ( toTeam == "allies" ) @@ -479,7 +479,7 @@ teamBots_loop() { player thread [[ level.spectator ]](); } - + break; } } @@ -489,11 +489,11 @@ teamBots_loop() else { playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) && player is_bot() ) { if ( player.pers[ "team" ] == "axis" ) @@ -540,42 +540,42 @@ teamBots() addBots_loop() { botsToAdd = getdvarint( "bots_manage_add" ); - + if ( botsToAdd > 0 ) { setdvar( "bots_manage_add", 0 ); - + if ( botsToAdd > 64 ) { botsToAdd = 64; } - + for ( ; botsToAdd > 0; botsToAdd-- ) { level add_bot(); wait 0.5; } } - + fillMode = getdvarint( "bots_manage_fill_mode" ); - + if ( fillMode == 2 || fillMode == 3 ) { setdvar( "bots_manage_fill", getGoodMapAmount() ); } - + fillAmount = getdvarint( "bots_manage_fill" ); - + players = 0; bots = 0; spec = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) ) { if ( player is_bot() ) @@ -592,18 +592,18 @@ addBots_loop() } } } - + if ( fillMode == 4 ) { axisplayers = 0; alliesplayers = 0; - + playercount = level.players.size; - + for ( i = 0; i < playercount; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) && !player is_bot() ) { if ( player.pers[ "team" ] == "axis" ) @@ -616,9 +616,9 @@ addBots_loop() } } } - + result = fillAmount - abs( axisplayers - alliesplayers ) + bots; - + if ( players == 0 ) { if ( bots < fillAmount ) @@ -634,10 +634,10 @@ addBots_loop() result = fillAmount; } } - + bots = result; } - + if ( !randomint( 999 ) ) { setdvar( "testclients_doreload", true ); @@ -645,19 +645,19 @@ addBots_loop() setdvar( "testclients_doreload", false ); doExtraCheck(); } - + 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 ); @@ -665,7 +665,7 @@ addBots_loop() else if ( amount > fillAmount && getdvarint( "bots_manage_fill_kick" ) ) { tempBot = getBotToKick(); - + if ( isdefined( tempBot ) ) { kick( tempBot getentitynumber() ); @@ -679,13 +679,13 @@ addBots_loop() addBots() { level endon ( "game_ended" ); - + bot_wait_for_host(); - + for ( ;; ) { wait 1.5; - + addBots_loop(); } } @@ -696,7 +696,7 @@ addBots() add_bot() { bot = addtestclient(); - + if ( isdefined( bot ) ) { bot.pers[ "isBot" ] = true; @@ -713,7 +713,7 @@ onPlayerConnect() for ( ;; ) { level waittill( "connected", player ); - + player thread connected(); } } @@ -724,34 +724,34 @@ onPlayerConnect() connected() { self endon( "disconnect" ); - + if ( !isdefined( self.pers ) || !isdefined( self.pers[ "bot_host" ] ) ) { self thread doHostCheck(); } - + if ( !self istestclient() ) { return; } - + if ( !isdefined( self.pers[ "isBot" ] ) ) { self.pers[ "isBot" ] = true; } - + if ( !isdefined( self.pers[ "isBotWarfare" ] ) ) { self.pers[ "isBotWarfare" ] = true; self thread added(); } - + self thread teamWatch(); self thread classWatch(); self thread onBotSpawned(); - + self thread setranks(); - + self thread watchBotDebugEvent(); } @@ -761,50 +761,50 @@ connected() watchBotDebugEvent() { self endon( "disconnect" ); - + for ( ;; ) { self waittill( "bot_event", msg, str, b, c, d, e, f, g ); - + if ( getdvarint( "bots_main_debug" ) >= 2 ) { 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 ); } else if ( msg == "debug" && getdvarint( "bots_main_debug" ) ) @@ -820,22 +820,22 @@ watchBotDebugEvent() onBotSpawned() { self endon( "disconnect" ); - + for ( ;; ) { self waittill( "spawned_player" ); self BotBuiltinClearOverrides( true ); self BotBuiltinWeaponOverride( self getcurrentweapon() ); - + self thread watch_for_override_stuff(); self thread watch_for_melee_override(); self thread bot_watch_think_mw2(); self BotNotifyBotEvent( "debug", "we spawned!" ); - + waittillframeend; - + self.bot_first_spawn = undefined; - + if ( randomint( 100 ) < 2 ) { self.bot_change_class = undefined; @@ -849,24 +849,24 @@ onBotSpawned() getValidTube() { weaps = self getweaponslist( true ); - + for ( i = 0; i < weaps.size; i++ ) { weap = weaps[ i ]; - + if ( !self getammocount( weap ) ) { continue; } - + if ( !isstrstart( weap, "gl_" ) ) { continue; } - + return weap; } - + return undefined; } @@ -878,23 +878,23 @@ bot_watch_think_mw2() self endon( "disconnect" ); self endon( "death" ); level endon( "game_ended" ); - + for ( ;; ) { wait randomintrange( 1, 4 ); - + if ( self isremotecontrolling() ) { continue; } - + if ( self maps\mp\bots\_bot_combat::bot_has_enemy() ) { continue; } - + tube = self getValidTube(); - + if ( !isdefined( tube ) ) { if ( self getammocount( "usrpg_mp" ) ) @@ -910,17 +910,17 @@ bot_watch_think_mw2() return; } } - + if ( self getcurrentweapon() == tube ) { return; } - + if ( randomint( 100 ) > 35 ) { return; } - + self switchtoweapon( tube ); } } @@ -932,53 +932,53 @@ watch_for_melee_override() { self endon( "disconnect" ); self endon( "death" ); - + for ( ;; ) { while ( ( !self maps\mp\bots\_bot_combat::threat_is_player() && !self maps\mp\bots\_bot_combat::threat_is_dog() ) || self isremotecontrolling() || !self hasweapon( "knife_mp" ) || !getdvarint( "aim_automelee_enabled" ) ) { wait 0.05; } - + threat = self.bot.threat.entity; - + while ( isdefined( threat ) && isdefined( self.bot.threat.entity ) && self.bot.threat.entity == threat ) { dist = distance( self.origin, threat.origin ); - + if ( self isonground() && self getstance() != "prone" && dist < getdvarfloat( "aim_automelee_range" ) && ( getConeDot( threat.origin, self.origin, self getplayerangles() ) > 0.9 || dist < 10 ) ) { self BotBuiltinBotMeleeParams( threat getentitynumber(), dist ); self BotBuiltinButtonOverride( "melee", "enable" ); self BotBuiltinAimOverride(); - + time_left = 1; once = false; - + while ( time_left > 0 && isdefined( threat ) && isalive( threat ) ) { self setplayerangles( vectortoangles( threat gettagorigin( "j_spine4" ) - self geteye() ) ); time_left -= 0.05; wait 0.05; - + if ( !once ) { once = true; self BotBuiltinClearButtonOverride( "melee" ); } } - + if ( !once ) { self BotBuiltinClearButtonOverride( "melee" ); } - + self BotBuiltinClearMeleeParams(); self BotBuiltinClearAimOverride(); wait 1; break; } - + wait 0.05; } } @@ -991,14 +991,14 @@ watch_for_override_stuff() { self endon( "disconnect" ); self endon( "death" ); - + NEAR_DIST = 80; LONG_DIST = 1000; SPAM_JUMP_TIME = 5000; - + diff = level maps\mp\bots\_bot::bot_get_difficulty(); chance = 0; - + if ( diff == "normal" ) { chance = 25; @@ -1011,33 +1011,33 @@ watch_for_override_stuff() { chance = 80; } - + last_jump_time = 0; - + if ( !getdvarint( "bots_play_jumpdrop" ) ) { return; } - + for ( ;; ) { while ( !self maps\mp\bots\_bot_combat::threat_is_player() || self isremotecontrolling() ) { wait 0.05; } - + threat = self.bot.threat.entity; dist = distance( threat.origin, self.origin ); time = gettime(); weap = self getcurrentweapon(); - + weapon_is_good = true; - + if ( weap == "none" || !self getweaponammoclip( weap ) ) { weapon_is_good = false; } - + if ( weapon_is_good && ( dist > NEAR_DIST ) && ( dist < LONG_DIST ) && ( randomint( 100 ) < chance ) && ( ( time - last_jump_time ) > SPAM_JUMP_TIME ) ) { if ( randomint( 2 ) ) @@ -1045,13 +1045,13 @@ watch_for_override_stuff() if ( ( getConeDot( threat.origin, self.origin, self getplayerangles() ) > 0.8 ) && ( dist > ( NEAR_DIST * 2 ) ) ) { last_jump_time = time; - + // drop shot self BotBuiltinMovementOverride( 0, 0 ); self BotBuiltinButtonOverride( "prone", "enable" ); - + wait 1.5; - + self BotBuiltinClearMovementOverride(); self BotBuiltinClearButtonOverride( "prone" ); } @@ -1059,14 +1059,14 @@ watch_for_override_stuff() else { last_jump_time = time; - + // jump shot self BotBuiltinButtonOverride( "gostand", "enable" ); wait 0.1; self BotBuiltinClearButtonOverride( "gostand" ); } } - + while ( isdefined( threat ) && isdefined( self.bot.threat.entity ) && ( threat == self.bot.threat.entity ) ) { wait 0.05; @@ -1080,16 +1080,16 @@ watch_for_override_stuff() setranks() { self endon( "disconnect" ); - + wait 0.05; - + self setCustomRanks(); - + if ( !level.gameended ) { level waittill( "game_ended" ); } - + self.pers[ "bot_rankxp" ] = self.pers[ "rankxp" ]; } @@ -1102,15 +1102,15 @@ setCustomRanks() { return; } - + self.pers[ "prestige" ] = self.pers[ "bot_prestige" ]; self.pers[ "plevel" ] = self.pers[ "bot_prestige" ]; - + self.pers[ "rankxp" ] = self.pers[ "bot_rankxp" ]; self.pers[ "rank" ] = self maps\mp\gametypes\_rank::getrankforxp( self.pers[ "rankxp" ] ); - + self setrank( self.pers[ "rank" ], self.pers[ "prestige" ] ); - + self maps\mp\gametypes\_rank::syncxpstat(); } @@ -1120,22 +1120,22 @@ setCustomRanks() teamWatch() { self endon( "disconnect" ); - + for ( ;; ) { while ( !isdefined( self.team ) || !allowTeamChoice() ) { wait .05; } - + wait 0.1; - + // multiteam? if ( self.team != "axis" && self.team != "allies" ) { self notify( "menuresponse", game[ "menu_team" ], getdvar( "bots_team" ) ); } - + while ( isdefined( self.team ) ) { wait .05; @@ -1149,23 +1149,23 @@ teamWatch() classWatch() { self endon( "disconnect" ); - + for ( ;; ) { while ( !isdefined( self.team ) || !allowClassChoice() ) { wait .05; } - + wait 0.5; - + if ( !maps\mp\gametypes\_globallogic_utils::isvalidclass( self.class ) || !isdefined( self.bot_change_class ) ) { self notify( "menuresponse", game[ "menu_changeclass" ], self chooseRandomClass() ); } - + self.bot_change_class = true; - + while ( isdefined( self.team ) && maps\mp\gametypes\_globallogic_utils::isvalidclass( self.class ) && isdefined( self.bot_change_class ) ) { wait .05; @@ -1188,7 +1188,7 @@ chooseRandomClass() classes[ classes.size ] = "class_sniper"; return PickRandom( classes ); } - + return PickRandom( self maps\mp\bots\_bot::bot_build_classes() ); } @@ -1198,7 +1198,7 @@ chooseRandomClass() added() { self endon( "disconnect" ); - + self thread doCustomRank(); } @@ -1209,18 +1209,18 @@ bot_get_prestige() { p_dvar = getdvarint( "bots_loadout_prestige" ); p = 0; - + if ( p_dvar == -1 ) { for ( i = 0; i < level.players.size; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) && !player is_bot() ) { p = player.pers[ "prestige" ]; } - + break; } } @@ -1232,7 +1232,7 @@ bot_get_prestige() { p = p_dvar; } - + return p; } @@ -1242,19 +1242,19 @@ bot_get_prestige() doCustomRank() { self endon( "disconnect" ); - + // prevent generating classes if ( getdvarint( "bots_loadout_rank" ) != -1 ) { self.pers[ "bot_loadout" ] = true; } - + // wait for the original scripts to execute wait 0.25; - + // get rank rankxp = self.pers[ "rankxp" ]; - + if ( getdvarint( "bots_loadout_rank" ) != -1 ) { if ( getdvarint( "bots_loadout_rank" ) == 0 ) @@ -1266,13 +1266,13 @@ doCustomRank() rankxp = maps\mp\gametypes\_rank::getrankinfominxp( getdvarint( "bots_loadout_rank" ) ); } } - + // apply self.pers[ "bot_prestige" ] = bot_get_prestige(); self.pers[ "bot_rankxp" ] = rankxp; - + self setCustomRanks(); - + // generate the custom classes if ( getdvarint( "bots_loadout_rank" ) != -1 ) { @@ -1281,7 +1281,7 @@ doCustomRank() self botsetdefaultclass( 7, "class_lmg" ); self botsetdefaultclass( 8, "class_cqb" ); self botsetdefaultclass( 9, "class_sniper" ); - + self maps\mp\bots\_bot_loadout::bot_construct_loadout( 10 ); } } @@ -1292,122 +1292,122 @@ doCustomRank() keyCodeToString( a ) { b = ""; - + switch ( a ) { case 0: b = "a"; break; - + case 1: b = "b"; break; - + case 2: b = "c"; break; - + case 3: b = "d"; break; - + case 4: b = "e"; break; - + case 5: b = "f"; break; - + case 6: b = "g"; break; - + case 7: b = "h"; break; - + case 8: b = "i"; break; - + case 9: b = "j"; break; - + case 10: b = "k"; break; - + case 11: b = "l"; break; - + case 12: b = "m"; break; - + case 13: b = "n"; break; - + case 14: b = "o"; break; - + case 15: b = "p"; break; - + case 16: b = "q"; break; - + case 17: b = "r"; break; - + case 18: b = "s"; break; - + case 19: b = "t"; break; - + case 20: b = "u"; break; - + case 21: b = "v"; break; - + case 22: b = "w"; break; - + case 23: b = "x"; break; - + case 24: b = "y"; break; - + case 25: b = "z"; break; - + case 26: b = "."; break; - + case 27: b = " "; break; } - + return b; } @@ -1432,7 +1432,7 @@ wait_for_builtins() { return true; } - + if ( i < 18 ) { waittillframeend; @@ -1442,7 +1442,7 @@ wait_for_builtins() wait 0.05; } } - + return false; } @@ -1647,7 +1647,7 @@ is_host() { return false; } - + return ( isdefined( self.pers[ "bot_host" ] ) && self.pers[ "bot_host" ] ); } @@ -1657,35 +1657,35 @@ is_host() doHostCheck() { self.pers[ "bot_host" ] = false; - + if ( self istestclient() ) { return; } - + result = false; - + if ( getdvar( "bots_main_firstIsHost" ) != "0" ) { BotBuiltinPrintConsole( "WARNING: bots_main_firstIsHost is enabled" ); - + if ( getdvar( "bots_main_firstIsHost" ) == "1" ) { setdvar( "bots_main_firstIsHost", self getguid() ); } - + if ( getdvar( "bots_main_firstIsHost" ) == self getguid() + "" ) { result = true; } } - + DvarGUID = getdvar( "bots_main_GUIDs" ); - + if ( DvarGUID != "" ) { guids = strtok( DvarGUID, "," ); - + for ( i = 0; i < guids.size; i++ ) { if ( self getguid() + "" == guids[ i ] ) @@ -1694,12 +1694,12 @@ doHostCheck() } } } - + if ( !self ishost() && !result ) { return; } - + self.pers[ "bot_host" ] = true; } @@ -1709,27 +1709,27 @@ doHostCheck() getBotToKick() { bots = getBotArray(); - + if ( !isdefined( bots ) || !isdefined( bots.size ) || bots.size <= 0 || !isdefined( bots[ 0 ] ) ) { return undefined; } - + tokick = undefined; axis = 0; allies = 0; team = getdvar( "bots_team" ); - + // count teams for ( i = 0; i < bots.size; i++ ) { bot = bots[ i ]; - + if ( !isdefined( bot ) || !isdefined( bot.team ) ) { continue; } - + if ( bot.team == "allies" ) { allies++; @@ -1743,7 +1743,7 @@ getBotToKick() return bot; } } - + // search for a bot on the other team if ( team == "custom" || team == "axis" ) { @@ -1753,7 +1753,7 @@ getBotToKick() { // get the team with the most bots team = "allies"; - + if ( axis > allies ) { team = "axis"; @@ -1763,43 +1763,43 @@ getBotToKick() { team = "axis"; } - + // get the bot on this team with lowest skill for ( i = 0; i < bots.size; i++ ) { bot = bots[ i ]; - + if ( !isdefined( bot ) || !isdefined( bot.team ) ) { continue; } - + if ( bot.team != team ) { continue; } - + tokick = bot; } - + if ( isdefined( tokick ) ) { return tokick; } - + // just kick lowest skill for ( i = 0; i < bots.size; i++ ) { bot = bots[ i ]; - + if ( !isdefined( bot ) || !isdefined( bot.team ) ) { continue; } - + tokick = bot; } - + return tokick; } @@ -1811,13 +1811,13 @@ GetHostPlayer() for ( i = 0; i < level.players.size; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && player is_host() ) { return player; } } - + return undefined; } @@ -1827,51 +1827,51 @@ GetHostPlayer() bot_wait_for_host() { host = undefined; - + while ( !isdefined( level ) || !isdefined( level.players ) ) { wait 0.05; } - + for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) { host = GetHostPlayer(); - + if ( isdefined( host ) ) { break; } - + wait 0.05; } - + if ( !isdefined( host ) ) { return; } - + for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) { if ( isdefined( host.team ) ) { break; } - + wait 0.05; } - + if ( !isdefined( host.team ) ) { return; } - + for ( i = getdvarfloat( "bots_main_waitForHostTime" ); i > 0; i -= 0.05 ) { if ( ( host.pers[ "team" ] == "allies" ) || ( host.pers[ "team" ] == "axis" ) ) { break; } - + wait 0.05; } } @@ -1901,7 +1901,7 @@ PickRandom( arr ) { return undefined; } - + return arr[ randomint( arr.size ) ]; } @@ -1911,17 +1911,17 @@ PickRandom( arr ) getBotArray() { answer = []; - + for ( i = 0; i < level.players.size; i++ ) { player = level.players[ i ]; - + if ( isdefined( player ) && isdefined( player.team ) && player is_bot() ) { answer[ answer.size ] = player; } } - + return answer; } @@ -1934,27 +1934,27 @@ is_bot() { return false; } - + if ( !isdefined( self.pers ) || !isdefined( self.team ) ) { return false; } - + if ( isdefined( self.pers[ "isBot" ] ) && self.pers[ "isBot" ] ) { return true; } - + if ( isdefined( self.pers[ "isBotWarfare" ] ) && self.pers[ "isBotWarfare" ] ) { return true; } - + if ( self istestclient() ) { return true; } - + return false; } @@ -1974,7 +1974,6 @@ checkTheBots() } - // _bot_sd // fix crash @@ -1985,7 +1984,7 @@ bot_sd_think() // checked changed to match cerberus output self.bot.patrol_update = 0; self.bot.lookat_update = 0; } - + foreach ( zone in level.bombzones ) { if ( !isdefined( zone.nearest_node ) ) @@ -1999,9 +1998,9 @@ bot_sd_think() // checked changed to match cerberus output zone.nearest_node = nodes[ 0 ]; } } - + zone = sd_get_planted_zone(); - + if ( isdefined( zone ) ) { self bot_sd_defender( zone, 1 ); @@ -2012,7 +2011,7 @@ bot_sd_think() // checked changed to match cerberus output { self.isbombcarrier = 1; } - + self bot_sd_attacker(); } else @@ -2025,11 +2024,11 @@ bot_sd_think() // checked changed to match cerberus output bot_sd_attacker() // checked changed to match cerberus output { level endon( "game_ended" ); - + if ( !level.multibomb && !isdefined( level.sdbomb.carrier ) && !level.bombplanted ) { self cancelgoal( "sd_protect_carrier" ); - + if ( !level.sdbomb maps\mp\gametypes\_gameobjects::isobjectawayfromhome() ) { if ( !self maps\mp\bots\_bot::bot_friend_goal_in_radius( "sd_pickup", level.sdbomb.curorigin, 64 ) ) @@ -2048,11 +2047,11 @@ bot_sd_attacker() // checked changed to match cerberus output { self cancelgoal( "sd_pickup" ); } - + if ( is_true( self.isbombcarrier ) ) { goal = self getgoal( "sd_plant" ); - + if ( isdefined( goal ) ) { if ( distancesquared( self.origin, goal ) < 2304 ) @@ -2061,30 +2060,30 @@ bot_sd_attacker() // checked changed to match cerberus output wait 0.5; self pressusebutton( level.planttime + 1 ); wait 0.5; - + if ( is_true( self.isplanting ) ) { wait ( level.planttime + 1 ); } - + self pressusebutton( 0 ); self setstance( "crouch" ); wait 0.25; self cancelgoal( "sd_plant" ); self setstance( "stand" ); } - + return; } else if ( gettime() > self.bot.patrol_update ) { frac = sd_get_time_frac(); - + if ( ( randomint( 100 ) < ( frac * 100 ) ) || ( frac > 0.85 ) ) { zone = sd_get_closest_bomb(); goal = sd_get_bomb_goal( zone.visuals[ 0 ] ); - + if ( isdefined( goal ) ) { if ( frac > 0.85 ) @@ -2097,7 +2096,7 @@ bot_sd_attacker() // checked changed to match cerberus output } } } - + self.bot.patrol_update = gettime() + randomintrange( 2500, 5000 ); } } @@ -2114,15 +2113,15 @@ bot_sd_attacker() // checked changed to match cerberus output self.protectcarrier = 0; } } - + if ( self.protectcarrier ) { goal = level.sdbomb.carrier getgoal( "sd_plant" ); - + if ( isdefined( goal ) ) { nodes = getnodesinradiussorted( goal, 256, 0 ); - + if ( isdefined( nodes ) && ( nodes.size > 0 ) && !isdefined( self getgoal( "sd_protect_carrier" ) ) ) { self addgoal( nodes[ randomint( nodes.size ) ], 24, 3, "sd_protect_carrier" ); @@ -2140,12 +2139,12 @@ doTheCheck_() bot_sd_defender( zone, isplanted ) // checked partially changed to match cerberus output did not use foreach see github for more info { bot_sd_grenade(); - + if ( isdefined( isplanted ) && isplanted && self hasgoal( "sd_defend" ) ) { goal = self getgoal( "sd_defend" ); planted = sd_get_planted_zone(); - + foreach ( zone in level.bombzones ) { if ( planted != zone && ( distance2d( goal, zone.nearest_node.origin ) < distance2d( goal, planted.nearest_node.origin ) ) ) @@ -2154,22 +2153,22 @@ bot_sd_defender( zone, isplanted ) // checked partially changed to match cerberu } } } - + if ( self atgoal( "sd_defend" ) || self bot_need_to_defuse() ) { bot_sd_defender_think( zone ); - + if ( self hasgoal( "sd_defend" ) ) { return; } } - + if ( self hasgoal( "enemy_patrol" ) ) { goal = self getgoal( "enemy_patrol" ); closezone = sd_get_closest_bomb(); - + if ( distancesquared( goal, closezone.nearest_node.origin ) < 262144 ) { self clearlookat(); @@ -2177,23 +2176,23 @@ bot_sd_defender( zone, isplanted ) // checked partially changed to match cerberu return; } } - + if ( self hasgoal( "sd_defend" ) ) { self.bot.patrol_update = gettime() + randomintrange( 2500, 5000 ); return; } - + if ( self hasgoal( "enemy_patrol" ) ) { return; } - + nodes = getvisiblenodes( zone.nearest_node ); best = undefined; highest = -100; i = 0; - + while ( i < nodes.size ) { if ( nodes[ i ].type == "BAD NODE" || !canclaimnode( nodes[ i ], self.team ) || ( distancesquared( nodes[ i ].origin, self.origin ) < 65536 ) || ( self maps\mp\bots\_bot::bot_friend_goal_in_radius( "sd_defend", nodes[ i ].origin, 256 ) > 0 ) ) @@ -2203,7 +2202,7 @@ bot_sd_defender( zone, isplanted ) // checked partially changed to match cerberu else { height = nodes[ i ].origin[ 2 ] - zone.nearest_node.origin[ 2 ]; - + if ( is_true( isplanted ) ) { dist = distance2d( nodes[ i ].origin, zone.nearest_node.origin ); @@ -2213,64 +2212,64 @@ bot_sd_defender( zone, isplanted ) // checked partially changed to match cerberu { score = height; } - + if ( score > highest ) { highest = score; best = nodes[ i ]; } - + i++; } } - + if ( !isdefined( best ) ) { return; } - + self addgoal( best, 24, 3, "sd_defend" ); } bot_get_look_at() // checked matches cebrerus output { enemy = self maps\mp\bots\_bot::bot_get_closest_enemy( self.origin, 1 ); - + if ( isdefined( enemy ) ) { node = getvisiblenode( self.origin, enemy.origin ); - + if ( isdefined( node ) && ( distancesquared( self.origin, node.origin ) > 16384 ) ) { return node.origin; } } - + enemies = self maps\mp\bots\_bot::bot_get_enemies( 0 ); - + if ( enemies.size ) { enemy = random( enemies ); } - + if ( isdefined( enemy ) ) { node = getvisiblenode( self.origin, enemy.origin ); - + if ( isdefined( node ) && ( distancesquared( self.origin, node.origin ) > 16384 ) ) { return node.origin; } } - + zone = sd_get_closest_bomb(); node = getvisiblenode( self.origin, zone.nearest_node.origin ); - + if ( isdefined( node ) && ( distancesquared( self.origin, node.origin ) > 16384 ) ) { return node.origin; } - + forward = anglestoforward( self getplayerangles() ); origin = self geteye() + ( forward * 1024 ); return origin; @@ -2284,22 +2283,22 @@ bot_sd_defender_think( zone ) // checked matches cerberus output { return; } - + self clearlookat(); goal = self getgoal( "sd_defuse" ); - + if ( isdefined( goal ) && ( distancesquared( self.origin, goal ) < 2304 ) ) { self setstance( "prone" ); wait 0.5; self pressusebutton( level.defusetime + 1 ); wait 0.5; - + if ( is_true( self.isdefusing ) ) { wait ( level.defusetime + 1 ); } - + self pressusebutton( 0 ); self setstance( "crouch" ); wait 0.25; @@ -2307,15 +2306,15 @@ bot_sd_defender_think( zone ) // checked matches cerberus output self setstance( "stand" ); return; } - + if ( !isdefined( goal ) && ( distance2dsquared( self.origin, level.sdbombmodel.origin ) < 1000000 ) ) { self addgoal( level.sdbombmodel.origin, 24, 4, "sd_defuse" ); } - + return; } - + if ( gettime() > self.bot.patrol_update ) { if ( cointoss() ) @@ -2324,15 +2323,15 @@ bot_sd_defender_think( zone ) // checked matches cerberus output self cancelgoal( "sd_defend" ); return; } - + self.bot.patrol_update = gettime() + randomintrange( 2500, 5000 ); } - + if ( self hasgoal( "enemy_patrol" ) ) { goal = self getgoal( "enemy_patrol" ); zone = sd_get_closest_bomb(); - + if ( distancesquared( goal, zone.nearest_node.origin ) < 262144 ) { self clearlookat(); @@ -2340,27 +2339,27 @@ bot_sd_defender_think( zone ) // checked matches cerberus output return; } } - + if ( gettime() > self.bot.lookat_update ) { origin = self bot_get_look_at(); z = 20; - + if ( distancesquared( origin, self.origin ) > 262144 ) { z = randomintrange( 16, 60 ); } - + self lookat( origin + ( 0, 0, z ) ); self.bot.lookat_update = gettime() + randomintrange( 1500, 3000 ); - + if ( distancesquared( origin, self.origin ) > 65536 ) { dir = vectornormalize( self.origin - origin ); dir = vectorScale( dir, 256 ); origin += dir; } - + self maps\mp\bots\_bot_combat::bot_combat_throw_proximity( origin ); } } @@ -2371,7 +2370,7 @@ bot_need_to_defuse() // checked changed at own discretion { return 1; } - + return 0; } @@ -2387,7 +2386,7 @@ sd_get_bomb_goal( ent ) // checked changed to match cerberus output goals[ 2 ] = ent.origin + dir; goals[ 3 ] = ent.origin - dir; goals = array_randomize( goals ); - + foreach ( goal in goals ) { if ( findpath( self.origin, goal, 0 ) ) @@ -2395,7 +2394,7 @@ sd_get_bomb_goal( ent ) // checked changed to match cerberus output return goal; } } - + return undefined; } @@ -2403,13 +2402,13 @@ sd_get_time_frac() // checked matches cerberus output { remaining = maps\mp\gametypes\_globallogic_utils::gettimeremaining(); end = ( level.timelimit * 60 ) * 1000; - + if ( end == 0 ) { end = self.spawntime + 120000; remaining = end - gettime(); } - + return 1 - ( remaining / end ); } @@ -2417,11 +2416,11 @@ sd_get_closest_bomb() // checked partially changed to match cerberus output did { best = undefined; distsq = 9999999; - + foreach ( zone in level.bombzones ) { d = distancesquared( self.origin, zone.curorigin ); - + if ( !isdefined( best ) ) { best = zone; @@ -2433,7 +2432,7 @@ sd_get_closest_bomb() // checked partially changed to match cerberus output did distsq = d; } } - + return best; } @@ -2449,21 +2448,21 @@ sd_get_planted_zone() // checked changed to match cerberus output } } } - + return undefined; } bot_sd_grenade() // checked changed to match cerberus output { enemies = bot_get_enemies(); - + if ( !enemies.size ) { return; } - + zone = sd_get_closest_bomb(); - + foreach ( enemy in enemies ) { if ( distancesquared( enemy.origin, zone.nearest_node.origin ) < 147456 ) @@ -2472,7 +2471,7 @@ bot_sd_grenade() // checked changed to match cerberus output { self maps\mp\bots\_bot_combat::bot_combat_throw_tactical( enemy.origin ); } - + return; } }