AutoScaleActivity refactoring (#1375)

* AutoScaleActivity refactoring

* Abandon AutoScaleActivity 5% stepping
This commit is contained in:
NoxMax
2025-06-12 15:21:35 -06:00
committed by GitHub
parent 097bd00f38
commit bb004825aa
2 changed files with 18 additions and 16 deletions

View File

@@ -717,8 +717,8 @@ AiPlayerbot.BotActiveAloneForceWhenInGuild = 1
# The default is 1. When enabled (smart) scales the 'BotActiveAlone' value.
# (The scaling will be overruled by the BotActiveAloneForceWhen...rules)
#
# Limitfloor - when DIFF (latency) above floor, activity scaling is applied starting with 90%
# LimitCeiling - when DIFF (latency) above ceiling, activity is 0%;
# Limitfloor - when DIFF (latency) is above floor, activity scaling begins
# LimitCeiling - when DIFF (latency) is above ceiling, activity is 0%
#
# MinLevel - only apply scaling when level is above or equal to min(bot)Level
# MaxLevel - only apply scaling when level is lower or equal of max(bot)Level

View File

@@ -4365,26 +4365,28 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow)
uint32 PlayerbotAI::AutoScaleActivity(uint32 mod)
{
// Current max server update time (ms), and the configured floor/ceiling values for bot scaling
uint32 maxDiff = sWorldUpdateTime.GetMaxUpdateTimeOfCurrentTable();
uint32 diffLimitFloor = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitfloor;
uint32 diffLimitCeiling = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitCeiling;
double spreadSize = (double)(diffLimitCeiling - diffLimitFloor) / 6;
// apply scaling
if (diffLimitCeiling <= diffLimitFloor)
{
// Perfrom binary decision if ceiling <= floor: Either all bots are active or none are
return (maxDiff > diffLimitCeiling) ? 0 : mod;
}
if (maxDiff > diffLimitCeiling)
return 0;
if (maxDiff > diffLimitFloor + (4 * spreadSize))
return (mod * 1) / 10;
if (maxDiff > diffLimitFloor + (3 * spreadSize))
return (mod * 3) / 10;
if (maxDiff > diffLimitFloor + (2 * spreadSize))
return (mod * 5) / 10;
if (maxDiff > diffLimitFloor + (1 * spreadSize))
return (mod * 7) / 10;
if (maxDiff > diffLimitFloor)
return (mod * 9) / 10;
return mod;
if (maxDiff <= diffLimitFloor)
return mod;
// Calculate lag progress from floor to ceiling (0 to 1)
double lagProgress = (maxDiff - diffLimitFloor) / (double)(diffLimitCeiling - diffLimitFloor);
// Apply the percentage of active bots (the complement of lag progress) to the mod value
return static_cast<uint32>(mod * (1 - lagProgress));
}
bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); }