mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-26 06:35:37 +03:00
Minor rework bot_quota_mode fill
This commit is contained in:
parent
c7be8bfe7c
commit
bdc96d26d9
@ -424,6 +424,12 @@ void CCSBotManager::ServerCommand(const char *pcmd)
|
||||
else
|
||||
kickThemAll = false;
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
bool fillMode = FStrEq(cv_bot_quota_mode.string, "fill");
|
||||
#else
|
||||
bool fillMode = false;
|
||||
#endif
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; i++)
|
||||
{
|
||||
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
|
||||
@ -443,7 +449,11 @@ void CCSBotManager::ServerCommand(const char *pcmd)
|
||||
// adjust bot quota so kicked bot is not immediately added back in
|
||||
int newQuota = cv_bot_quota.value - 1;
|
||||
SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", name));
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, int(cv_bot_quota.value)));
|
||||
|
||||
if (kickThemAll || !fillMode)
|
||||
{
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, int(cv_bot_quota.value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -790,7 +800,8 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole)
|
||||
// decrease the bot quota
|
||||
if (!isFromConsole)
|
||||
{
|
||||
CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value - 1);
|
||||
int newQuota = cv_bot_quota.value - 1;
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, (int)cv_bot_quota.value));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -824,7 +835,8 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole)
|
||||
if (isFromConsole)
|
||||
{
|
||||
// increase the bot quota to account for manually added bot
|
||||
CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value + 1);
|
||||
int newQuota = cv_bot_quota.value + 1;
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, gpGlobals->maxClients));
|
||||
}
|
||||
}
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
@ -833,7 +845,8 @@ bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole)
|
||||
// decrease the bot quota
|
||||
if (!isFromConsole)
|
||||
{
|
||||
CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value - 1);
|
||||
int newQuota = cv_bot_quota.value - 1;
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, (int)cv_bot_quota.value));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -863,10 +876,17 @@ void CCSBotManager::MaintainBotQuota()
|
||||
int desiredBotCount = int(cv_bot_quota.value);
|
||||
int occupiedBotSlots = UTIL_BotsInGame();
|
||||
|
||||
bool isRoundInDeathmatch = false;
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (round_infinite.value > 0)
|
||||
isRoundInDeathmatch = true; // is no round end gameplay
|
||||
#endif
|
||||
|
||||
// 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());
|
||||
(CSGameRules()->GetRoundRespawnTime() != -1 && CSGameRules()->GetRoundElapsedTime() >= CSGameRules()->GetRoundRespawnTime()) && !isRoundInDeathmatch;
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
if (FStrEq(cv_bot_quota_mode.string, "fill"))
|
||||
@ -875,7 +895,7 @@ void CCSBotManager::MaintainBotQuota()
|
||||
// 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 + spectatorPlayersInGame);
|
||||
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -922,13 +942,15 @@ void CCSBotManager::MaintainBotQuota()
|
||||
if (cv_bot_auto_vacate.value > 0.0)
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - (humanPlayersInGame + 1));
|
||||
else
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - humanPlayersInGame + spectatorPlayersInGame);
|
||||
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - humanPlayersInGame);
|
||||
|
||||
#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 (occupiedBotSlots > 0 && desiredBotCount == occupiedBotSlots && (CSGameRules()->IsGameStarted() || isRoundInDeathmatch))
|
||||
{
|
||||
if (CSGameRules()->GetRoundElapsedTime() < CSGameRules()->GetRoundRespawnTime()) // new bots can still spawn during this time
|
||||
if (isRoundInDeathmatch ||
|
||||
(CSGameRules()->GetRoundRespawnTime() == -1 || // means no time limit
|
||||
CSGameRules()->GetRoundElapsedTime() < CSGameRules()->GetRoundRespawnTime())) // new bots can still spawn during this time
|
||||
{
|
||||
if (autoteambalance.value > 0.0f)
|
||||
{
|
||||
@ -1045,7 +1067,8 @@ void CCSBotManager::MaintainBotQuota()
|
||||
UTIL_KickBotFromTeam(TERRORIST);
|
||||
}
|
||||
|
||||
CVAR_SET_FLOAT("bot_quota", cv_bot_quota.value - 1.0f);
|
||||
int newQuota = cv_bot_quota.value - 1;
|
||||
CVAR_SET_FLOAT("bot_quota", clamp(newQuota, 0, (int)cv_bot_quota.value));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user