Skip to content

Commit

Permalink
CCSBotManager::MaintainBotQuota: Added autobalance
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jun 21, 2019
1 parent 555b08f commit f8b082f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,40 @@ void CCSBotManager::MaintainBotQuota()
else
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - totalHumansInGame);

#ifdef REGAMEDLL_FIXES
// Try to balance teams, if we are in the first specified seconds of a round and bots can join either team.
if (occupiedBotSlots > 0 && desiredBotCount == occupiedBotSlots && CSGameRules()->IsGameStarted())
{
if (CSGameRules()->GetRoundElapsedTime() < CSGameRules()->GetRoundRespawnTime()) // new bots can still spawn during this time
{
if (autoteambalance.value > 0.0f)
{
int numAliveTerrorist;
int numAliveCT;
int numDeadTerrorist;
int numDeadCT;

CSGameRules()->InitializePlayerCounts(numAliveTerrorist, numAliveCT, numDeadTerrorist, numDeadCT);

if (!FStrEq(cv_bot_join_team.string, "T") &&
!FStrEq(cv_bot_join_team.string, "CT"))
{
if (numAliveTerrorist > CSGameRules()->m_iNumCT + 1)
{
if (UTIL_KickBotFromTeam(TERRORIST))
return;
}
else if (numAliveCT > CSGameRules()->m_iNumTerrorist + 1)
{
if (UTIL_KickBotFromTeam(CT))
return;
}
}
}
}
}
#endif // #ifdef REGAMEDLL_FIXES

// add bots if necessary
if (desiredBotCount > occupiedBotSlots)
{
Expand Down

0 comments on commit f8b082f

Please sign in to comment.