Bot fill timing config

This commit is contained in:
RGreenlees 2024-02-06 16:04:38 +00:00 committed by pierow
parent 09a0206b9c
commit 96cad0f3b0
3 changed files with 47 additions and 0 deletions

View file

@ -14,6 +14,8 @@ bool bLerkAllowed = true;
bool bFadeAllowed = true; bool bFadeAllowed = true;
bool bOnosAllowed = true; bool bOnosAllowed = true;
BotFillTiming CurrentBotFillTiming = FILLTIMING_MAPLOAD;
std::unordered_map<std::string, TeamSizeDefinitions> TeamSizeMap; std::unordered_map<std::string, TeamSizeDefinitions> TeamSizeMap;
std::unordered_map<std::string, bot_skill> BotSkillLevelsMap; std::unordered_map<std::string, bot_skill> BotSkillLevelsMap;
@ -241,6 +243,14 @@ void CONFIG_ParseConfigFile()
continue; continue;
} }
if (key.compare("BotFillTiming") == 0)
{
int FillSetting = atoi(value.c_str());
FillSetting = clampi(FillSetting, 0, 2);
CurrentBotFillTiming = (BotFillTiming)FillSetting;
continue;
}
if (key.compare("BotSkillName") == 0) if (key.compare("BotSkillName") == 0)
{ {
BotSkillLevelsMap[value.c_str()].marine_bot_aim_skill = 0.5f; BotSkillLevelsMap[value.c_str()].marine_bot_aim_skill = 0.5f;
@ -479,3 +489,8 @@ void CONFIG_ParseConfigFile()
GlobalSkillLevel = "default"; GlobalSkillLevel = "default";
} }
} }
BotFillTiming CONFIG_GetBotFillTiming()
{
return CurrentBotFillTiming;
}

View file

@ -21,6 +21,13 @@ typedef struct _TEAMSIZEDEFINITIONS
int TeamBSize = 6; int TeamBSize = 6;
} TeamSizeDefinitions; } TeamSizeDefinitions;
typedef enum _BOTFILLTIMING
{
FILLTIMING_MAPLOAD = 0, // Bots will start filling teams after map load (after grace period)
FILLTIMING_ALLHUMANS, // Bots will only start filling teams once all humans in the ready room have joined a team
FILLTIMING_ROUNDSTART // Bots will only start filling teams after round start
} BotFillTiming;
// Reads evobot.cfg in addons/evobot and populates all the settings from it // Reads evobot.cfg in addons/evobot and populates all the settings from it
void CONFIG_ParseConfigFile(); void CONFIG_ParseConfigFile();
@ -55,6 +62,8 @@ bot_skill CONFIG_GetGlobalBotSkillLevel();
void CONFIG_SetGlobalBotSkillLevel(const char* NewSkillLevel); void CONFIG_SetGlobalBotSkillLevel(const char* NewSkillLevel);
BotFillTiming CONFIG_GetBotFillTiming();
#endif #endif

View file

@ -126,6 +126,29 @@ void AIMGR_UpdateAIPlayerCounts()
return; return;
} }
BotFillTiming CurrentFillTiming = CONFIG_GetBotFillTiming();
if (!GetGameRules()->GetGameStarted())
{
if (CurrentFillTiming == FILLTIMING_ROUNDSTART) { return; }
if (CurrentFillTiming == FILLTIMING_ALLHUMANS)
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
edict_t* PlayerEdict = INDEXENT(i);
if (FNullEnt(PlayerEdict) || PlayerEdict->free || (PlayerEdict->v.flags & FL_FAKECLIENT)) { continue; }
AvHPlayer* PlayerRef = dynamic_cast<AvHPlayer*>(CBaseEntity::Instance(PlayerEdict));
if (!PlayerRef) { continue; }
if (PlayerRef->GetInReadyRoom()) { return; }
}
}
}
if (avh_botautomode.value == 1) // Fill teams: bots will be added and removed to maintain a minimum player count if (avh_botautomode.value == 1) // Fill teams: bots will be added and removed to maintain a minimum player count
{ {
AIMGR_UpdateFillTeams(); AIMGR_UpdateFillTeams();