better bot kick logic

This commit is contained in:
ineed bots 2023-12-13 12:43:34 -06:00
parent 7458491ac1
commit 532eb70a47
2 changed files with 33 additions and 1 deletions

View File

@ -483,7 +483,7 @@ addBots_loop()
setDvar( "bots_manage_add", 1 );
else if ( amount > fillAmount && getDvarInt( "bots_manage_fill_kick" ) )
{
tempBot = PickRandom( getBotArray() );
tempBot = getBotToKick();
if ( isDefined( tempBot ) )
BotBuiltinCmdExec( "clientkick " + tempBot getEntityNumber() );

View File

@ -1168,6 +1168,38 @@ getMapName( map )
return map;
}
/*
Returns a bot to be kicked
*/
getBotToKick()
{
bots = getBotArray();
if ( !isDefined( bots ) || !isDefined( bots.size ) || bots.size <= 0 || !isDefined( bots[0] ) )
return undefined;
tokick = undefined;
// just kick lowest skill
for ( i = 0; i < bots.size; i++ )
{
bot = bots[i];
if ( !isDefined( bot ) )
continue;
if ( !isDefined( bot.pers ) || !isDefined( bot.pers["bots"] ) || !isDefined( bot.pers["bots"]["skill"] ) || !isDefined( bot.pers["bots"]["skill"]["base"] ) )
continue;
if ( isDefined( tokick ) && bot.pers["bots"]["skill"]["base"] > tokick.pers["bots"]["skill"]["base"] )
continue;
tokick = bot;
}
return tokick;
}
/*
Returns an array of all the bots in the game.
*/