AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
PlayerMenu Class Reference

#include "GossipDef.h"

Public Member Functions

GossipMenuGetGossipMenu ()
 
QuestMenuGetQuestMenu ()
 
bool Empty () const
 
uint32 GetGossipOptionSender (uint32 selection) const
 
uint32 GetGossipOptionAction (uint32 selection) const
 
bool IsGossipOptionCoded (uint32 selection) const
 
AddMenuItem

Adds a localized gossip menu item from db by menu id and menu item id.

Parameters
menuIdGossip menu id.
menuItemIdGossip menu item id.
senderIdentifier of the current menu.
actionCustom action given to OnGossipHello.
boxMoneyCustom price for pop-up box. If > 0, it will replace DB value.
 PlayerMenu (WorldSession *session)
 
 ~PlayerMenu ()
 
void ClearMenus ()
 
void SendGossipMenu (uint32 titleTextId, ObjectGuid objectGUID)
 
void SendCloseGossip ()
 
void SendPointOfInterest (uint32 poiId) const
 
void SendQuestGiverStatus (uint8 questStatus, ObjectGuid npcGUID) const
 
void SendQuestGiverQuestList (QEmote const &eEmote, std::string const &Title, ObjectGuid guid)
 
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 SendQuestGiverRequestItems (Quest const *quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const
 

Private Attributes

GossipMenu _gossipMenu
 
QuestMenu _questMenu
 
WorldSession_session
 

Detailed Description

Constructor & Destructor Documentation

◆ PlayerMenu()

PlayerMenu::PlayerMenu ( WorldSession session)
explicit
177 : _session(session)
178{
180}
void SetLocale(LocaleConstant locale)
Definition: GossipDef.h:172
GossipMenu _gossipMenu
Definition: GossipDef.h:291
WorldSession * _session
Definition: GossipDef.h:293
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498

References _gossipMenu, WorldSession::GetSessionDbLocaleIndex(), and GossipMenu::SetLocale().

◆ ~PlayerMenu()

PlayerMenu::~PlayerMenu ( )
183{
184 ClearMenus();
185}
void ClearMenus()
Definition: GossipDef.cpp:187

References ClearMenus().

Member Function Documentation

◆ ClearMenus()

void PlayerMenu::ClearMenus ( )
188{
191}
void ClearMenu()
Definition: GossipDef.cpp:171
void ClearMenu()
Definition: GossipDef.cpp:310
QuestMenu _questMenu
Definition: GossipDef.h:292

References _gossipMenu, _questMenu, GossipMenu::ClearMenu(), and QuestMenu::ClearMenu().

Referenced by ClearGossipMenuFor(), Player::PrepareGossipMenu(), and ~PlayerMenu().

◆ Empty()

bool PlayerMenu::Empty ( ) const
inline
266{ return _gossipMenu.Empty() && _questMenu.Empty(); }
bool Empty() const
Definition: GossipDef.h:182
bool Empty() const
Definition: GossipDef.h:241

References _gossipMenu, _questMenu, GossipMenu::Empty(), and QuestMenu::Empty().

◆ GetGossipMenu()

◆ GetGossipOptionAction()

◆ GetGossipOptionSender()

uint32 PlayerMenu::GetGossipOptionSender ( uint32  selection) const
inline
269{ return _gossipMenu.GetMenuItemSender(selection); }
uint32 GetMenuItemSender(uint32 menuItemId) const
Definition: GossipDef.cpp:144

References _gossipMenu, and GossipMenu::GetMenuItemSender().

Referenced by WorldSession::HandleGossipSelectOptionOpcode().

◆ GetQuestMenu()

◆ IsGossipOptionCoded()

bool PlayerMenu::IsGossipOptionCoded ( uint32  selection) const
inline
271{ return _gossipMenu.IsMenuItemCoded(selection); }
bool IsMenuItemCoded(uint32 menuItemId) const
Definition: GossipDef.cpp:162

References _gossipMenu, and GossipMenu::IsMenuItemCoded().

Referenced by WorldSession::HandleGossipSelectOptionOpcode().

◆ SendCloseGossip()

◆ SendGossipMenu()

void PlayerMenu::SendGossipMenu ( uint32  titleTextId,
ObjectGuid  objectGUID 
)
194{
195 _gossipMenu.SetSenderGUID(objectGUID);
196
198 data << objectGUID;
199 data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
200 data << uint32(titleTextId);
201 data << uint32(_gossipMenu.GetMenuItemCount()); // max count 0x10
202
203 for (GossipMenuItemContainer::const_iterator itr = _gossipMenu.GetMenuItems().begin(); itr != _gossipMenu.GetMenuItems().end(); ++itr)
204 {
205 GossipMenuItem const& item = itr->second;
206 data << uint32(itr->first);
207 data << uint8(item.MenuItemIcon);
208 data << uint8(item.IsCoded); // makes pop up box password
209 data << uint32(item.BoxMoney); // money required to open menu, 2.0.3
210 data << item.Message; // text for gossip item
211 data << item.BoxMessage; // accept text (related to money) pop up box, 2.0.3
212 }
213
214 data << uint32(_questMenu.GetMenuItemCount()); // max count 0x20
215
216 for (uint32 iI = 0; iI < _questMenu.GetMenuItemCount(); ++iI)
217 {
218 QuestMenuItem const& item = _questMenu.GetItem(iI);
219 uint32 questID = item.QuestId;
220 if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
221 {
222 data << uint32(questID);
223 data << uint32(item.QuestIcon);
224 data << int32(quest->GetQuestLevel());
225 data << uint32(quest->GetFlags()); // 3.3.3 quest flags
226 data << uint8(quest->IsRepeatable() && !quest->IsDailyOrWeekly() && !quest->IsMonthly()); // 3.3.3 icon changes: blue question mark or yellow exclamation mark
227 std::string title = quest->GetTitle();
228
230 if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
231 ObjectMgr::GetLocaleString(localeData->Title, locale, title);
232 data << title;
233 }
234 }
235
236 _session->SendPacket(&data);
237}
std::int32_t int32
Definition: Define.h:103
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ SMSG_GOSSIP_MESSAGE
Definition: Opcodes.h:411
Definition: GossipDef.h:131
std::string BoxMessage
Definition: GossipDef.h:137
uint32 BoxMoney
Definition: GossipDef.h:138
uint8 MenuItemIcon
Definition: GossipDef.h:132
bool IsCoded
Definition: GossipDef.h:133
std::string Message
Definition: GossipDef.h:134
Definition: GossipDef.h:154
uint32 QuestId
Definition: GossipDef.h:155
uint8 QuestIcon
Definition: GossipDef.h:156
uint32 GetMenuItemCount() const
Definition: GossipDef.h:177
uint32 GetMenuId() const
Definition: GossipDef.h:171
GossipMenuItemContainer const & GetMenuItems() const
Definition: GossipDef.h:211
QuestMenuItem const & GetItem(uint16 index) const
Definition: GossipDef.h:248
uint8 GetMenuItemCount() const
Definition: GossipDef.h:236
static std::string_view GetLocaleString(std::vector< std::string > const &data, std::size_t locale)
Definition: ObjectMgr.h:1405
Definition: QuestDef.h:183
Definition: QuestDef.h:210

References _gossipMenu, _questMenu, _session, GossipMenuItem::BoxMessage, GossipMenuItem::BoxMoney, QuestMenu::GetItem(), ObjectMgr::GetLocaleString(), GossipMenu::GetMenuId(), GossipMenu::GetMenuItemCount(), QuestMenu::GetMenuItemCount(), GossipMenu::GetMenuItems(), WorldSession::GetSessionDbLocaleIndex(), GossipMenuItem::IsCoded, GossipMenuItem::MenuItemIcon, GossipMenuItem::Message, QuestMenuItem::QuestIcon, QuestMenuItem::QuestId, WorldSession::SendPacket(), GossipMenu::SetSenderGUID(), SMSG_GOSSIP_MESSAGE, and sObjectMgr.

Referenced by SendGossipMenuFor(), and Player::SendPreparedGossip().

◆ SendPointOfInterest()

void PlayerMenu::SendPointOfInterest ( uint32  poiId) const
248{
249 PointOfInterest const* poi = sObjectMgr->GetPointOfInterest(poiId);
250 if (!poi)
251 {
252 LOG_ERROR("sql.sql", "Request to send non-existing POI (Id: {}), ignored.", poiId);
253 return;
254 }
255
256 std::string name = poi->Name;
258 if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId))
259 ObjectMgr::GetLocaleString(localeData->Name, locale, name);
260
261 WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 20); // guess size
262 data << uint32(poi->Flags);
263 data << float(poi->PositionX);
264 data << float(poi->PositionY);
265 data << uint32(poi->Icon);
266 data << uint32(poi->Importance);
267 data << name;
268
269 _session->SendPacket(&data);
270}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
@ SMSG_GOSSIP_POI
Definition: Opcodes.h:578
Definition: CreatureData.h:358
Definition: ObjectMgr.h:588
std::string Name
Definition: ObjectMgr.h:595
uint32 Flags
Definition: ObjectMgr.h:593
float PositionX
Definition: ObjectMgr.h:590
uint32 Importance
Definition: ObjectMgr.h:594
uint32 Icon
Definition: ObjectMgr.h:592
float PositionY
Definition: ObjectMgr.h:591

References _session, PointOfInterest::Flags, ObjectMgr::GetLocaleString(), WorldSession::GetSessionDbLocaleIndex(), PointOfInterest::Icon, PointOfInterest::Importance, LOG_ERROR, PointOfInterest::Name, PointOfInterest::PositionX, PointOfInterest::PositionY, WorldSession::SendPacket(), SMSG_GOSSIP_POI, and sObjectMgr.

Referenced by Player::OnGossipSelect().

◆ SendQuestGiverOfferReward()

void PlayerMenu::SendQuestGiverOfferReward ( Quest const *  quest,
ObjectGuid  npcGUID,
bool  enableNext 
) const
648{
649 std::string questTitle = quest->GetTitle();
650 std::string RewardText = quest->GetOfferRewardText();
651
653 if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
654 ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
655
656 if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
657 ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
658
659 WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
660 data << npcGUID;
661 data << uint32(quest->GetQuestId());
662 data << questTitle;
663 data << RewardText;
664
665 data << uint8(enableNext ? 1 : 0); // Auto Finish
666 data << uint32(quest->GetFlags()); // 3.3.3 questFlags
667 data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum
668
669 uint32 emoteCount = 0;
670 for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
671 {
672 if (quest->OfferRewardEmote[i] <= 0)
673 break;
674 ++emoteCount;
675 }
676
677 data << emoteCount; // Emote Count
678 for (uint32 i = 0; i < emoteCount; ++i)
679 {
680 data << uint32(quest->OfferRewardEmoteDelay[i]); // Delay Emote
681 data << uint32(quest->OfferRewardEmote[i]);
682 }
683
684 data << uint32(quest->GetRewChoiceItemsCount());
685 for (uint32 i = 0; i < quest->GetRewChoiceItemsCount(); ++i)
686 {
687 data << uint32(quest->RewardChoiceItemId[i]);
688 data << uint32(quest->RewardChoiceItemCount[i]);
689
690 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
691 data << uint32(itemTemplate->DisplayInfoID);
692 else
693 data << uint32(0);
694 }
695
696 data << uint32(quest->GetRewItemsCount());
697 for (uint32 i = 0; i < quest->GetRewItemsCount(); ++i)
698 {
699 data << uint32(quest->RewardItemId[i]);
700 data << uint32(quest->RewardItemIdCount[i]);
701
702 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
703 data << uint32(itemTemplate->DisplayInfoID);
704 else
705 data << uint32(0);
706 }
707
708 uint32 moneyRew = 0;
709 Player* player = _session->GetPlayer();
710 if (player && (player->GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player)))
711 {
712 moneyRew = quest->GetRewMoneyMaxLevel();
713 }
714 moneyRew += quest->GetRewOrReqMoney(player ? player->GetLevel() : 0); // reward money (below max lvl)
715 data << moneyRew;
716 uint32 questXp;
717 if (player && !sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player))
718 {
719 questXp = player->CalculateQuestRewardXP(quest);
720 }
721 else
722 {
723 questXp = 0;
724 }
725 sScriptMgr->OnQuestComputeXP(player, quest, questXp);
726 data << questXp;
727
728 // rewarded honor points. Multiply with 10 to satisfy client
729 data << uint32(10 * quest->CalculateHonorGain(_session->GetPlayer()->GetQuestLevel(quest)));
730 data << float(0.0f); // unk, honor multiplier?
731 data << uint32(0x08); // unused by client?
732 data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
733 data << int32(quest->GetRewSpellCast()); // casted spell
734 data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
735 data << uint32(quest->GetBonusTalents()); // bonus talents
736 data << uint32(quest->GetRewArenaPoints()); // arena points
737 data << uint32(0);
738
739 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
740 data << uint32(quest->RewardFactionId[i]);
741
742 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)?
743 data << int32(quest->RewardFactionValueId[i]);
744
745 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override?
746 data << uint32(quest->RewardFactionValueIdOverride[i]);
747
748 _session->SendPacket(&data);
749 LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD {}, questid={}", npcGUID.ToString(), quest->GetQuestId());
750}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
#define sScriptMgr
Definition: ScriptMgr.h:708
#define QUEST_EMOTE_COUNT
Definition: QuestDef.h:42
#define QUEST_REPUTATIONS_COUNT
Definition: QuestDef.h:41
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:240
@ SMSG_QUESTGIVER_OFFER_REWARD
Definition: Opcodes.h:427
#define sWorld
Definition: World.h:444
Definition: ItemTemplate.h:619
Definition: Player.h:1064
int32 GetQuestLevel(Quest const *quest) const
Definition: Player.h:1415
uint32 CalculateQuestRewardXP(Quest const *quest)
Definition: PlayerQuest.cpp:1396
uint8 GetLevel() const
Definition: Unit.h:855
Definition: QuestDef.h:202
Player * GetPlayer() const
Definition: WorldSession.h:362

References _session, Quest::CalculateHonorGain(), Player::CalculateQuestRewardXP(), CONFIG_MAX_PLAYER_LEVEL, Quest::GetBonusTalents(), Quest::GetCharTitleId(), Quest::GetFlags(), Unit::GetLevel(), ObjectMgr::GetLocaleString(), Quest::GetOfferRewardText(), WorldSession::GetPlayer(), Quest::GetQuestId(), Player::GetQuestLevel(), Quest::GetRewArenaPoints(), Quest::GetRewChoiceItemsCount(), Quest::GetRewItemsCount(), Quest::GetRewMoneyMaxLevel(), Quest::GetRewOrReqMoney(), Quest::GetRewSpell(), Quest::GetRewSpellCast(), WorldSession::GetSessionDbLocaleIndex(), Quest::GetSuggestedPlayers(), Quest::GetTitle(), LOG_DEBUG, Quest::OfferRewardEmote, Quest::OfferRewardEmoteDelay, QUEST_EMOTE_COUNT, QUEST_REPUTATIONS_COUNT, Quest::RewardChoiceItemCount, Quest::RewardChoiceItemId, Quest::RewardFactionId, Quest::RewardFactionValueId, Quest::RewardFactionValueIdOverride, Quest::RewardItemId, Quest::RewardItemIdCount, WorldSession::SendPacket(), SMSG_QUESTGIVER_OFFER_REWARD, sObjectMgr, sScriptMgr, sWorld, and ObjectGuid::ToString().

Referenced by WorldSession::HandleQuestgiverChooseRewardOpcode(), WorldSession::HandleQuestgiverCompleteQuest(), WorldSession::HandleQuestgiverRequestRewardOpcode(), and SendQuestGiverRequestItems().

◆ SendQuestGiverQuestDetails()

void PlayerMenu::SendQuestGiverQuestDetails ( Quest const *  quest,
ObjectGuid  npcGUID,
bool  activateAccept 
) const
389{
390 std::string questTitle = quest->GetTitle();
391 std::string questDetails = quest->GetDetails();
392 std::string questObjectives = quest->GetObjectives();
393 std::string questAreaDescription = quest->GetAreaDescription();
394
396 if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
397 {
398 ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
399 ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
400 ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
401 ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
402 }
403
404 WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size
405 data << npcGUID;
406 data << _session->GetPlayer()->GetDivider();
407 data << uint32(quest->GetQuestId());
408 data << questTitle;
409 data << questDetails;
410 data << questObjectives;
411 data << uint8(activateAccept ? 1 : 0); // auto finish
412 data << uint32(quest->GetFlags()); // 3.3.3 questFlags
413 data << uint32(quest->GetSuggestedPlayers());
414 data << uint8(0); // IsFinished? value is sent back to server in quest accept packet
415
416 if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
417 {
418 data << uint32(0); // Rewarded chosen items hidden
419 data << uint32(0); // Rewarded items hidden
420 data << uint32(0); // Rewarded money hidden
421 data << uint32(0); // Rewarded XP hidden
422 }
423 else
424 {
425 data << uint32(quest->GetRewChoiceItemsCount());
426 for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
427 {
428 if (!quest->RewardChoiceItemId[i])
429 continue;
430
431 data << uint32(quest->RewardChoiceItemId[i]);
432 data << uint32(quest->RewardChoiceItemCount[i]);
433
434 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
435 data << uint32(itemTemplate->DisplayInfoID);
436 else
437 data << uint32(0x00);
438 }
439
440 data << uint32(quest->GetRewItemsCount());
441
442 for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i)
443 {
444 if (!quest->RewardItemId[i])
445 continue;
446
447 data << uint32(quest->RewardItemId[i]);
448 data << uint32(quest->RewardItemIdCount[i]);
449
450 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardItemId[i]))
451 data << uint32(itemTemplate->DisplayInfoID);
452 else
453 data << uint32(0);
454 }
455
456 uint32 moneyRew = 0;
457 Player* player = _session->GetPlayer();
458 if (player && (player->GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player)))
459 {
460 moneyRew = quest->GetRewMoneyMaxLevel();
461 }
462 moneyRew += quest->GetRewOrReqMoney(player ? player->GetLevel() : 0); // reward money (below max lvl)
463 data << moneyRew;
464 uint32 questXp;
465 if (player && !sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player))
466 {
467 questXp = player->CalculateQuestRewardXP(quest);
468 }
469 else
470 {
471 questXp = 0;
472 }
473 sScriptMgr->OnQuestComputeXP(player, quest, questXp);
474 data << questXp;
475 }
476
477 // rewarded honor points. Multiply with 10 to satisfy client
478 data << uint32(10 * quest->CalculateHonorGain(_session->GetPlayer()->GetQuestLevel(quest)));
479 data << float(0.0f); // unk, honor multiplier?
480 data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
481 data << int32(quest->GetRewSpellCast()); // casted spell
482 data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
483 data << uint32(quest->GetBonusTalents()); // bonus talents
484 data << uint32(quest->GetRewArenaPoints()); // reward arena points
485 data << uint32(0); // unk
486
487 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
488 data << uint32(quest->RewardFactionId[i]);
489
490 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
491 data << int32(quest->RewardFactionValueId[i]);
492
493 for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
494 data << int32(quest->RewardFactionValueIdOverride[i]);
495
496 data << uint32(QUEST_EMOTE_COUNT);
497 for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
498 {
499 data << uint32(quest->DetailsEmote[i]);
500 data << uint32(quest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms)
501 }
502 _session->SendPacket(&data);
503
504 LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS {}, questid={}", npcGUID.ToString(), quest->GetQuestId());
505}
#define QUEST_REWARDS_COUNT
Definition: QuestDef.h:39
@ QUEST_FLAGS_HIDDEN_REWARDS
Definition: QuestDef.h:141
#define QUEST_REWARD_CHOICES_COUNT
Definition: QuestDef.h:38
@ SMSG_QUESTGIVER_QUEST_DETAILS
Definition: Opcodes.h:422
ObjectGuid GetDivider()
Definition: Player.h:1538

References _session, Quest::CalculateHonorGain(), Player::CalculateQuestRewardXP(), CONFIG_MAX_PLAYER_LEVEL, Quest::DetailsEmote, Quest::DetailsEmoteDelay, Quest::GetAreaDescription(), Quest::GetBonusTalents(), Quest::GetCharTitleId(), Quest::GetDetails(), Player::GetDivider(), Quest::GetFlags(), Unit::GetLevel(), ObjectMgr::GetLocaleString(), Quest::GetObjectives(), WorldSession::GetPlayer(), Quest::GetQuestId(), Player::GetQuestLevel(), Quest::GetRewArenaPoints(), Quest::GetRewChoiceItemsCount(), Quest::GetRewItemsCount(), Quest::GetRewMoneyMaxLevel(), Quest::GetRewOrReqMoney(), Quest::GetRewSpell(), Quest::GetRewSpellCast(), WorldSession::GetSessionDbLocaleIndex(), Quest::GetSuggestedPlayers(), Quest::GetTitle(), Quest::HasFlag(), LOG_DEBUG, QUEST_EMOTE_COUNT, QUEST_FLAGS_HIDDEN_REWARDS, QUEST_REPUTATIONS_COUNT, QUEST_REWARD_CHOICES_COUNT, QUEST_REWARDS_COUNT, Quest::RewardChoiceItemCount, Quest::RewardChoiceItemId, Quest::RewardFactionId, Quest::RewardFactionValueId, Quest::RewardFactionValueIdOverride, Quest::RewardItemId, Quest::RewardItemIdCount, WorldSession::SendPacket(), SMSG_QUESTGIVER_QUEST_DETAILS, sObjectMgr, sScriptMgr, sWorld, and ObjectGuid::ToString().

Referenced by Spell::EffectQuestStart(), WorldSession::HandlePushQuestToParty(), WorldSession::HandleQuestgiverChooseRewardOpcode(), WorldSession::HandleQuestgiverQueryQuestOpcode(), SmartScript::ProcessAction(), and Player::SendPreparedQuest().

◆ SendQuestGiverQuestList()

void PlayerMenu::SendQuestGiverQuestList ( QEmote const &  eEmote,
std::string const &  Title,
ObjectGuid  guid 
)
316{
317 WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100); // guess size
318 data << guid;
319
320 if (QuestGreeting const* questGreeting = sObjectMgr->GetQuestGreeting(guid.GetTypeId(), guid.GetEntry()))
321 {
322 std::string strGreeting;
323 // Check if greeting exists. Blizzlike that some creatures have empty greeting
324 if (!questGreeting->Greeting.empty())
325 {
327 if (questGreeting->Greeting.size() > size_t(locale))
328 strGreeting = questGreeting->Greeting[locale];
329 else
330 strGreeting = questGreeting->Greeting[DEFAULT_LOCALE];
331 }
332
333 data << strGreeting;
334 data << uint32(questGreeting->EmoteDelay);
335 data << uint32(questGreeting->EmoteType);
336 }
337 else
338 {
339 data << Title;
340 data << uint32(eEmote._Delay); // player emote
341 data << uint32(eEmote._Emote); // NPC emote
342 }
343
344 std::size_t count_pos = data.wpos();
345 data << uint8(0);
346 uint32 count = 0;
347
348 for (uint32 i = 0; i < _questMenu.GetMenuItemCount(); ++i)
349 {
350 QuestMenuItem const& questMenuItem = _questMenu.GetItem(i);
351
352 uint32 questID = questMenuItem.QuestId;
353
354 if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
355 {
356 ++count;
357 std::string title = quest->GetTitle();
358
360 if (localeConstant != LOCALE_enUS)
361 if (QuestLocale const* questTemplateLocale = sObjectMgr->GetQuestLocale(questID))
362 ObjectMgr::GetLocaleString(questTemplateLocale->Title, localeConstant, title);
363
364 data << uint32(questID);
365 data << uint32(questMenuItem.QuestIcon);
366 data << int32(quest->GetQuestLevel());
367 data << uint32(quest->GetFlags()); // 3.3.3 quest flags
368 data << uint8(quest->IsRepeatable() && !quest->IsDailyOrWeekly() && !quest->IsMonthly()); // 3.3.3 changes icon: blue question or yellow exclamation
369 data << title;
370 }
371 }
372
373 data.put<uint8>(count_pos, count);
374 _session->SendPacket(&data);
375 LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST (QuestGiver: {})", guid.ToString());
376}
LocaleConstant
Definition: Common.h:65
@ LOCALE_enUS
Definition: Common.h:66
#define DEFAULT_LOCALE
Definition: Common.h:79
@ SMSG_QUESTGIVER_QUEST_LIST
Definition: Opcodes.h:419
Definition: ObjectMgr.h:599

References QEmote::_Delay, QEmote::_Emote, _questMenu, _session, DEFAULT_LOCALE, ObjectGuid::GetEntry(), QuestMenu::GetItem(), ObjectMgr::GetLocaleString(), QuestMenu::GetMenuItemCount(), WorldSession::GetSessionDbLocaleIndex(), ObjectGuid::GetTypeId(), LOCALE_enUS, LOG_DEBUG, ByteBuffer::put(), QuestMenuItem::QuestIcon, QuestMenuItem::QuestId, WorldSession::SendPacket(), SMSG_QUESTGIVER_QUEST_LIST, sObjectMgr, ObjectGuid::ToString(), and ByteBuffer::wpos().

Referenced by Player::SendPreparedQuest().

◆ SendQuestGiverRequestItems()

void PlayerMenu::SendQuestGiverRequestItems ( Quest const *  quest,
ObjectGuid  npcGUID,
bool  canComplete,
bool  closeOnCancel 
) const
753{
754 // We can always call to RequestItems, but this packet only goes out if there are actually
755 // items. Otherwise, we'll skip straight to the OfferReward
756
757 std::string questTitle = quest->GetTitle();
758 std::string requestItemsText = quest->GetRequestItemsText();
759
761 if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
762 ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
763
764 if (QuestRequestItemsLocale const* questRequestItemsLocale = sObjectMgr->GetQuestRequestItemsLocale(quest->GetQuestId()))
765 ObjectMgr::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText);
766
767 if (!quest->GetReqItemsCount() && canComplete)
768 {
769 SendQuestGiverOfferReward(quest, npcGUID, true);
770 return;
771 }
772
773 // Xinef: recheck completion on reward display
774 Player* _player = _session->GetPlayer();
775 QuestStatusMap::iterator qsitr = _player->getQuestStatusMap().find(quest->GetQuestId());
776 if (qsitr != _player->getQuestStatusMap().end() && qsitr->second.Status == QUEST_STATUS_INCOMPLETE)
777 {
778 for (uint8 i = 0; i < 6; ++i)
779 if (quest->RequiredItemId[i] && qsitr->second.ItemCount[i] < quest->RequiredItemCount[i])
780 if (_player->GetItemCount(quest->RequiredItemId[i], false) >= quest->RequiredItemCount[i])
781 qsitr->second.ItemCount[i] = quest->RequiredItemCount[i];
782
783 if (_player->CanCompleteQuest(quest->GetQuestId()))
784 {
785 _player->CompleteQuest(quest->GetQuestId());
786 canComplete = true;
787 }
788 }
789
790 WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 300); // guess size
791 data << npcGUID;
792 data << uint32(quest->GetQuestId());
793 data << questTitle;
794 data << requestItemsText;
795
796 data << uint32(0x00); // unknown
797
798 if (canComplete)
799 data << quest->GetCompleteEmote();
800 else
801 data << quest->GetIncompleteEmote();
802
803 // Close Window after cancel
804 if (closeOnCancel)
805 data << uint32(0x01);
806 else
807 data << uint32(0x00);
808
809 data << uint32(quest->GetFlags()); // 3.3.3 questFlags
810 data << uint32(quest->GetSuggestedPlayers()); // SuggestedGroupNum
811
812 // Required Money
813 data << uint32(quest->GetRewOrReqMoney() < 0 ? -quest->GetRewOrReqMoney() : 0);
814
815 data << uint32(quest->GetReqItemsCount());
816 for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
817 {
818 if (!quest->RequiredItemId[i])
819 continue;
820
821 data << uint32(quest->RequiredItemId[i]);
822 data << uint32(quest->RequiredItemCount[i]);
823
824 if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RequiredItemId[i]))
825 data << uint32(itemTemplate->DisplayInfoID);
826 else
827 data << uint32(0);
828 }
829
830 if (!canComplete)
831 data << uint32(0x00);
832 else
833 data << uint32(0x03);
834
835 data << uint32(0x04);
836 data << uint32(0x08);
837 data << uint32(0x10);
838
839 _session->SendPacket(&data);
840 LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS {}, questid={}", npcGUID.ToString(), quest->GetQuestId());
841}
#define QUEST_ITEM_OBJECTIVES_COUNT
Definition: QuestDef.h:36
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:103
@ SMSG_QUESTGIVER_REQUEST_ITEMS
Definition: Opcodes.h:425
void SendQuestGiverOfferReward(Quest const *quest, ObjectGuid npcGUID, bool enableNext) const
Definition: GossipDef.cpp:647
QuestStatusMap & getQuestStatusMap()
Definition: Player.h:1614
uint32 GetItemCount(uint32 item, bool inBankAlso=false, Item *skipItem=nullptr) const
Definition: PlayerStorage.cpp:333
void CompleteQuest(uint32 quest_id)
Definition: PlayerQuest.cpp:597
bool CanCompleteQuest(uint32 quest_id, const QuestStatusData *q_savedStatus=nullptr)
Definition: PlayerQuest.cpp:288
Definition: QuestDef.h:197

References _session, Player::CanCompleteQuest(), Player::CompleteQuest(), Quest::GetCompleteEmote(), Quest::GetFlags(), Quest::GetIncompleteEmote(), Player::GetItemCount(), ObjectMgr::GetLocaleString(), WorldSession::GetPlayer(), Quest::GetQuestId(), Player::getQuestStatusMap(), Quest::GetReqItemsCount(), Quest::GetRequestItemsText(), Quest::GetRewOrReqMoney(), WorldSession::GetSessionDbLocaleIndex(), Quest::GetSuggestedPlayers(), Quest::GetTitle(), LOG_DEBUG, QUEST_ITEM_OBJECTIVES_COUNT, QUEST_STATUS_INCOMPLETE, Quest::RequiredItemCount, Quest::RequiredItemId, WorldSession::SendPacket(), SendQuestGiverOfferReward(), SMSG_QUESTGIVER_REQUEST_ITEMS, sObjectMgr, and ObjectGuid::ToString().

Referenced by WorldSession::HandlePushQuestToParty(), WorldSession::HandleQuestgiverCompleteQuest(), WorldSession::HandleQuestgiverQueryQuestOpcode(), npc_elder_clearwater::OnGossipHello(), and Player::SendPreparedQuest().

◆ SendQuestGiverStatus()

void PlayerMenu::SendQuestGiverStatus ( uint8  questStatus,
ObjectGuid  npcGUID 
) const
379{
381 data << npcGUID;
382 data << uint8(questStatus);
383
384 _session->SendPacket(&data);
385 LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC {}, status={}", npcGUID.ToString(), questStatus);
386}
@ SMSG_QUESTGIVER_STATUS
Definition: Opcodes.h:417

References _session, LOG_DEBUG, WorldSession::SendPacket(), SMSG_QUESTGIVER_STATUS, and ObjectGuid::ToString().

Referenced by WorldSession::HandleQuestgiverChooseRewardOpcode(), and WorldSession::HandleQuestgiverStatusQueryOpcode().

◆ SendQuestQueryResponse()

void PlayerMenu::SendQuestQueryResponse ( Quest const *  quest) const
508{
509 std::string questTitle = quest->GetTitle();
510 std::string questDetails = quest->GetDetails();
511 std::string questObjectives = quest->GetObjectives();
512 std::string questAreaDescription = quest->GetAreaDescription();
513 std::string questCompletedText = quest->GetCompletedText();
514
515 std::string questObjectiveText[QUEST_OBJECTIVES_COUNT];
516 for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
517 questObjectiveText[i] = quest->ObjectiveText[i];
518
520 if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
521 {
522 ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
523 ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
524 ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
525 ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription);
526 ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
527
528 for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
529 ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);
530 }
531
532 WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100); // guess size
533
534 data << uint32(quest->GetQuestId()); // quest id
535 data << uint32(quest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0 == IsAutoComplete() (skip objectives/details)
536 data << uint32(quest->GetQuestLevel()); // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevel (0 is not known, but assuming this is no longer valid for quest intended for client)
537 data << uint32(quest->GetMinLevel()); // min level
538 data << uint32(quest->GetZoneOrSort()); // zone or sort to display in quest log
539
540 data << uint32(quest->GetType()); // quest type
541 data << uint32(quest->GetSuggestedPlayers()); // suggested players count
542
543 data << uint32(quest->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
544 data << uint32(quest->GetRepObjectiveValue()); // shown in quest log as part of quest objective
545
546 data << uint32(quest->GetRepObjectiveFaction2()); // shown in quest log as part of quest objective OPPOSITE faction
547 data << uint32(quest->GetRepObjectiveValue2()); // shown in quest log as part of quest objective OPPOSITE faction
548
549 data << uint32(quest->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
550 data << uint32(quest->GetXPId()); // used for calculating rewarded experience
551
552 if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
553 data << uint32(0); // Hide money rewarded
554 else
555 {
556 uint32 moneyRew = 0;
557 Player* player = _session->GetPlayer();
558 if (player && (player->GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player)))
559 {
560 moneyRew = quest->GetRewMoneyMaxLevel();
561 }
562 moneyRew += quest->GetRewOrReqMoney(player ? player->GetLevel() : 0); // reward money (below max lvl)
563 data << moneyRew;
564 }
565
566 data << uint32(quest->GetRewMoneyMaxLevel()); // used in XP calculation at client
567 data << uint32(quest->GetRewSpell()); // reward spell, this spell will display (icon) (cast if RewSpellCast == 0)
568 data << int32(quest->GetRewSpellCast()); // cast spell
569
570 // rewarded honor points
571 data << uint32(quest->GetRewHonorAddition());
572 data << float(quest->GetRewHonorMultiplier());
573 data << uint32(quest->GetSrcItemId()); // source item id
574 data << uint32(quest->GetFlags() & 0xFFFF); // quest flags
575 data << uint32(quest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
576 data << uint32(quest->GetPlayersSlain()); // players slain
577 data << uint32(quest->GetBonusTalents()); // bonus talents
578 data << uint32(quest->GetRewArenaPoints()); // bonus arena points
579 data << uint32(0); // review rep show mask
580
581 if (quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
582 {
583 for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
584 data << uint32(0) << uint32(0);
585 for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
586 data << uint32(0) << uint32(0);
587 }
588 else
589 {
590 for (uint8 i = 0; i < QUEST_REWARDS_COUNT; ++i)
591 {
592 data << uint32(quest->RewardItemId[i]);
593 data << uint32(quest->RewardItemIdCount[i]);
594 }
595 for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
596 {
597 data << uint32(quest->RewardChoiceItemId[i]);
598 data << uint32(quest->RewardChoiceItemCount[i]);
599 }
600 }
601
602 for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
603 data << uint32(quest->RewardFactionId[i]);
604
605 for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid+1 QuestFactionReward.dbc?
606 data << int32(quest->RewardFactionValueId[i]);
607
608 for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // unk (0)
609 data << int32(quest->RewardFactionValueIdOverride[i]);
610
611 data << uint32(quest->GetPOIContinent());
612 data << float(quest->GetPOIx());
613 data << float(quest->GetPOIy());
614 data << uint32(quest->GetPointOpt());
615
616 data << questTitle;
617 data << questObjectives;
618 data << questDetails;
619 data << questAreaDescription;
620 data << questCompletedText; // display in quest objectives window once all objectives are completed
621
622 for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
623 {
624 if (quest->RequiredNpcOrGo[i] < 0)
625 data << uint32((quest->RequiredNpcOrGo[i] * (-1)) | 0x80000000); // client expects gameobject template id in form (id|0x80000000)
626 else
627 data << uint32(quest->RequiredNpcOrGo[i]);
628
629 data << uint32(quest->RequiredNpcOrGoCount[i]);
630 data << uint32(quest->ItemDrop[i]);
631 data << uint32(0); // req source count?
632 }
633
634 for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
635 {
636 data << uint32(quest->RequiredItemId[i]);
637 data << uint32(quest->RequiredItemCount[i]);
638 }
639
640 for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
641 data << questObjectiveText[i];
642
643 _session->SendPacket(&data);
644 LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid={}", quest->GetQuestId());
645}
#define QUEST_OBJECTIVES_COUNT
Definition: QuestDef.h:35
@ SMSG_QUEST_QUERY_RESPONSE
Definition: Opcodes.h:123

References _session, CONFIG_MAX_PLAYER_LEVEL, Quest::GetAreaDescription(), Quest::GetBonusTalents(), Quest::GetCharTitleId(), Quest::GetCompletedText(), Quest::GetDetails(), Quest::GetFlags(), Unit::GetLevel(), ObjectMgr::GetLocaleString(), Quest::GetMinLevel(), Quest::GetNextQuestInChain(), Quest::GetObjectives(), WorldSession::GetPlayer(), Quest::GetPlayersSlain(), Quest::GetPOIContinent(), Quest::GetPointOpt(), Quest::GetPOIx(), Quest::GetPOIy(), Quest::GetQuestId(), Quest::GetQuestLevel(), Quest::GetQuestMethod(), Quest::GetRepObjectiveFaction(), Quest::GetRepObjectiveFaction2(), Quest::GetRepObjectiveValue(), Quest::GetRepObjectiveValue2(), Quest::GetRewArenaPoints(), Quest::GetRewHonorAddition(), Quest::GetRewHonorMultiplier(), Quest::GetRewMoneyMaxLevel(), Quest::GetRewOrReqMoney(), Quest::GetRewSpell(), Quest::GetRewSpellCast(), WorldSession::GetSessionDbLocaleIndex(), Quest::GetSrcItemId(), Quest::GetSuggestedPlayers(), Quest::GetTitle(), Quest::GetType(), Quest::GetXPId(), Quest::GetZoneOrSort(), Quest::HasFlag(), Quest::ItemDrop, LOG_DEBUG, Quest::ObjectiveText, QUEST_FLAGS_HIDDEN_REWARDS, QUEST_ITEM_OBJECTIVES_COUNT, QUEST_OBJECTIVES_COUNT, QUEST_REPUTATIONS_COUNT, QUEST_REWARD_CHOICES_COUNT, QUEST_REWARDS_COUNT, Quest::RequiredItemCount, Quest::RequiredItemId, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, Quest::RewardChoiceItemCount, Quest::RewardChoiceItemId, Quest::RewardFactionId, Quest::RewardFactionValueId, Quest::RewardFactionValueIdOverride, Quest::RewardItemId, Quest::RewardItemIdCount, WorldSession::SendPacket(), SMSG_QUEST_QUERY_RESPONSE, sObjectMgr, sScriptMgr, and sWorld.

Referenced by WorldSession::HandleQuestQueryOpcode().

Member Data Documentation

◆ _gossipMenu

◆ _questMenu

QuestMenu PlayerMenu::_questMenu
private

◆ _session