diff --git a/conf/mod_player_bot_level_brackets.conf.dist b/conf/mod_player_bot_level_brackets.conf.dist index 9f0c9e4..741b8b4 100644 --- a/conf/mod_player_bot_level_brackets.conf.dist +++ b/conf/mod_player_bot_level_brackets.conf.dist @@ -34,6 +34,13 @@ BotLevelBrackets.UseDynamicDistribution = 0 # Default: 1.0 BotLevelBrackets.RealPlayerWeight = 1.0 +# +# BotLevelBrackets.IgnoreFriendListed +# Description: Ignore bots that are on real players friend's lists from any brackets +# Default: 1 (enabled) +# Valid values: 0 (off) / 1 (on) +BotLevelBrackets.IgnoreFriendListed = 1 + # # Alliance Level Brackets Configuration # The percentages below must sum to 100. diff --git a/src/mod-player-bot-level-brackets.cpp b/src/mod-player-bot-level-brackets.cpp index b1a159a..815fa45 100644 --- a/src/mod-player-bot-level-brackets.cpp +++ b/src/mod-player-bot-level-brackets.cpp @@ -15,6 +15,9 @@ #include #include #include "PlayerbotFactory.h" +#include "DatabaseEnv.h" +#include "QueryResult.h" + static bool IsAlliancePlayerBot(Player* bot); static bool IsHordePlayerBot(Player* bot); @@ -47,6 +50,7 @@ static uint32 g_BotDistCheckFrequency = 300; // in seconds static uint32 g_BotDistFlaggedCheckFrequency = 15; // in seconds static bool g_BotDistDebugMode = false; static bool g_UseDynamicDistribution = false; +static bool g_IgnoreFriendListed = true; // Real player weight to boost bracket contributions. static float g_RealPlayerWeight = 1.0f; @@ -59,6 +63,7 @@ static void LoadBotLevelBracketsConfig() g_BotDistFlaggedCheckFrequency = sConfigMgr->GetOption("BotLevelBrackets.CheckFlaggedFrequency", 15); g_UseDynamicDistribution = sConfigMgr->GetOption("BotLevelBrackets.UseDynamicDistribution", false); g_RealPlayerWeight = sConfigMgr->GetOption("BotLevelBrackets.RealPlayerWeight", 1.0f); + g_IgnoreFriendListed = sConfigMgr->GetOption("BotLevelBrackets.IgnoreFriendListed", true); // Load the bot level restrictions. g_RandomBotMinLevel = static_cast(sConfigMgr->GetOption("AiPlayerbot.RandomBotMinLevel", 1)); @@ -350,6 +355,20 @@ static bool IsBotSafeForLevelReset(Player* bot) } } } + // Lets ignore bots that have human friends + if (g_IgnoreFriendListed) + { + QueryResult result = CharacterDatabase.Query("SELECT COUNT(friend) FROM character_social WHERE friend IN (SELECT guid FROM characters WHERE name ='{}') and flags = 1", bot->GetName()); + uint32 friendCount = 0; + friendCount = result->Fetch()->Get(); + + if (friendCount >= 1) + { + LOG_INFO("server.loading", "[BotLevelBrackets] Bot {} (Level {}) is on a Real Player's friends list", bot->GetName(), bot->GetLevel()); + return false; + } + } + return true; }