From 9452b8a0c3f492bab8b139ed152894f3495705bd Mon Sep 17 00:00:00 2001 From: RGreenlees Date: Thu, 23 May 2024 20:17:46 +0100 Subject: [PATCH] Team fill logic adjusted * The auto-fill system for bots now takes mp_limitteams into account, and will continue to add bots to one side if the team size config specifies it to --- main/source/mod/AvHAICommander.cpp | 37 ++++++++++++++++++++++++-- main/source/mod/AvHAICommander.h | 2 ++ main/source/mod/AvHAIPlayerManager.cpp | 8 ++++-- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/main/source/mod/AvHAICommander.cpp b/main/source/mod/AvHAICommander.cpp index e1e35ed6..95b5303e 100644 --- a/main/source/mod/AvHAICommander.cpp +++ b/main/source/mod/AvHAICommander.cpp @@ -3309,8 +3309,10 @@ void AICOMM_CommanderThink(AvHAIPlayer* pBot) if (RelocationHive) { char msg[128]; - sprintf(msg, "We're relocating to %s, lads", RelocationHive->HiveName); - BotSay(pBot, true, 1.0f, msg); + if (AICOMM_GetRelocationMessage(pBot->RelocationSpot, msg)) + { + BotSay(pBot, true, 1.0f, msg); + } } } } @@ -3329,6 +3331,37 @@ void AICOMM_CommanderThink(AvHAIPlayer* pBot) if (AICOMM_CheckForNextSupplyAction(pBot)) { return; } } +bool AICOMM_GetRelocationMessage(Vector RelocationPoint, char* MessageBuffer) +{ + const AvHAIHiveDefinition* RelocationHive = AITAC_GetHiveNearestLocation(RelocationPoint); + + if (!RelocationHive) + { + sprintf(MessageBuffer, "We're relocating, get ready"); + return true; + } + + int MsgIndex = irandrange(0, 2); + + switch (MsgIndex) + { + case 0: + sprintf(MessageBuffer, "We're relocating to %s, lads", RelocationHive->HiveName); + return true; + case 1: + sprintf(MessageBuffer, "Relocate to %s, go go go", RelocationHive->HiveName); + return true; + case 2: + sprintf(MessageBuffer, "I'm relocating to %s", RelocationHive->HiveName); + return true; + default: + sprintf(MessageBuffer, "We're relocating, get ready"); + return true; + } + + return false; +} + bool AICOMM_IsCommanderActionValid(AvHAIPlayer* pBot, commander_action* Action) { if (Action->NumActionAttempts > 5) { return false; } diff --git a/main/source/mod/AvHAICommander.h b/main/source/mod/AvHAICommander.h index fdf8ac1b..007c3f2b 100644 --- a/main/source/mod/AvHAICommander.h +++ b/main/source/mod/AvHAICommander.h @@ -74,4 +74,6 @@ void AICOMM_ReceiveChatRequest(AvHAIPlayer* Commander, edict_t* Requestor, const bool AICOMM_ShouldCommanderRelocate(AvHAIPlayer* pBot); +bool AICOMM_GetRelocationMessage(Vector RelocationPoint, char* MessageBuffer); + #endif // AVH_AI_COMMANDER_H \ No newline at end of file diff --git a/main/source/mod/AvHAIPlayerManager.cpp b/main/source/mod/AvHAIPlayerManager.cpp index 095ab8b4..27309e9d 100644 --- a/main/source/mod/AvHAIPlayerManager.cpp +++ b/main/source/mod/AvHAIPlayerManager.cpp @@ -24,6 +24,7 @@ extern cvar_t avh_botusemapdefaults; extern cvar_t avh_botcommandermode; extern cvar_t avh_botdebugmode; extern cvar_t avh_botskill; +extern cvar_t avh_limitteams; float LastAIPlayerCountUpdate = 0.0f; @@ -224,8 +225,11 @@ void AIMGR_UpdateFillTeams() bRemoveB = !bRemoveB; } } + + bool bCanAddToTeamA = (GetGameRules()->GetCheatsEnabled() || TeamSizeA < TeamSizeB || TeamSizeA - TeamSizeB < avh_limitteams.value); + bool bCanAddToTeamB = (GetGameRules()->GetCheatsEnabled() || TeamSizeB < TeamSizeA || TeamSizeB - TeamSizeA < avh_limitteams.value); - if (TeamSizeA < NumDesiredTeamA && TeamSizeA <= TeamSizeB) + if (TeamSizeA < NumDesiredTeamA && bCanAddToTeamA) { // Don't add a bot if we have any stuck in the ready room, wait for teams to resolve themselves if (AIMGR_GetNumAIPlayersOnTeam(TEAM_IND) > 0) { return; } @@ -242,7 +246,7 @@ void AIMGR_UpdateFillTeams() } } - if (TeamSizeB < NumDesiredTeamB && TeamSizeB <= TeamSizeA) + if (TeamSizeB < NumDesiredTeamB && bCanAddToTeamB) { // Don't add a bot if we have any stuck in the ready room, wait for teams to resolve themselves if (AIMGR_GetNumAIPlayersOnTeam(TEAM_IND) > 0) { return; }