diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 71c3a051..1e881ce8 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -1530,9 +1530,19 @@ AiPlayerbot.BotActiveAloneForceWhenInGuild = 1 # Specify smart scaling is enabled or not. # The default is 1. When enabled (smart) scales the 'BotActiveAlone' value. # Only when botLevel is between WhenMinLevel and WhenMaxLevel. +# +# AiPlayerbot.botActiveAloneDiff +# Method: 1 - Check against average Diff +# Method: 2 - Check against Max Diff (spikes) +# +# LimitFloor - No active bot decrease below this DIFF +# LimitCeiling - Max active bot decrease above this DIFF AiPlayerbot.botActiveAloneSmartScale = 1 AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel = 1 AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel = 80 +AiPlayerbot.botActiveAloneSmartScaleDiffMethod = 2 +AiPlayerbot.botActiveAloneSmartScaleDiffLimitFloor = 40 +AiPlayerbot.botActiveAloneSmartScaleDiffLimitCeiling = 150 # Premade spell to avoid (undetected spells) # spellid-radius, ... @@ -1543,7 +1553,6 @@ AiPlayerbot.MaxRandomBotsPriceChangeInterval = 172800 AiPlayerbot.MinRandomBotChangeStrategyTime = 180 AiPlayerbot.MaxRandomBotChangeStrategyTime = 720 - # How often tasks are changed AiPlayerbot.MinGuildTaskChangeTime = 172800 AiPlayerbot.MaxGuildTaskChangeTime = 432000 diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 00c84c57..fea6197f 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4352,10 +4352,22 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow) uint32 PlayerbotAI::AutoScaleActivity(uint32 mod) { - uint32 maxDiff = sWorldUpdateTime.GetAverageUpdateTime(); + uint32 diffLimitFloor = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitFloor; + uint32 diffLimitCeil = sPlayerbotAIConfig->botActiveAloneSmartScaleDiffLimitCeiling; + uint32 chkDiff = (sPlayerbotAIConfig->botActiveAloneSmartScaleDiffMethod == 2) + ? sWorldUpdateTime.GetMaxUpdateTime() + : sWorldUpdateTime.GetAverageUpdateTime(); - if (maxDiff > 500) return 0; - if (maxDiff > 250) + if (diffLimitFloor > diffLimitCeil) + diffLimitFloor = diffLimitCeil; + + if (chkDiff <= diffLimitFloor) return mod; + if (chkDiff >= diffLimitCeil) return 0; + + uint32 diffRange = diffLimitCeil - diffLimitFloor; + double spread = (double)diffRange / 5; // Calculate the equal spread between each number /w 5 steps + + if (chkDiff > diffLimitFloor + (4 * spread)) { if (Map* map = bot->GetMap()) { @@ -4375,10 +4387,10 @@ uint32 PlayerbotAI::AutoScaleActivity(uint32 mod) 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; + if (chkDiff > diffLimitFloor + (3 * spread)) return (mod * 2) / 10; + if (chkDiff > diffLimitFloor + (2 * spread)) return (mod * 4) / 10; + if (chkDiff > diffLimitFloor + (1 * spread)) return (mod * 7) / 10; + if (chkDiff > diffLimitFloor + (0 * spread)) return (mod * 9) / 10; return mod; } diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index df0dd650..ef913533 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -476,10 +476,11 @@ 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); + botActiveAloneSmartScaleDiffMethod = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneSmartScaleDiffMethod", 2); + botActiveAloneSmartScaleDiffLimitFloor = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneSmartScaleDiffLimitFloor", 40); + botActiveAloneSmartScaleDiffLimitCeiling = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneSmartScaleDiffLimitCeiling", 150); + 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 f8d36152..919cc21d 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -263,15 +263,20 @@ public: bool disableRandomLevels; uint32 playerbotsXPrate; bool disableDeathKnightLogin; + uint32 botActiveAlone; uint32 BotActiveAloneForceWhenInRadius; bool BotActiveAloneForceWhenInZone; bool BotActiveAloneForceWhenInMap; bool BotActiveAloneForceWhenIsFriend; - bool BotActiveAloneForceWhenInGuild; + bool BotActiveAloneForceWhenInGuild; + bool botActiveAloneSmartScale; uint32 botActiveAloneSmartScaleWhenMinLevel; uint32 botActiveAloneSmartScaleWhenMaxLevel; + uint32 botActiveAloneSmartScaleDiffMethod; + uint32 botActiveAloneSmartScaleDiffLimitFloor; + uint32 botActiveAloneSmartScaleDiffLimitCeiling; bool freeMethodLoot; int32 lootRollLevel;