From ea944aeefa83be506be5583902bf911dfe967b8d Mon Sep 17 00:00:00 2001 From: bash <31279994+hermensbas@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:18:36 +0100 Subject: [PATCH] added additional botActiveAlone confguration options (#780) --- conf/playerbots.conf.dist | 6 ++++++ src/PlayerbotAI.cpp | 45 +++++++++++++++++++++++---------------- src/PlayerbotAIConfig.cpp | 4 ++++ src/PlayerbotAIConfig.h | 4 ++++ 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index bc7510aa..e28a473d 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -1511,6 +1511,12 @@ AiPlayerbot.RandombotsWalkingRPG.InDoors = 0 # enforced to 100% AiPlayerbot.BotActiveAlone = 100 +# Force botActiveAlone when bot is ... of real player +AiPlayerbot.BotActiveAloneForceWhenInRadius = 150; +AiPlayerbot.BotActiveAloneForceWhenInZone = 1; +AiPlayerbot.BotActiveAloneForceWhenIsFriend = 1; +AiPlayerbot.BotActiveAloneForceWhenInGuild = 1; + # Specify smart scaling is enabled or not. # The default is 1. When enabled (smart) scales the 'BotActiveAlone' value. # Only when botLevel is between WhenMinLevel and WhenMaxLevel. diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 067825ee..1416ae48 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4173,19 +4173,31 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) } // bot zone has active players. - if (ZoneHasRealPlayers(bot)) + if (sPlayerbotAIConfig->BotActiveAloneForceWhenInZone) { - return true; + if (ZoneHasRealPlayers(bot)) + { + return true; + } } // when in real guild - if (IsInRealGuild()) + if (sPlayerbotAIConfig->BotActiveAloneForceWhenInGuild) + { + if (IsInRealGuild()) + { + return true; + } + } + + // Player is near. Always active. + if (HasPlayerNearby(sPlayerbotAIConfig->BotActiveAloneWhenInRadius)) { return true; } // Has player master. Always active. - if (GetMaster()) + if (GetMaster()) { PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(GetMaster()); if (!masterBotAI || masterBotAI->IsRealPlayer()) @@ -4253,30 +4265,27 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) return true; } - // Player is near. Always active. - if (HasPlayerNearby(300.f)) - { - return true; - } - // HasFriend - for (auto& player : sRandomPlayerbotMgr->GetPlayers()) + if (sPlayerbotAIConfig->BotActiveAloneForceWhenIsFriend) { - if (!player || !player->IsInWorld() || !player->GetSocial() || !bot->GetGUID()) + for (auto& player : sRandomPlayerbotMgr->GetPlayers()) { - continue; - } + if (!player || !player->IsInWorld() || !player->GetSocial() || !bot->GetGUID()) + { + continue; + } - if (player->GetSocial()->HasFriend(bot->GetGUID())) - { - return true; + if (player->GetSocial()->HasFriend(bot->GetGUID())) + { + return true; + } } } // Force the bots to spread if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY) { - if (HasManyPlayersNearby(10, sPlayerbotAIConfig->sightDistance)) + if (HasManyPlayersNearby(10, 40)) { return true; } diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index 48ff9b63..c6b7cf98 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -468,6 +468,10 @@ bool PlayerbotAIConfig::Initialize() playerbotsXPrate = sConfigMgr->GetOption("AiPlayerbot.KillXPRate", 1); disableDeathKnightLogin = sConfigMgr->GetOption("AiPlayerbot.DisableDeathKnightLogin", 0); botActiveAlone = sConfigMgr->GetOption("AiPlayerbot.BotActiveAlone", 100); + BotActiveAloneWhenInRadius = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneWhenInRadius", 150); + BotActiveAloneForceWhenInZone = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneForceWhenInZone", 1); + BotActiveAloneForceWhenIsFriend = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneForceWhenIsFriend", 1); + BotActiveAloneForceWhenInGuild = sConfigMgr->GetOption("AiPlayerbot.BotActiveAloneForceWhenInGuild", 1); botActiveAloneSmartScale = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScale", 1); botActiveAloneSmartScaleWhenMinLevel = sConfigMgr->GetOption("AiPlayerbot.botActiveAloneSmartScaleWhenMinLevel", 1); diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 714b7073..749047ce 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -264,6 +264,10 @@ public: uint32 playerbotsXPrate; bool disableDeathKnightLogin; uint32 botActiveAlone; + uint32 BotActiveAloneWhenInRadius; + bool BotActiveAloneForceWhenInZone; + bool BotActiveAloneForceWhenIsFriend; + bool BotActiveAloneForceWhenInGuild; bool botActiveAloneSmartScale; uint32 botActiveAloneSmartScaleWhenMinLevel; uint32 botActiveAloneSmartScaleWhenMaxLevel;