mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
AutoScaleActivity refactoring (#1375)
* AutoScaleActivity refactoring * Abandon AutoScaleActivity 5% stepping
This commit is contained in:
@@ -717,8 +717,8 @@ AiPlayerbot.BotActiveAloneForceWhenInGuild = 1
|
|||||||
# The default is 1. When enabled (smart) scales the 'BotActiveAlone' value.
|
# The default is 1. When enabled (smart) scales the 'BotActiveAlone' value.
|
||||||
# (The scaling will be overruled by the BotActiveAloneForceWhen...rules)
|
# (The scaling will be overruled by the BotActiveAloneForceWhen...rules)
|
||||||
#
|
#
|
||||||
# Limitfloor - when DIFF (latency) above floor, activity scaling is applied starting with 90%
|
# Limitfloor - when DIFF (latency) is above floor, activity scaling begins
|
||||||
# LimitCeiling - when DIFF (latency) above ceiling, activity is 0%;
|
# LimitCeiling - when DIFF (latency) is above ceiling, activity is 0%
|
||||||
#
|
#
|
||||||
# MinLevel - only apply scaling when level is above or equal to min(bot)Level
|
# 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
|
# MaxLevel - only apply scaling when level is lower or equal of max(bot)Level
|
||||||
|
|||||||
@@ -4365,26 +4365,28 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow)
|
|||||||
|
|
||||||
uint32 PlayerbotAI::AutoScaleActivity(uint32 mod)
|
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 maxDiff = sWorldUpdateTime.GetMaxUpdateTimeOfCurrentTable();
|
||||||
uint32 diffLimitFloor = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitfloor;
|
uint32 diffLimitFloor = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitfloor;
|
||||||
uint32 diffLimitCeiling = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitCeiling;
|
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)
|
if (maxDiff > diffLimitCeiling)
|
||||||
return 0;
|
return 0;
|
||||||
if (maxDiff > diffLimitFloor + (4 * spreadSize))
|
|
||||||
return (mod * 1) / 10;
|
if (maxDiff <= diffLimitFloor)
|
||||||
if (maxDiff > diffLimitFloor + (3 * spreadSize))
|
return mod;
|
||||||
return (mod * 3) / 10;
|
|
||||||
if (maxDiff > diffLimitFloor + (2 * spreadSize))
|
// Calculate lag progress from floor to ceiling (0 to 1)
|
||||||
return (mod * 5) / 10;
|
double lagProgress = (maxDiff - diffLimitFloor) / (double)(diffLimitCeiling - diffLimitFloor);
|
||||||
if (maxDiff > diffLimitFloor + (1 * spreadSize))
|
|
||||||
return (mod * 7) / 10;
|
// Apply the percentage of active bots (the complement of lag progress) to the mod value
|
||||||
if (maxDiff > diffLimitFloor)
|
return static_cast<uint32>(mod * (1 - lagProgress));
|
||||||
return (mod * 9) / 10;
|
|
||||||
|
|
||||||
return mod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); }
|
bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); }
|
||||||
|
|||||||
Reference in New Issue
Block a user