mgr: random bot kick is now more even across teams

This commit is contained in:
jeefo 2024-06-01 13:58:48 +03:00
commit 87cbd144c2
No known key found for this signature in database
GPG key ID: D696786B81B667C8
3 changed files with 24 additions and 18 deletions

View file

@ -126,6 +126,7 @@ public:
bool isTeamStacked (int team); bool isTeamStacked (int team);
bool kickRandom (bool decQuota = true, Team fromTeam = Team::Unassigned); bool kickRandom (bool decQuota = true, Team fromTeam = Team::Unassigned);
bool balancedKickRandom (bool decQuota);
bool hasCustomCSDMSpawnEntities (); bool hasCustomCSDMSpawnEntities ();
bool isLineBlockedBySmoke (const Vector &from, const Vector &to, float grenadeBloat = 1.0f); bool isLineBlockedBySmoke (const Vector &from, const Vector &to, float grenadeBloat = 1.0f);

View file

@ -53,7 +53,7 @@ int BotControl::cmdKickBot () {
bots.kickFromTeam (Team::Terrorist); bots.kickFromTeam (Team::Terrorist);
} }
else { else {
bots.kickRandom (); bots.balancedKickRandom (true);
} }
return BotCommandResult::Handled; return BotCommandResult::Handled;
} }

View file

@ -460,23 +460,7 @@ void BotManager::maintainQuota () {
createRandom (); createRandom ();
} }
else if (desiredBotCount < botsInGame) { else if (desiredBotCount < botsInGame) {
const auto &tp = countTeamPlayers (); balancedKickRandom (false);
bool isKicked = false;
if (tp.first > tp.second) {
isKicked = kickRandom (false, Team::Terrorist);
}
else if (tp.first < tp.second) {
isKicked = kickRandom (false, Team::CT);
}
else {
isKicked = kickRandom (false, Team::Unassigned);
}
// if we can't kick player from correct team, just kick any random to keep quota control work
if (!isKicked) {
kickRandom (false, Team::Unassigned);
}
} }
else { else {
// clear the saved names when quota balancing ended // clear the saved names when quota balancing ended
@ -796,6 +780,27 @@ bool BotManager::kickRandom (bool decQuota, Team fromTeam) {
return false; return false;
} }
bool BotManager::balancedKickRandom (bool decQuota) {
const auto &tp = countTeamPlayers ();
bool isKicked = false;
if (tp.first > tp.second) {
isKicked = kickRandom (decQuota, Team::Terrorist);
}
else if (tp.first < tp.second) {
isKicked = kickRandom (decQuota, Team::CT);
}
else {
isKicked = kickRandom (decQuota, Team::Unassigned);
}
// if we can't kick player from correct team, just kick any random to keep quota control work
if (!isKicked) {
isKicked = kickRandom (decQuota, Team::Unassigned);
}
return isKicked;
}
bool BotManager::hasCustomCSDMSpawnEntities () { bool BotManager::hasCustomCSDMSpawnEntities () {
if (!game.is (GameFlags::CSDM | GameFlags::FreeForAll)) { if (!game.is (GameFlags::CSDM | GameFlags::FreeForAll)) {
return false; return false;