From 77ba59ed547a514b09a105cb97cd3d7dd25de990 Mon Sep 17 00:00:00 2001 From: bash Date: Sun, 13 Oct 2024 00:00:41 +0000 Subject: [PATCH] [performance] Smartscale added missing acitivity --- src/PlayerbotAI.cpp | 63 ++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index c42ad985..94bc7d2d 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -4101,10 +4101,12 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType) if (member == bot) continue; + //IN_GROUP_WITH_REAL_PLAYER PlayerbotAI* memberBotAI = GET_PLAYERBOT_AI(member); if (!memberBotAI || memberBotAI->HasRealPlayerMaster()) return ActivePiorityType::IN_GROUP_WITH_REAL_PLAYER; + //IN_GROUP_WITH_REAL_PLAYER if (group->IsLeader(member->GetGUID())) { if (!memberBotAI->AllowActivity(PARTY_ACTIVITY)) @@ -4113,22 +4115,27 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType) } } + //IN_INSTANCE if (bot->IsBeingTeleported()) // Allow activity while teleportation. return ActivePiorityType::IN_INSTANCE; + //IN_INSTANCE if (!WorldPosition(bot).isOverworld()) return ActivePiorityType::IN_INSTANCE; - if (HasPlayerNearby()) + //VISIBLE_FOR_PLAYER + if (HasPlayerNearby(sPlayerbotAIConfig->reactDistance)) return ActivePiorityType::VISIBLE_FOR_PLAYER; + //IN_COMBAT if (activityType != OUT_OF_PARTY_ACTIVITY && activityType != PACKET_ACTIVITY) { - // Is in combat.Defend yourself. + // Is in combat, defend yourself. if (bot->IsInCombat()) return ActivePiorityType::IN_COMBAT; } + //NEARBY_PLAYER if (HasPlayerNearby(300.f)) return ActivePiorityType::NEARBY_PLAYER; @@ -4153,33 +4160,38 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType) if (isLFG) return ActivePiorityType::IN_LFG; - // If has real players - slow down continents without player - // This means we first disable bots in a different continent/area. + //IN_EMPTY_SERVER if (sRandomPlayerbotMgr->GetPlayers().empty()) return ActivePiorityType::IN_EMPTY_SERVER; - // friends always active - // for (auto& player : sRandomPlayerbotMgr->GetPlayers()) - // { - // if (!player || !player->IsInWorld()) - // continue; + //PLAYER_FRIEND (on friendlist of real player) (needs to be tested for stability) + /*for (auto& player : sRandomPlayerbotMgr->GetPlayers()) + { + if (!player || !player->IsInWorld()) + continue; - // if (player->GetSocial()->HasFriend(bot->GetGUID())) - // return ActivePiorityType::PLAYER_FRIEND; - // } + if (player->GetSocial() && + bot->GetGUID() && + player->GetSocial()->HasFriend(bot->GetGUID())) + return ActivePiorityType::PLAYER_FRIEND; + }*/ - // real guild always active if member+ + //PLAYER_GUILD (contains real player) if (IsInRealGuild()) return ActivePiorityType::PLAYER_GUILD; + //IN_INACTIVE_MAP if (bot->IsBeingTeleported() || !bot->IsInWorld() || !HasRealPlayers(bot->GetMap())) return ActivePiorityType::IN_INACTIVE_MAP; + //IN_ACTIVE_MAP + if (!bot->IsBeingTeleported() && bot->IsInWorld() && HasRealPlayers(bot->GetMap())) + return ActivePiorityType::IN_ACTIVE_MAP; + // IN_ACTIVE_AREA if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY) { - // Many bots nearby. Do not do heavy area checks. - if (HasManyPlayersNearby()) + if (HasManyPlayersNearby(20, sPlayerbotAIConfig->sightDistance)) return ActivePiorityType::IN_ACTIVE_AREA; } @@ -4190,7 +4202,7 @@ ActivePiorityType PlayerbotAI::GetPriorityType(ActivityType activityType) // Ie. { 10, 20 } means all bots in this bracket will be inactive below 10% activityMod, // and will be active above 20% activityMod and scale between those values. std::pair PlayerbotAI::GetPriorityBracket(ActivePiorityType type) -{ +{ switch (type) { case ActivePiorityType::HAS_REAL_PLAYER_MASTER: @@ -4203,24 +4215,27 @@ std::pair PlayerbotAI::GetPriorityBracket(ActivePiorityType type case ActivePiorityType::IN_COMBAT: return {0, 10}; case ActivePiorityType::IN_BG_QUEUE: - case ActivePiorityType::IN_LFG: return {0, 20}; - case ActivePiorityType::NEARBY_PLAYER: + case ActivePiorityType::IN_LFG: return {0, 30}; - case ActivePiorityType::PLAYER_FRIEND: + case ActivePiorityType::NEARBY_PLAYER: return {0, 40}; - case ActivePiorityType::IN_ACTIVE_AREA: + case ActivePiorityType::PLAYER_FRIEND: case ActivePiorityType::PLAYER_GUILD: return {0, 50}; + case ActivePiorityType::IN_ACTIVE_AREA: + return {30, 100}; case ActivePiorityType::IN_ACTIVE_MAP: - return {20, 100}; + return {50, 100}; case ActivePiorityType::IN_INACTIVE_MAP: - return {50, 100}; + return {70, 100}; case ActivePiorityType::IN_EMPTY_SERVER: - return {90, 100}; + return {80, 100}; default: - return {50, 100}; + return {90, 100}; } + + return {90, 100}; } bool PlayerbotAI::AllowActive(ActivityType activityType)