Enhanced bot_quota_mode

This commit is contained in:
s1lent 2019-06-22 02:57:09 +07:00
parent 0aa974cd63
commit 3442cb3bf3
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
2 changed files with 28 additions and 2 deletions

View File

@ -829,14 +829,37 @@ void CCSBotManager::MaintainBotQuota()
int desiredBotCount = int(cv_bot_quota.value);
int occupiedBotSlots = UTIL_BotsInGame();
// isRoundInProgress is true if the round has progressed far enough that new players will join as dead.
bool isRoundInProgress = CSGameRules()->IsGameStarted() &&
!TheCSBots()->IsRoundOver() &&
(CSGameRules()->GetRoundElapsedTime() >= CSGameRules()->GetRoundRespawnTime());
#ifdef REGAMEDLL_ADD
if (FStrEq(cv_bot_quota_mode.string, "fill"))
{
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame);
// If bot_quota_mode is 'fill', we want the number of bots and humans together to equal bot_quota
// unless the round is already in progress, in which case we play with what we've been dealt
if (!isRoundInProgress)
{
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame);
}
else
{
desiredBotCount = occupiedBotSlots;
}
}
else if (FStrEq(cv_bot_quota_mode.string, "match"))
{
desiredBotCount = Q_max<int>(0, cv_bot_quota.value * humanPlayersInGame);
// If bot_quota_mode is 'match', we want the number of bots to be bot_quota * total humans
// unless the round is already in progress, in which case we play with what we've been dealt
if (!isRoundInProgress)
{
desiredBotCount = Q_max<int>(0, cv_bot_quota.value * humanPlayersInGame);
}
else
{
desiredBotCount = occupiedBotSlots;
}
}
#else // #ifdef REGAMEDLL_ADD
if (cv_bot_quota_match.value > 0.0)

View File

@ -634,6 +634,7 @@ public:
float GetRoundRemainingTime() const { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundStartTime; }
float GetRoundRemainingTimeReal() const;
float GetTimeLeft() const { return m_flTimeLimit - gpGlobals->time; }
float GetRoundElapsedTime() const { return gpGlobals->time - m_fRoundStartTime; }
BOOL TeamFull(int team_id);
BOOL TeamStacked(int newTeam_id, int curTeam_id);
@ -668,6 +669,8 @@ public:
float GetRoundRespawnTime() const;
float GetRoundRestartDelay() const;
bool IsGameStarted() const { return m_bGameStarted; }
// has a style of gameplay when aren't any teams
bool IsFreeForAll() const;
bool CanPlayerBuy(CBasePlayer *pPlayer) const;