mirror of
https://github.com/ineedbots/t4_bot_warfare.git
synced 2025-04-19 15:02:53 +00:00
better bot kicking logic
This commit is contained in:
parent
6075cee7e4
commit
58c8498991
@ -816,7 +816,7 @@ addBots_loop()
|
|||||||
setDvar( "bots_manage_add", 1 );
|
setDvar( "bots_manage_add", 1 );
|
||||||
else if ( amount > fillAmount && getDvarInt( "bots_manage_fill_kick" ) )
|
else if ( amount > fillAmount && getDvarInt( "bots_manage_fill_kick" ) )
|
||||||
{
|
{
|
||||||
tempBot = PickRandom( getBotArray() );
|
tempBot = getBotToKick();
|
||||||
|
|
||||||
if ( isDefined( tempBot ) )
|
if ( isDefined( tempBot ) )
|
||||||
kick( tempBot getEntityNumber() );
|
kick( tempBot getEntityNumber() );
|
||||||
|
@ -1825,6 +1825,98 @@ doExtraCheck()
|
|||||||
maps\mp\bots\_bot_internal::checkTheBots();
|
maps\mp\bots\_bot_internal::checkTheBots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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;
|
||||||
|
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++;
|
||||||
|
else if ( bot.team == "axis" )
|
||||||
|
axis++;
|
||||||
|
else // choose bots that are not on a team first
|
||||||
|
return bot;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search for a bot on the other team
|
||||||
|
if ( team == "custom" || team == "axis" )
|
||||||
|
{
|
||||||
|
team = "allies";
|
||||||
|
}
|
||||||
|
else if ( team == "autoassign" )
|
||||||
|
{
|
||||||
|
// get the team with the most bots
|
||||||
|
team = "allies";
|
||||||
|
|
||||||
|
if ( axis > allies )
|
||||||
|
team = "axis";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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.
|
Returns an array of all the bots in the game.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user