[Bots]: Add requested feature (#665)

This commit is contained in:
Edo 2022-12-24 23:14:47 +01:00 committed by GitHub
parent 2698921382
commit 9f67a4f62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View File

@ -35,8 +35,8 @@ namespace Components
Loader::Register(new Exception());
Loader::Register(new Auth());
Loader::Register(new Bans());
Loader::Register(new Bots());
Loader::Register(new Dvar());
Loader::Register(new Bots());
Loader::Register(new Lean());
Loader::Register(new Maps());
Loader::Register(new News());

View File

@ -64,8 +64,8 @@ namespace Components
#include "Modules/Scheduler.hpp"
#include "Modules/Auth.hpp"
#include "Modules/Bans.hpp"
#include "Modules/Bots.hpp"
#include "Modules/Dvar.hpp"
#include "Modules/Bots.hpp"
#include "Modules/Lean.hpp"
#include "Modules/Maps.hpp"
#include "Modules/News.hpp"

View File

@ -5,6 +5,8 @@ namespace Components
{
std::vector<Bots::botData> Bots::BotNames;
Dvar::Var Bots::SVRandomBotNames;
struct BotMovementInfo
{
std::int32_t buttons; // Actions
@ -57,6 +59,13 @@ namespace Components
{
auto data = Utils::String::Split(bots.getBuffer(), '\n');
if (SVRandomBotNames.get<bool>())
{
std::random_device rd;
std::mt19937 gen(rd());
std::ranges::shuffle(data, gen);
}
for (auto& entry : data)
{
// Take into account for CR line endings
@ -334,6 +343,8 @@ namespace Components
Utils::Hook(0x441B80, G_SelectWeaponIndex_Hk, HOOK_JUMP).install()->quick();
SVRandomBotNames = Dvar::Register<bool>("sv_RandomBotNames", false, Game::DVAR_NONE, "Randomize the bots' names");
// Reset BotMovementInfo.active when client is dropped
Events::OnClientDisconnect([](const int clientNum)
{

View File

@ -11,6 +11,8 @@ namespace Components
using botData = std::pair< std::string, std::string>;
static std::vector<botData> BotNames;
static Dvar::Var SVRandomBotNames;
static int BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port);
static void Spawn(unsigned int count);