mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[performance] BotActiveAlone SmartScale toggle
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.
|
||||
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)
|
||||
# spellid-radius, ...
|
||||
AiPlayerbot.PremadeAvoidAoe = 62234-4
|
||||
|
||||
@@ -239,6 +239,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() ||
|
||||
// GetMaster()->GetSession()->isLogingOut()) {
|
||||
// return;
|
||||
@@ -301,6 +302,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
// bot->GetMotionMaster()->MoveIdle();
|
||||
// }
|
||||
|
||||
// cheat options
|
||||
if (bot->IsAlive() && ((uint32)GetCheat() > 0 || (uint32)sPlayerbotAIConfig->botCheatMask > 0))
|
||||
{
|
||||
@@ -4225,7 +4227,7 @@ std::pair<uint32, uint32> PlayerbotAI::GetPriorityBracket(ActivePiorityType type
|
||||
|
||||
bool PlayerbotAI::AllowActive(ActivityType activityType)
|
||||
{
|
||||
//General exceptions
|
||||
// General exceptions
|
||||
if (activityType == PACKET_ACTIVITY)
|
||||
return true;
|
||||
|
||||
@@ -4285,19 +4287,17 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
|
||||
}
|
||||
|
||||
// GetPriorityBracket acitivity
|
||||
float activePerc = 100;
|
||||
if (sPlayerbotAIConfig->botActiveAloneSmartScale)
|
||||
{
|
||||
std::pair<uint8, uint8> priorityBracket = GetPriorityBracket(type);
|
||||
if (!priorityBracket.second)
|
||||
return true; // No scaling
|
||||
|
||||
// Activity between 0 and 100.
|
||||
if (!priorityBracket.second) return true;
|
||||
float activityPercentage = sRandomPlayerbotMgr->getActivityPercentage();
|
||||
if (priorityBracket.first >= activityPercentage)
|
||||
return false;
|
||||
if (priorityBracket.second <= activityPercentage && priorityBracket.second < 100)
|
||||
return true;
|
||||
|
||||
float activePerc = (activityPercentage - priorityBracket.first) / (priorityBracket.second - priorityBracket.first);
|
||||
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) ? sPlayerbotAIConfig->botActiveAlone : 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, activePerc * 0.01f);
|
||||
@@ -5427,15 +5427,29 @@ bool PlayerbotAI::CanMove()
|
||||
if (IsInVehicle() && !IsInVehicle(true))
|
||||
return false;
|
||||
|
||||
if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) ||
|
||||
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))
|
||||
if (bot->isFrozen() ||
|
||||
bot->IsPolymorphed() ||
|
||||
(bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) ||
|
||||
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 bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE;
|
||||
}
|
||||
|
||||
bool PlayerbotAI::IsTaxiFlying()
|
||||
{
|
||||
return bot->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) &&
|
||||
bot->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING);
|
||||
}
|
||||
|
||||
bool PlayerbotAI::IsInRealGuild()
|
||||
{
|
||||
if (!bot->GetGuildId())
|
||||
|
||||
@@ -576,6 +576,7 @@ public:
|
||||
void ResetJumpDestination() { jumpDestination = Position(); }
|
||||
|
||||
bool CanMove();
|
||||
bool IsTaxiFlying();
|
||||
bool IsInRealGuild();
|
||||
static std::vector<std::string> dispel_whitelist;
|
||||
bool EqualLowercaseName(std::string s1, std::string s2);
|
||||
|
||||
@@ -465,6 +465,7 @@ bool PlayerbotAIConfig::Initialize()
|
||||
playerbotsXPrate = sConfigMgr->GetOption<int32>("AiPlayerbot.KillXPRate", 1);
|
||||
disableDeathKnightLogin = sConfigMgr->GetOption<bool>("AiPlayerbot.DisableDeathKnightLogin", 0);
|
||||
botActiveAlone = sConfigMgr->GetOption<int32>("AiPlayerbot.BotActiveAlone", 100);
|
||||
botActiveAloneSmartScale = sConfigMgr->GetOption<bool>("AiPlayerbot.botActiveAloneSmartScale", 1);
|
||||
|
||||
enablePrototypePerformanceDiff = sConfigMgr->GetOption<bool>("AiPlayerbot.EnablePrototypePerformanceDiff", false);
|
||||
diffWithPlayer = sConfigMgr->GetOption<int32>("AiPlayerbot.DiffWithPlayer", 100);
|
||||
|
||||
@@ -263,6 +263,7 @@ public:
|
||||
uint32 playerbotsXPrate;
|
||||
bool disableDeathKnightLogin;
|
||||
uint32 botActiveAlone;
|
||||
bool botActiveAloneSmartScale;
|
||||
|
||||
uint32 enablePrototypePerformanceDiff;
|
||||
uint32 diffWithPlayer;
|
||||
|
||||
Reference in New Issue
Block a user