mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Scripts/Quests: Implemented new quest scripting hook, OnQuestAcknowledgeAutoAccept, used when player closes quest frame after viewing details of autoaccept quests
This commit is contained in:
@@ -612,6 +612,18 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPackets::Quest::QuestGiver
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleQuestgiverCloseQuest(WorldPackets::Quest::QuestGiverCloseQuest& questGiverCloseQuest)
|
||||
{
|
||||
if (_player->FindQuestSlot(questGiverCloseQuest.QuestID) >= MAX_QUEST_LOG_SIZE)
|
||||
return;
|
||||
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(questGiverCloseQuest.QuestID);
|
||||
if (!quest)
|
||||
return;
|
||||
|
||||
sScriptMgr->OnQuestAcknowledgeAutoAccept(_player, quest);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet)
|
||||
{
|
||||
if (!_player->CanShareQuest(packet.QuestID))
|
||||
|
||||
@@ -2254,6 +2254,15 @@ void ScriptMgr::OnQuestStatusChange(Player* player, Quest const* quest, QuestSta
|
||||
tmpscript->OnQuestStatusChange(player, quest, oldStatus, newStatus);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnQuestAcknowledgeAutoAccept(Player* player, Quest const* quest)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(quest);
|
||||
|
||||
GET_SCRIPT(QuestScript, quest->GetScriptId(), tmpscript);
|
||||
tmpscript->OnAcknowledgeAutoAccept(player, quest);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnQuestObjectiveChange(Player* player, Quest const* quest, QuestObjective const& objective, int32 oldAmount, int32 newAmount)
|
||||
{
|
||||
ASSERT(player);
|
||||
|
||||
@@ -863,6 +863,9 @@ class TC_GAME_API QuestScript : public ScriptObject
|
||||
// Called when a quest status change
|
||||
virtual void OnQuestStatusChange(Player* /*player*/, Quest const* /*quest*/, QuestStatus /*oldStatus*/, QuestStatus /*newStatus*/) { }
|
||||
|
||||
// Called for auto accept quests when player closes quest UI after seeing initial quest details
|
||||
virtual void OnAcknowledgeAutoAccept(Player* /*player*/, Quest const* /*quest*/) { }
|
||||
|
||||
// Called when a quest objective data change
|
||||
virtual void OnQuestObjectiveChange(Player* /*player*/, Quest const* /*quest*/, QuestObjective const& /*objective*/, int32 /*oldAmount*/, int32 /*newAmount*/) { }
|
||||
};
|
||||
@@ -1144,6 +1147,7 @@ class TC_GAME_API ScriptMgr
|
||||
public: /* QuestScript */
|
||||
|
||||
void OnQuestStatusChange(Player* player, Quest const* quest, QuestStatus oldStatus, QuestStatus newStatus);
|
||||
void OnQuestAcknowledgeAutoAccept(Player* player, Quest const* quest);
|
||||
void OnQuestObjectiveChange(Player* player, Quest const* quest, QuestObjective const& objective, int32 oldAmount, int32 newAmount);
|
||||
|
||||
private:
|
||||
|
||||
@@ -388,6 +388,11 @@ void QuestGiverCompleteQuest::Read()
|
||||
FromScript = _worldPacket.ReadBit();
|
||||
}
|
||||
|
||||
void QuestGiverCloseQuest::Read()
|
||||
{
|
||||
_worldPacket >> QuestID;
|
||||
}
|
||||
|
||||
WorldPacket const* QuestGiverQuestDetails::Write()
|
||||
{
|
||||
_worldPacket << QuestGiverGUID;
|
||||
|
||||
@@ -353,6 +353,16 @@ namespace WorldPackets
|
||||
bool FromScript = false; // 0 - standart complete quest mode with npc, 1 - auto-complete mode
|
||||
};
|
||||
|
||||
class QuestGiverCloseQuest final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
QuestGiverCloseQuest(WorldPacket&& packet) : ClientPacket(CMSG_QUEST_GIVER_CLOSE_QUEST, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
int32 QuestID = 0;
|
||||
};
|
||||
|
||||
struct QuestObjectiveSimple
|
||||
{
|
||||
int32 ID = 0;
|
||||
|
||||
@@ -690,7 +690,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_QUEST_CONFIRM_ACCEPT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestConfirmAccept);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_ACCEPT_QUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverAcceptQuestOpcode);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_CHOOSE_REWARD, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverChooseRewardOpcode);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_CLOSE_QUEST, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_CLOSE_QUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverCloseQuest);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_COMPLETE_QUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverCompleteQuest);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_HELLO, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverHelloOpcode);
|
||||
DEFINE_HANDLER(CMSG_QUEST_GIVER_QUERY_QUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQuestgiverQueryQuestOpcode);
|
||||
|
||||
@@ -615,6 +615,7 @@ namespace WorldPackets
|
||||
class QuestGiverHello;
|
||||
class QueryQuestInfo;
|
||||
class QuestGiverChooseReward;
|
||||
class QuestGiverCloseQuest;
|
||||
class QuestGiverCompleteQuest;
|
||||
class QuestGiverRequestReward;
|
||||
class QuestGiverQueryQuest;
|
||||
@@ -1472,6 +1473,7 @@ class TC_GAME_API WorldSession
|
||||
void HandleQuestLogRemoveQuest(WorldPackets::Quest::QuestLogRemoveQuest& packet);
|
||||
void HandleQuestConfirmAccept(WorldPackets::Quest::QuestConfirmAccept& packet);
|
||||
void HandleQuestgiverCompleteQuest(WorldPackets::Quest::QuestGiverCompleteQuest& packet);
|
||||
void HandleQuestgiverCloseQuest(WorldPackets::Quest::QuestGiverCloseQuest& questGiverCloseQuest);
|
||||
void HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet);
|
||||
void HandleQuestPushResult(WorldPackets::Quest::QuestPushResult& packet);
|
||||
void HandleRequestWorldQuestUpdate(WorldPackets::Quest::RequestWorldQuestUpdate& packet);
|
||||
|
||||
Reference in New Issue
Block a user