Autocalc Accounts - take rotation into account (#971)

* Takes bot rotation into account and adjust accordingly when enabled as it requires to be higher than MaxRandomBots to function properly.
* Correct default config to reflect that bots pool size for rotation should be higher than MaxRandomBots
* Revert space at start of all lines.
This commit is contained in:
SaW
2025-02-14 23:31:26 +01:00
committed by GitHub
parent dfcfe46865
commit 624e48068e
4 changed files with 916 additions and 888 deletions

View File

@@ -507,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 MaxRandomBots)
AiPlayerbot.RotationPoolSize = 20
# Bots pool size for rotation (should be higher than MaxRandomBots)
AiPlayerbot.RotationPoolSize = 100
AiPlayerbot.RandomBotMinLevel = 1
AiPlayerbot.RandomBotMaxLevel = 80

View File

@@ -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", 20);
rotationPoolSize = sConfigMgr->GetOption<int32>("AiPlayerbot.RotationPoolSize", 100);
gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false);
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);

View File

@@ -393,17 +393,44 @@
return std::move(botName);
}
uint32 RandomPlayerbotFactory::CalculateTotalAccountCount()
{
// Calculates the total number of required accounts, either using the specified randomBotAccountCount
// or determining it dynamically based on the WOTLK condition, max random bots, rotation pool size,
// and additional class account pool size.
// Checks if randomBotAccountCount is set, otherwise calculate it dynamically.
if (sPlayerbotAIConfig->randomBotAccountCount > 0)
{
return sPlayerbotAIConfig->randomBotAccountCount;
}
bool isWOTLK = sWorld->getIntConfig(CONFIG_EXPANSION) == EXPANSION_WRATH_OF_THE_LICH_KING;
// Determine divisor based on WOTLK condition
int divisor = isWOTLK ? 10 : 9;
// Calculate max bots or rotation pool size
int maxBotsOrRotation = std::max(
sPlayerbotAIConfig->maxRandomBots,
sPlayerbotAIConfig->enableRotation ? sPlayerbotAIConfig->rotationPoolSize : 0
);
// Calculate base accounts, add class account pool size, and add 1 as a fixed offset
uint32 baseAccounts = maxBotsOrRotation / divisor;
return baseAccounts + sPlayerbotAIConfig->addClassAccountPoolSize + 1;
}
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;
// Calculates the total number of required accounts.
uint32 totalAccountCount = CalculateTotalAccountCount();
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
{
@@ -446,9 +473,9 @@
std::unordered_map<NameRaceAndGender, std::vector<std::string>> nameCache;
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;
// Calculates the total number of required accounts.
uint32 totalAccountCount = CalculateTotalAccountCount();
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
{

View File

@@ -60,6 +60,7 @@ private:
static std::string const CreateRandomArenaTeamName();
uint32 accountId;
static uint32 CalculateTotalAccountCount();
static std::map<uint8, std::vector<uint8>> availableRaces;
};