From 3c2bc1c959753d15584b99d949596a93cd6bddec Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 18 Dec 2023 20:29:48 +0800 Subject: [PATCH] quest share --- src/PlayerbotAI.cpp | 2 +- src/strategy/actions/AcceptQuestAction.cpp | 8 ++++++++ src/strategy/generic/QuestStrategies.cpp | 2 +- src/strategy/triggers/GenericTriggers.h | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index d7fef3ec..d60e6e45 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -134,7 +134,7 @@ PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHel masterIncomingPacketHandlers.AddHandler(CMSG_TAXICLEARNODE, "taxi done"); masterIncomingPacketHandlers.AddHandler(CMSG_GROUP_UNINVITE, "uninvite"); masterIncomingPacketHandlers.AddHandler(CMSG_GROUP_UNINVITE_GUID, "uninvite guid"); - // masterIncomingPacketHandlers.AddHandler(CMSG_PUSHQUESTTOPARTY, "quest share"); + masterIncomingPacketHandlers.AddHandler(CMSG_PUSHQUESTTOPARTY, "quest share"); masterIncomingPacketHandlers.AddHandler(CMSG_LFG_TELEPORT, "lfg teleport"); masterIncomingPacketHandlers.AddHandler(CMSG_CAST_SPELL, "see spell"); masterIncomingPacketHandlers.AddHandler(CMSG_REPOP_REQUEST, "release spirit"); diff --git a/src/strategy/actions/AcceptQuestAction.cpp b/src/strategy/actions/AcceptQuestAction.cpp index 003f9866..ec6674cc 100644 --- a/src/strategy/actions/AcceptQuestAction.cpp +++ b/src/strategy/actions/AcceptQuestAction.cpp @@ -88,6 +88,14 @@ bool AcceptQuestShareAction::Execute(Event event) return false; quest = qInfo->GetQuestId(); + + if (bot->HasQuest(quest)) + { + bot->SetDivider(ObjectGuid::Empty); + botAI->TellError("I have this quest"); + return false; + } + if (!bot->CanTakeQuest(qInfo, false)) { // can't take quest diff --git a/src/strategy/generic/QuestStrategies.cpp b/src/strategy/generic/QuestStrategies.cpp index 613b826c..7ea6c656 100644 --- a/src/strategy/generic/QuestStrategies.cpp +++ b/src/strategy/generic/QuestStrategies.cpp @@ -14,7 +14,7 @@ void QuestStrategy::InitTriggers(std::vector& triggers) { PassTroughStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("quest share", NextAction::array(0, new NextAction("accept quest share", relevance), nullptr))); + triggers.push_back(new TriggerNode("quest share", NextAction::array(0, new NextAction("accept quest share", relevance), nullptr))); } void DefaultQuestStrategy::InitTriggers(std::vector& triggers) diff --git a/src/strategy/triggers/GenericTriggers.h b/src/strategy/triggers/GenericTriggers.h index 911fa6da..d72ad48a 100644 --- a/src/strategy/triggers/GenericTriggers.h +++ b/src/strategy/triggers/GenericTriggers.h @@ -660,7 +660,7 @@ class NewPlayerNearbyTrigger : public Trigger class CollisionTrigger : public Trigger { public: - CollisionTrigger(PlayerbotAI* botAI) : Trigger(botAI, "collision", 5) { } + CollisionTrigger(PlayerbotAI* botAI) : Trigger(botAI, "collision", 5 * 1000) { } bool IsActive() override; };