2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "GossipDef.h"
21 #include "ObjectMgr.h"
23 #include "WorldPacket.h"
24 #include "WorldSession.h"
27 GossipMenu::GossipMenu()
29 m_gItems
.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
32 GossipMenu::~GossipMenu()
37 void GossipMenu::AddMenuItem(uint8 Icon
, const std::string
& Message
, uint32 dtSender
, uint32 dtAction
, const std::string
& BoxMessage
, uint32 BoxMoney
, bool Coded
)
39 ASSERT( m_gItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
44 gItem
.m_gMessage
= Message
;
45 gItem
.m_gCoded
= Coded
;
46 gItem
.m_gSender
= dtSender
;
47 gItem
.m_gAction
= dtAction
;
48 gItem
.m_gBoxMessage
= BoxMessage
;
49 gItem
.m_gBoxMoney
= BoxMoney
;
51 m_gItems
.push_back(gItem
);
54 void GossipMenu::AddMenuItem(uint8 Icon
, const std::string
& Message
, bool Coded
)
56 AddMenuItem( Icon
, Message
, 0, 0, "", 0, Coded
);
59 void GossipMenu::AddMenuItem(uint8 Icon
, char const* Message
, bool Coded
)
61 AddMenuItem(Icon
, std::string(Message
? Message
: ""),Coded
);
64 void GossipMenu::AddMenuItem(uint8 Icon
, char const* Message
, uint32 dtSender
, uint32 dtAction
, char const* BoxMessage
, uint32 BoxMoney
, bool Coded
)
66 AddMenuItem(Icon
, std::string(Message
? Message
: ""), dtSender
, dtAction
, std::string(BoxMessage
? BoxMessage
: ""), BoxMoney
, Coded
);
69 uint32
GossipMenu::MenuItemSender( unsigned int ItemId
)
71 if ( ItemId
>= m_gItems
.size() ) return 0;
73 return m_gItems
[ ItemId
].m_gSender
;
76 uint32
GossipMenu::MenuItemAction( unsigned int ItemId
)
78 if ( ItemId
>= m_gItems
.size() ) return 0;
80 return m_gItems
[ ItemId
].m_gAction
;
83 bool GossipMenu::MenuItemCoded( unsigned int ItemId
)
85 if ( ItemId
>= m_gItems
.size() ) return 0;
87 return m_gItems
[ ItemId
].m_gCoded
;
90 void GossipMenu::ClearMenu()
95 PlayerMenu::PlayerMenu( WorldSession
*session
) : pSession(session
)
99 PlayerMenu::~PlayerMenu()
104 void PlayerMenu::ClearMenus()
106 mGossipMenu
.ClearMenu();
107 mQuestMenu
.ClearMenu();
110 uint32
PlayerMenu::GossipOptionSender( unsigned int Selection
)
112 return mGossipMenu
.MenuItemSender( Selection
);
115 uint32
PlayerMenu::GossipOptionAction( unsigned int Selection
)
117 return mGossipMenu
.MenuItemAction( Selection
);
120 bool PlayerMenu::GossipOptionCoded( unsigned int Selection
)
122 return mGossipMenu
.MenuItemCoded( Selection
);
125 void PlayerMenu::SendGossipMenu( uint32 TitleTextId
, uint64 npcGUID
)
127 WorldPacket
data( SMSG_GOSSIP_MESSAGE
, (100) ); // guess size
129 data
<< uint32(0); // new 2.4.0
130 data
<< uint32( TitleTextId
);
131 data
<< uint32( mGossipMenu
.MenuItemCount() ); // max count 0x0F
133 for ( unsigned int iI
= 0; iI
< mGossipMenu
.MenuItemCount(); iI
++ )
135 GossipMenuItem
const& gItem
= mGossipMenu
.GetItem(iI
);
136 data
<< uint32( iI
);
137 data
<< uint8( gItem
.m_gIcon
);
138 data
<< uint8( gItem
.m_gCoded
); // makes pop up box password
139 data
<< uint32(gItem
.m_gBoxMoney
); // money required to open menu, 2.0.3
140 data
<< gItem
.m_gMessage
; // text for gossip item
141 data
<< gItem
.m_gBoxMessage
; // accept text (related to money) pop up box, 2.0.3
144 data
<< uint32( mQuestMenu
.MenuItemCount() ); // max count 0x20
146 for ( uint16 iI
= 0; iI
< mQuestMenu
.MenuItemCount(); iI
++ )
148 QuestMenuItem
const& qItem
= mQuestMenu
.GetItem(iI
);
149 uint32 questID
= qItem
.m_qId
;
150 Quest
const* pQuest
= objmgr
.GetQuestTemplate(questID
);
152 data
<< uint32(questID
);
153 data
<< uint32( qItem
.m_qIcon
);
154 data
<< uint32( pQuest
? pQuest
->GetQuestLevel() : 0 );
155 std::string Title
= pQuest
->GetTitle();
157 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
160 QuestLocale
const *ql
= objmgr
.GetQuestLocale(questID
);
163 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
164 Title
=ql
->Title
[loc_idx
];
170 pSession
->SendPacket( &data
);
171 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) );
174 void PlayerMenu::CloseGossip()
176 WorldPacket
data( SMSG_GOSSIP_COMPLETE
, 0 );
177 pSession
->SendPacket( &data
);
179 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_COMPLETE" );
182 void PlayerMenu::SendPointOfInterest( float X
, float Y
, uint32 Icon
, uint32 Flags
, uint32 Data
, char const * locName
)
184 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
187 data
<< uint32(Icon
);
188 data
<< uint32(Data
);
191 pSession
->SendPacket( &data
);
192 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
195 void PlayerMenu::SendTalking( uint32 textID
)
198 std::string GossipStr
;
200 pGossip
= objmgr
.GetGossipText(textID
);
202 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 100 ); // guess size
203 data
<< textID
; // can be < 0
207 for(uint32 i
= 0; i
< 8; ++i
)
210 data
<< "Greetings $N";
211 data
<< "Greetings $N";
223 std::string Text_0
[8],Text_1
[8];
224 for (int i
=0;i
<8;i
++)
226 Text_0
[i
]=pGossip
->Options
[i
].Text_0
;
227 Text_1
[i
]=pGossip
->Options
[i
].Text_1
;
229 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
232 NpcTextLocale
const *nl
= objmgr
.GetNpcTextLocale(textID
);
235 for (int i
=0;i
<8;i
++)
237 if (nl
->Text_0
[i
].size() > loc_idx
&& !nl
->Text_0
[i
][loc_idx
].empty())
238 Text_0
[i
]=nl
->Text_0
[i
][loc_idx
];
239 if (nl
->Text_1
[i
].size() > loc_idx
&& !nl
->Text_1
[i
][loc_idx
].empty())
240 Text_1
[i
]=nl
->Text_1
[i
][loc_idx
];
244 for (int i
=0; i
<8; i
++)
246 data
<< pGossip
->Options
[i
].Probability
;
248 if ( Text_0
[i
].empty() )
253 if ( Text_1
[i
].empty() )
258 data
<< pGossip
->Options
[i
].Language
;
260 data
<< pGossip
->Options
[i
].Emotes
[0]._Delay
;
261 data
<< pGossip
->Options
[i
].Emotes
[0]._Emote
;
263 data
<< pGossip
->Options
[i
].Emotes
[1]._Delay
;
264 data
<< pGossip
->Options
[i
].Emotes
[1]._Emote
;
266 data
<< pGossip
->Options
[i
].Emotes
[2]._Delay
;
267 data
<< pGossip
->Options
[i
].Emotes
[2]._Emote
;
270 pSession
->SendPacket( &data
);
272 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
275 void PlayerMenu::SendTalking( char const * title
, char const * text
)
277 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 50 ); // guess size
279 for(uint32 i
= 0; i
< 8; ++i
)
293 pSession
->SendPacket( &data
);
295 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
298 /*********************************************************/
299 /*** QUEST SYSTEM ***/
300 /*********************************************************/
302 QuestMenu::QuestMenu()
304 m_qItems
.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
307 QuestMenu::~QuestMenu()
312 void QuestMenu::AddMenuItem( uint32 QuestId
, uint8 Icon
)
314 Quest
const* qinfo
= objmgr
.GetQuestTemplate(QuestId
);
317 ASSERT( m_qItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
321 qItem
.m_qId
= QuestId
;
322 qItem
.m_qIcon
= Icon
;
324 m_qItems
.push_back(qItem
);
327 bool QuestMenu::HasItem( uint32 questid
)
329 for (QuestMenuItemList::iterator i
= m_qItems
.begin(); i
!= m_qItems
.end(); ++i
)
331 if(i
->m_qId
==questid
)
339 void QuestMenu::ClearMenu()
344 void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote
, const std::string
& Title
, uint64 npcGUID
)
346 WorldPacket
data( SMSG_QUESTGIVER_QUEST_LIST
, 100 ); // guess size
347 data
<< uint64(npcGUID
);
349 data
<< uint32(eEmote
._Delay
); // player emote
350 data
<< uint32(eEmote
._Emote
); // NPC emote
351 data
<< uint8 ( mQuestMenu
.MenuItemCount() );
353 for ( uint16 iI
= 0; iI
< mQuestMenu
.MenuItemCount(); iI
++ )
355 QuestMenuItem
const& qmi
= mQuestMenu
.GetItem(iI
);
357 uint32 questID
= qmi
.m_qId
;
358 Quest
const *pQuest
= objmgr
.GetQuestTemplate(questID
);
360 std::string title
= pQuest
? pQuest
->GetTitle() : "";
362 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
365 if(QuestLocale
const *ql
= objmgr
.GetQuestLocale(questID
))
367 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
368 title
=ql
->Title
[loc_idx
];
372 data
<< uint32(questID
);
373 data
<< uint32(qmi
.m_qIcon
);
374 data
<< uint32(pQuest
? pQuest
->GetQuestLevel() : 0);
377 pSession
->SendPacket( &data
);
378 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID
));
381 void PlayerMenu::SendQuestGiverStatus( uint8 questStatus
, uint64 npcGUID
)
383 WorldPacket
data( SMSG_QUESTGIVER_STATUS
, 9 );
384 data
<< uint64(npcGUID
);
385 data
<< uint8(questStatus
);
387 pSession
->SendPacket( &data
);
388 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID
), questStatus
);
391 void PlayerMenu::SendQuestGiverQuestDetails( Quest
const *pQuest
, uint64 npcGUID
, bool ActivateAccept
)
393 WorldPacket
data(SMSG_QUESTGIVER_QUEST_DETAILS
, 100); // guess size
395 std::string Title
= pQuest
->GetTitle();
396 std::string Details
= pQuest
->GetDetails();
397 std::string Objectives
= pQuest
->GetObjectives();
398 std::string EndText
= pQuest
->GetEndText();
400 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
403 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
406 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
407 Title
=ql
->Title
[loc_idx
];
408 if (ql
->Details
.size() > loc_idx
&& !ql
->Details
[loc_idx
].empty())
409 Details
=ql
->Details
[loc_idx
];
410 if (ql
->Objectives
.size() > loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
411 Objectives
=ql
->Objectives
[loc_idx
];
412 if (ql
->EndText
.size() > loc_idx
&& !ql
->EndText
[loc_idx
].empty())
413 EndText
=ql
->EndText
[loc_idx
];
417 data
<< uint64(npcGUID
);
418 data
<< uint32(pQuest
->GetQuestId());
419 data
<< Title
<< Details
<< Objectives
;
420 data
<< uint32(ActivateAccept
);
421 data
<< uint32(pQuest
->GetSuggestedPlayers());
423 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
425 data
<< uint32(0); // Rewarded chosen items hidden
426 data
<< uint32(0); // Rewarded items hidden
427 data
<< uint32(0); // Rewarded money hidden
431 ItemPrototype
const* IProto
;
433 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
434 for (uint32 i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; i
++)
436 if ( !pQuest
->RewChoiceItemId
[i
] ) continue;
437 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
438 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
439 IProto
= objmgr
.GetItemPrototype(pQuest
->RewChoiceItemId
[i
]);
441 data
<< uint32(IProto
->DisplayInfoID
);
443 data
<< uint32( 0x00 );
446 data
<< uint32(pQuest
->GetRewItemsCount());
447 for (uint32 i
=0; i
< QUEST_REWARDS_COUNT
; i
++)
449 if ( !pQuest
->RewItemId
[i
] ) continue;
450 data
<< uint32(pQuest
->RewItemId
[i
]);
451 data
<< uint32(pQuest
->RewItemCount
[i
]);
452 IProto
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
454 data
<< uint32(IProto
->DisplayInfoID
);
459 data
<< uint32(pQuest
->GetRewOrReqMoney());
462 // rewarded honor points. Multiply with 10 to satisfy client
463 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
464 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
465 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
466 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
468 data
<< uint32(QUEST_EMOTE_COUNT
);
469 for (uint32 i
=0; i
< QUEST_EMOTE_COUNT
; i
++)
471 data
<< uint32(pQuest
->DetailsEmote
[i
]);
472 data
<< uint32(0); // DetailsEmoteDelay
474 pSession
->SendPacket( &data
);
476 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId());
479 void PlayerMenu::SendQuestQueryResponse( Quest
const *pQuest
)
481 std::string Title
,Details
,Objectives
,EndText
;
482 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
483 Title
= pQuest
->GetTitle();
484 Details
= pQuest
->GetDetails();
485 Objectives
= pQuest
->GetObjectives();
486 EndText
= pQuest
->GetEndText();
487 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;i
++)
488 ObjectiveText
[i
]=pQuest
->ObjectiveText
[i
];
490 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
493 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
496 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
497 Title
=ql
->Title
[loc_idx
];
498 if (ql
->Details
.size() > loc_idx
&& !ql
->Details
[loc_idx
].empty())
499 Details
=ql
->Details
[loc_idx
];
500 if (ql
->Objectives
.size() > loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
501 Objectives
=ql
->Objectives
[loc_idx
];
502 if (ql
->EndText
.size() > loc_idx
&& !ql
->EndText
[loc_idx
].empty())
503 EndText
=ql
->EndText
[loc_idx
];
505 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;i
++)
506 if (ql
->ObjectiveText
[i
].size() > loc_idx
&& !ql
->ObjectiveText
[i
][loc_idx
].empty())
507 ObjectiveText
[i
]=ql
->ObjectiveText
[i
][loc_idx
];
511 WorldPacket
data( SMSG_QUEST_QUERY_RESPONSE
, 100 ); // guess size
513 data
<< uint32(pQuest
->GetQuestId());
514 data
<< uint32(pQuest
->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
515 data
<< uint32(pQuest
->GetQuestLevel()); // may be 0
516 data
<< uint32(pQuest
->GetZoneOrSort()); // zone or sort to display in quest log
518 data
<< uint32(pQuest
->GetType());
519 data
<< uint32(pQuest
->GetSuggestedPlayers());
521 data
<< uint32(pQuest
->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
522 data
<< uint32(pQuest
->GetRepObjectiveValue()); // shown in quest log as part of quest objective
524 data
<< uint32(0); // RequiredOpositeRepFaction
525 data
<< uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
527 data
<< uint32(pQuest
->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
529 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
530 data
<< uint32(0); // Hide money rewarded
532 data
<< uint32(pQuest
->GetRewOrReqMoney());
534 data
<< uint32(pQuest
->GetRewMoneyMaxLevel()); // used in XP calculation at client
535 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
536 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
538 // rewarded honor points
539 data
<< uint32(MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
540 data
<< uint32(pQuest
->GetSrcItemId());
541 data
<< uint32(pQuest
->GetFlags() & 0xFFFF);
542 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
546 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
548 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; iI
++)
549 data
<< uint32(0) << uint32(0);
550 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; iI
++)
551 data
<< uint32(0) << uint32(0);
555 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; iI
++)
557 data
<< uint32(pQuest
->RewItemId
[iI
]);
558 data
<< uint32(pQuest
->RewItemCount
[iI
]);
560 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; iI
++)
562 data
<< uint32(pQuest
->RewChoiceItemId
[iI
]);
563 data
<< uint32(pQuest
->RewChoiceItemCount
[iI
]);
567 data
<< pQuest
->GetPointMapId();
568 data
<< pQuest
->GetPointX();
569 data
<< pQuest
->GetPointY();
570 data
<< pQuest
->GetPointOpt();
577 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; iI
++)
579 if (pQuest
->ReqCreatureOrGOId
[iI
] < 0)
581 // client expected gameobject template id in form (id|0x80000000)
582 data
<< uint32((pQuest
->ReqCreatureOrGOId
[iI
]*(-1))|0x80000000);
586 data
<< uint32(pQuest
->ReqCreatureOrGOId
[iI
]);
588 data
<< uint32(pQuest
->ReqCreatureOrGOCount
[iI
]);
589 data
<< uint32(pQuest
->ReqItemId
[iI
]);
590 data
<< uint32(pQuest
->ReqItemCount
[iI
]);
593 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; iI
++)
594 data
<< ObjectiveText
[iI
];
596 pSession
->SendPacket( &data
);
597 sLog
.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest
->GetQuestId() );
600 void PlayerMenu::SendQuestGiverOfferReward( Quest
const* pQuest
, uint64 npcGUID
, bool EnbleNext
)
602 std::string Title
= pQuest
->GetTitle();
603 std::string OfferRewardText
= pQuest
->GetOfferRewardText();
605 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
608 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
611 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
612 Title
=ql
->Title
[loc_idx
];
613 if (ql
->OfferRewardText
.size() > loc_idx
&& !ql
->OfferRewardText
[loc_idx
].empty())
614 OfferRewardText
=ql
->OfferRewardText
[loc_idx
];
618 WorldPacket
data( SMSG_QUESTGIVER_OFFER_REWARD
, 50 ); // guess size
621 data
<< pQuest
->GetQuestId();
623 data
<< OfferRewardText
;
625 data
<< uint32( EnbleNext
);
626 data
<< uint32(0); // unk
628 uint32 EmoteCount
= 0;
629 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; i
++)
631 if(pQuest
->OfferRewardEmote
[i
] <= 0)
636 data
<< EmoteCount
; // Emote Count
637 for (uint32 i
= 0; i
< EmoteCount
; i
++)
639 data
<< uint32(0); // Delay Emote
640 data
<< pQuest
->OfferRewardEmote
[i
];
643 ItemPrototype
const *pItem
;
645 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
646 for (uint32 i
=0; i
< pQuest
->GetRewChoiceItemsCount(); i
++)
648 pItem
= objmgr
.GetItemPrototype( pQuest
->RewChoiceItemId
[i
] );
650 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
651 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
654 data
<< uint32(pItem
->DisplayInfoID
);
659 data
<< uint32(pQuest
->GetRewItemsCount());
660 for (uint16 i
=0; i
< pQuest
->GetRewItemsCount(); i
++)
662 pItem
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
663 data
<< uint32(pQuest
->RewItemId
[i
]);
664 data
<< uint32(pQuest
->RewItemCount
[i
]);
667 data
<< uint32(pItem
->DisplayInfoID
);
672 data
<< uint32(pQuest
->GetRewOrReqMoney());
674 // rewarded honor points. Multiply with 10 to satisfy client
675 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
676 data
<< uint32(0x08); // unused by client?
677 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
678 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
679 data
<< uint32(0x00); // unk, NOT honor
680 pSession
->SendPacket( &data
);
681 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID
),pQuest
->GetQuestId() );
684 void PlayerMenu::SendQuestGiverRequestItems( Quest
const *pQuest
, uint64 npcGUID
, bool Completable
, bool CloseOnCancel
)
686 // We can always call to RequestItems, but this packet only goes out if there are actually
687 // items. Otherwise, we'll skip straight to the OfferReward
689 // We may wish a better check, perhaps checking the real quest requirements
690 if (pQuest
->GetRequestItemsText().empty())
692 SendQuestGiverOfferReward(pQuest
, npcGUID
, true);
696 std::string Title
,RequestItemsText
;
697 Title
= pQuest
->GetTitle();
698 RequestItemsText
= pQuest
->GetRequestItemsText();
700 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
703 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
706 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
707 Title
=ql
->Title
[loc_idx
];
708 if (ql
->RequestItemsText
.size() > loc_idx
&& !ql
->RequestItemsText
[loc_idx
].empty())
709 RequestItemsText
=ql
->RequestItemsText
[loc_idx
];
713 WorldPacket
data( SMSG_QUESTGIVER_REQUEST_ITEMS
, 50 ); // guess size
715 data
<< pQuest
->GetQuestId();
717 data
<< RequestItemsText
;
719 data
<< uint32(0x00); // unknown
722 data
<< pQuest
->GetCompleteEmote();
724 data
<< pQuest
->GetIncompleteEmote();
726 // Close Window after cancel
728 data
<< uint32(0x01);
730 data
<< uint32(0x00);
732 data
<< uint32(0x00); // unknown
735 data
<< uint32(pQuest
->GetRewOrReqMoney() < 0 ? -pQuest
->GetRewOrReqMoney() : 0);
737 data
<< uint32( pQuest
->GetReqItemsCount() );
738 ItemPrototype
const *pItem
;
739 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; i
++)
741 if ( !pQuest
->ReqItemId
[i
] ) continue;
742 pItem
= objmgr
.GetItemPrototype(pQuest
->ReqItemId
[i
]);
743 data
<< uint32(pQuest
->ReqItemId
[i
]);
744 data
<< uint32(pQuest
->ReqItemCount
[i
]);
747 data
<< uint32(pItem
->DisplayInfoID
);
753 data
<< uint32(0x00);
755 data
<< uint32(0x03);
757 data
<< uint32(0x04);
758 data
<< uint32(0x08);
759 data
<< uint32(0x10);
761 pSession
->SendPacket( &data
);
762 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );