mirror of
https://github.com/kadeshar/mod-player-bot-level-brackets.git
synced 2026-01-13 09:17:19 +00:00
Merge pull request #66 from DustinHendrickson/Dustin/FixesAndReload
Dustin/fixes and reload
This commit is contained in:
@@ -79,8 +79,8 @@ 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.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.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.FlaggedProcessLimit | Maximum number of flagged bots to process per pending level change step. | 5 | Positive Integer
|
||||||
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.UseDynamicDistribution | Enables dynamic bot distribution: when on, brackets with more real players get a higher share of bots in their level bracket, 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.RealPlayerWeight | Controls how much bots "follow" real player activity when dynamic distribution is enabled. 0.0 = bots always spread evenly; 1.0 = minimal effect; 10.0 = heavy 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.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.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 from adjustments. Uses persistent database tracking for both online and offline real players. | 1 | 0 (disabled) / 1 (enabled)
|
BotLevelBrackets.IgnoreGuildBotsWithRealPlayers | Excludes bots in a guild with at least one real (non-bot) player from adjustments. Uses persistent database tracking for both online and offline real players. | 1 | 0 (disabled) / 1 (enabled)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ BotLevelBrackets.NumRanges = 9
|
|||||||
#
|
#
|
||||||
# BotLevelBrackets.Dynamic.UseDynamicDistribution
|
# BotLevelBrackets.Dynamic.UseDynamicDistribution
|
||||||
# Description: Enables dynamic recalculation of bot distribution percentages based on the number of non-bot players
|
# Description: Enables dynamic recalculation of bot distribution percentages based on the number of non-bot players
|
||||||
# present in each level bracket.
|
# present in each level bracket. This overrides any custom brackets in the conf.
|
||||||
# Default: 0 (disabled)
|
# Default: 0 (disabled)
|
||||||
# Valid values: 0 (off) / 1 (on)
|
# Valid values: 0 (off) / 1 (on)
|
||||||
BotLevelBrackets.Dynamic.UseDynamicDistribution = 0
|
BotLevelBrackets.Dynamic.UseDynamicDistribution = 0
|
||||||
@@ -95,7 +95,7 @@ BotLevelBrackets.Dynamic.UseDynamicDistribution = 0
|
|||||||
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# The value is a multiplier (not a percent): 0.0 = no extra effect, 1.0 = minimal, 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.
|
# 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.
|
# If you want a large congestion of bots in your level bracket for solo play I recommend 10-15 for RealPlayerWeight.
|
||||||
# What to expect:
|
# What to expect:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
|
#include "CommandScript.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "PlayerbotAI.h"
|
#include "PlayerbotAI.h"
|
||||||
#include "PlayerbotMgr.h"
|
#include "PlayerbotMgr.h"
|
||||||
@@ -20,6 +21,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
|
||||||
|
using namespace Acore::ChatCommands;
|
||||||
|
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class Guild;
|
class Guild;
|
||||||
static bool IsAlliancePlayerBot(Player* bot);
|
static bool IsAlliancePlayerBot(Player* bot);
|
||||||
@@ -71,7 +74,7 @@ static float g_RealPlayerWeight = 1.0f;
|
|||||||
static bool g_SyncFactions = false;
|
static bool g_SyncFactions = false;
|
||||||
|
|
||||||
// Array for character social list friends
|
// Array for character social list friends
|
||||||
std::vector<int> g_SocialFriendsList;
|
std::vector<uint64> g_SocialFriendsList;
|
||||||
|
|
||||||
// Array for excluded bot names.
|
// Array for excluded bot names.
|
||||||
static std::vector<std::string> g_ExcludeBotNames;
|
static std::vector<std::string> g_ExcludeBotNames;
|
||||||
@@ -251,39 +254,6 @@ static bool IsHordePlayerBot(Player* bot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Logs the number of player bots at each level if full debug mode is enabled.
|
|
||||||
*
|
|
||||||
* This function iterates through all players in the world, counts the number of bots at each level,
|
|
||||||
* and logs the results. Only bots that are currently in the world are considered. The logging occurs
|
|
||||||
* only if the global debug mode flag `g_BotDistFullDebugMode` is set to true.
|
|
||||||
*/
|
|
||||||
static void LogAllBotLevels()
|
|
||||||
{
|
|
||||||
if (g_BotDistFullDebugMode)
|
|
||||||
{
|
|
||||||
std::map<uint8, uint32> botLevelCount;
|
|
||||||
for (auto const& itr : ObjectAccessor::GetPlayers())
|
|
||||||
{
|
|
||||||
Player* player = itr.second;
|
|
||||||
if (!player || !player->IsInWorld())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!IsPlayerBot(player))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
botLevelCount[player->GetLevel()]++;
|
|
||||||
}
|
|
||||||
for (const auto& entry : botLevelCount)
|
|
||||||
{
|
|
||||||
LOG_INFO("server.loading", "[BotLevelBrackets] Level {}: {} bots", entry.first, entry.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Removes a bot from the list of pending level resets.
|
* @brief Removes a bot from the list of pending level resets.
|
||||||
*
|
*
|
||||||
@@ -338,7 +308,7 @@ static void LoadSocialFriendList()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
uint32 socialFriendGUID = result->Fetch()->Get<uint32>();
|
uint32 socialFriendGUID = result->Fetch()->Get<uint32>();
|
||||||
g_SocialFriendsList.push_back(socialFriendGUID);
|
g_SocialFriendsList.push_back(static_cast<uint64>(socialFriendGUID));
|
||||||
if (g_BotDistFullDebugMode)
|
if (g_BotDistFullDebugMode)
|
||||||
{
|
{
|
||||||
LOG_INFO("server.load", "[BotLevelBrackets] Adding GUID {} to Social Friend List", socialFriendGUID);
|
LOG_INFO("server.load", "[BotLevelBrackets] Adding GUID {} to Social Friend List", socialFriendGUID);
|
||||||
@@ -664,11 +634,27 @@ static void AdjustBotToRange(Player* bot, int targetRangeIndex, const LevelRange
|
|||||||
{
|
{
|
||||||
lowerBound = 55;
|
lowerBound = 55;
|
||||||
}
|
}
|
||||||
|
if (lowerBound > upperBound)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
newLevel = urand(lowerBound, upperBound);
|
newLevel = urand(lowerBound, upperBound);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newLevel = GetRandomLevelInRange(factionRanges[targetRangeIndex]);
|
const LevelRangeConfig& range = factionRanges[targetRangeIndex];
|
||||||
|
if (range.lower > range.upper)
|
||||||
|
{
|
||||||
|
if (g_BotDistFullDebugMode)
|
||||||
|
{
|
||||||
|
std::string playerFaction = IsAlliancePlayerBot(bot) ? "Alliance" : "Horde";
|
||||||
|
LOG_INFO("server.loading",
|
||||||
|
"[BotLevelBrackets] AdjustBotToRange: Invalid range {}-{} for {} bot '{}'.",
|
||||||
|
range.lower, range.upper, playerFaction, bot->GetName());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newLevel = GetRandomLevelInRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerbotFactory newFactory(bot, newLevel);
|
PlayerbotFactory newFactory(bot, newLevel);
|
||||||
@@ -1361,6 +1347,9 @@ public:
|
|||||||
applyWeights(g_AllianceLevelRanges, allianceWeights);
|
applyWeights(g_AllianceLevelRanges, allianceWeights);
|
||||||
applyWeights(g_HordeLevelRanges, hordeWeights);
|
applyWeights(g_HordeLevelRanges, hordeWeights);
|
||||||
|
|
||||||
|
// Ensure brackets respect global min/max levels and percentages sum to 100
|
||||||
|
ClampAndBalanceBrackets();
|
||||||
|
|
||||||
// Debug output for new bracket percentages after normalization
|
// Debug output for new bracket percentages after normalization
|
||||||
if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
|
if (g_BotDistFullDebugMode || g_BotDistLiteDebugMode)
|
||||||
{
|
{
|
||||||
@@ -1799,18 +1788,47 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class BotLevelBracketsCommandScript
|
||||||
|
* @brief Handles chat commands for the Player Bot Level Brackets module.
|
||||||
|
*
|
||||||
|
* This script provides administrative commands to manage the bot level brackets configuration.
|
||||||
|
*/
|
||||||
|
class BotLevelBracketsCommandScript : public CommandScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BotLevelBracketsCommandScript() : CommandScript("BotLevelBracketsCommandScript") {}
|
||||||
|
|
||||||
|
ChatCommandTable GetCommands() const override
|
||||||
|
{
|
||||||
|
static ChatCommandTable commandTable =
|
||||||
|
{
|
||||||
|
{ "reload", HandleReloadConfig, SEC_ADMINISTRATOR, Console::No }
|
||||||
|
};
|
||||||
|
return commandTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleReloadConfig(ChatHandler* handler)
|
||||||
|
{
|
||||||
|
LoadBotLevelBracketsConfig();
|
||||||
|
handler->SendSysMessage("Bot level brackets config reloaded.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// ENTRY POINT: Register the Bot Level Distribution Module
|
// ENTRY POINT: Register the Bot Level Distribution Module
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Registers the world and player scripts for the Player Bot Level Brackets module.
|
* @brief Registers the world, player, and command scripts for the Player Bot Level Brackets module.
|
||||||
*
|
*
|
||||||
* This function instantiates and adds the BotLevelBracketsWorldScript and BotLevelBracketsPlayerScript
|
* This function instantiates and adds the BotLevelBracketsWorldScript, BotLevelBracketsPlayerScript,
|
||||||
* to the script system, enabling custom logic for player bot level brackets within the game world.
|
* and BotLevelBracketsCommandScript to the script system, enabling custom logic and commands
|
||||||
|
* for player bot level brackets within the game world.
|
||||||
*/
|
*/
|
||||||
void Addmod_player_bot_level_bracketsScripts()
|
void Addmod_player_bot_level_bracketsScripts()
|
||||||
{
|
{
|
||||||
new BotLevelBracketsWorldScript();
|
new BotLevelBracketsWorldScript();
|
||||||
new BotLevelBracketsPlayerScript();
|
new BotLevelBracketsPlayerScript();
|
||||||
|
new BotLevelBracketsCommandScript();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user