* [sql/updates/2008_10_22_01_mangos_quest_template.sql] Implemented honor rewards...
[auctionmangos.git] / src / game / GossipDef.cpp
blob173e69f6645c128f6fed4137d876b1dd5eccf1fc
1 /*
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
19 #include "QuestDef.h"
20 #include "GossipDef.h"
21 #include "ObjectMgr.h"
22 #include "Opcodes.h"
23 #include "WorldPacket.h"
24 #include "WorldSession.h"
25 #include "Formulas.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()
34 ClearMenu();
37 void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded)
39 ASSERT( m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS );
41 GossipMenuItem gItem;
43 gItem.m_gIcon = Icon;
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, 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()
92 m_gItems.clear();
95 PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session)
99 PlayerMenu::~PlayerMenu()
101 ClearMenus();
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
128 data << npcGUID;
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 // icons:
139 // 0 unlearn talents/misc
140 // 1 trader
141 // 2 taxi
142 // 3 trainer
143 // 9 BG/arena
144 data << uint8( gItem.m_gCoded ); // makes pop up box password
145 data << uint32(gItem.m_gBoxMoney); // money required to open menu, 2.0.3
146 data << gItem.m_gMessage; // text for gossip item
147 data << gItem.m_gBoxMessage; // accept text (related to money) pop up box, 2.0.3
150 data << uint32( mQuestMenu.MenuItemCount() ); // max count 0x20
152 for ( uint16 iI = 0; iI < mQuestMenu.MenuItemCount(); iI++ )
154 QuestMenuItem const& qItem = mQuestMenu.GetItem(iI);
155 uint32 questID = qItem.m_qId;
156 Quest const* pQuest = objmgr.GetQuestTemplate(questID);
158 data << questID;
159 data << uint32( qItem.m_qIcon );
160 data << uint32( pQuest ? pQuest->GetQuestLevel() : 0 );
161 std::string Title = pQuest->GetTitle();
163 int loc_idx = pSession->GetSessionDbLocaleIndex();
164 if (loc_idx >= 0)
166 QuestLocale const *ql = objmgr.GetQuestLocale(questID);
167 if (ql)
169 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
170 Title=ql->Title[loc_idx];
173 data << Title;
176 pSession->SendPacket( &data );
177 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) );
180 void PlayerMenu::CloseGossip()
182 WorldPacket data( SMSG_GOSSIP_COMPLETE, 0 );
183 pSession->SendPacket( &data );
185 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_COMPLETE" );
188 void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const * locName )
190 WorldPacket data( SMSG_GOSSIP_POI, (4+4+4+4+4+10) ); // guess size
191 data << Flags;
192 data << X << Y;
193 data << uint32(Icon);
194 data << uint32(Data);
195 data << locName;
197 pSession->SendPacket( &data );
198 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
201 void PlayerMenu::SendTalking( uint32 textID )
203 GossipText *pGossip;
204 std::string GossipStr;
206 pGossip = objmgr.GetGossipText(textID);
208 WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size
209 data << textID; // can be < 0
211 if (!pGossip)
213 for(uint32 i = 0; i < 8; ++i)
215 data << float(0);
216 data << "Greetings $N";
217 data << "Greetings $N";
218 data << uint32(0);
219 data << uint32(0);
220 data << uint32(0);
221 data << uint32(0);
222 data << uint32(0);
223 data << uint32(0);
224 data << uint32(0);
227 else
229 std::string Text_0[8],Text_1[8];
230 for (int i=0;i<8;i++)
232 Text_0[i]=pGossip->Options[i].Text_0;
233 Text_1[i]=pGossip->Options[i].Text_1;
235 int loc_idx = pSession->GetSessionDbLocaleIndex();
236 if (loc_idx >= 0)
238 NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textID);
239 if (nl)
241 for (int i=0;i<8;i++)
243 if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty())
244 Text_0[i]=nl->Text_0[i][loc_idx];
245 if (nl->Text_1[i].size() > loc_idx && !nl->Text_1[i][loc_idx].empty())
246 Text_1[i]=nl->Text_1[i][loc_idx];
250 for (int i=0; i<8; i++)
252 data << pGossip->Options[i].Probability;
254 if ( Text_0[i].empty() )
255 data << Text_1[i];
256 else
257 data << Text_0[i];
259 if ( Text_1[i].empty() )
260 data << Text_0[i];
261 else
262 data << Text_1[i];
264 data << pGossip->Options[i].Language;
266 data << pGossip->Options[i].Emotes[0]._Delay;
267 data << pGossip->Options[i].Emotes[0]._Emote;
269 data << pGossip->Options[i].Emotes[1]._Delay;
270 data << pGossip->Options[i].Emotes[1]._Emote;
272 data << pGossip->Options[i].Emotes[2]._Delay;
273 data << pGossip->Options[i].Emotes[2]._Emote;
276 pSession->SendPacket( &data );
278 sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
281 void PlayerMenu::SendTalking( char const * title, char const * text )
283 WorldPacket data( SMSG_NPC_TEXT_UPDATE, 50 ); // guess size
284 data << uint32(0);
285 for(uint32 i = 0; i < 8; ++i)
287 data << float(0);
288 data << title;
289 data << text;
290 data << uint32(0);
291 data << uint32(0);
292 data << uint32(0);
293 data << uint32(0);
294 data << uint32(0);
295 data << uint32(0);
296 data << uint32(0);
299 pSession->SendPacket( &data );
301 sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
304 /*********************************************************/
305 /*** QUEST SYSTEM ***/
306 /*********************************************************/
308 QuestMenu::QuestMenu()
310 m_qItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
313 QuestMenu::~QuestMenu()
315 ClearMenu();
318 void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon)
320 Quest const* qinfo = objmgr.GetQuestTemplate(QuestId);
321 if (!qinfo) return;
323 ASSERT( m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS );
325 QuestMenuItem qItem;
327 qItem.m_qId = QuestId;
328 qItem.m_qIcon = Icon;
330 m_qItems.push_back(qItem);
333 bool QuestMenu::HasItem( uint32 questid )
335 for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); i++)
337 if(i->m_qId==questid)
339 return true;
342 return false;
345 void QuestMenu::ClearMenu()
347 m_qItems.clear();
350 void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID )
352 WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size
353 data << uint64(npcGUID);
354 data << Title;
355 data << uint32(eEmote._Delay ); // player emote
356 data << uint32(eEmote._Emote ); // NPC emote
357 data << uint8 ( mQuestMenu.MenuItemCount() );
359 for ( uint16 iI = 0; iI < mQuestMenu.MenuItemCount(); iI++ )
361 QuestMenuItem const& qmi = mQuestMenu.GetItem(iI);
363 uint32 questID = qmi.m_qId;
364 Quest const *pQuest = objmgr.GetQuestTemplate(questID);
366 std::string title = pQuest ? pQuest->GetTitle() : "";
368 int loc_idx = pSession->GetSessionDbLocaleIndex();
369 if (loc_idx >= 0)
371 if(QuestLocale const *ql = objmgr.GetQuestLocale(questID))
373 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
374 title=ql->Title[loc_idx];
378 data << uint32(questID);
379 data << uint32(qmi.m_qIcon);
380 data << uint32(pQuest ? pQuest->GetQuestLevel() : 0);
381 data << title;
383 pSession->SendPacket( &data );
384 //uint32 fqid=pQuestMenu->GetItem(0).m_qId;
385 //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u, questid-0=%u",npcGUID,fqid);
388 void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID )
390 WorldPacket data( SMSG_QUESTGIVER_STATUS, 9 );
391 data << uint64(npcGUID);
392 data << uint8(questStatus);
394 pSession->SendPacket( &data );
395 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus);
398 void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept )
400 WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size
402 std::string Title = pQuest->GetTitle();
403 std::string Details = pQuest->GetDetails();
404 std::string Objectives = pQuest->GetObjectives();
405 std::string EndText = pQuest->GetEndText();
407 int loc_idx = pSession->GetSessionDbLocaleIndex();
408 if (loc_idx >= 0)
410 QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId());
411 if (ql)
413 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
414 Title=ql->Title[loc_idx];
415 if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty())
416 Details=ql->Details[loc_idx];
417 if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty())
418 Objectives=ql->Objectives[loc_idx];
419 if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty())
420 EndText=ql->EndText[loc_idx];
424 data << uint64(npcGUID);
425 data << uint32(pQuest->GetQuestId());
426 data << Title << Details << Objectives;
427 data << uint32(ActivateAccept);
428 data << uint32(pQuest->GetSuggestedPlayers());
430 if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
432 data << uint32(0); // Rewarded chosen items hidden
433 data << uint32(0); // Rewarded items hidden
434 data << uint32(0); // Rewarded money hidden
436 else
438 ItemPrototype const* IProto;
440 data << uint32(pQuest->GetRewChoiceItemsCount());
441 for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; i++)
443 if ( !pQuest->RewChoiceItemId[i] ) continue;
444 data << uint32(pQuest->RewChoiceItemId[i]);
445 data << uint32(pQuest->RewChoiceItemCount[i]);
446 IProto = objmgr.GetItemPrototype(pQuest->RewChoiceItemId[i]);
447 if ( IProto )
448 data << uint32(IProto->DisplayInfoID);
449 else
450 data << uint32( 0x00 );
453 data << uint32(pQuest->GetRewItemsCount());
454 for (uint32 i=0; i < QUEST_REWARDS_COUNT; i++)
456 if ( !pQuest->RewItemId[i] ) continue;
457 data << uint32(pQuest->RewItemId[i]);
458 data << uint32(pQuest->RewItemCount[i]);
459 IProto = objmgr.GetItemPrototype(pQuest->RewItemId[i]);
460 if ( IProto )
461 data << uint32(IProto->DisplayInfoID);
462 else
463 data << uint32(0);
465 data << uint32(pQuest->GetRewOrReqMoney());
468 // rewarded honor points. Multiply with 10 to satisfy client
469 data << uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
470 data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
471 data << uint32(pQuest->GetRewSpellCast()); // casted spell
472 data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
474 data << uint32(QUEST_EMOTE_COUNT);
475 for (uint32 i=0; i < QUEST_EMOTE_COUNT; i++)
477 data << uint32(pQuest->DetailsEmote[i]);
478 data << uint32(0); // DetailsEmoteDelay
480 pSession->SendPacket( &data );
482 sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId());
485 void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
487 std::string Title,Details,Objectives,EndText;
488 std::string ObjectiveText[QUEST_OBJECTIVES_COUNT];
489 Title = pQuest->GetTitle();
490 Details = pQuest->GetDetails();
491 Objectives = pQuest->GetObjectives();
492 EndText = pQuest->GetEndText();
493 for (int i=0;i<QUEST_OBJECTIVES_COUNT;i++)
494 ObjectiveText[i]=pQuest->ObjectiveText[i];
496 int loc_idx = pSession->GetSessionDbLocaleIndex();
497 if (loc_idx >= 0)
499 QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId());
500 if (ql)
502 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
503 Title=ql->Title[loc_idx];
504 if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty())
505 Details=ql->Details[loc_idx];
506 if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty())
507 Objectives=ql->Objectives[loc_idx];
508 if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty())
509 EndText=ql->EndText[loc_idx];
511 for (int i=0;i<QUEST_OBJECTIVES_COUNT;i++)
512 if (ql->ObjectiveText[i].size() > loc_idx && !ql->ObjectiveText[i][loc_idx].empty())
513 ObjectiveText[i]=ql->ObjectiveText[i][loc_idx];
517 WorldPacket data( SMSG_QUEST_QUERY_RESPONSE, 100 ); // guess size
519 data << uint32(pQuest->GetQuestId());
520 data << uint32(pQuest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
521 data << uint32(pQuest->GetQuestLevel()); // may be 0
522 data << uint32(pQuest->GetZoneOrSort()); // zone or sort to display in quest log
524 data << uint32(pQuest->GetType());
525 data << uint32(pQuest->GetSuggestedPlayers());
527 data << uint32(pQuest->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
528 data << uint32(pQuest->GetRepObjectiveValue()); // shown in quest log as part of quest objective
530 data << uint32(0); // RequiredOpositeRepFaction
531 data << uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
533 data << uint32(pQuest->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
535 if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
536 data << uint32(0); // Hide money rewarded
537 else
538 data << uint32(pQuest->GetRewOrReqMoney());
540 data << uint32(pQuest->GetRewMoneyMaxLevel()); // used in XP calculation at client
541 data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
542 data << uint32(pQuest->GetRewSpellCast()); // casted spell
544 // rewarded honor points
545 data << uint32(MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
546 data << uint32(pQuest->GetSrcItemId());
547 data << uint32(pQuest->GetFlags() & 0xFFFF);
548 data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
550 int iI;
552 if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS))
554 for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++)
555 data << uint32(0) << uint32(0);
556 for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++)
557 data << uint32(0) << uint32(0);
559 else
561 for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++)
563 data << uint32(pQuest->RewItemId[iI]);
564 data << uint32(pQuest->RewItemCount[iI]);
566 for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++)
568 data << uint32(pQuest->RewChoiceItemId[iI]);
569 data << uint32(pQuest->RewChoiceItemCount[iI]);
573 data << pQuest->GetPointMapId();
574 data << pQuest->GetPointX();
575 data << pQuest->GetPointY();
576 data << pQuest->GetPointOpt();
578 data << Title;
579 data << Objectives;
580 data << Details;
581 data << EndText;
583 for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++)
585 if (pQuest->ReqCreatureOrGOId[iI] < 0)
587 // client expected gameobject template id in form (id|0x80000000)
588 data << uint32((pQuest->ReqCreatureOrGOId[iI]*(-1))|0x80000000);
590 else
592 data << uint32(pQuest->ReqCreatureOrGOId[iI]);
594 data << uint32(pQuest->ReqCreatureOrGOCount[iI]);
595 data << uint32(pQuest->ReqItemId[iI]);
596 data << uint32(pQuest->ReqItemCount[iI]);
599 for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++)
600 data << ObjectiveText[iI];
602 pSession->SendPacket( &data );
603 sLog.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest->GetQuestId() );
606 void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext )
608 std::string Title = pQuest->GetTitle();
609 std::string OfferRewardText = pQuest->GetOfferRewardText();
611 int loc_idx = pSession->GetSessionDbLocaleIndex();
612 if (loc_idx >= 0)
614 QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId());
615 if (ql)
617 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
618 Title=ql->Title[loc_idx];
619 if (ql->OfferRewardText.size() > loc_idx && !ql->OfferRewardText[loc_idx].empty())
620 OfferRewardText=ql->OfferRewardText[loc_idx];
624 WorldPacket data( SMSG_QUESTGIVER_OFFER_REWARD, 50 ); // guess size
626 data << npcGUID;
627 data << pQuest->GetQuestId();
628 data << Title;
629 data << OfferRewardText;
631 data << uint32( EnbleNext );
632 data << uint32(0); // unk
634 uint32 EmoteCount = 0;
635 for (uint32 i = 0; i < QUEST_EMOTE_COUNT; i++)
637 if(pQuest->OfferRewardEmote[i] <= 0)
638 break;
639 ++EmoteCount;
642 data << EmoteCount; // Emote Count
643 for (uint32 i = 0; i < EmoteCount; i++)
645 data << uint32(0); // Delay Emote
646 data << pQuest->OfferRewardEmote[i];
649 ItemPrototype const *pItem;
651 data << uint32(pQuest->GetRewChoiceItemsCount());
652 for (uint32 i=0; i < pQuest->GetRewChoiceItemsCount(); i++)
654 pItem = objmgr.GetItemPrototype( pQuest->RewChoiceItemId[i] );
656 data << uint32(pQuest->RewChoiceItemId[i]);
657 data << uint32(pQuest->RewChoiceItemCount[i]);
659 if ( pItem )
660 data << uint32(pItem->DisplayInfoID);
661 else
662 data << uint32(0);
665 data << uint32(pQuest->GetRewItemsCount());
666 for (uint16 i=0; i < pQuest->GetRewItemsCount(); i++)
668 pItem = objmgr.GetItemPrototype(pQuest->RewItemId[i]);
669 data << uint32(pQuest->RewItemId[i]);
670 data << uint32(pQuest->RewItemCount[i]);
672 if ( pItem )
673 data << uint32(pItem->DisplayInfoID);
674 else
675 data << uint32(0);
678 data << uint32(pQuest->GetRewOrReqMoney());
680 // rewarded honor points. Multiply with 10 to satisfy client
681 data << uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession->GetPlayer()->getLevel(), pQuest->GetRewHonorableKills()));
682 data << uint32(0x08); // unused by client?
683 data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
684 data << uint32(pQuest->GetRewSpellCast()); // casted spell
685 data << uint32(0x00); // unk, NOT honor
686 pSession->SendPacket( &data );
687 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() );
690 void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel )
692 // We can always call to RequestItems, but this packet only goes out if there are actually
693 // items. Otherwise, we'll skip straight to the OfferReward
695 // We may wish a better check, perhaps checking the real quest requirements
696 if (pQuest->GetRequestItemsText().empty())
698 SendQuestGiverOfferReward(pQuest, npcGUID, true);
699 return;
702 std::string Title,RequestItemsText;
703 Title = pQuest->GetTitle();
704 RequestItemsText = pQuest->GetRequestItemsText();
706 int loc_idx = pSession->GetSessionDbLocaleIndex();
707 if (loc_idx >= 0)
709 QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId());
710 if (ql)
712 if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty())
713 Title=ql->Title[loc_idx];
714 if (ql->RequestItemsText.size() > loc_idx && !ql->RequestItemsText[loc_idx].empty())
715 RequestItemsText=ql->RequestItemsText[loc_idx];
719 WorldPacket data( SMSG_QUESTGIVER_REQUEST_ITEMS, 50 ); // guess size
720 data << npcGUID;
721 data << pQuest->GetQuestId();
722 data << Title;
723 data << RequestItemsText;
725 data << uint32(0x00); // unknown
727 if(Completable)
728 data << pQuest->GetCompleteEmote();
729 else
730 data << pQuest->GetIncompleteEmote();
732 // Close Window after cancel
733 if (CloseOnCancel)
734 data << uint32(0x01);
735 else
736 data << uint32(0x00);
738 data << uint32(0x00); // unknown
740 // Required Money
741 data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0);
743 data << uint32( pQuest->GetReqItemsCount() );
744 ItemPrototype const *pItem;
745 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
747 if ( !pQuest->ReqItemId[i] ) continue;
748 pItem = objmgr.GetItemPrototype(pQuest->ReqItemId[i]);
749 data << uint32(pQuest->ReqItemId[i]);
750 data << uint32(pQuest->ReqItemCount[i]);
752 if ( pItem )
753 data << uint32(pItem->DisplayInfoID);
754 else
755 data << uint32(0);
758 if ( !Completable )
759 data << uint32(0x00);
760 else
761 data << uint32(0x03);
763 data << uint32(0x04) << uint32(0x08) << uint32(0x10);
765 pSession->SendPacket( &data );
766 sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() );