mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 09:07:19 +00:00
[performance] bots scale idle fix (#678)
* [performance] bots scale idle fix * [performance] featureset
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
#include "Unit.h"
|
||||
#include "UpdateTime.h"
|
||||
#include "World.h"
|
||||
#include "GameTime.h"
|
||||
|
||||
void PrintStatsThread() { sRandomPlayerbotMgr->PrintStats(); }
|
||||
|
||||
@@ -164,12 +163,8 @@ RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0)
|
||||
sPlayerbotCommandServer->Start();
|
||||
PrepareTeleportCache();
|
||||
}
|
||||
if (!sPlayerbotAIConfig->randomBotAutologin)
|
||||
{
|
||||
setBotInitializing(false);
|
||||
}
|
||||
BattlegroundData.clear();
|
||||
|
||||
BattlegroundData.clear();
|
||||
BgCheckTimer = 0;
|
||||
LfgCheckTimer = 0;
|
||||
PlayersCheckTimer = 0;
|
||||
@@ -296,6 +291,15 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
|
||||
if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled)
|
||||
return;
|
||||
|
||||
/*if (sPlayerbotAIConfig->enablePrototypePerformanceDiff)
|
||||
{
|
||||
LOG_INFO("playerbots", "---------------------------------------");
|
||||
LOG_INFO("playerbots",
|
||||
"PROTOTYPE: Playerbot performance enhancements are active. Issues and instability may occur.");
|
||||
LOG_INFO("playerbots", "---------------------------------------");
|
||||
ScaleBotActivity();
|
||||
}*/
|
||||
|
||||
uint32 maxAllowedBotCount = GetEventValue(0, "bot_count");
|
||||
if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots ||
|
||||
maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots))
|
||||
@@ -313,17 +317,16 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
|
||||
|
||||
uint32 onlineBotFocus = 75;
|
||||
if (onlineBotCount < (uint32)(sPlayerbotAIConfig->minRandomBots * 90 / 100))
|
||||
{
|
||||
onlineBotFocus = 25;
|
||||
|
||||
// only keep updating till initializing time has completed,
|
||||
// which prevents unneeded expensive GameTime calls.
|
||||
if (_isBotInitializing)
|
||||
{
|
||||
_isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.13;
|
||||
}
|
||||
|
||||
setBotInitializing(
|
||||
//onlineBotCount < maxAllowedBotCount && <-- these fields are incorrect when using bot amount min/max are not equal.
|
||||
GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.12);
|
||||
|
||||
// when server is balancing bots then boost (decrease value of) the nextCheckDelay till
|
||||
// onlineBotCount reached the AllowedBotCount.
|
||||
uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||
uint32 updateIntervalTurboBoost = _isBotInitializing ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
|
||||
|
||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(
|
||||
@@ -407,6 +410,26 @@ 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->diffEmpty : sPlayerbotAIConfig->diffWithPlayer,
|
||||
// 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 maxAllowedBotCount = GetEventValue(0, "bot_count");
|
||||
@@ -996,7 +1019,6 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
||||
if (isLogginIn)
|
||||
return false;
|
||||
|
||||
|
||||
uint32 randomTime;
|
||||
if (!player)
|
||||
{
|
||||
@@ -1004,21 +1026,21 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
||||
randomTime = urand(1, 2);
|
||||
SetEventValue(bot, "login", 1, randomTime);
|
||||
|
||||
uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||
randomTime = urand(std::max(5, static_cast<int>(updateIntervalTurboBoost * 0.5)),
|
||||
std::max(12, static_cast<int>(updateIntervalTurboBoost * 2)));
|
||||
uint32 randomBotUpdateInterval = _isBotInitializing ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||
randomTime = urand(std::max(5, static_cast<int>(randomBotUpdateInterval * 0.5)),
|
||||
std::max(12, static_cast<int>(randomBotUpdateInterval * 2)));
|
||||
SetEventValue(bot, "update", 1, randomTime);
|
||||
|
||||
// do not randomize or teleport immediately after server start (prevent lagging)
|
||||
if (!GetEventValue(bot, "randomize"))
|
||||
{
|
||||
randomTime = urand(3, std::max(4, static_cast<int>(updateIntervalTurboBoost * 0.4)));
|
||||
randomTime = urand(3, std::max(4, static_cast<int>(randomBotUpdateInterval * 0.4)));
|
||||
ScheduleRandomize(bot, randomTime);
|
||||
}
|
||||
if (!GetEventValue(bot, "teleport"))
|
||||
{
|
||||
randomTime = urand(std::max(7, static_cast<int>(updateIntervalTurboBoost * 0.7)),
|
||||
std::max(14, static_cast<int>(updateIntervalTurboBoost * 1.4)));
|
||||
randomTime = urand(std::max(7, static_cast<int>(randomBotUpdateInterval * 0.7)),
|
||||
std::max(14, static_cast<int>(randomBotUpdateInterval * 1.4)));
|
||||
ScheduleTeleport(bot, randomTime);
|
||||
}
|
||||
|
||||
@@ -1088,9 +1110,6 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
||||
|
||||
bool RandomPlayerbotMgr::ProcessBot(Player* player)
|
||||
{
|
||||
if (!player || !player->IsInWorld() || player->IsBeingTeleported() || player->GetSession()->isLogingOut())
|
||||
return false;
|
||||
|
||||
uint32 bot = player->GetGUID().GetCounter();
|
||||
|
||||
if (player->InBattleground())
|
||||
@@ -1245,7 +1264,9 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
|
||||
if (botAI)
|
||||
{
|
||||
// ignore when in when taxi with boat/zeppelin and has players nearby
|
||||
if (botAI->IsTaxiFlying() && botAI->HasPlayerNearby())
|
||||
if (bot->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
|
||||
bot->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) &&
|
||||
botAI->HasPlayerNearby())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user