mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/PacketIO: Update SMSG_QUESTGIVER_OFFER_REWARD (#25251)
Co-authored-by: Carbenium <carbenium@outlook.com>
This commit is contained in:
@@ -452,98 +452,40 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
|
||||
}
|
||||
|
||||
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const
|
||||
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool autoLaunched) const
|
||||
{
|
||||
std::string questTitle = quest->GetTitle();
|
||||
std::string RewardText = quest->GetOfferRewardText();
|
||||
WorldPackets::Quest::QuestGiverOfferRewardMessage packet;
|
||||
|
||||
packet.Title = quest->GetTitle();
|
||||
packet.RewardText = quest->GetOfferRewardText();
|
||||
|
||||
LocaleConstant localeConstant = _session->GetSessionDbLocaleIndex();
|
||||
if (localeConstant != LOCALE_enUS)
|
||||
{
|
||||
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(localeData->Title, localeConstant, questTitle);
|
||||
ObjectMgr::GetLocaleString(localeData->Title, localeConstant, packet.Title);
|
||||
|
||||
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
|
||||
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, localeConstant, RewardText);
|
||||
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, localeConstant, packet.RewardText);
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS))
|
||||
Quest::AddQuestLevelToTitle(questTitle, quest->GetQuestLevel());
|
||||
Quest::AddQuestLevelToTitle(packet.Title, quest->GetQuestLevel());
|
||||
|
||||
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 50); // guess size
|
||||
data << uint64(npcGUID);
|
||||
data << uint32(quest->GetQuestId());
|
||||
data << questTitle;
|
||||
data << RewardText;
|
||||
packet.QuestGiverGUID = npcGUID;
|
||||
packet.QuestID = quest->GetQuestId();
|
||||
packet.AutoLaunched = autoLaunched;
|
||||
packet.Flags = quest->GetFlags();
|
||||
packet.SuggestedGroupNum = quest->GetSuggestedPlayers();
|
||||
|
||||
data << uint8(enableNext ? 1 : 0); // Auto Finish
|
||||
data << uint32(quest->GetFlags()); // 3.3.3 questFlags
|
||||
data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum
|
||||
for (uint32 i = 0; i < QUEST_EMOTE_COUNT && quest->OfferRewardEmote[i]; ++i)
|
||||
packet.Emotes.emplace_back(quest->OfferRewardEmote[i], quest->OfferRewardEmoteDelay[i]);
|
||||
|
||||
uint32 emoteCount = 0;
|
||||
for (uint8 i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
{
|
||||
if (quest->OfferRewardEmote[i] <= 0)
|
||||
break;
|
||||
++emoteCount;
|
||||
}
|
||||
quest->BuildQuestRewards(packet.Rewards, _session->GetPlayer(), true);
|
||||
|
||||
data << emoteCount; // Emote Count
|
||||
for (uint8 i = 0; i < emoteCount; ++i)
|
||||
{
|
||||
data << uint32(quest->OfferRewardEmoteDelay[i]); // Delay Emote
|
||||
data << uint32(quest->OfferRewardEmote[i]);
|
||||
}
|
||||
_session->SendPacket(packet.Write());
|
||||
|
||||
data << uint32(quest->GetRewChoiceItemsCount());
|
||||
for (uint32 i=0; i < quest->GetRewChoiceItemsCount(); ++i)
|
||||
{
|
||||
data << uint32(quest->RewardChoiceItemId[i]);
|
||||
data << uint32(quest->RewardChoiceItemCount[i]);
|
||||
|
||||
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
|
||||
data << uint32(itemTemplate->DisplayInfoID);
|
||||
else
|
||||
data << uint32(0);
|
||||
}
|
||||
|
||||
data << uint32(quest->GetRewItemsCount());
|
||||
for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
|
||||
{
|
||||
data << uint32(quest->RewardItemId[i]);
|
||||
data << uint32(quest->RewardItemIdCount[i]);
|
||||
|
||||
if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
|
||||
data << uint32(itemTemplate->DisplayInfoID);
|
||||
else
|
||||
data << uint32(0);
|
||||
}
|
||||
|
||||
data << uint32(quest->GetRewOrReqMoney(_session->GetPlayer()));
|
||||
data << uint32(quest->GetXPReward(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST));
|
||||
|
||||
// rewarded honor points. Multiply with 10 to satisfy client
|
||||
data << uint32(10 * quest->CalculateHonorGain(_session->GetPlayer()->GetQuestLevel(quest)));
|
||||
data << float(0.0f); // unk, honor multiplier?
|
||||
data << uint32(0x08); // unused by client?
|
||||
data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast == 0)
|
||||
data << int32(quest->GetRewSpellCast()); // cast spell
|
||||
data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
|
||||
data << uint32(quest->GetBonusTalents()); // bonus talents
|
||||
data << uint32(quest->GetRewArenaPoints()); // arena points
|
||||
data << uint32(0);
|
||||
|
||||
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
|
||||
data << uint32(quest->RewardFactionId[i]);
|
||||
|
||||
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)?
|
||||
data << int32(quest->RewardFactionValueId[i]);
|
||||
|
||||
for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override?
|
||||
data << uint32(quest->RewardFactionValueIdOverride[i]);
|
||||
|
||||
_session->SendPacket(&data);
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPC=%s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_GIVER_OFFER_REWARD NPC=%s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
|
||||
}
|
||||
|
||||
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const
|
||||
|
||||
@@ -283,7 +283,7 @@ class TC_GAME_API PlayerMenu
|
||||
void SendQuestQueryResponse(Quest const* quest) const;
|
||||
void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const;
|
||||
|
||||
void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const;
|
||||
void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool autoLaunched) const;
|
||||
void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -235,9 +235,9 @@ uint32 Quest::GetXPReward(Player const* player) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void Quest::BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player) const
|
||||
void Quest::BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player, bool sendHiddenRewards) const
|
||||
{
|
||||
if (!HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
|
||||
if (!HasFlag(QUEST_FLAGS_HIDDEN_REWARDS) || sendHiddenRewards)
|
||||
{
|
||||
for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#define TRINITYCORE_QUEST_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "DBCEnums.h"
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "DBCEnums.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "WorldPacket.h"
|
||||
#include <vector>
|
||||
@@ -328,7 +328,7 @@ class TC_GAME_API Quest
|
||||
void InitializeQueryData();
|
||||
WorldPacket BuildQueryData(LocaleConstant loc) const;
|
||||
|
||||
void BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player) const;
|
||||
void BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player, bool sendHiddenRewards = false) const;
|
||||
|
||||
std::vector<uint32> DependentPreviousQuests;
|
||||
std::vector<uint32> DependentBreadcrumbQuests;
|
||||
|
||||
@@ -184,3 +184,63 @@ WorldPacket const* WorldPackets::Quest::QuestGiverQuestDetails::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Quest::QuestGiverOfferRewardMessage::Write()
|
||||
{
|
||||
_worldPacket << QuestGiverGUID;
|
||||
_worldPacket << uint32(QuestID);
|
||||
|
||||
_worldPacket << Title;
|
||||
_worldPacket << RewardText;
|
||||
|
||||
_worldPacket << uint8(AutoLaunched);
|
||||
_worldPacket << uint32(Flags);
|
||||
_worldPacket << uint32(SuggestedGroupNum);
|
||||
|
||||
_worldPacket << uint32(Emotes.size());
|
||||
for (WorldPackets::Quest::QuestDescEmote const& emote : Emotes)
|
||||
{
|
||||
_worldPacket << uint32(emote.Delay);
|
||||
_worldPacket << uint32(emote.Type);
|
||||
}
|
||||
|
||||
_worldPacket << uint32(Rewards.UnfilteredChoiceItems.size());
|
||||
for (WorldPackets::Quest::QuestChoiceItem const& item : Rewards.UnfilteredChoiceItems)
|
||||
{
|
||||
_worldPacket << uint32(item.ItemID);
|
||||
_worldPacket << uint32(item.Quantity);
|
||||
_worldPacket << uint32(item.DisplayID);
|
||||
}
|
||||
|
||||
_worldPacket << uint32(Rewards.RewardItems.size());
|
||||
for (WorldPackets::Quest::QuestChoiceItem const& item : Rewards.RewardItems)
|
||||
{
|
||||
_worldPacket << uint32(item.ItemID);
|
||||
_worldPacket << uint32(item.Quantity);
|
||||
_worldPacket << uint32(item.DisplayID);
|
||||
}
|
||||
|
||||
_worldPacket << uint32(Rewards.RewardMoney);
|
||||
_worldPacket << uint32(Rewards.RewardXPDifficulty);
|
||||
|
||||
_worldPacket << uint32(Rewards.RewardHonor);
|
||||
_worldPacket << float(Rewards.RewardKillHonor);
|
||||
_worldPacket << uint32(0); // Unknown value. Read in the packet handler but unused
|
||||
_worldPacket << uint32(Rewards.RewardDisplaySpell);
|
||||
_worldPacket << int32(Rewards.RewardSpell);
|
||||
_worldPacket << uint32(Rewards.RewardTitleId);
|
||||
_worldPacket << uint32(Rewards.RewardTalents);
|
||||
_worldPacket << uint32(Rewards.RewardArenaPoints);
|
||||
_worldPacket << uint32(Rewards.RewardFactionFlags);
|
||||
|
||||
for (uint32 factionId : Rewards.RewardFactionID)
|
||||
_worldPacket << uint32(factionId);
|
||||
|
||||
for (uint32 value : Rewards.RewardFactionValue)
|
||||
_worldPacket << int32(value);
|
||||
|
||||
for (uint32 valueOverride : Rewards.RewardFactionValueOverride)
|
||||
_worldPacket << int32(valueOverride);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -166,6 +166,24 @@ namespace WorldPackets
|
||||
QuestRewards Rewards;
|
||||
std::vector<QuestDescEmote> DescEmotes;
|
||||
};
|
||||
|
||||
class QuestGiverOfferRewardMessage final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
QuestGiverOfferRewardMessage() : ServerPacket(SMSG_QUEST_GIVER_OFFER_REWARD_MESSAGE, 600) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid QuestGiverGUID;
|
||||
uint32 QuestID = 0;
|
||||
std::string Title;
|
||||
std::string RewardText;
|
||||
bool AutoLaunched = false;
|
||||
uint32 Flags = 0;
|
||||
uint32 SuggestedGroupNum = 0;
|
||||
std::vector<QuestDescEmote> Emotes;
|
||||
QuestRewards Rewards;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ void OpcodeTable::Initialize()
|
||||
/*0x18A*/ DEFINE_HANDLER(CMSG_QUESTGIVER_COMPLETE_QUEST, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestgiverCompleteQuest );
|
||||
/*0x18B*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUESTGIVER_REQUEST_ITEMS, STATUS_NEVER);
|
||||
/*0x18C*/ DEFINE_HANDLER(CMSG_QUESTGIVER_REQUEST_REWARD, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestgiverRequestRewardOpcode);
|
||||
/*0x18D*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUESTGIVER_OFFER_REWARD, STATUS_NEVER);
|
||||
/*0x18D*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_GIVER_OFFER_REWARD_MESSAGE, STATUS_NEVER);
|
||||
/*0x18E*/ DEFINE_HANDLER(CMSG_QUESTGIVER_CHOOSE_REWARD, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestgiverChooseRewardOpcode);
|
||||
/*0x18F*/ DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUESTGIVER_QUEST_INVALID, STATUS_NEVER);
|
||||
/*0x190*/ DEFINE_HANDLER(CMSG_QUESTGIVER_CANCEL, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestgiverCancel );
|
||||
|
||||
@@ -423,7 +423,7 @@ enum Opcodes : uint16
|
||||
CMSG_QUESTGIVER_COMPLETE_QUEST = 0x18A,
|
||||
SMSG_QUESTGIVER_REQUEST_ITEMS = 0x18B,
|
||||
CMSG_QUESTGIVER_REQUEST_REWARD = 0x18C,
|
||||
SMSG_QUESTGIVER_OFFER_REWARD = 0x18D,
|
||||
SMSG_QUEST_GIVER_OFFER_REWARD_MESSAGE = 0x18D,
|
||||
CMSG_QUESTGIVER_CHOOSE_REWARD = 0x18E,
|
||||
SMSG_QUESTGIVER_QUEST_INVALID = 0x18F,
|
||||
CMSG_QUESTGIVER_CANCEL = 0x190,
|
||||
|
||||
Reference in New Issue
Block a user