From 863248b3f34e20a790fa729b6da6a2bec9e025f4 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 8 Aug 2023 18:24:56 +0800 Subject: [PATCH] random and teleport delay --- src/RandomPlayerbotMgr.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index db36c97a..0ac52603 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -797,6 +797,15 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); SetEventValue(bot, "update", 1, randomTime); + // do not randomize or teleport immediately after server start (prevent lagging) + if (!GetEventValue(bot, "randomize")) { + randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval, sPlayerbotAIConfig->randomBotUpdateInterval * 10); + ScheduleRandomize(bot, randomTime); + } + if (!GetEventValue(bot, "teleport")) { + randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval, sPlayerbotAIConfig->randomBotUpdateInterval * 10); + ScheduleTeleport(bot, randomTime); + } return true; } @@ -915,7 +924,6 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) uint32 randomize = GetEventValue(bot, "randomize"); if (!randomize) { - // if (randomiser) Randomize(player); LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->getLevel(), player->GetName()); uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime);