diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index c6644435..f76afa53 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -1534,10 +1534,19 @@ AiPlayerbot.BotActiveAloneForceWhenInMap = 0 AiPlayerbot.BotActiveAloneForceWhenIsFriend = 1 AiPlayerbot.BotActiveAloneForceWhenInGuild = 1 -# Specify smart scaling is enabled or not. +# SmartScale is enabled or not. # The default is 1. When enabled (smart) scales the 'BotActiveAlone' value. -# Only when botLevel is between WhenMinLevel and WhenMaxLevel. +# (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%; +# +# 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 +# AiPlayerbot.botActiveAloneSmartScale = 1 +AiPlayerbot.botActiveAloneSmartScaleDiffLimitfloor = 50 +AiPlayerbot.botActiveAloneSmartScaleDiffLimitCeiling = 200 AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel = 1 AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel = 80 diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index eb5e9c29..310463a9 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4159,7 +4159,7 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) // which prevents unneeded expensive GameTime calls. if (_isBotInitializing) { - _isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.12; + _isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.11; // no activity allowed during bot initialization if (_isBotInitializing) @@ -4359,33 +4359,18 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow) uint32 PlayerbotAI::AutoScaleActivity(uint32 mod) { - uint32 maxDiff = sWorldUpdateTime.GetAverageUpdateTime(); + uint32 maxDiff = sWorldUpdateTime.GetMaxUpdateTimeOfCurrentTable(); + uint32 diffLimitFloor = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitfloor; + uint32 diffLimitCeiling = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitCeiling; + double spreadSize = (double)(diffLimitCeiling - diffLimitFloor) / 6; - if (maxDiff > 500) return 0; - if (maxDiff > 250) - { - if (Map* map = bot->GetMap()) - { - if (map->GetEntry()->IsWorldMap()) - { - if (!HasRealPlayers(map)) - { - return 0; - } - - if (!map->IsGridLoaded(bot->GetPositionX(), bot->GetPositionY())) - { - return 0; - } - } - } - - return (mod * 1) / 10; - } - if (maxDiff > 200) return (mod * 3) / 10; - if (maxDiff > 150) return (mod * 5) / 10; - if (maxDiff > 100) return (mod * 6) / 10; - if (maxDiff > 75) return (mod * 9) / 10; + // apply scaling + 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; } diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 2b4c17ee..347c3033 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -427,8 +427,7 @@ bool PlayerbotAIConfig::Initialize() minGuildTaskChangeTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskChangeTime", 3 * 24 * 3600); maxGuildTaskChangeTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskChangeTime", 4 * 24 * 3600); minGuildTaskAdvertisementTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskAdvertisementTime", 300); - maxGuildTaskAdvertisementTime = - sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600); + maxGuildTaskAdvertisementTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600); minGuildTaskRewardTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskRewardTime", 300); maxGuildTaskRewardTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskRewardTime", 3600); guildTaskAdvertCleanupTime = sConfigMgr->GetOption("AiPlayerbot.GuildTaskAdvertCleanupTime", 300); @@ -478,10 +477,10 @@ bool PlayerbotAIConfig::Initialize() BotActiveAloneForceWhenIsFriend = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneForceWhenIsFriend", 1); BotActiveAloneForceWhenInGuild = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneForceWhenInGuild", 1); botActiveAloneSmartScale = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScale", 1); - botActiveAloneSmartScaleWhenMinLevel = - sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1); - botActiveAloneSmartScaleWhenMaxLevel = - sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80); + botActiveAloneSmartScaleDiffLimitfloor = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleDiffLimitfloor", 50); + botActiveAloneSmartScaleDiffLimitCeiling = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleDiffLimitCeiling", 200); + botActiveAloneSmartScaleWhenMinLevel = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1); + botActiveAloneSmartScaleWhenMaxLevel = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80); randombotsWalkingRPG = sConfigMgr->GetOption("AiPlayerbot.RandombotsWalkingRPG", false); randombotsWalkingRPGInDoors = sConfigMgr->GetOption("AiPlayerbot.RandombotsWalkingRPG.InDoors", false); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index b5049dbb..4c49fec1 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -272,6 +272,8 @@ public: bool BotActiveAloneForceWhenIsFriend; bool BotActiveAloneForceWhenInGuild; bool botActiveAloneSmartScale; + uint32 botActiveAloneSmartScaleDiffLimitfloor; + uint32 botActiveAloneSmartScaleDiffLimitCeiling; uint32 botActiveAloneSmartScaleWhenMinLevel; uint32 botActiveAloneSmartScaleWhenMaxLevel; diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index 5386d9b2..97ee6dc7 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -101,11 +101,11 @@ public: if (sPlayerbotAIConfig->enabled || sPlayerbotAIConfig->randomBotAutologin) { std::string roundedTime = - std::to_string(std::ceil((sPlayerbotAIConfig->maxRandomBots * 0.13 / 60) * 10) / 10.0); + std::to_string(std::ceil((sPlayerbotAIConfig->maxRandomBots * 0.11 / 60) * 10) / 10.0); roundedTime = roundedTime.substr(0, roundedTime.find('.') + 2); ChatHandler(player->GetSession()).SendSysMessage( - "Playerbots: bot initialization at server startup will require '" + roundedTime + "' minutes."); + "Playerbots: bot initialization at server startup takes about '" + roundedTime + "' minutes."); } } } diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index c1f7aabb..1722cab4 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -337,7 +337,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) // which prevents unneeded expensive GameTime calls. if (_isBotInitializing) { - _isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.15; + _isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * (0.11 + 0.4); } uint32 updateIntervalTurboBoost = _isBotInitializing ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;