Added Option to Enable/Disable Mod

This commit is contained in:
jimm0thy
2025-02-24 18:07:59 -05:00
parent 5a6c54eab4
commit 69e346e357
2 changed files with 576 additions and 559 deletions

View File

@@ -3,6 +3,12 @@
##############################################
# mod-player-bot-level-brackets configuration
##############################################
# BotLevelBrackets.ModEnabled
# Description: Turns module on/on
# Default: 1 (enabled)
# Valid Values: 0 (off) / 1 (on)
BotLevelBrackets.ModEnabled = 1
#
# BotLevelBrackets.DebugMode
# Description: Enables debug logging for the Bot Level Brackets module.

View File

@@ -51,6 +51,7 @@ static uint32 g_BotDistFlaggedCheckFrequency = 15; // in seconds
static bool g_BotDistDebugMode = false;
static bool g_UseDynamicDistribution = false;
static bool g_IgnoreFriendListed = true;
static bool g_EnableMod = true;
// Real player weight to boost bracket contributions.
static float g_RealPlayerWeight = 1.0f;
@@ -64,6 +65,7 @@ static void LoadBotLevelBracketsConfig()
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);
g_EnableMod = sConfigMgr->GetOption<bool>("BotLevelBrackets.ModEnabled", true);
// Load the bot level restrictions.
g_RandomBotMinLevel = static_cast<uint8>(sConfigMgr->GetOption<uint32>("AiPlayerbot.RandomBotMinLevel", 1));
@@ -97,6 +99,8 @@ static void LoadBotLevelBracketsConfig()
// Returns the index of the level range bracket that the given level belongs to.
// If the bot is out of range, it returns -1
static int GetLevelRangeIndex(uint8 level, uint8 teamID)
{
if (g_EnableMod)
{
// If the bot's level is outside the allowed global bounds, signal an invalid bracket.
if (level < g_RandomBotMinLevel || level > g_RandomBotMaxLevel)
@@ -122,6 +126,7 @@ static int GetLevelRangeIndex(uint8 level, uint8 teamID)
return -1;
}
}
// Returns a random level within the provided range.
static uint8 GetRandomLevelInRange(const LevelRangeConfig& range)
@@ -237,6 +242,8 @@ static void LogAllBotLevels()
}
static void ClampAndBalanceBrackets()
{
if (g_EnableMod)
{
// First, adjust Alliance brackets.
for (uint8 i = 0; i < NUM_RANGES; ++i)
@@ -307,6 +314,7 @@ static void ClampAndBalanceBrackets()
}
}
}
}
// -----------------------------------------------------------------------------
// SAFETY CHECKS FOR LEVEL RESET
@@ -395,7 +403,7 @@ static void ProcessPendingLevelResets()
Player* bot = it->bot;
int targetRange = it->targetRange;
if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot))
if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot) && g_EnableMod)
{
AdjustBotToRange(bot, targetRange, it->factionRanges);
LOG_INFO("server.loading", "[BotLevelBrackets] Bot '{}' successfully reset to level range {}-{}.",
@@ -496,6 +504,8 @@ public:
}
void OnUpdate(uint32 diff) override
{
if (g_EnableMod)
{
m_timer += diff;
m_flaggedTimer += diff;
@@ -1044,6 +1054,7 @@ public:
}
}
}
private:
uint32 m_timer; // For distribution adjustments