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

@@ -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()); }