Feat: Bot rotation

This commit is contained in:
Yunfan Li
2023-12-24 15:33:27 +08:00
parent 290a6bad71
commit b84542a745
4 changed files with 27 additions and 4 deletions

View File

@@ -44,6 +44,13 @@ AiPlayerbot.MaxRandomBots = 50
AiPlayerbot.RandomBotMinLevel = 1
AiPlayerbot.RandomBotMaxLevel = 80
# Enable/Disable rotation of bots (randomly select a bot from the bots pool to go online and rotate them periodically)
# 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
# Accounts to create for random bots
AiPlayerbot.RandomBotAccountPrefix = "rndbot"
AiPlayerbot.RandomBotAccountCount = 200
@@ -251,7 +258,7 @@ AiPlayerbot.LootDelay = 1000
# Distances
AiPlayerbot.FarDistance = 20.0
AiPlayerbot.SightDistance = 100.0
AiPlayerbot.SightDistance = 75.0
AiPlayerbot.SpellDistance = 28.5
AiPlayerbot.ShootDistance = 5.0
AiPlayerbot.ReactDistance = 150.0
@@ -338,7 +345,7 @@ AiPlayerbot.RandomBotUpdateInterval = 20
AiPlayerbot.RandomBotCountChangeMinInterval = 1800
AiPlayerbot.RandomBotCountChangeMaxInterval = 7200
AiPlayerbot.MinRandomBotInWorldTime = 3600
AiPlayerbot.MaxRandomBotInWorldTime = 1209600
AiPlayerbot.MaxRandomBotInWorldTime = 43200
AiPlayerbot.MinRandomBotRandomizeTime = 302400
AiPlayerbot.MaxRandomRandomizeTime = 1209600
AiPlayerbot.RandomBotsPerInterval = 500
@@ -350,6 +357,7 @@ AiPlayerbot.MinRandomBotReviveTime = 60
AiPlayerbot.MaxRandomBotReviveTime = 300
AiPlayerbot.MinRandomBotTeleportInterval = 3600
AiPlayerbot.MaxRandomBotTeleportInterval = 18000
AiPlayerbot.RandomBotInWorldWithRotaionDisabled = 31104000
# How far random bots are teleported after death
AiPlayerbot.RandomBotTeleportDistance = 100

View File

@@ -124,6 +124,7 @@ bool PlayerbotAIConfig::Initialize()
maxRandomBotReviveTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBotReviveTime", 5 * MINUTE);
minRandomBotTeleportInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.MinRandomBotTeleportInterval", 1 * HOUR);
maxRandomBotTeleportInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBotTeleportInterval", 5 * HOUR);
randomBotInWorldWithRotaionDisabled = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotInWorldWithRotaionDisabled", 1 * YEAR);
randomBotTeleportDistance = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotTeleportDistance", 100);
randomBotsPerInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotsPerInterval", MINUTE);
minRandomBotsPriceChangeInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.MinRandomBotsPriceChangeInterval", 2 * HOUR);
@@ -328,6 +329,8 @@ bool PlayerbotAIConfig::Initialize()
randombotsWalkingRPGInDoors = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG.InDoors", false);
minEnchantingBotLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.MinEnchantingBotLevel", 60);
randombotStartingLevel = sConfigMgr->GetOption<int32>("AiPlayerbot.RandombotStartingLevel", 5);
enableRotation = sConfigMgr->GetOption<bool>("AiPlayerbot.EnableRotation", false);
rotationPoolSize = sConfigMgr->GetOption<int32>("AiPlayerbot.RotationPoolSize", 500);
gearscorecheck = sConfigMgr->GetOption<bool>("AiPlayerbot.GearScoreCheck", false);
randomBotPreQuests = sConfigMgr->GetOption<bool>("AiPlayerbot.PreQuests", true);

View File

@@ -70,6 +70,7 @@ class PlayerbotAIConfig
uint32 minRandomBotChangeStrategyTime, maxRandomBotChangeStrategyTime;
uint32 minRandomBotReviveTime, maxRandomBotReviveTime;
uint32 minRandomBotTeleportInterval, maxRandomBotTeleportInterval;
uint32 randomBotInWorldWithRotaionDisabled;
uint32 minRandomBotPvpTime, maxRandomBotPvpTime;
uint32 randomBotsPerInterval;
uint32 minRandomBotsPriceChangeInterval, maxRandomBotsPriceChangeInterval;
@@ -108,6 +109,8 @@ class PlayerbotAIConfig
bool randombotsWalkingRPGInDoors;
uint32 minEnchantingBotLevel;
uint32 randombotStartingLevel;
bool enableRotation;
uint32 rotationPoolSize;
bool gearscorecheck;
bool randomBotPreQuests;

View File

@@ -337,6 +337,11 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
for (std::vector<uint32>::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); i != sPlayerbotAIConfig->randomBotAccounts.end(); i++)
{
uint32 accountId = *i;
if (sPlayerbotAIConfig->enableRotation) {
uint32 limit = std::min((uint32)sPlayerbotAIConfig->randomBotAccounts.size(), sPlayerbotAIConfig->rotationPoolSize / 10 + 1);
uint32 index = urand(0, limit);
accountId = sPlayerbotAIConfig->randomBotAccounts[index];
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
stmt->SetData(0, accountId);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -359,8 +364,12 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
if (std::find(currentBots.begin(), currentBots.end(), guid) != currentBots.end())
continue;
SetEventValue(guid, "add", 1, urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime));
uint32 add_time = sPlayerbotAIConfig->enableRotation ?
urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) :
sPlayerbotAIConfig->randomBotInWorldWithRotaionDisabled;
SetEventValue(guid, "add", 1, add_time);
SetEventValue(guid, "logout", 0, 0);
currentBots.push_back(guid);