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
, std::string Message
, uint32 dtSender
, uint32 dtAction
, 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
, 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
);
139 // 0 unlearn talents/misc
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
);
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();
166 QuestLocale
const *ql
= objmgr
.GetQuestLocale(questID
);
169 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
170 Title
=ql
->Title
[loc_idx
];
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
193 data
<< uint32(Icon
);
194 data
<< uint32(Data
);
197 pSession
->SendPacket( &data
);
198 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
201 void PlayerMenu::SendTalking( uint32 textID
)
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
213 for(uint32 i
= 0; i
< 8; ++i
)
216 data
<< "Greetings $N";
217 data
<< "Greetings $N";
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();
238 NpcTextLocale
const *nl
= objmgr
.GetNpcTextLocale(textID
);
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() )
259 if ( Text_1
[i
].empty() )
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
285 for(uint32 i
= 0; i
< 8; ++i
)
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()
318 void QuestMenu::AddMenuItem( uint32 QuestId
, uint8 Icon
)
320 Quest
const* qinfo
= objmgr
.GetQuestTemplate(QuestId
);
323 ASSERT( m_qItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
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
)
345 void QuestMenu::ClearMenu()
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
);
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();
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);
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();
410 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
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
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
]);
448 data
<< uint32(IProto
->DisplayInfoID
);
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
]);
461 data
<< uint32(IProto
->DisplayInfoID
);
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();
499 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
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
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)
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);
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();
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);
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();
614 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
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
627 data
<< pQuest
->GetQuestId();
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)
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
]);
660 data
<< uint32(pItem
->DisplayInfoID
);
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
]);
673 data
<< uint32(pItem
->DisplayInfoID
);
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);
702 std::string Title
,RequestItemsText
;
703 Title
= pQuest
->GetTitle();
704 RequestItemsText
= pQuest
->GetRequestItemsText();
706 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
709 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
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
721 data
<< pQuest
->GetQuestId();
723 data
<< RequestItemsText
;
725 data
<< uint32(0x00); // unknown
728 data
<< pQuest
->GetCompleteEmote();
730 data
<< pQuest
->GetIncompleteEmote();
732 // Close Window after cancel
734 data
<< uint32(0x01);
736 data
<< uint32(0x00);
738 data
<< uint32(0x00); // unknown
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
]);
753 data
<< uint32(pItem
->DisplayInfoID
);
759 data
<< uint32(0x00);
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() );