Revert "Rewrote scaling, moving away from cmangos solutions"

This reverts commit 62aef235d1.
This commit is contained in:
bash
2024-10-17 17:52:05 +00:00
parent ca9bfc4b9c
commit 12be2c9971
8 changed files with 113 additions and 90 deletions

View File

@@ -292,6 +292,11 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled)
return;
if (sPlayerbotAIConfig->botActiveAloneSmartScale)
{
ScaleBotActivity();
}
uint32 maxAllowedBotCount = GetEventValue(0, "bot_count");
if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots ||
maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots))
@@ -397,6 +402,27 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
}
}
void RandomPlayerbotMgr::ScaleBotActivity()
{
float activityPercentage = getActivityPercentage();
// if (activityPercentage >= 100.0f || activityPercentage <= 0.0f) pid.reset(); //Stop integer buildup during
// max/min activity
// % increase/decrease wanted diff , avg diff
float activityPercentageMod = pid.calculate(sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer,
sWorldUpdateTime.GetAverageUpdateTime());
activityPercentage = activityPercentageMod + 50;
// Cap the percentage between 0 and 100.
activityPercentage = std::max(0.0f, std::min(100.0f, activityPercentage));
setActivityPercentage(activityPercentage);
}
uint32 RandomPlayerbotMgr::AddRandomBots()
{
uint32 maxAllowedBotCount = GetEventValue(0, "bot_count");