_bot no longer crashes but...

Bots do not spawn in after picking their teams. Also including
This commit is contained in:
JezuzLizard 2020-05-10 17:43:31 -07:00
parent 786d5cd109
commit 1070187ae8

View File

@ -19,6 +19,14 @@
init() //checked matches cerberus output init() //checked matches cerberus output
{ {
//begin debug code
level.custom_bot_loaded = 1;
maps/mp/gametypes/_clientids::init();
if ( !isDefined( level.debugLogging_bot ) )
{
level.debugLogging_bot = 0;
}
//end debug code
/* /*
/# /#
level thread bot_system_devgui_think(); level thread bot_system_devgui_think();
@ -29,18 +37,23 @@ init() //checked matches cerberus output
{ {
return; return;
} }
/*
if ( level.rankedmatch && !is_bot_ranked_match() ) if ( level.rankedmatch && !is_bot_ranked_match() )
{ {
return; return;
} }
*/
/*
bot_friends = getDvarInt( "bot_friends" ); bot_friends = getDvarInt( "bot_friends" );
bot_enemies = getDvarInt( "bot_enemies" ); bot_enemies = getDvarInt( "bot_enemies" );
if ( bot_friends <= 0 && bot_enemies <= 0 ) if ( bot_friends <= 0 && bot_enemies <= 0 )
{ {
return; return;
} }
bot_wait_for_host(); */
//bot_wait_for_host();
bot_set_difficulty(); bot_set_difficulty();
/*
if ( is_bot_comp_stomp() ) if ( is_bot_comp_stomp() )
{ {
team = bot_choose_comp_stomp_team(); team = bot_choose_comp_stomp_team();
@ -52,8 +65,9 @@ init() //checked matches cerberus output
} }
else else
{ {
*/
level thread bot_local_think(); level thread bot_local_think();
} //}
} }
spawn_bot( team ) //checked matches cerberus output spawn_bot( team ) //checked matches cerberus output
@ -80,7 +94,7 @@ getenemyteamwithlowestplayercount( player_team ) //checked partially changed to
counts[ team ] = 0; counts[ team ] = 0;
} }
i = 0; i = 0;
players = get_players; players = get_players();
while ( i < players.size ) while ( i < players.size )
{ {
if ( !isDefined( players[ i ].team ) ) if ( !isDefined( players[ i ].team ) )
@ -98,26 +112,19 @@ getenemyteamwithlowestplayercount( player_team ) //checked partially changed to
} }
count = 999999; count = 999999;
enemy_team = player_team; enemy_team = player_team;
i = 0; foreach ( team in level.teams )
teams = getArrayKeys( level.teams );
while ( i < teams.size )
{ {
if ( teams[ i ] == player_team ) if ( team == player_team )
{ {
i++;
continue;
} }
if ( teams[ i ] == "spectator" ) else if ( team == "spectator" )
{ {
i++;
continue;
} }
if ( counts[ teams[ i ] ] < count ) else if ( counts[ team ] < count )
{ {
enemy_team = teams[ i ]; enemy_team = team;
count = counts[ teams[ i ] ]; count = counts[ team ];
} }
i++;
} }
return enemy_team; return enemy_team;
} }
@ -153,26 +160,19 @@ getenemyteamwithgreatestbotcount( player_team ) //checked partially changed to m
} }
count = -1; count = -1;
enemy_team = undefined; enemy_team = undefined;
i = 0; foreach ( team in level.teams )
teams = getArrayKeys( level.teams );
while ( i < teams.size )
{ {
if ( teams[ i ] == player_team ) if ( team == player_team )
{ {
i++;
continue;
} }
if ( teams[ i ] == "spectator" ) else if ( team == "spectator" )
{ {
i++;
continue;
} }
if ( counts[ teams[ i ] ] > count ) else if ( counts[ team ] > count )
{ {
enemy_team = teams[ i ]; enemy_team = team;
count = counts[ teams[ i ] ]; count = counts[ team ];
} }
i++;
} }
return enemy_team; return enemy_team;
} }
@ -252,17 +252,15 @@ bot_count_enemy_bots( friend_team ) //checked partially changed to match cerberu
return bot_count_bots(); return bot_count_bots();
} }
enemies = 0; enemies = 0;
i = 0; foreach ( team in level.teams )
teams = getArrayKeys( level.teams );
while ( i < teams.size )
{ {
if ( teams[ i ] == friend_team ) if ( team == friend_team )
{ {
i++;
continue;
} }
enemies += bot_count_bots( teams[ i ] ); else
i++; {
enemies += bot_count_bots( team );
}
} }
return enemies; return enemies;
} }
@ -486,8 +484,10 @@ bot_local_think() //checked changed at own discretion
{ {
host_team = "allies"; host_team = "allies";
} }
bot_expected_friends = getDvarInt( "bot_friends" ); //bot_expected_friends = getDvarInt( "bot_friends" );
bot_expected_enemies = getDvarInt( "bot_enemies" ); //bot_expected_enemies = getDvarInt( "bot_enemies" );
bot_expected_friends = 1;
bot_expected_enemies = 1;
if ( islocalgame() ) if ( islocalgame() )
{ {
} }
@ -502,7 +502,7 @@ bot_local_think() //checked changed at own discretion
wait 0.5; wait 0.5;
continue; continue;
} }
else if ( bot_local_enemies( bot_expected_enemies, max_players, host_team ) ) if ( bot_local_enemies( bot_expected_enemies, max_players, host_team ) )
{ {
wait 0.5; wait 0.5;
continue; continue;
@ -1762,21 +1762,20 @@ bot_update_weapon()
{ {
return; return;
} }
primariesArray = self getweaponslistprimaries(); primaries = self getweaponslistprimaries();
i = 0; foreach ( primary in primaries )
primaries = getArrayKeys( primariesArray );
while ( i < primaries.size )
{ {
if ( primaries[ i ] == "knife_held_mp" ) if ( primary == "knife_held_mp" )
{ {
i++; i++;
continue; continue;
} }
if ( ( self getweaponammoclip( primaries[ i ] ) || self getweaponammostock( primaries[ i ] ) ) && primaries[ i ] != weapon ) if ( ( self getweaponammoclip( primary ) || self getweaponammostock( primary ) ) && primary != weapon )
{ {
self switchtoweapon( primaries[ i ] ); self switchtoweapon( primary );
return; return;
} }
i++;
} }
} }
@ -2596,3 +2595,5 @@ devgui_bot_spawn_think( origin, yaw ) //didn't check dev call