From 2a0bae60c8c767421721bacd02181d42ac715897 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 8 Sep 2024 12:53:21 +0800 Subject: [PATCH] Quest auto pick "yes" --- src/strategy/actions/TalkToQuestGiverAction.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/strategy/actions/TalkToQuestGiverAction.cpp b/src/strategy/actions/TalkToQuestGiverAction.cpp index f6e62bb0..772d3ff7 100644 --- a/src/strategy/actions/TalkToQuestGiverAction.cpp +++ b/src/strategy/actions/TalkToQuestGiverAction.cpp @@ -11,6 +11,7 @@ #include "Object.h" #include "Playerbots.h" #include "QuestDef.h" +#include "StatsWeightCalculator.h" #include "WorldPacket.h" #include "BroadcastHelper.h" @@ -176,8 +177,20 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques bestIds = BestRewards(quest); if (!bestIds.empty()) { - ItemTemplate const* item = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[*bestIds.begin()]); - bot->RewardQuest(quest, *bestIds.begin(), questGiver, true); + StatsWeightCalculator calc(bot); + uint32 best = 0; + float bestScore = 0; + for (uint32 id : bestIds) + { + float score = calc.CalculateItem(quest->RewardChoiceItemId[id]); + if (score > bestScore) + { + bestScore = score; + best = id; + } + } + ItemTemplate const* item = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[best]); + bot->RewardQuest(quest, best, questGiver, true); out << "Rewarded " << ChatHelper::FormatItem(item); } else