mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[performance] initialize server and bots fase
This commit is contained in:
@@ -728,7 +728,7 @@ AiPlayerbot.FastReactInBG = 1
|
|||||||
#
|
#
|
||||||
|
|
||||||
# All In seconds
|
# All In seconds
|
||||||
AiPlayerbot.RandomBotUpdateInterval = 1
|
AiPlayerbot.RandomBotUpdateInterval = 5
|
||||||
AiPlayerbot.RandomBotCountChangeMinInterval = 1800
|
AiPlayerbot.RandomBotCountChangeMinInterval = 1800
|
||||||
AiPlayerbot.RandomBotCountChangeMaxInterval = 7200
|
AiPlayerbot.RandomBotCountChangeMaxInterval = 7200
|
||||||
AiPlayerbot.MinRandomBotInWorldTime = 3600
|
AiPlayerbot.MinRandomBotInWorldTime = 3600
|
||||||
|
|||||||
@@ -4219,8 +4219,7 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
|
|||||||
{
|
{
|
||||||
// no activity allowed during bot initialization during first
|
// no activity allowed during bot initialization during first
|
||||||
// few minutes after starting the server based on maxRandomBots.
|
// few minutes after starting the server based on maxRandomBots.
|
||||||
if (!sRandomPlayerbotMgr->isBotInitCompleted() &&
|
if (sRandomPlayerbotMgr->isBotInitializing())
|
||||||
GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.15)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// General exceptions
|
// General exceptions
|
||||||
|
|||||||
@@ -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", 1);
|
randomBotUpdateInterval = sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotUpdateInterval", 5);
|
||||||
randomBotCountChangeMinInterval =
|
randomBotCountChangeMinInterval =
|
||||||
sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE);
|
sConfigMgr->GetOption<int32>("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE);
|
||||||
randomBotCountChangeMaxInterval =
|
randomBotCountChangeMaxInterval =
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "UpdateTime.h"
|
#include "UpdateTime.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
#include "GameTime.h"
|
||||||
|
|
||||||
void PrintStatsThread() { sRandomPlayerbotMgr->PrintStats(); }
|
void PrintStatsThread() { sRandomPlayerbotMgr->PrintStats(); }
|
||||||
|
|
||||||
@@ -309,12 +310,17 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
|
|||||||
|
|
||||||
uint32 onlineBotFocus = 75;
|
uint32 onlineBotFocus = 75;
|
||||||
if (onlineBotCount < (uint32)(sPlayerbotAIConfig->minRandomBots * 90 / 100))
|
if (onlineBotCount < (uint32)(sPlayerbotAIConfig->minRandomBots * 90 / 100))
|
||||||
|
{
|
||||||
onlineBotFocus = 25;
|
onlineBotFocus = 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBotInitializing(
|
||||||
|
onlineBotCount < maxAllowedBotCount &&
|
||||||
|
GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.15);
|
||||||
|
|
||||||
// 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 = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||||
uint32 updateIntervalTurboBoost = onlineBotCount < maxAllowedBotCount ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
|
||||||
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
|
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
|
||||||
|
|
||||||
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(
|
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(
|
||||||
@@ -987,6 +993,7 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
|||||||
if (isLogginIn)
|
if (isLogginIn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
uint32 randomTime;
|
uint32 randomTime;
|
||||||
if (!player)
|
if (!player)
|
||||||
{
|
{
|
||||||
@@ -994,23 +1001,21 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
|||||||
randomTime = urand(1, 2);
|
randomTime = urand(1, 2);
|
||||||
SetEventValue(bot, "login", 1, randomTime);
|
SetEventValue(bot, "login", 1, randomTime);
|
||||||
|
|
||||||
randomTime = urand(
|
uint32 updateIntervalTurboBoost = isBotInitializing() ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
|
||||||
std::max(5, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.5)),
|
randomTime = urand(std::max(5, static_cast<int>(updateIntervalTurboBoost * 0.5)),
|
||||||
std::max(12, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 2)));
|
std::max(10, static_cast<int>(updateIntervalTurboBoost * 2)));
|
||||||
SetEventValue(bot, "update", 1, randomTime);
|
SetEventValue(bot, "update", 1, randomTime);
|
||||||
|
|
||||||
// do not randomize or teleport immediately after server start (prevent lagging)
|
// do not randomize or teleport immediately after server start (prevent lagging)
|
||||||
if (!GetEventValue(bot, "randomize"))
|
if (!GetEventValue(bot, "randomize"))
|
||||||
{
|
{
|
||||||
randomTime = urand(
|
randomTime = urand(3, std::max(4, static_cast<int>(updateIntervalTurboBoost * 0.4)));
|
||||||
3,std::max(4, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.4)));
|
|
||||||
ScheduleRandomize(bot, randomTime);
|
ScheduleRandomize(bot, randomTime);
|
||||||
}
|
}
|
||||||
if (!GetEventValue(bot, "teleport"))
|
if (!GetEventValue(bot, "teleport"))
|
||||||
{
|
{
|
||||||
randomTime = urand(
|
randomTime = urand(std::max(7, static_cast<int>(updateIntervalTurboBoost * 0.7)),
|
||||||
std::max(7, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 0.7)),
|
std::max(14, static_cast<int>(updateIntervalTurboBoost * 1.4)));
|
||||||
std::max(14, static_cast<int>(sPlayerbotAIConfig->randomBotUpdateInterval * 1.4)));
|
|
||||||
ScheduleTeleport(bot, randomTime);
|
ScheduleTeleport(bot, randomTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -165,8 +165,8 @@ public:
|
|||||||
|
|
||||||
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; }
|
bool isBotInitializing() const { return _isBotInitializing; }
|
||||||
void setIsBotInitCompleted(bool completed) { _isBotInitCompleted = completed; }
|
void setBotInitializing(bool completed) { _isBotInitializing = completed; }
|
||||||
|
|
||||||
void PrepareAddclassCache();
|
void PrepareAddclassCache();
|
||||||
std::map<uint8, std::vector<ObjectGuid>> addclassCache;
|
std::map<uint8, std::vector<ObjectGuid>> addclassCache;
|
||||||
@@ -176,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);
|
||||||
bool _isBotInitCompleted = false;
|
bool _isBotInitializing = true;
|
||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user