Merge pull request #1 from jimm0thy/IgnoreFriends

Ignore friends addition
This commit is contained in:
Semil
2025-03-03 11:06:08 -05:00
committed by GitHub
2 changed files with 26 additions and 0 deletions

View File

@@ -52,6 +52,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.

View File

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