diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 05a57951..ee0efee6 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -12,6 +12,8 @@ namespace Components { std::vector Bots::BotNames; + Dvar::Var Bots::SVRandomBotNames; + struct BotMovementInfo { std::int32_t buttons; // Actions @@ -48,6 +50,13 @@ namespace Components { "activate", Game::CMD_BUTTON_ACTIVATE }, }; + void Bots::RandomizeBotNames() + { + std::random_device rd; + std::mt19937 gen(rd()); + std::ranges::shuffle(BotNames, gen); + } + void Bots::LoadBotNames() { FileSystem::File bots("bots.txt"); @@ -87,6 +96,11 @@ namespace Components BotNames.emplace_back(entry, clanAbbrev); } + + if (SVRandomBotNames.get()) + { + RandomizeBotNames(); + } } int Bots::BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port) @@ -351,6 +365,8 @@ namespace Components Utils::Hook(0x441B80, G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick(); + SVRandomBotNames = Dvar::Register("sv_RandomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names"); + // Reset BotMovementInfo.active when client is dropped Events::OnClientDisconnect([](const int clientNum) { diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index 2136016f..b7423914 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -11,6 +11,9 @@ namespace Components using botData = std::pair< std::string, std::string>; static std::vector BotNames; + static Dvar::Var SVRandomBotNames; + + static void RandomizeBotNames(); static void LoadBotNames(); static int BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port);