[performance] new baseline (#644)

This commit is contained in:
bash
2024-10-29 01:15:26 +01:00
committed by GitHub
parent b061f0016c
commit 3cd68c6dec
8 changed files with 115 additions and 172 deletions

View File

@@ -728,7 +728,7 @@ AiPlayerbot.FastReactInBG = 1
# #
# All In seconds # All In seconds
AiPlayerbot.RandomBotUpdateInterval = 20 AiPlayerbot.RandomBotUpdateInterval = 1
AiPlayerbot.RandomBotCountChangeMinInterval = 1800 AiPlayerbot.RandomBotCountChangeMinInterval = 1800
AiPlayerbot.RandomBotCountChangeMaxInterval = 7200 AiPlayerbot.RandomBotCountChangeMaxInterval = 7200
AiPlayerbot.MinRandomBotInWorldTime = 3600 AiPlayerbot.MinRandomBotInWorldTime = 3600
@@ -1459,17 +1459,11 @@ AiPlayerbot.BotActiveAlone = 100
# Specify smart scaling is enabled or not. # Specify smart scaling is enabled or not.
# The default is 1. When enabled (smart) scales the 'BotActiveAlone' value. # The default is 1. When enabled (smart) scales the 'BotActiveAlone' value.
AiPlayerbot.botActiveAloneSmartScale = 1
# Only when botLevel is between WhenMinLevel and WhenMaxLevel. # Only when botLevel is between WhenMinLevel and WhenMaxLevel.
AiPlayerbot.botActiveAloneSmartScale = 1
AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel = 1 AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel = 1
AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel = 80 AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel = 80
# The server will tune bot activity to reach the desired server tick speed (in ms)
# bots will only join battleground when there is no lag based on latency diffs below
AiPlayerbot.botActiveAloneSmartScaleDiffWithPlayer = 100
AiPlayerbot.botActiveAloneSmartScaleDiffEmpty = 200
# Premade spell to avoid (undetected spells) # Premade spell to avoid (undetected spells)
# spellid-radius, ... # spellid-radius, ...
AiPlayerbot.PremadeAvoidAoe = 62234-4 AiPlayerbot.PremadeAvoidAoe = 62234-4

View File

@@ -31,6 +31,7 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "PerformanceMonitor.h" #include "PerformanceMonitor.h"
#include "Player.h" #include "Player.h"
#include "GameTime.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "PlayerbotDbStore.h" #include "PlayerbotDbStore.h"
#include "PlayerbotMgr.h" #include "PlayerbotMgr.h"
@@ -4095,7 +4096,7 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{ {
Player* member = gref->GetSource(); Player* member = gref->GetSource();
if (!member || !member->IsInWorld() && member->GetMapId() != bot->GetMapId()) if (!member || (!member->IsInWorld() && member->GetMapId() != bot->GetMapId()))
continue; continue;
if (member == bot) if (member == bot)
@@ -4106,11 +4107,11 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
if (!memberBotAI || memberBotAI->HasRealPlayerMaster()) if (!memberBotAI || memberBotAI->HasRealPlayerMaster())
return ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER; return ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER;
//IN_GROUP_WITH_REAL_PLAYER //ALLOWED_PARTY_ACTIVITY
if (group->IsLeader(member->GetGUID())) if (group->IsLeader(member->GetGUID()))
{ {
if (!memberBotAI->AllowActivity(PARTY_ACTIVITY)) if (!memberBotAI->AllowActivity(PARTY_ACTIVITY))
return ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER; return ActivePiorityType::ALLOWED_PARTY_ACTIVITY;
} }
} }
} }
@@ -4180,145 +4181,103 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
if (IsInRealGuild()) if (IsInRealGuild())
return ActivePiorityType::PLAYER_GUILD; return ActivePiorityType::PLAYER_GUILD;
//IN_INACTIVE_MAP
if (bot->IsBeingTeleported() || !bot->IsInWorld() || !HasRealPlayers(bot->GetMap())) //IN_NOT_ACTIVE_MAP
return ActivePiorityType::IN_INACTIVE_MAP; if (Map* map = bot->GetMap())
{
if (map->GetEntry()->IsWorldMap())
{
if (!HasRealPlayers(map))
return ActivePiorityType::IN_NOT_ACTIVE_MAP;
if (!map->IsGridLoaded(bot->GetPositionX(), bot->GetPositionY()))
return ActivePiorityType::IN_NOT_ACTIVE_MAP;
}
}
//IN_ACTIVE_MAP //IN_ACTIVE_MAP
if (!bot->IsBeingTeleported() && bot->IsInWorld() && HasRealPlayers(bot->GetMap())) if (Map* map = bot->GetMap())
{
if (map->GetEntry()->IsWorldMap())
{
if (HasRealPlayers(map))
return ActivePiorityType::IN_ACTIVE_MAP; return ActivePiorityType::IN_ACTIVE_MAP;
}
}
// IN_ACTIVE_AREA // IN_ACTIVE_AREA
if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY) if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY)
{ {
if (HasManyPlayersNearby(20, sPlayerbotAIConfig->sightDistance)) if (HasManyPlayersNearby(20, sPlayerbotAIConfig->sightDistance))
return ActivePiorityType::IN_ACTIVE_AREA; return ActivePiorityType::IN_VERY_ACTIVE_AREA;
} }
return ActivePiorityType::IN_ACTIVE_AREA; return ActivePiorityType::DEFAULT;
}
// Returns the lower and upper bracket for bots to be active.
// Ie. { 10, 20 } means all bots in this bracket will be inactive below 10% activityMod,
// and will be active above 20% activityMod and scale between those values.
std::pair<uint32, uint32> PlayerbotAI::GetPriorityBracket(ActivePiorityType type)
{
switch (type)
{
case ActivePiorityType::HAS_REAL_PLAYER_MASTER:
case ActivePiorityType::IS_REAL_PLAYER:
case ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER:
case ActivePiorityType::IN_INSTANCE:
case ActivePiorityType::VISIBLE_FOR_PLAYER:
return {0, 0};
case ActivePiorityType::IS_ALWAYS_ACTIVE:
case ActivePiorityType::IN_COMBAT:
return {0, 10};
case ActivePiorityType::IN_BG_QUEUE:
return {0, 20};
case ActivePiorityType::IN_LFG:
return {0, 30};
case ActivePiorityType::NEARBY_PLAYER:
return {0, 40};
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
return {0, 50};
case ActivePiorityType::IN_ACTIVE_AREA:
case ActivePiorityType::IN_EMPTY_SERVER:
return {50, 100};
case ActivePiorityType::IN_ACTIVE_MAP:
return {70, 100};
case ActivePiorityType::IN_INACTIVE_MAP:
return {80, 100};
default:
return {90, 100};
}
return {90, 100};
} }
bool PlayerbotAI::AllowActive(ActivityType activityType) bool PlayerbotAI::AllowActive(ActivityType activityType)
{ {
// no activity allowed during bot initialization during first
// few minutes after starting the server based on maxRandomBots.
if (!sRandomPlayerbotMgr->isBotInitCompleted() &&
GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.15)
return false;
// General exceptions // General exceptions
if (activityType == PACKET_ACTIVITY) if (activityType == PACKET_ACTIVITY)
return true; return true;
ActivePiorityType type = GetPriorityType(activityType); ActivePiorityType type = GetPriorityType(activityType);
if (activityType == DETAILED_MOVE_ACTIVITY)
{
switch (type) switch (type)
{ {
case ActivePiorityType::HAS_REAL_PLAYER_MASTER: case ActivePiorityType::HAS_REAL_PLAYER_MASTER:
case ActivePiorityType::IS_REAL_PLAYER: case ActivePiorityType::IS_REAL_PLAYER:
case ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER: case ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER:
case ActivePiorityType::IN_INSTANCE: case ActivePiorityType::IN_INSTANCE:
case ActivePiorityType::VISIBLE_FOR_PLAYER:
case ActivePiorityType::IN_COMBAT: case ActivePiorityType::IN_COMBAT:
case ActivePiorityType::NEARBY_PLAYER: case ActivePiorityType::NEARBY_PLAYER:
return true;
break;
case ActivePiorityType::IS_ALWAYS_ACTIVE:
case ActivePiorityType::IN_BG_QUEUE:
case ActivePiorityType::IN_LFG:
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
case ActivePiorityType::IN_ACTIVE_AREA:
case ActivePiorityType::IN_EMPTY_SERVER:
case ActivePiorityType::IN_ACTIVE_MAP:
case ActivePiorityType::IN_INACTIVE_MAP:
default:
break;
}
}
else if (activityType == REACT_ACTIVITY)
{
switch (type)
{
case ActivePiorityType::HAS_REAL_PLAYER_MASTER:
case ActivePiorityType::IS_REAL_PLAYER:
case ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER:
case ActivePiorityType::IN_INSTANCE:
case ActivePiorityType::VISIBLE_FOR_PLAYER: case ActivePiorityType::VISIBLE_FOR_PLAYER:
case ActivePiorityType::IS_ALWAYS_ACTIVE: case ActivePiorityType::IS_ALWAYS_ACTIVE:
case ActivePiorityType::IN_COMBAT:
return true; return true;
break; break;
case ActivePiorityType::NEARBY_PLAYER: case ActivePiorityType::ALLOWED_PARTY_ACTIVITY:
case ActivePiorityType::IN_BG_QUEUE:
case ActivePiorityType::IN_LFG:
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
case ActivePiorityType::IN_ACTIVE_AREA:
case ActivePiorityType::IN_EMPTY_SERVER:
case ActivePiorityType::IN_ACTIVE_MAP:
case ActivePiorityType::IN_INACTIVE_MAP:
default:
return false; return false;
break; break;
} case ActivePiorityType::IN_BG_QUEUE:
case ActivePiorityType::IN_LFG:
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
case ActivePiorityType::IN_ACTIVE_MAP:
case ActivePiorityType::IN_NOT_ACTIVE_MAP:
case ActivePiorityType::IN_EMPTY_SERVER:
default:
break;
} }
// GetPriorityBracket acitivity // Bots do not need to move using PathGenerator.
float normalizedBotActiveAlone = sPlayerbotAIConfig->botActiveAlone > 100 ? 100 : sPlayerbotAIConfig->botActiveAlone; if (activityType == DETAILED_MOVE_ACTIVITY) return false;
float activePerc = normalizedBotActiveAlone;
// All exceptions are now done, below is the code to have a specified % of bots
// active at all times. The default is 10%. With 0.1% of all bots going active
// or inactive each minute.
if (sPlayerbotAIConfig->botActiveAlone <= 0) return false;
// Normalize the configured botActiveAlone value, and set as default mod.
uint32 botActiveAlonePerc = sPlayerbotAIConfig->botActiveAlone > 100 ? 100 : sPlayerbotAIConfig->botActiveAlone;
uint32 mod = botActiveAlonePerc;
if (sPlayerbotAIConfig->botActiveAloneSmartScale && if (sPlayerbotAIConfig->botActiveAloneSmartScale &&
bot->GetLevel() >= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMinLevel && bot->GetLevel() >= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMinLevel &&
bot->GetLevel() <= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMaxLevel) bot->GetLevel() <= sPlayerbotAIConfig->botActiveAloneSmartScaleWhenMaxLevel)
{ {
std::pair<uint8, uint8> priorityBracket = GetPriorityBracket(type); mod = SmartScaleActivity(type, botActiveAlonePerc);
if (!priorityBracket.second) return true;
float activityPercentage = sRandomPlayerbotMgr->getActivityPercentage();
if (priorityBracket.first >= activityPercentage) return false;
if (priorityBracket.second <= activityPercentage && priorityBracket.second < 100) return true;
activePerc = (activityPercentage - priorityBracket.first) / (priorityBracket.second - priorityBracket.first);
activePerc *= (priorityBracket.second == 100) ? normalizedBotActiveAlone : 100;
} }
// The last number if the amount it cycles per min. Currently set to 1% of the active bots. uint32 ActivityNumber = GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100,
uint32 ActivityNumber = GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100, activePerc * 0.01f); botActiveAlonePerc * static_cast<float>(mod) / 100 * 0.01f);
// The given percentage of bots should be active and rotate 1% of those active bots each minute. // The given percentage of bots should be active and rotate 1% of those active bots each minute.
return ActivityNumber <= (activePerc); return ActivityNumber <= (botActiveAlonePerc * mod) / 100;
} }
bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow) bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow)
@@ -4335,6 +4294,42 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow)
return allowed; return allowed;
} }
uint32 PlayerbotAI::SmartScaleActivity(ActivePiorityType type, uint32 botActiveAlonePerc)
{
uint32 maxDiff = sWorldUpdateTime.GetMaxUpdateTime();
if (maxDiff > 1000) return false;
switch (type)
{
case ActivePiorityType::IN_BG_QUEUE:
case ActivePiorityType::IN_LFG:
if (maxDiff > 100) return 80;
if (maxDiff > 50) return 90;
break;
case ActivePiorityType::PLAYER_FRIEND:
case ActivePiorityType::PLAYER_GUILD:
case ActivePiorityType::IN_ACTIVE_MAP:
if (maxDiff > 200) return 10;
if (maxDiff > 150) return 25;
if (maxDiff > 100) return 50;
if (maxDiff > 50) return 80;
break;
case ActivePiorityType::IN_VERY_ACTIVE_AREA: // Many bots nearby. Do not do heavy area checks.
case ActivePiorityType::IN_NOT_ACTIVE_MAP:
if (maxDiff > 100) return 10;
if (maxDiff > 50) return 25;
else return 30;
case ActivePiorityType::IN_EMPTY_SERVER:
return 10;
default:
if (maxDiff > 200) return 10;
if (maxDiff > 150) return 25;
if (maxDiff > 100) return 50;
break;
}
return botActiveAlonePerc;
}
bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); } bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); }
bool PlayerbotAI::IsOpposing(uint8 race1, uint8 race2) bool PlayerbotAI::IsOpposing(uint8 race1, uint8 race2)

View File

@@ -255,11 +255,12 @@ enum class ActivePiorityType : uint8
NEARBY_PLAYER = 9, NEARBY_PLAYER = 9,
PLAYER_FRIEND = 10, PLAYER_FRIEND = 10,
PLAYER_GUILD = 11, PLAYER_GUILD = 11,
IN_ACTIVE_AREA = 12, IN_VERY_ACTIVE_AREA = 12,
IN_ACTIVE_MAP = 13, IN_ACTIVE_MAP = 13,
IN_INACTIVE_MAP = 14, IN_NOT_ACTIVE_MAP = 14,
IN_EMPTY_SERVER = 15, IN_EMPTY_SERVER = 15,
MAX_TYPE ALLOWED_PARTY_ACTIVITY = 16,
DEFAULT
}; };
enum ActivityType enum ActivityType
@@ -547,9 +548,9 @@ public:
bool HasPlayerNearby(float range = sPlayerbotAIConfig->reactDistance); bool HasPlayerNearby(float range = sPlayerbotAIConfig->reactDistance);
bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance); bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance);
ActivePiorityType GetPriorityType(ActivityType activityType); ActivePiorityType GetPriorityType(ActivityType activityType);
std::pair<uint32, uint32> GetPriorityBracket(ActivePiorityType type);
bool AllowActive(ActivityType activityType); bool AllowActive(ActivityType activityType);
bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false); bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false);
uint32 SmartScaleActivity(ActivePiorityType type, uint32 botActiveAlonePerc);
// Check if player is safe to use. // Check if player is safe to use.
bool IsSafe(Player* player); bool IsSafe(Player* player);

View File

@@ -156,7 +156,7 @@ bool PlayerbotAIConfig::Initialize()
randomBotAutologin = sConfigMgr->GetOption<bool>("AiPlayerbot.RandomBotAutologin", true); randomBotAutologin = sConfigMgr->GetOption<bool>("AiPlayerbot.RandomBotAutologin", true);
minRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MinRandomBots", 50); minRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MinRandomBots", 50);
maxRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBots", 200); maxRandomBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxRandomBots", 200);
randomBotUpdateInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotUpdateInterval", 20); randomBotUpdateInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotUpdateInterval", 1);
randomBotCountChangeMinInterval = randomBotCountChangeMinInterval =
sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE); sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE);
randomBotCountChangeMaxInterval = randomBotCountChangeMaxInterval =
@@ -470,10 +470,6 @@ bool PlayerbotAIConfig::Initialize()
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1); sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1);
botActiveAloneSmartScaleWhenMaxLevel = botActiveAloneSmartScaleWhenMaxLevel =
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80); sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleWhenMaxLevel", 80);
botActiveAloneSmartScaleDiffWithPlayer =
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleDiffWithPlayer", 100);
botActiveAloneSmartScaleDiffEmpty =
sConfigMgr->GetOption<uint32>("AiPlayerbot.botActiveAloneSmartScaleDiffEmpty", 200);
randombotsWalkingRPG = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG", false); randombotsWalkingRPG = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG", false);
randombotsWalkingRPGInDoors = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG.InDoors", false); randombotsWalkingRPGInDoors = sConfigMgr->GetOption<bool>("AiPlayerbot.RandombotsWalkingRPG.InDoors", false);

View File

@@ -266,8 +266,6 @@ public:
bool botActiveAloneSmartScale; bool botActiveAloneSmartScale;
uint32 botActiveAloneSmartScaleWhenMinLevel; uint32 botActiveAloneSmartScaleWhenMinLevel;
uint32 botActiveAloneSmartScaleWhenMaxLevel; uint32 botActiveAloneSmartScaleWhenMaxLevel;
uint32 botActiveAloneSmartScaleDiffWithPlayer;
uint32 botActiveAloneSmartScaleDiffEmpty;
bool freeMethodLoot; bool freeMethodLoot;
int32 lootRollLevel; int32 lootRollLevel;

View File

@@ -292,11 +292,6 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled) if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled)
return; return;
if (sPlayerbotAIConfig->botActiveAloneSmartScale)
{
ScaleBotActivity();
}
uint32 maxAllowedBotCount = GetEventValue(0, "bot_count"); uint32 maxAllowedBotCount = GetEventValue(0, "bot_count");
if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots || if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots ||
maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots)) maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots))
@@ -318,6 +313,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
// when server is balancing bots then boost (decrease value of) the nextCheckDelay till // when server is balancing bots then boost (decrease value of) the nextCheckDelay till
// onlineBotCount reached the AllowedBotCount. // onlineBotCount reached the AllowedBotCount.
setIsBotInitCompleted(onlineBotCount < maxAllowedBotCount);
uint32 updateIntervalTurboBoost = onlineBotCount < maxAllowedBotCount ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval; uint32 updateIntervalTurboBoost = onlineBotCount < maxAllowedBotCount ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10); SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
@@ -402,27 +398,6 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
} }
} }
void RandomPlayerbotMgr::ScaleBotActivity()
{
float activityPercentage = getActivityPercentage();
// if (activityPercentage >= 100.0f || activityPercentage <= 0.0f) pid.reset(); //Stop integer buildup during
// max/min activity
// % increase/decrease wanted diff , avg diff
float activityPercentageMod = pid.calculate(sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer,
sWorldUpdateTime.GetAverageUpdateTime());
activityPercentage = activityPercentageMod + 50;
// Cap the percentage between 0 and 100.
activityPercentage = std::max(0.0f, std::min(100.0f, activityPercentage));
setActivityPercentage(activityPercentage);
}
uint32 RandomPlayerbotMgr::AddRandomBots() uint32 RandomPlayerbotMgr::AddRandomBots()
{ {
uint32 maxAllowedBotCount = GetEventValue(0, "bot_count"); uint32 maxAllowedBotCount = GetEventValue(0, "bot_count");

View File

@@ -103,8 +103,7 @@ public:
void LogPlayerLocation(); void LogPlayerLocation();
void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; void UpdateAIInternal(uint32 elapsed, bool minimal = false) override;
private: //private:
void ScaleBotActivity();
public: public:
uint32 activeBots = 0; uint32 activeBots = 0;
@@ -164,11 +163,11 @@ public:
return BattleMastersCache; return BattleMastersCache;
} }
float getActivityMod() { return activityMod; }
float getActivityPercentage() { return activityMod * 100.0f; }
void setActivityPercentage(float percentage) { activityMod = percentage / 100.0f; }
static uint8 GetTeamClassIdx(bool isAlliance, uint8 claz) { return isAlliance * 20 + claz; } static uint8 GetTeamClassIdx(bool isAlliance, uint8 claz) { return isAlliance * 20 + claz; }
bool isBotInitCompleted() const { return _isBotInitCompleted; }
void setIsBotInitCompleted(bool completed) { _isBotInitCompleted = completed; }
void PrepareAddclassCache(); void PrepareAddclassCache();
std::map<uint8, std::vector<ObjectGuid>> addclassCache; std::map<uint8, std::vector<ObjectGuid>> addclassCache;
protected: protected:
@@ -177,7 +176,7 @@ protected:
private: private:
// pid values are set in constructor // pid values are set in constructor
botPID pid = botPID(1, 50, -50, 0, 0, 0); botPID pid = botPID(1, 50, -50, 0, 0, 0);
float activityMod = 0.25; bool _isBotInitCompleted = false;
uint32 GetEventValue(uint32 bot, std::string const event); uint32 GetEventValue(uint32 bot, std::string const event);
std::string const GetEventData(uint32 bot, std::string const event); std::string const GetEventData(uint32 bot, std::string const event);
uint32 SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, uint32 SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn,

View File

@@ -234,17 +234,9 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
return false; return false;
TeamId teamId = bot->GetTeamId(); TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2; uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam(); uint32 TeamSize = bg->GetMaxPlayersPerTeam();
// If performance diff is enabled, only queue if there is no lag
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
return false;
// If the bot is in a group, only the leader can queue // If the bot is in a group, only the leader can queue
if (bot->GetGroup() && !bot->GetGroup()->IsLeader(bot->GetGUID())) if (bot->GetGroup() && !bot->GetGroup()->IsLeader(bot->GetGUID()))
return false; return false;
@@ -577,17 +569,10 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
return false; return false;
TeamId teamId = bot->GetTeamId(); TeamId teamId = bot->GetTeamId();
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2; uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
uint32 TeamSize = bg->GetMaxPlayersPerTeam(); uint32 TeamSize = bg->GetMaxPlayersPerTeam();
// If performance diff is enabled, only queue if there is no lag
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
return false;
// If the bot is in a group, only the leader can queue // If the bot is in a group, only the leader can queue
if (bot->GetGroup() && !bot->GetGroup()->IsLeader(bot->GetGUID())) if (bot->GetGroup() && !bot->GetGroup()->IsLeader(bot->GetGUID()))
return false; return false;