mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #562 from hermensbas/feature/performance_botActiveAutoScale
Modified the botActiveAlone autoscale functionality
This commit is contained in:
@@ -1462,6 +1462,10 @@ AiPlayerbot.RandombotsWalkingRPG.InDoors = 0
|
|||||||
# The default is 10. With 10% of all bots going active or inactive each minute.
|
# The default is 10. With 10% of all bots going active or inactive each minute.
|
||||||
AiPlayerbot.BotActiveAlone = 100
|
AiPlayerbot.BotActiveAlone = 100
|
||||||
|
|
||||||
|
# Specify 1 for enabled, 0 for disabled.
|
||||||
|
# The default is 1. Automatically adjusts 'BotActiveAlone' percentage based on server latency.
|
||||||
|
AiPlayerbot.botActiveAloneAutoScale = 1
|
||||||
|
|
||||||
# Premade spell to avoid (undetected spells)
|
# Premade spell to avoid (undetected spells)
|
||||||
# spellid-radius, ...
|
# spellid-radius, ...
|
||||||
AiPlayerbot.PremadeAvoidAoe = 62234-4
|
AiPlayerbot.PremadeAvoidAoe = 62234-4
|
||||||
|
|||||||
@@ -4095,8 +4095,6 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 maxDiff = sWorldUpdateTime.GetMaxUpdateTime();
|
|
||||||
|
|
||||||
Group* group = bot->GetGroup();
|
Group* group = bot->GetGroup();
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
@@ -4176,37 +4174,10 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
|
|||||||
if (sPlayerbotAIConfig->botActiveAlone <= 0)
|
if (sPlayerbotAIConfig->botActiveAlone <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->botActiveAlone >= 100)
|
uint32 mod = sPlayerbotAIConfig->botActiveAlone > 100 ? 100 : sPlayerbotAIConfig->botActiveAlone;
|
||||||
return true;
|
if (sPlayerbotAIConfig->botActiveAloneAutoScale)
|
||||||
|
|
||||||
if (maxDiff > 1000)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 mod = 100;
|
|
||||||
|
|
||||||
// if has real players - slow down continents without player
|
|
||||||
if (maxDiff > 100)
|
|
||||||
mod = 50;
|
|
||||||
|
|
||||||
if (maxDiff > 150)
|
|
||||||
mod = 25;
|
|
||||||
|
|
||||||
if (maxDiff > 200)
|
|
||||||
mod = 10;
|
|
||||||
|
|
||||||
if (maxDiff > 250)
|
|
||||||
{
|
{
|
||||||
if (Map* map = bot->GetMap())
|
mod = AutoScaleActivity(mod);
|
||||||
{
|
|
||||||
if (map->GetEntry()->IsWorldMap())
|
|
||||||
{
|
|
||||||
if (!HasRealPlayers(map))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!map->IsGridLoaded(bot->GetPositionX(), bot->GetPositionY()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ActivityNumber =
|
uint32 ActivityNumber =
|
||||||
@@ -4232,6 +4203,31 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow)
|
|||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 PlayerbotAI::AutoScaleActivity(uint32 mod)
|
||||||
|
{
|
||||||
|
uint32 maxDiff = sWorldUpdateTime.GetAverageUpdateTime();
|
||||||
|
|
||||||
|
if (maxDiff > 500) return 0;
|
||||||
|
if (maxDiff > 250)
|
||||||
|
{
|
||||||
|
if (Map* map = bot->GetMap())
|
||||||
|
{
|
||||||
|
if (map->GetEntry()->IsWorldMap() &&
|
||||||
|
(!HasRealPlayers(map) ||
|
||||||
|
!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 > 80) return (mod * 9) / 10;
|
||||||
|
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -527,6 +527,7 @@ public:
|
|||||||
bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance);
|
bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance);
|
||||||
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 AutoScaleActivity(uint32 mod);
|
||||||
|
|
||||||
// Check if player is safe to use.
|
// Check if player is safe to use.
|
||||||
bool IsSafe(Player* player);
|
bool IsSafe(Player* player);
|
||||||
|
|||||||
@@ -465,6 +465,7 @@ bool PlayerbotAIConfig::Initialize()
|
|||||||
playerbotsXPrate = sConfigMgr->GetOption<int32>("AiPlayerbot.KillXPRate", 1);
|
playerbotsXPrate = sConfigMgr->GetOption<int32>("AiPlayerbot.KillXPRate", 1);
|
||||||
disableDeathKnightLogin = sConfigMgr->GetOption<bool>("AiPlayerbot.DisableDeathKnightLogin", 0);
|
disableDeathKnightLogin = sConfigMgr->GetOption<bool>("AiPlayerbot.DisableDeathKnightLogin", 0);
|
||||||
botActiveAlone = sConfigMgr->GetOption<int32>("AiPlayerbot.BotActiveAlone", 100);
|
botActiveAlone = sConfigMgr->GetOption<int32>("AiPlayerbot.BotActiveAlone", 100);
|
||||||
|
botActiveAloneAutoScale = sConfigMgr->GetOption<bool>("AiPlayerbot.botActiveAloneAutoScale", true);
|
||||||
|
|
||||||
enablePrototypePerformanceDiff = sConfigMgr->GetOption<bool>("AiPlayerbot.EnablePrototypePerformanceDiff", false);
|
enablePrototypePerformanceDiff = sConfigMgr->GetOption<bool>("AiPlayerbot.EnablePrototypePerformanceDiff", false);
|
||||||
diffWithPlayer = sConfigMgr->GetOption<int32>("AiPlayerbot.DiffWithPlayer", 100);
|
diffWithPlayer = sConfigMgr->GetOption<int32>("AiPlayerbot.DiffWithPlayer", 100);
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ public:
|
|||||||
uint32 playerbotsXPrate;
|
uint32 playerbotsXPrate;
|
||||||
bool disableDeathKnightLogin;
|
bool disableDeathKnightLogin;
|
||||||
uint32 botActiveAlone;
|
uint32 botActiveAlone;
|
||||||
|
bool botActiveAloneAutoScale;
|
||||||
|
|
||||||
uint32 enablePrototypePerformanceDiff;
|
uint32 enablePrototypePerformanceDiff;
|
||||||
uint32 diffWithPlayer;
|
uint32 diffWithPlayer;
|
||||||
|
|||||||
Reference in New Issue
Block a user