Optimized the init bots, assign first level and teleportForLevel

This commit is contained in:
bash
2024-09-10 20:24:38 +00:00
parent ae78d51d8f
commit 010a1101eb
2 changed files with 15 additions and 14 deletions

View File

@@ -1014,26 +1014,26 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
if (isLogginIn)
return false;
uint32 randomTime;
if (!player)
{
AddPlayerBot(botGUID, 0);
SetEventValue(bot, "login", 1, sPlayerbotAIConfig->randomBotUpdateInterval);
SetEventValue(bot, "login", 1,
std::max(1, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.2)));
uint32 randomTime =
urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime);
randomTime = urand(std::max(5, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval)),
std::max(15, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 2.2)));
SetEventValue(bot, "update", 1, randomTime);
// do not randomize or teleport immediately after server start (prevent lagging)
if (!GetEventValue(bot, "randomize"))
{
randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5,
sPlayerbotAIConfig->randomBotUpdateInterval * 20);
ScheduleRandomize(bot, randomTime);
ScheduleRandomize(bot, std::max(3, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.5)));
}
if (!GetEventValue(bot, "teleport"))
{
randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5,
sPlayerbotAIConfig->randomBotUpdateInterval * 20);
randomTime = urand(std::max(7, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.8)),
std::max(14, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 2)));
ScheduleTeleport(bot, randomTime);
}
return true;
@@ -1076,8 +1076,9 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
if (update)
ProcessBot(player);
uint32 randomTime =
urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime);
randomTime = urand(
sPlayerbotAIConfig->minRandomBotReviveTime,
sPlayerbotAIConfig->maxRandomBotReviveTime);
SetEventValue(bot, "update", 1, randomTime);
return true;