From 5c579ecf1793908169f2cee86a776715b6010e26 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Nov 2023 23:23:01 +0800 Subject: [PATCH] quest confirm accept(group quest) --- src/PlayerbotAI.cpp | 3 ++- .../actions/QuestConfirmAcceptAction.cpp | 18 +++++++++++++ .../actions/QuestConfirmAcceptAction.h | 25 +++++++++++++++++++ .../generic/WorldPacketHandlerStrategy.cpp | 1 + .../triggers/WorldPacketTriggerContext.h | 2 ++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/strategy/actions/QuestConfirmAcceptAction.cpp create mode 100644 src/strategy/actions/QuestConfirmAcceptAction.h diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 0c6e0cc2..dceebd25 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -166,7 +166,8 @@ PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHel botOutgoingPacketHandlers.AddHandler(SMSG_EMOTE, "receive emote"); botOutgoingPacketHandlers.AddHandler(SMSG_LOOT_START_ROLL, "master loot roll"); botOutgoingPacketHandlers.AddHandler(SMSG_ARENA_TEAM_INVITE, "arena team invite"); - + botOutgoingPacketHandlers.AddHandler(SMSG_QUEST_CONFIRM_ACCEPT, "quest confirm accept"); + masterOutgoingPacketHandlers.AddHandler(SMSG_PARTY_COMMAND_RESULT, "party command"); masterOutgoingPacketHandlers.AddHandler(MSG_RAID_READY_CHECK, "ready check"); masterOutgoingPacketHandlers.AddHandler(MSG_RAID_READY_CHECK_FINISHED, "ready check finished"); diff --git a/src/strategy/actions/QuestConfirmAcceptAction.cpp b/src/strategy/actions/QuestConfirmAcceptAction.cpp new file mode 100644 index 00000000..ab580432 --- /dev/null +++ b/src/strategy/actions/QuestConfirmAcceptAction.cpp @@ -0,0 +1,18 @@ +#include "QuestConfirmAcceptAction.h" +#include "WorldPacket.h" + +bool QuestConfirmAcceptAction::Execute(Event event) +{ + WorldPacket packet(event.getPacket()); + uint32 questId; + packet >> questId; + + WorldPacket sendPacket(CMSG_QUEST_CONFIRM_ACCEPT); + sendPacket << questId; + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest || !bot->CanAddQuest(quest, true)) { + return false; + } + bot->GetSession()->HandleQuestConfirmAccept(sendPacket); + return true; +} \ No newline at end of file diff --git a/src/strategy/actions/QuestConfirmAcceptAction.h b/src/strategy/actions/QuestConfirmAcceptAction.h new file mode 100644 index 00000000..ecbc7263 --- /dev/null +++ b/src/strategy/actions/QuestConfirmAcceptAction.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + */ + +#ifndef _PLAYERBOT_QUESTCONFIRMACCEPTACTION_H +#define _PLAYERBOT_QUESTCONFIRMACCEPTACTION_H + +#include "PlayerbotAI.h" +#include "QuestAction.h" +#include "Player.h" + +class ObjectGuid; +class Quest; +class Player; +class PlayerbotAI; +class WorldObject; + +class QuestConfirmAcceptAction : public QuestAction +{ + public: + QuestConfirmAcceptAction(PlayerbotAI* botAI) : QuestAction(botAI, "quest confirm accept") {} + bool Execute(Event event) override; +}; + +#endif \ No newline at end of file diff --git a/src/strategy/generic/WorldPacketHandlerStrategy.cpp b/src/strategy/generic/WorldPacketHandlerStrategy.cpp index b06b3a6a..bf5d2af1 100644 --- a/src/strategy/generic/WorldPacketHandlerStrategy.cpp +++ b/src/strategy/generic/WorldPacketHandlerStrategy.cpp @@ -32,6 +32,7 @@ void WorldPacketHandlerStrategy::InitTriggers(std::vector& trigger triggers.push_back(new TriggerNode("lfg proposal", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); triggers.push_back(new TriggerNode("lfg proposal active", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); triggers.push_back(new TriggerNode("arena team invite", NextAction::array(0, new NextAction("arena team accept", relevance), nullptr))); + triggers.push_back(new TriggerNode("quest confirm accept", NextAction::array(0, new NextAction("quest confirm accept", relevance), nullptr))); //triggers.push_back(new TriggerNode("no non bot players around", NextAction::array(0, new NextAction("delay", relevance), nullptr))); triggers.push_back(new TriggerNode("bg status", NextAction::array(0, new NextAction("bg status", relevance), nullptr))); triggers.push_back(new TriggerNode("xpgain", NextAction::array(0, new NextAction("xp gain", relevance), nullptr))); diff --git a/src/strategy/triggers/WorldPacketTriggerContext.h b/src/strategy/triggers/WorldPacketTriggerContext.h index 6cdb40e5..350c7e87 100644 --- a/src/strategy/triggers/WorldPacketTriggerContext.h +++ b/src/strategy/triggers/WorldPacketTriggerContext.h @@ -60,6 +60,7 @@ class WorldPacketTriggerContext : public NamedObjectContext creators["receive emote"] = &WorldPacketTriggerContext::receive_emote; creators["receive text emote"] = &WorldPacketTriggerContext::receive_text_emote; creators["arena team invite"] = &WorldPacketTriggerContext::arena_team_invite; + creators["quest confirm accept"] = &WorldPacketTriggerContext::quest_confirm_accept; } private: @@ -109,6 +110,7 @@ class WorldPacketTriggerContext : public NamedObjectContext static Trigger* receive_emote(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "receive emote"); } static Trigger* receive_text_emote(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "receive text emote"); } static Trigger* arena_team_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "arena team invite"); } + static Trigger* quest_confirm_accept(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "quest confirm accept"); } }; #endif