diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index bcb4ad11..2e0a2a69 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -130,6 +130,11 @@ AiPlayerbot.AddClassAccountPoolSize = 50 # Default: 1 (accept based on level) AiPlayerbot.GroupInvitationPermission = 1 +# Keep alt bots in the party even when the master leaves +# 0 = disabled (default behavior) +# 1 = enabled (prevents bots from automatically leaving the group) +AiPlayerbot.KeepAltsInGroup = 0 + # Auto-login all player alts as altbots on player login AiPlayerbot.BotAutologin = 0 diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 15acf4f7..aa944177 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -510,6 +510,7 @@ bool PlayerbotAIConfig::Initialize() equipmentPersistence = sConfigMgr->GetOption("AiPlayerbot.EquipmentPersistence", false); equipmentPersistenceLevel = sConfigMgr->GetOption("AiPlayerbot.EquipmentPersistenceLevel", 80); groupInvitationPermission = sConfigMgr->GetOption("AiPlayerbot.GroupInvitationPermission", 1); + keepAltsInGroup = sConfigMgr->GetOption("AiPlayerbot.KeepAltsInGroup", false); allowSummonInCombat = sConfigMgr->GetOption("AiPlayerbot.AllowSummonInCombat", true); allowSummonWhenMasterIsDead = sConfigMgr->GetOption("AiPlayerbot.AllowSummonWhenMasterIsDead", true); allowSummonWhenBotIsDead = sConfigMgr->GetOption("AiPlayerbot.AllowSummonWhenBotIsDead", true); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index e951e52d..a6dc9666 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -333,6 +333,8 @@ public: bool equipmentPersistence; int32 equipmentPersistenceLevel; int32 groupInvitationPermission; + bool keepAltsInGroup = false; + bool KeepAltsInGroup() const { return keepAltsInGroup; } bool allowSummonInCombat; bool allowSummonWhenMasterIsDead; bool allowSummonWhenBotIsDead; diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index b0de82ab..72489431 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -473,11 +473,11 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) } Player* master = botAI->GetMaster(); - if (!master) + if (master) { - // Log a warning to indicate that the master is null - LOG_DEBUG("mod-playerbots", "Master is null for bot with GUID: {}", bot->GetGUID().GetRawValue()); - return; + ObjectGuid masterGuid = master->GetGUID(); + if (master->GetGroup() && !master->GetGroup()->IsLeader(masterGuid)) + master->GetGroup()->ChangeLeader(masterGuid); } Group* group = bot->GetGroup(); @@ -496,7 +496,10 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) break; } } - else + + // Don't disband alt groups when master goes away + // Controlled by config + if (sPlayerbotAIConfig->KeepAltsInGroup()) { uint32 account = sCharacterCache->GetCharacterAccountIdByGuid(member); if (!sPlayerbotAIConfig->IsInRandomAccountList(account))