From fccfcb7266b11f1294b987e1ab392d8527db6209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E8=8C=B9?= Date: Thu, 22 Sep 2022 16:46:39 -0600 Subject: [PATCH] Is in real guild function --- src/PlayerbotAI.cpp | 19 +++++++++++++++++-- src/PlayerbotAI.h | 1 + src/PlayerbotAIBase.cpp | 5 +---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 6fdedc7c..ec58665f 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -26,6 +26,7 @@ #include "SpellAuraEffects.h" #include "UpdateTime.h" #include "Vehicle.h" +#include "GuildMgr.h" std::vector& split(std::string const s, char delim, std::vector& elems); std::vector split(std::string const s, char delim); @@ -241,8 +242,6 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) } bool min = minimal; - if (HasRealPlayerMaster()) - min = false; UpdateAIInternal(elapsed, min); @@ -250,6 +249,9 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) if (bot && !inCombat) min = true; + if (HasRealPlayerMaster()) + min = false; + YieldThread(min); } @@ -3508,3 +3510,16 @@ bool PlayerbotAI::CanMove() return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE; } + +bool PlayerbotAI::IsInRealGuild() +{ + if (!bot->GetGuildId()) + return false; + + Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); + uint32 leaderAccount = sCharacterCache->GetCharacterAccountIdByGuid(guild->GetLeaderGUID()); + if (!leaderAccount) + return false; + + return sPlayerbotAIConfig->IsInRandomAccountList(leaderAccount); +} \ No newline at end of file diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index b15ef742..e48d6529 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -366,6 +366,7 @@ class PlayerbotAI : public PlayerbotAIBase void ResetJumpDestination() { jumpDestination = Position(); } bool CanMove(); + bool IsInRealGuild(); private: void _fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore); diff --git a/src/PlayerbotAIBase.cpp b/src/PlayerbotAIBase.cpp index 2c5503a6..8cbd24a4 100644 --- a/src/PlayerbotAIBase.cpp +++ b/src/PlayerbotAIBase.cpp @@ -50,10 +50,7 @@ bool PlayerbotAIBase::CanUpdateAI() void PlayerbotAIBase::YieldThread(bool delay) { if (nextAICheckDelay < sPlayerbotAIConfig->reactDelay) - nextAICheckDelay = sPlayerbotAIConfig->reactDelay; - - if (delay && nextAICheckDelay <= sPlayerbotAIConfig->reactDelay * 10) - nextAICheckDelay = sPlayerbotAIConfig->reactDelay * 10; + nextAICheckDelay = delay ? sPlayerbotAIConfig->reactDelay * 10 : sPlayerbotAIConfig->reactDelay; } bool PlayerbotAIBase::IsActive()