From f383f46e2d92667329dc8d9360d6cca03f2eb9de Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 8 Aug 2023 15:22:01 +0800 Subject: [PATCH] random bots maintanence --- src/PlayerbotMgr.cpp | 2 +- src/RandomItemMgr.cpp | 2 +- src/RandomPlayerbotMgr.cpp | 16 ++++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 2d54c099..89feb26c 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -533,7 +533,7 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje return "bot not found"; if (!isRandomAccount || isRandomBot) { - return "ERROR: You can not use this command on summoned random bot."; + return "ERROR: You can not use this command on non-summoned random bot."; } if (Player* master = GET_PLAYERBOT_AI(bot)->GetMaster()) diff --git a/src/RandomItemMgr.cpp b/src/RandomItemMgr.cpp index a788250d..8269b845 100644 --- a/src/RandomItemMgr.cpp +++ b/src/RandomItemMgr.cpp @@ -2182,7 +2182,7 @@ void RandomItemMgr::BuildAmmoCache() for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_THROWN; subClass++) { QueryResult results = WorldDatabase.Query("SELECT entry FROM item_template WHERE class = {} AND subclass = {} AND RequiredLevel <= {} " - "ORDER BY RequiredLevel DESC", ITEM_CLASS_PROJECTILE, subClass, level); + "ORDER BY RequiredLevel DESC, Quality DESC, ItemLevel DESC", ITEM_CLASS_PROJECTILE, subClass, level); if (!results) return; diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 613b38eb..4445f80b 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -261,13 +261,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) if (time(nullptr) > (PlayersCheckTimer + 60)) activateCheckPlayersThread(); } - - if (sPlayerbotAIConfig->syncLevelWithPlayers && !players.empty()) - { - if (time(nullptr) > (PlayersCheckTimer + 60)) - activateCheckPlayersThread(); - } - + if (sPlayerbotAIConfig->randomBotJoinBG/* && !players.empty()*/) { if (time(nullptr) > (BgCheckTimer + 30)) @@ -1483,8 +1477,9 @@ bool RandomPlayerbotMgr::IsRandomBot(ObjectGuid::LowType bot) ObjectGuid guid = ObjectGuid::Create(bot); if (!sPlayerbotAIConfig->IsInRandomAccountList(sCharacterCache->GetCharacterAccountIdByGuid(guid))) return false; - - return GetEventValue(bot, "add"); + if (std::find(currentBots.begin(), currentBots.end(), bot) != currentBots.end()) + return true; + return false; } std::list RandomPlayerbotMgr::GetBots() @@ -1501,7 +1496,8 @@ std::list RandomPlayerbotMgr::GetBots() { Field* fields = result->Fetch(); uint32 bot = fields[0].Get(); - currentBots.push_back(bot); + if (GetEventValue(bot, "add")) + currentBots.push_back(bot); } while (result->NextRow()); }