mirror of
https://github.com/kadeshar/mod-player-bot-level-brackets.git
synced 2026-01-13 01:08:36 +00:00
Revert "Added Option to Enable/Disable Mod"
This reverts commit 69e346e357.
Setting up separate branch
This commit is contained in:
@@ -3,12 +3,6 @@
|
||||
##############################################
|
||||
# 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.
|
||||
|
||||
@@ -51,7 +51,6 @@ 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;
|
||||
@@ -65,7 +64,6 @@ 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));
|
||||
@@ -100,13 +98,11 @@ static void LoadBotLevelBracketsConfig()
|
||||
// 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)
|
||||
return -1;
|
||||
|
||||
if (teamID == TEAM_ALLIANCE)
|
||||
if(teamID == TEAM_ALLIANCE)
|
||||
{
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
@@ -115,7 +111,7 @@ static int GetLevelRangeIndex(uint8 level, uint8 teamID)
|
||||
}
|
||||
}
|
||||
|
||||
if (teamID == TEAM_HORDE)
|
||||
if(teamID == TEAM_HORDE)
|
||||
{
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
@@ -125,7 +121,6 @@ static int GetLevelRangeIndex(uint8 level, uint8 teamID)
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a random level within the provided range.
|
||||
@@ -243,8 +238,6 @@ static void LogAllBotLevels()
|
||||
|
||||
static void ClampAndBalanceBrackets()
|
||||
{
|
||||
if (g_EnableMod)
|
||||
{
|
||||
// First, adjust Alliance brackets.
|
||||
for (uint8 i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
@@ -275,17 +268,17 @@ static void ClampAndBalanceBrackets()
|
||||
totalHorde += g_HordeLevelRanges[i].desiredPercent;
|
||||
}
|
||||
// If totals are not 100, then distribute the missing percent among valid brackets.
|
||||
if (totalAlliance != 100 && totalAlliance > 0)
|
||||
if(totalAlliance != 100 && totalAlliance > 0)
|
||||
{
|
||||
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance: Sum of percentages is {} (expected 100). Auto adjusting.", totalAlliance);
|
||||
|
||||
int missing = 100 - totalAlliance;
|
||||
while (missing > 0)
|
||||
while(missing > 0)
|
||||
{
|
||||
for (uint8 i = 0; i < NUM_RANGES && missing > 0; ++i)
|
||||
{
|
||||
if (g_AllianceLevelRanges[i].lower <= g_AllianceLevelRanges[i].upper &&
|
||||
if(g_AllianceLevelRanges[i].lower <= g_AllianceLevelRanges[i].upper &&
|
||||
g_AllianceLevelRanges[i].desiredPercent > 0)
|
||||
{
|
||||
g_AllianceLevelRanges[i].desiredPercent++;
|
||||
@@ -294,17 +287,17 @@ static void ClampAndBalanceBrackets()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (totalHorde != 100 && totalHorde > 0)
|
||||
if(totalHorde != 100 && totalHorde > 0)
|
||||
{
|
||||
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] Horde: Sum of percentages is {} (expected 100). Auto adjusting.", totalHorde);
|
||||
|
||||
int missing = 100 - totalHorde;
|
||||
while (missing > 0)
|
||||
while(missing > 0)
|
||||
{
|
||||
for (uint8 i = 0; i < NUM_RANGES && missing > 0; ++i)
|
||||
{
|
||||
if (g_HordeLevelRanges[i].lower <= g_HordeLevelRanges[i].upper &&
|
||||
if(g_HordeLevelRanges[i].lower <= g_HordeLevelRanges[i].upper &&
|
||||
g_HordeLevelRanges[i].desiredPercent > 0)
|
||||
{
|
||||
g_HordeLevelRanges[i].desiredPercent++;
|
||||
@@ -313,7 +306,6 @@ static void ClampAndBalanceBrackets()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -403,7 +395,7 @@ static void ProcessPendingLevelResets()
|
||||
Player* bot = it->bot;
|
||||
int targetRange = it->targetRange;
|
||||
|
||||
if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot) && g_EnableMod)
|
||||
if (bot && bot->IsInWorld() && IsBotSafeForLevelReset(bot))
|
||||
{
|
||||
AdjustBotToRange(bot, targetRange, it->factionRanges);
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] Bot '{}' successfully reset to level range {}-{}.",
|
||||
@@ -504,8 +496,6 @@ public:
|
||||
}
|
||||
|
||||
void OnUpdate(uint32 diff) override
|
||||
{
|
||||
if (g_EnableMod)
|
||||
{
|
||||
m_timer += diff;
|
||||
m_flaggedTimer += diff;
|
||||
@@ -526,8 +516,8 @@ public:
|
||||
// Dynamic distribution: recalc desired percentages based on non-bot players.
|
||||
if (g_UseDynamicDistribution)
|
||||
{
|
||||
int allianceRealCounts[NUM_RANGES] = { 0 };
|
||||
int hordeRealCounts[NUM_RANGES] = { 0 };
|
||||
int allianceRealCounts[NUM_RANGES] = {0};
|
||||
int hordeRealCounts[NUM_RANGES] = {0};
|
||||
uint32 totalAllianceReal = 0;
|
||||
uint32 totalHordeReal = 0;
|
||||
// Iterate over all players and count non-bot players.
|
||||
@@ -556,8 +546,8 @@ public:
|
||||
const float baseline = 1.0f;
|
||||
float allianceTotalWeight = 0.0f;
|
||||
float hordeTotalWeight = 0.0f;
|
||||
float allianceWeights[NUM_RANGES] = { 0 };
|
||||
float hordeWeights[NUM_RANGES] = { 0 };
|
||||
float allianceWeights[NUM_RANGES] = {0};
|
||||
float hordeWeights[NUM_RANGES] = {0};
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
// Only count valid brackets.
|
||||
@@ -674,12 +664,12 @@ public:
|
||||
|
||||
// Containers for Alliance bots.
|
||||
uint32 totalAllianceBots = 0;
|
||||
int allianceActualCounts[NUM_RANGES] = { 0 };
|
||||
int allianceActualCounts[NUM_RANGES] = {0};
|
||||
std::vector<Player*> allianceBotsByRange[NUM_RANGES];
|
||||
|
||||
// Containers for Horde bots.
|
||||
uint32 totalHordeBots = 0;
|
||||
int hordeActualCounts[NUM_RANGES] = { 0 };
|
||||
int hordeActualCounts[NUM_RANGES] = {0};
|
||||
std::vector<Player*> hordeBotsByRange[NUM_RANGES];
|
||||
|
||||
// Iterate only over player bots.
|
||||
@@ -759,7 +749,7 @@ public:
|
||||
if (totalAllianceBots > 0)
|
||||
{
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
|
||||
int allianceDesiredCounts[NUM_RANGES] = { 0 };
|
||||
int allianceDesiredCounts[NUM_RANGES] = {0};
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
allianceDesiredCounts[i] = static_cast<int>(round((g_AllianceLevelRanges[i].desiredPercent / 100.0) * totalAllianceBots));
|
||||
@@ -882,7 +872,7 @@ public:
|
||||
}
|
||||
if (!alreadyFlagged)
|
||||
{
|
||||
g_PendingLevelResets.push_back({ bot, targetRange, g_AllianceLevelRanges });
|
||||
g_PendingLevelResets.push_back({bot, targetRange, g_AllianceLevelRanges});
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] Alliance bot '{}' flagged for pending level reset to range {}-{}.",
|
||||
bot->GetName(), g_AllianceLevelRanges[targetRange].lower, g_AllianceLevelRanges[targetRange].upper);
|
||||
}
|
||||
@@ -894,7 +884,7 @@ public:
|
||||
if (totalHordeBots > 0)
|
||||
{
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
|
||||
int hordeDesiredCounts[NUM_RANGES] = { 0 };
|
||||
int hordeDesiredCounts[NUM_RANGES] = {0};
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
hordeDesiredCounts[i] = static_cast<int>(round((g_HordeLevelRanges[i].desiredPercent / 100.0) * totalHordeBots));
|
||||
@@ -1016,7 +1006,7 @@ public:
|
||||
}
|
||||
if (!alreadyFlagged)
|
||||
{
|
||||
g_PendingLevelResets.push_back({ bot, targetRange, g_HordeLevelRanges });
|
||||
g_PendingLevelResets.push_back({bot, targetRange, g_HordeLevelRanges});
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] Horde bot '{}' flagged for pending level reset to range {}-{}.",
|
||||
bot->GetName(), g_HordeLevelRanges[targetRange].lower, g_HordeLevelRanges[targetRange].upper);
|
||||
}
|
||||
@@ -1033,7 +1023,7 @@ public:
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
|
||||
LogAllBotLevels();
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] =========================================");
|
||||
int allianceDesiredCounts[NUM_RANGES] = { 0 };
|
||||
int allianceDesiredCounts[NUM_RANGES] = {0};
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
allianceDesiredCounts[i] = static_cast<int>(round((g_AllianceLevelRanges[i].desiredPercent / 100.0) * totalAllianceBots));
|
||||
@@ -1042,7 +1032,7 @@ public:
|
||||
allianceDesiredCounts[i], allianceActualCounts[i]);
|
||||
}
|
||||
LOG_INFO("server.loading", "[BotLevelBrackets] ----------------------------------------");
|
||||
int hordeDesiredCounts[NUM_RANGES] = { 0 };
|
||||
int hordeDesiredCounts[NUM_RANGES] = {0};
|
||||
for (int i = 0; i < NUM_RANGES; ++i)
|
||||
{
|
||||
hordeDesiredCounts[i] = static_cast<int>(round((g_HordeLevelRanges[i].desiredPercent / 100.0) * totalHordeBots));
|
||||
@@ -1054,7 +1044,6 @@ public:
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 m_timer; // For distribution adjustments
|
||||
|
||||
Reference in New Issue
Block a user