mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[performance] smart scaling configurable (#834)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -427,8 +427,7 @@ bool PlayerbotAIConfig::Initialize()
|
||||
minGuildTaskChangeTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MinGuildTaskChangeTime", 3 * 24 * 3600);
|
||||
maxGuildTaskChangeTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxGuildTaskChangeTime", 4 * 24 * 3600);
|
||||
minGuildTaskAdvertisementTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MinGuildTaskAdvertisementTime", 300);
|
||||
maxGuildTaskAdvertisementTime =
|
||||
sConfigMgr->GetOption<int32>("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600);
|
||||
maxGuildTaskAdvertisementTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600);
|
||||
minGuildTaskRewardTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MinGuildTaskRewardTime", 300);
|
||||
maxGuildTaskRewardTime = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxGuildTaskRewardTime", 3600);
|
||||
guildTaskAdvertCleanupTime = sConfigMgr->GetOption<int32>("AiPlayerbot.GuildTaskAdvertCleanupTime", 300);
|
||||
@@ -478,10 +477,10 @@ bool PlayerbotAIConfig::Initialize()
|
||||
BotActiveAloneForceWhenIsFriend = sConfigMgr->GetOption<bool>("AiPlayerbot.BotActiveAloneForceWhenIsFriend", 1);
|
||||
BotActiveAloneForceWhenInGuild = sConfigMgr->GetOption<bool>("AiPlayerbot.BotActiveAloneForceWhenInGuild", 1);
|
||||
botActiveAloneSmartScale = sConfigMgr->GetOption<bool>("AiPlayerbot.botActiveAloneSmartScale", 1);
|
||||
botActiveAloneSmartScaleWhenMinLevel =
|
||||
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1);
|
||||
botActiveAloneSmartScaleWhenMaxLevel =
|
||||
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80);
|
||||
botActiveAloneSmartScaleDiffLimitfloor = sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleDiffLimitfloor", 50);
|
||||
botActiveAloneSmartScaleDiffLimitCeiling = sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleDiffLimitCeiling", 200);
|
||||
botActiveAloneSmartScaleWhenMinLevel = sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1);
|
||||
botActiveAloneSmartScaleWhenMaxLevel = sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80);
|
||||
|
||||
randombotsWalkingRPG = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG", false);
|
||||
randombotsWalkingRPGInDoors = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG.InDoors", false);
|
||||
|
||||
@@ -272,6 +272,8 @@ public:
|
||||
bool BotActiveAloneForceWhenIsFriend;
|
||||
bool BotActiveAloneForceWhenInGuild;
|
||||
bool botActiveAloneSmartScale;
|
||||
uint32 botActiveAloneSmartScaleDiffLimitfloor;
|
||||
uint32 botActiveAloneSmartScaleDiffLimitCeiling;
|
||||
uint32 botActiveAloneSmartScaleWhenMinLevel;
|
||||
uint32 botActiveAloneSmartScaleWhenMaxLevel;
|
||||
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user