Auto calculate RandomBotAccountCount by default (#964)

* Remove RandomBotAccountCount requirement

* Remove RandomBotAccountCount

* Remove randomBotAccountCount

* Remove randomBotAccountCount

* Update playerbots.conf.dist

* Style

* Set RotationPoolSize to 20 to work with the bot amount defaults

* Update PlayerbotAIConfig.cpp: Sync with default config

* Set +1 where appropriate

* Acc patch (#73)

* Account for TBC
* Still made it possible to change manually if desired

* uint32 randomBotAccountCount;

* Update Playerbots.cpp
This commit is contained in:
SaW
2025-02-14 15:03:53 +01:00
committed by GitHub
parent c2caf3c564
commit 4793644a15
3 changed files with 896 additions and 891 deletions

View File

@@ -81,14 +81,16 @@ AiPlayerbot.Enabled = 1
# Enable random bot system
AiPlayerbot.RandomBotAutologin = 1
# Random bot account
# Please ensure that RandomBotAccountCount is greater than (MaxRandomBots / 10 + AddClassAccountPoolSize)
AiPlayerbot.RandomBotAccountCount = 200
# Random bot count
AiPlayerbot.MinRandomBots = 50
AiPlayerbot.MaxRandomBots = 50
# Random bot accounts
# If you are not using any expansion at all, you may have to set this manually, then
# please ensure that RandomBotAccountCount is at least greater than (MaxRandomBots / 10 + AddClassAccountPoolSize)
# default: 0 - Automatic
AiPlayerbot.RandomBotAccountCount = 0
# Delete all random bot accounts (reset randombots)
AiPlayerbot.DeleteRandomBotAccounts = 0
@@ -115,7 +117,6 @@ AiPlayerbot.MaxAddedBots = 40
AiPlayerbot.AddClassCommand = 1
# Set the addclass command account pool size
# Addclass command uses a subset of accounts from RandomBotAccountCount
AiPlayerbot.AddClassAccountPoolSize = 50
# Bot group invitation permission level (0 = GM only, 1 = accept based on level, 2 = always accept)
@@ -506,8 +507,8 @@ AiPlayerbot.RandomBotAccountPrefix = "rndbot"
# default: 0 (disable, the online bots are fixed)
AiPlayerbot.EnableRotation = 0
# Bots pool size for rotation (should be less than RandomBotAccountCount * 10)
AiPlayerbot.RotationPoolSize = 500
# Bots pool size for rotation (should be less than MaxRandomBots)
AiPlayerbot.RotationPoolSize = 20
AiPlayerbot.RandomBotMinLevel = 1
AiPlayerbot.RandomBotMaxLevel = 80

View File

@@ -155,7 +155,7 @@ bool PlayerbotAIConfig::Initialize()
botAutologin = sConfigMgr->GetOption<bool>("AiPlayerbot.BotAutologin", false);
randomBotAutologin = sConfigMgr->GetOption<bool>("AiPlayerbot.RandomBotAutologin", true);
minRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MinRandomBots", 50);
maxRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBots", 200);
maxRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBots", 50);
randomBotUpdateInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotUpdateInterval", 20);
randomBotCountChangeMinInterval =
sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE);
@@ -434,7 +434,7 @@ bool PlayerbotAIConfig::Initialize()
}
randomBotAccountPrefix = sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotAccountPrefix", "rndbot");
randomBotAccountCount = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotAccountCount", 200);
randomBotAccountCount = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotAccountCount", 0);
deleteRandomBotAccounts = sConfigMgr->GetOption<bool>("AiPlayerbot.DeleteRandomBotAccounts", false);
randomBotGuildCount = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotGuildCount", 20);
deleteRandomBotGuilds = sConfigMgr->GetOption<bool>("AiPlayerbot.DeleteRandomBotGuilds", false);
@@ -505,7 +505,7 @@ bool PlayerbotAIConfig::Initialize()
limitGearExpansion = sConfigMgr->GetOption<int32>("AiPlayerbot.LimitGearExpansion", 1);
randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5);
enableRotation = sConfigMgr->GetOption<bool>("AiPlayerbot.EnableRotation", false);
rotationPoolSize = sConfigMgr->GetOption<int32>("AiPlayerbot.RotationPoolSize", 500);
rotationPoolSize = sConfigMgr->GetOption<int32>("AiPlayerbot.RotationPoolSize", 20);
gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false);
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);

View File

@@ -395,13 +395,17 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(NameRaceAndGender
void RandomPlayerbotFactory::CreateRandomBots()
{
bool isWOTLK = sWorld->getIntConfig(CONFIG_EXPANSION) == EXPANSION_WRATH_OF_THE_LICH_KING;
/* multi-thread here is meaningless? since the async db operations */
if (sPlayerbotAIConfig->deleteRandomBotAccounts)
{
std::vector<uint32> botAccounts;
std::vector<uint32> botFriends;
uint32 totalAccountCount = (sPlayerbotAIConfig->randomBotAccountCount != 0) ? sPlayerbotAIConfig->randomBotAccountCount
: (isWOTLK ? (sPlayerbotAIConfig->maxRandomBots / 10) : (sPlayerbotAIConfig->maxRandomBots / 9))
+ sPlayerbotAIConfig->addClassAccountPoolSize + 1;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
{
std::ostringstream out;
out << sPlayerbotAIConfig->randomBotAccountPrefix << accountNumber;
@@ -440,11 +444,13 @@ void RandomPlayerbotFactory::CreateRandomBots()
LOG_INFO("playerbots", "Creating random bot accounts...");
std::unordered_map<NameRaceAndGender, std::vector<std::string>> nameCache;
uint32 totalAccCount = sPlayerbotAIConfig->randomBotAccountCount;
std::vector<std::future<void>> account_creations;
int account_creation = 0;
uint32 totalAccountCount = (sPlayerbotAIConfig->randomBotAccountCount != 0) ? sPlayerbotAIConfig->randomBotAccountCount
: (isWOTLK ? (sPlayerbotAIConfig->maxRandomBots / 10) : (sPlayerbotAIConfig->maxRandomBots / 9))
+ sPlayerbotAIConfig->addClassAccountPoolSize + 1;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
{
std::ostringstream out;
out << sPlayerbotAIConfig->randomBotAccountPrefix << accountNumber;
@@ -488,13 +494,12 @@ void RandomPlayerbotFactory::CreateRandomBots()
LOG_INFO("playerbots", "Creating random bot characters...");
uint32 totalRandomBotChars = 0;
uint32 totalCharCount = sPlayerbotAIConfig->randomBotAccountCount * 10;
std::vector<std::pair<Player*, uint32>> playerBots;
std::vector<WorldSession*> sessionBots;
int bot_creation = 0;
bool nameCached = false;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
{
std::ostringstream out;
out << sPlayerbotAIConfig->randomBotAccountPrefix << accountNumber;
@@ -546,8 +551,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
} while (result->NextRow());
}
LOG_DEBUG("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1,
sPlayerbotAIConfig->randomBotAccountCount);
LOG_DEBUG("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, totalAccountCount);
RandomPlayerbotFactory factory(accountId);
WorldSession* session = new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING,