From c6f2c42cf931c09e3f57624acc38d6796e47ef53 Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Wed, 13 Nov 2024 12:30:13 +0100 Subject: [PATCH] Always bot: Enabling/disabling alwaysbot for a real player now properly enables/disables the ai. --- playerbot/PlayerbotMgr.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/playerbot/PlayerbotMgr.cpp b/playerbot/PlayerbotMgr.cpp index a01ff4ff..db5cb66b 100644 --- a/playerbot/PlayerbotMgr.cpp +++ b/playerbot/PlayerbotMgr.cpp @@ -849,6 +849,13 @@ std::list PlayerbotHolder::HandlePlayerbotCommand(char const* args, master->GetSession()->GetAccountId(), master->GetGuildId()); } + else + { + Player* player = sObjectMgr.GetPlayer(guid, false); + + if(player) + OnBotLogin(player); + } } } else @@ -856,13 +863,18 @@ std::list PlayerbotHolder::HandlePlayerbotCommand(char const* args, sRandomPlayerbotMgr.SetValue(guid.GetCounter(), "always", (uint32)BotAlwaysOnline::DISABLED_BY_COMMAND); messages.push_back("Disable offline player ai for " + alwaysName); - if (guid != master->GetObjectGuid()) - { - Player* bot = sRandomPlayerbotMgr.GetPlayerBot(guid); + Player* bot = sObjectMgr.GetPlayer(guid, false); - if (bot && bot->GetPlayerbotAI() && !bot->GetPlayerbotAI()->GetMaster() && sPlayerbotAIConfig.IsFreeAltBot(bot)) + if (bot && bot->GetPlayerbotAI()) + { + if (guid != master->GetObjectGuid() && !bot->isRealPlayer()) + { + if (sPlayerbotAIConfig.IsFreeAltBot(bot)) + sRandomPlayerbotMgr.LogoutPlayerBot(guid); + } + else { - sRandomPlayerbotMgr.LogoutPlayerBot(guid); + DisablePlayerBot(guid); } }