5 Commits

Author SHA1 Message Date
Dustin Hendrickson
12aac35118 Merge pull request #52 from DustinHendrickson/Dustin/DocUpdated
Clarifying how Dynamic Scaling and player weight works
2025-07-12 11:15:24 -07:00
Dustin Hendrickson
8b91c9549b update 2025-07-12 11:14:41 -07:00
Dustin Hendrickson
813a042b11 Clarifying how Dynamic Scaling and player weight works 2025-07-12 11:10:44 -07:00
Dustin Hendrickson
417aa84e9c Merge pull request #51 from DustinHendrickson/Dustin/ExtraSafetyChecks
Exclusion list
2025-07-05 12:30:14 -07:00
Dustin Hendrickson
8cb77796bb Exclusion list 2025-07-05 12:27:37 -07:00
3 changed files with 84 additions and 7 deletions

View File

@@ -79,12 +79,13 @@ BotLevelBrackets.LiteDebugMode | Enables lite debug logging for th
BotLevelBrackets.CheckFrequency | Frequency (in seconds) at which the bot level distribution check is performed. | 300 | Positive Integer
BotLevelBrackets.CheckFlaggedFrequency | Frequency (in seconds) at which the bot level reset is performed for flagged bots that initially failed safety checks. | 15 | Positive Integer
BotLevelBrackets.FlaggedProcessLimit | Maximum number of flagged bots to process per pending level change step. | 5 | Positive Integer
BotLevelBrackets.Dynamic.UseDynamicDistribution | Enables dynamic recalculation of bot distribution percentages based on non-bot player counts per bracket. | 0 | 0 (off) / 1 (on)
BotLevelBrackets.Dynamic.RealPlayerWeight | Multiplier applied to each real player's contribution (active only if dynamic distribution is enabled). | 1.0 | Floating point number
BotLevelBrackets.Dynamic.UseDynamicDistribution | Enables dynamic bot distribution: when on, brackets with more real players get a higher share of bots, based on the weight below. | 0 | 0 (off) / 1 (on)
BotLevelBrackets.Dynamic.RealPlayerWeight | Controls how much bots "follow" real player activity when dynamic distribution is enabled. 0.0 = bots always spread evenly; 1.0 = mild effect; higher values = more bots go where players are, but the effect is scaled. | 1.0 | ≥ 0.0 (float)
BotLevelBrackets.Dynamic.SyncFactions | Enables synchronized brackets and weighting between Alliance and Horde factions when Dynamic Distribution is also enabled. | 0 | 0 (off) / 1 (on)
BotLevelBrackets.IgnoreFriendListed | Ignores bots that are on real players' friend lists from any bracket calculations. | 1 | 0 (off) / 1 (on)
BotLevelBrackets.IgnoreGuildBotsWithRealPlayers | Excludes bots in a guild with at least one real (non-bot) player online from adjustments. | 1 | 0 (disabled) / 1 (enabled)
BotLevelBrackets.NumRanges | Number of level brackets used for bot distribution. Both factions must have the same number defined. | 9 | Positive Integer
BotLevelBrackets.ExcludeNames | Comma-separated list of case insensitive bot names to exclude from all bracket checks. | | String
**IMPORTANT:** If you extend the number of brackets beyond the default 9, you must update both your `mod_player_bot_level_brackets.conf` file and the accompanying `mod_player_bot_level_brackets.conf.dist` file to include configuration lines for the additional ranges (e.g. Range10, Range11, etc.), ensuring that the sum of the Pct values remains 100.

View File

@@ -57,6 +57,11 @@ BotLevelBrackets.IgnoreGuildBotsWithRealPlayers = 1
# Valid values: 0 (off) / 1 (on)
BotLevelBrackets.IgnoreFriendListed = 1
# BotLevelBrackets.ExcludeNames
# Description: Comma-separated list of case insensitive bot names to exclude from all bracket checks.
# Default: ""
BotLevelBrackets.ExcludeNames =
#
# BotLevelBrackets.NumRanges
# Description: The number of level brackets used for bot distribution.
@@ -77,12 +82,24 @@ BotLevelBrackets.NumRanges = 9
# Valid values: 0 (off) / 1 (on)
BotLevelBrackets.Dynamic.UseDynamicDistribution = 0
#
# BotLevelBrackets.Dynamic.RealPlayerWeight
# Description: A multiplier applied to each real player's contribution in their level bracket.
# When combined with inverse scaling by total player count, a higher value significantly boosts the effective weight
# of a real player when few are online.
# Default: 1.0
# Description: This setting controls how much extra weight is given to brackets (level ranges) that contain real (non-bot) players, when dynamic distribution is enabled.
# The higher you set this value, the more bots will move to the same level brackets where real players are found, but the effect is *gentle*, not extreme.
# A value of 0.0 means bots always distribute evenly across all brackets, regardless of where players are. The default value of 1.0 gives a mild, balanced effect.
# Raising this to 3.0, 5.0, or higher will make bots concentrate more in brackets with real players.
# The value is a multiplier (not a percent): 0.0 = no extra effect, 1.0 = default, 3.0 = stronger, 5.0 = strong but not extreme.
# Experiment based on your total bot count and real player counts to find a good number for your server.
# If you want a large congestion of bots in your level bracket for solo play I recommend 10-15 for RealPlayerWeight.
# What to expect:
# - With 1.0 (default): If 6/10 real players are in one bracket, that bracket gets about 12.77% of bots. All-empty brackets get about 10.69% each.
# - With 3.0: Same scenario: bracket gets about 15.73% of bots. All-empty brackets: 9.93% each.
# - With 5.0: Bracket with 6/10 real players gets 18.31%. All-empty brackets: 9.28% each.
# - If all real players are in one bracket and weight is 5.0, that bracket gets about 21.56% of bots (others: 9.80% each).
# - With 0.0: Every bracket always gets the same number of bots (e.g., 11.11% each for 9 brackets).
# Formula (per bracket):
# bracket_weight = 1.0 + (RealPlayerWeight × (1 / TotalRealPlayers) × log(1 + RealPlayersInBracket))
# All bracket weights are normalized to total 100%.
# Default: 1.0
BotLevelBrackets.Dynamic.RealPlayerWeight = 1.0
#

View File

@@ -71,6 +71,9 @@ static bool g_SyncFactions = false;
// Array for character social list friends
std::vector<int> g_SocialFriendsList;
// Array for excluded bot names.
static std::vector<std::string> g_ExcludeBotNames;
// Array for real player guild IDs.
std::unordered_set<uint32> g_RealPlayerGuildIds;
@@ -111,6 +114,17 @@ static void LoadBotLevelBracketsConfig()
g_IgnoreFriendListed = sConfigMgr->GetOption<bool>("BotLevelBrackets.IgnoreFriendListed", true);
g_FlaggedProcessLimit = sConfigMgr->GetOption<uint32>("BotLevelBrackets.FlaggedProcessLimit", 5);
std::string excludeNames = sConfigMgr->GetOption<std::string>("BotLevelBrackets.ExcludeNames", "");
g_ExcludeBotNames.clear();
std::istringstream f(excludeNames);
std::string s;
while (getline(f, s, ',')) {
s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
if (!s.empty()) {
g_ExcludeBotNames.push_back(s);
}
}
// Load the bot level restrictions.
g_RandomBotMinLevel = static_cast<uint8>(sConfigMgr->GetOption<uint32>("AiPlayerbot.RandomBotMinLevel", 1));
g_RandomBotMaxLevel = static_cast<uint8>(sConfigMgr->GetOption<uint32>("AiPlayerbot.RandomBotMaxLevel", 80));
@@ -737,6 +751,32 @@ static bool IsBotSafeForLevelReset(Player* bot)
return true;
}
/**
* @brief Checks if a given bot is in the exclusion list for bracket processing.
*
* This function determines whether the provided bot's name matches any entry in the global
* exclusion list `g_ExcludeBotNames`, which is populated from the BotLevelBrackets.ExcludeNames config.
* If a match is found, this bot will not be considered for any bracket checks or level resets.
*
* @param bot Pointer to the Player object representing the bot to check.
* @return true if the bot is excluded from bracket processing, false otherwise.
*/
static bool IsBotExcluded(Player* bot)
{
if (!bot)
{
return false;
}
const std::string& name = bot->GetName();
for (const auto& excluded : g_ExcludeBotNames)
{
if (excluded == name)
{
return true;
}
}
return false;
}
/**
* @brief Processes the pending level reset requests for player bots.
@@ -788,6 +828,12 @@ static void ProcessPendingLevelResets()
continue;
}
if (IsBotExcluded(bot))
{
it = g_PendingLevelResets.erase(it);
continue;
}
int targetRange = it->targetRange;
if (g_IgnoreGuildBotsWithRealPlayers && BotInGuildWithRealPlayer(bot))
{
@@ -831,6 +877,11 @@ static void ProcessPendingLevelResets()
*/
static int GetOrFlagPlayerBracket(Player* player)
{
if (IsPlayerBot(player) && IsBotExcluded(player))
{
return -1;
}
int rangeIndex = GetLevelRangeIndex(player->GetLevel(), player->GetTeamId());
if (rangeIndex >= 0)
{
@@ -1172,6 +1223,14 @@ public:
}
continue;
}
if (IsBotExcluded(player))
{
if (g_BotDistFullDebugMode)
{
LOG_INFO("server.loading", "[BotLevelBrackets] Skipping excluded bot '{}'.", player->GetName());
}
continue;
}
if (g_IgnoreGuildBotsWithRealPlayers && BotInGuildWithRealPlayer(player))
{
continue;