[performance] BotActiveAlone SmartScale toggle

This commit is contained in:
bash
2024-10-09 22:34:37 +00:00
parent 4c13a11ff2
commit c7197f0911
5 changed files with 41 additions and 20 deletions

View File

@@ -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 smart scaling is enabled or not.
# The default is 1. When enabled (smart) scales the 'BotActiveAlone' value.
AiPlayerbot.botActiveAloneSmartScale = 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

View File

@@ -239,6 +239,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
{ {
return; return;
} }
// if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() || // if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() ||
// GetMaster()->GetSession()->isLogingOut()) { // GetMaster()->GetSession()->isLogingOut()) {
// return; // return;
@@ -301,6 +302,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
// bot->GetMotionMaster()->Clear(); // bot->GetMotionMaster()->Clear();
// bot->GetMotionMaster()->MoveIdle(); // bot->GetMotionMaster()->MoveIdle();
// } // }
// cheat options // cheat options
if (bot->IsAlive() && ((uint32)GetCheat() > 0 || (uint32)sPlayerbotAIConfig->botCheatMask > 0)) if (bot->IsAlive() && ((uint32)GetCheat() > 0 || (uint32)sPlayerbotAIConfig->botCheatMask > 0))
{ {
@@ -4188,7 +4190,7 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType)
// Ie. 10,20 means all bots in this bracket will be inactive below 10% activityMod, all bots in this bracket will be // Ie. 10,20 means all bots in this bracket will be inactive below 10% activityMod, all bots in this bracket will be
// active above 20% activityMod and scale between those values. // active above 20% activityMod and scale between those values.
std::pair<uint32, uint32> PlayerbotAI::GetPriorityBracket(ActivePiorityType type) std::pair<uint32, uint32> PlayerbotAI::GetPriorityBracket(ActivePiorityType type)
{ {
switch (type) switch (type)
{ {
case ActivePiorityType::HAS_REAL_PLAYER_MASTER: case ActivePiorityType::HAS_REAL_PLAYER_MASTER:
@@ -4219,13 +4221,13 @@ std::pair<uint32, uint32> PlayerbotAI::GetPriorityBracket(ActivePiorityType type
default: default:
return {90, 100}; return {90, 100};
} }
return {90, 100}; return {90, 100};
} }
bool PlayerbotAI::AllowActive(ActivityType activityType) bool PlayerbotAI::AllowActive(ActivityType activityType)
{ {
//General exceptions // General exceptions
if (activityType == PACKET_ACTIVITY) if (activityType == PACKET_ACTIVITY)
return true; return true;
@@ -4285,19 +4287,17 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
} }
// GetPriorityBracket acitivity // GetPriorityBracket acitivity
std::pair<uint8, uint8> priorityBracket = GetPriorityBracket(type); float activePerc = 100;
if (!priorityBracket.second) if (sPlayerbotAIConfig->botActiveAloneSmartScale)
return true; // No scaling {
std::pair<uint8, uint8> priorityBracket = GetPriorityBracket(type);
// Activity between 0 and 100. if (!priorityBracket.second) return true;
float activityPercentage = sRandomPlayerbotMgr->getActivityPercentage(); float activityPercentage = sRandomPlayerbotMgr->getActivityPercentage();
if (priorityBracket.first >= activityPercentage) if (priorityBracket.first >= activityPercentage) return false;
return false; if (priorityBracket.second <= activityPercentage && priorityBracket.second < 100) return true;
if (priorityBracket.second <= activityPercentage && priorityBracket.second < 100) activePerc = (activityPercentage - priorityBracket.first) / (priorityBracket.second - priorityBracket.first);
return true; activePerc *= (priorityBracket.second == 100) ? sPlayerbotAIConfig->botActiveAlone : 100;
}
float activePerc = (activityPercentage - priorityBracket.first) / (priorityBracket.second - priorityBracket.first);
activePerc *= (priorityBracket.second == 100) ? sPlayerbotAIConfig->botActiveAlone : 100;
// The last number if the amount it cycles per min. Currently set to 1% of the active bots. // 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, activePerc * 0.01f); uint32 ActivityNumber = GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100, activePerc * 0.01f);
@@ -5427,15 +5427,29 @@ bool PlayerbotAI::CanMove()
if (IsInVehicle() && !IsInVehicle(true)) if (IsInVehicle() && !IsInVehicle(true))
return false; return false;
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || if (bot->isFrozen() ||
bot->IsBeingTeleported() || bot->isInRoots() || bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || bot->IsPolymorphed() ||
bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || bot->HasAuraType(SPELL_AURA_MOD_STUN) || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) ||
bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) bot->IsBeingTeleported() ||
bot->isInRoots() ||
bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) ||
bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) ||
bot->IsCharmed() ||
bot->HasAuraType(SPELL_AURA_MOD_STUN) ||
bot->HasUnitState(UNIT_STATE_IN_FLIGHT) ||
bot->HasUnitState(UNIT_STATE_LOST_CONTROL))
return false; return false;
return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE; return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE;
} }
bool PlayerbotAI::IsTaxiFlying()
{
return bot->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
bot->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING);
}
bool PlayerbotAI::IsInRealGuild() bool PlayerbotAI::IsInRealGuild()
{ {
if (!bot->GetGuildId()) if (!bot->GetGuildId())

View File

@@ -576,6 +576,7 @@ public:
void ResetJumpDestination() { jumpDestination = Position(); } void ResetJumpDestination() { jumpDestination = Position(); }
bool CanMove(); bool CanMove();
bool IsTaxiFlying();
bool IsInRealGuild(); bool IsInRealGuild();
static std::vector<std::string> dispel_whitelist; static std::vector<std::string> dispel_whitelist;
bool EqualLowercaseName(std::string s1, std::string s2); bool EqualLowercaseName(std::string s1, std::string s2);

View File

@@ -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);
botActiveAloneSmartScale = sConfigMgr->GetOption<bool>("AiPlayerbot.botActiveAloneSmartScale", 1);
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);

View File

@@ -263,6 +263,7 @@ public:
uint32 playerbotsXPrate; uint32 playerbotsXPrate;
bool disableDeathKnightLogin; bool disableDeathKnightLogin;
uint32 botActiveAlone; uint32 botActiveAlone;
bool botActiveAloneSmartScale;
uint32 enablePrototypePerformanceDiff; uint32 enablePrototypePerformanceDiff;
uint32 diffWithPlayer; uint32 diffWithPlayer;