mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
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:
@@ -507,8 +507,8 @@ AiPlayerbot.RandomBotAccountPrefix = "rndbot"
|
|||||||
# default: 0 (disable, the online bots are fixed)
|
# default: 0 (disable, the online bots are fixed)
|
||||||
AiPlayerbot.EnableRotation = 0
|
AiPlayerbot.EnableRotation = 0
|
||||||
|
|
||||||
# Bots pool size for rotation (should be less than MaxRandomBots)
|
# Bots pool size for rotation (should be higher than MaxRandomBots)
|
||||||
AiPlayerbot.RotationPoolSize = 20
|
AiPlayerbot.RotationPoolSize = 100
|
||||||
|
|
||||||
AiPlayerbot.RandomBotMinLevel = 1
|
AiPlayerbot.RandomBotMinLevel = 1
|
||||||
AiPlayerbot.RandomBotMaxLevel = 80
|
AiPlayerbot.RandomBotMaxLevel = 80
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ bool PlayerbotAIConfig::Initialize()
|
|||||||
limitGearExpansion = sConfigMgr->GetOption<int32>("AiPlayerbot.LimitGearExpansion", 1);
|
limitGearExpansion = sConfigMgr->GetOption<int32>("AiPlayerbot.LimitGearExpansion", 1);
|
||||||
randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5);
|
randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5);
|
||||||
enableRotation = sConfigMgr->GetOption<bool>("AiPlayerbot.EnableRotation", false);
|
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);
|
gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false);
|
||||||
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);
|
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);
|
||||||
|
|
||||||
|
|||||||
@@ -393,17 +393,44 @@
|
|||||||
return std::move(botName);
|
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()
|
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 */
|
/* multi-thread here is meaningless? since the async db operations */
|
||||||
if (sPlayerbotAIConfig->deleteRandomBotAccounts)
|
if (sPlayerbotAIConfig->deleteRandomBotAccounts)
|
||||||
{
|
{
|
||||||
std::vector<uint32> botAccounts;
|
std::vector<uint32> botAccounts;
|
||||||
std::vector<uint32> botFriends;
|
std::vector<uint32> botFriends;
|
||||||
uint32 totalAccountCount = (sPlayerbotAIConfig->randomBotAccountCount != 0) ? sPlayerbotAIConfig->randomBotAccountCount
|
|
||||||
: (isWOTLK ? (sPlayerbotAIConfig->maxRandomBots / 10) : (sPlayerbotAIConfig->maxRandomBots / 9))
|
// Calculates the total number of required accounts.
|
||||||
+ sPlayerbotAIConfig->addClassAccountPoolSize + 1;
|
uint32 totalAccountCount = CalculateTotalAccountCount();
|
||||||
|
|
||||||
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
|
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
|
||||||
{
|
{
|
||||||
@@ -446,9 +473,9 @@
|
|||||||
std::unordered_map<NameRaceAndGender, std::vector<std::string>> nameCache;
|
std::unordered_map<NameRaceAndGender, std::vector<std::string>> nameCache;
|
||||||
std::vector<std::future<void>> account_creations;
|
std::vector<std::future<void>> account_creations;
|
||||||
int account_creation = 0;
|
int account_creation = 0;
|
||||||
uint32 totalAccountCount = (sPlayerbotAIConfig->randomBotAccountCount != 0) ? sPlayerbotAIConfig->randomBotAccountCount
|
|
||||||
: (isWOTLK ? (sPlayerbotAIConfig->maxRandomBots / 10) : (sPlayerbotAIConfig->maxRandomBots / 9))
|
// Calculates the total number of required accounts.
|
||||||
+ sPlayerbotAIConfig->addClassAccountPoolSize + 1;
|
uint32 totalAccountCount = CalculateTotalAccountCount();
|
||||||
|
|
||||||
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
|
for (uint32 accountNumber = 0; accountNumber < totalAccountCount; ++accountNumber)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ private:
|
|||||||
static std::string const CreateRandomArenaTeamName();
|
static std::string const CreateRandomArenaTeamName();
|
||||||
|
|
||||||
uint32 accountId;
|
uint32 accountId;
|
||||||
|
static uint32 CalculateTotalAccountCount();
|
||||||
static std::map<uint8, std::vector<uint8>> availableRaces;
|
static std::map<uint8, std::vector<uint8>> availableRaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user