From 0281fe73ad68273011b37bf0ea00514998806f3d Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 1 Sep 2024 00:05:31 +0800 Subject: [PATCH] Estimated group dps calculation --- src/PlayerbotAI.cpp | 26 +++++++++++++++++++ src/PlayerbotAI.h | 1 + src/strategy/values/ExpectedLifetimeValue.cpp | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 27214fc5..c8842cf4 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -5178,6 +5178,32 @@ uint32 PlayerbotAI::GetBuffedCount(Player* player, std::string const spellname) return bcount; } +int32 PlayerbotAI::GetNearGroupMemberCount(float dis) +{ + int count = 1; // yourself + if (Group* group = bot->GetGroup()) + { + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) + { + Player* member = gref->GetSource(); + if (member == bot) // calculated + continue; + + if (!member || !member->IsInWorld()) + continue; + + if (member->GetMapId() != bot->GetMapId()) + continue; + + if (member->GetExactDist(bot) > dis) + continue; + + count++; + } + } + return count; +} + bool PlayerbotAI::CanMove() { // do not allow if not vehicle driver diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index 61242629..73bc61a0 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -469,6 +469,7 @@ public: void ImbueItem(Item* item); void EnchantItemT(uint32 spellid, uint8 slot); uint32 GetBuffedCount(Player* player, std::string const spellname); + int32 GetNearGroupMemberCount(float dis = sPlayerbotAIConfig->sightDistance); virtual bool CanCastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); virtual bool CastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); diff --git a/src/strategy/values/ExpectedLifetimeValue.cpp b/src/strategy/values/ExpectedLifetimeValue.cpp index 0f3f4b83..892ee349 100644 --- a/src/strategy/values/ExpectedLifetimeValue.cpp +++ b/src/strategy/values/ExpectedLifetimeValue.cpp @@ -31,7 +31,7 @@ float ExpectedGroupDpsValue::Calculate() } else { - dps_num = group->GetMembersCount() * 0.7; + dps_num = botAI->GetNearGroupMemberCount() * 0.7; } uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(bot, true, false, 12); // efficiency record based on rare gear level, is there better calculation method?