Ignore Friend Listed Bots

Added option to ignore bots that are on a real player's friend list
This commit is contained in:
jimm0thy
2025-02-24 12:13:39 -05:00
parent d352b5b937
commit 5a6c54eab4
2 changed files with 26 additions and 0 deletions

View File

@@ -34,6 +34,13 @@ BotLevelBrackets.UseDynamicDistribution = 0
# Default: 1.0 # Default: 1.0
BotLevelBrackets.RealPlayerWeight = 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 # Alliance Level Brackets Configuration
# The percentages below must sum to 100. # The percentages below must sum to 100.

View File

@@ -15,6 +15,9 @@
#include <limits> #include <limits>
#include <algorithm> #include <algorithm>
#include "PlayerbotFactory.h" #include "PlayerbotFactory.h"
#include "DatabaseEnv.h"
#include "QueryResult.h"
static bool IsAlliancePlayerBot(Player* bot); static bool IsAlliancePlayerBot(Player* bot);
static bool IsHordePlayerBot(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 uint32 g_BotDistFlaggedCheckFrequency = 15; // in seconds
static bool g_BotDistDebugMode = false; static bool g_BotDistDebugMode = false;
static bool g_UseDynamicDistribution = false; static bool g_UseDynamicDistribution = false;
static bool g_IgnoreFriendListed = true;
// Real player weight to boost bracket contributions. // Real player weight to boost bracket contributions.
static float g_RealPlayerWeight = 1.0f; static float g_RealPlayerWeight = 1.0f;
@@ -59,6 +63,7 @@ static void LoadBotLevelBracketsConfig()
g_BotDistFlaggedCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFlaggedFrequency", 15); g_BotDistFlaggedCheckFrequency = sConfigMgr->GetOption<uint32>("BotLevelBrackets.CheckFlaggedFrequency", 15);
g_UseDynamicDistribution = sConfigMgr->GetOption<bool>("BotLevelBrackets.UseDynamicDistribution", false); g_UseDynamicDistribution = sConfigMgr->GetOption<bool>("BotLevelBrackets.UseDynamicDistribution", false);
g_RealPlayerWeight = sConfigMgr->GetOption<float>("BotLevelBrackets.RealPlayerWeight", 1.0f); g_RealPlayerWeight = sConfigMgr->GetOption<float>("BotLevelBrackets.RealPlayerWeight", 1.0f);
g_IgnoreFriendListed = sConfigMgr->GetOption<bool>("BotLevelBrackets.IgnoreFriendListed", true);
// Load the bot level restrictions. // Load the bot level restrictions.
g_RandomBotMinLevel = static_cast<uint8>(sConfigMgr->GetOption<uint32>("AiPlayerbot.RandomBotMinLevel", 1)); g_RandomBotMinLevel = static_cast<uint8>(sConfigMgr->GetOption<uint32>("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<uint32>();
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; return true;
} }