diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 0a2f3b68..23943cb1 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -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 diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 20c04971..fd7872ee 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -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(mod * (1 - lagProgress)); } bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); }