2 * Copyright (C) 2005-2009 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
128 data
<< uint64(npcGUID
);
129 data
<< uint32(0); // new 2.4.0
130 data
<< uint32( TitleTextId
);
131 data
<< uint32( mGossipMenu
.MenuItemCount() ); // max count 0x10
133 for (uint32 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 (uint32 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(pSession
->GetPlayer()->GetQuestLevel(pQuest
));
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" );
183 void PlayerMenu::SendPointOfInterest( float X
, float Y
, uint32 Icon
, uint32 Flags
, uint32 Data
, char const * locName
)
185 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
188 data
<< uint32(Icon
);
189 data
<< uint32(Data
);
192 pSession
->SendPacket( &data
);
193 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
196 void PlayerMenu::SendPointOfInterest( uint32 poi_id
)
198 PointOfInterest
const* poi
= objmgr
.GetPointOfInterest(poi_id
);
201 sLog
.outErrorDb("Requested send not existed POI (Id: %u), ignore.",poi_id
);
205 std::string icon_name
= poi
->icon_name
;
207 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
210 PointOfInterestLocale
const *pl
= objmgr
.GetPointOfInterestLocale(poi_id
);
213 if (pl
->IconName
.size() > size_t(loc_idx
) && !pl
->IconName
[loc_idx
].empty())
214 icon_name
= pl
->IconName
[loc_idx
];
218 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
219 data
<< uint32(poi
->flags
);
220 data
<< float(poi
->x
);
221 data
<< float(poi
->y
);
222 data
<< uint32(poi
->icon
);
223 data
<< uint32(poi
->data
);
226 pSession
->SendPacket( &data
);
227 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
230 void PlayerMenu::SendTalking( uint32 textID
)
232 GossipText
const* pGossip
= objmgr
.GetGossipText(textID
);
234 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 100 ); // guess size
235 data
<< textID
; // can be < 0
239 for(uint32 i
= 0; i
< 8; ++i
)
242 data
<< "Greetings $N";
243 data
<< "Greetings $N";
255 std::string Text_0
[8],Text_1
[8];
256 for (int i
=0;i
<8;++i
)
258 Text_0
[i
]=pGossip
->Options
[i
].Text_0
;
259 Text_1
[i
]=pGossip
->Options
[i
].Text_1
;
261 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
264 NpcTextLocale
const *nl
= objmgr
.GetNpcTextLocale(textID
);
267 for (int i
=0;i
<8;++i
)
269 if (nl
->Text_0
[i
].size() > loc_idx
&& !nl
->Text_0
[i
][loc_idx
].empty())
270 Text_0
[i
]=nl
->Text_0
[i
][loc_idx
];
271 if (nl
->Text_1
[i
].size() > loc_idx
&& !nl
->Text_1
[i
][loc_idx
].empty())
272 Text_1
[i
]=nl
->Text_1
[i
][loc_idx
];
276 for (int i
=0; i
<8; ++i
)
278 data
<< pGossip
->Options
[i
].Probability
;
280 if ( Text_0
[i
].empty() )
285 if ( Text_1
[i
].empty() )
290 data
<< pGossip
->Options
[i
].Language
;
292 for(int j
= 0; j
< 3; ++j
)
294 data
<< pGossip
->Options
[i
].Emotes
[j
]._Delay
;
295 data
<< pGossip
->Options
[i
].Emotes
[j
]._Emote
;
299 pSession
->SendPacket( &data
);
301 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
304 void PlayerMenu::SendTalking( char const * title
, char const * text
)
306 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 50 ); // guess size
308 for(uint32 i
= 0; i
< 8; ++i
)
322 pSession
->SendPacket( &data
);
324 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
327 /*********************************************************/
328 /*** QUEST SYSTEM ***/
329 /*********************************************************/
331 QuestMenu::QuestMenu()
333 m_qItems
.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
336 QuestMenu::~QuestMenu()
341 void QuestMenu::AddMenuItem( uint32 QuestId
, uint8 Icon
)
343 Quest
const* qinfo
= objmgr
.GetQuestTemplate(QuestId
);
346 ASSERT( m_qItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
350 qItem
.m_qId
= QuestId
;
351 qItem
.m_qIcon
= Icon
;
353 m_qItems
.push_back(qItem
);
356 bool QuestMenu::HasItem( uint32 questid
)
358 for (QuestMenuItemList::const_iterator i
= m_qItems
.begin(); i
!= m_qItems
.end(); ++i
)
360 if(i
->m_qId
==questid
)
368 void QuestMenu::ClearMenu()
373 void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote
, const std::string
& Title
, uint64 npcGUID
)
375 WorldPacket
data( SMSG_QUESTGIVER_QUEST_LIST
, 100 ); // guess size
376 data
<< uint64(npcGUID
);
378 data
<< uint32(eEmote
._Delay
); // player emote
379 data
<< uint32(eEmote
._Emote
); // NPC emote
380 data
<< uint8 ( mQuestMenu
.MenuItemCount() );
382 for (uint32 iI
= 0; iI
< mQuestMenu
.MenuItemCount(); ++iI
)
384 QuestMenuItem
const& qmi
= mQuestMenu
.GetItem(iI
);
386 uint32 questID
= qmi
.m_qId
;
387 Quest
const *pQuest
= objmgr
.GetQuestTemplate(questID
);
389 std::string title
= pQuest
? pQuest
->GetTitle() : "";
391 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
394 if(QuestLocale
const *ql
= objmgr
.GetQuestLocale(questID
))
396 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
397 title
=ql
->Title
[loc_idx
];
401 data
<< uint32(questID
);
402 data
<< uint32(qmi
.m_qIcon
);
403 data
<< uint32(pSession
->GetPlayer()->GetQuestLevel(pQuest
));
406 pSession
->SendPacket( &data
);
407 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID
));
410 void PlayerMenu::SendQuestGiverStatus( uint8 questStatus
, uint64 npcGUID
)
412 WorldPacket
data( SMSG_QUESTGIVER_STATUS
, 9 );
413 data
<< uint64(npcGUID
);
414 data
<< uint8(questStatus
);
416 pSession
->SendPacket( &data
);
417 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID
), questStatus
);
420 void PlayerMenu::SendQuestGiverQuestDetails( Quest
const *pQuest
, uint64 npcGUID
, bool ActivateAccept
)
422 WorldPacket
data(SMSG_QUESTGIVER_QUEST_DETAILS
, 100); // guess size
424 std::string Title
= pQuest
->GetTitle();
425 std::string Details
= pQuest
->GetDetails();
426 std::string Objectives
= pQuest
->GetObjectives();
427 std::string EndText
= pQuest
->GetEndText();
429 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
432 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
435 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
436 Title
=ql
->Title
[loc_idx
];
437 if (ql
->Details
.size() > loc_idx
&& !ql
->Details
[loc_idx
].empty())
438 Details
=ql
->Details
[loc_idx
];
439 if (ql
->Objectives
.size() > loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
440 Objectives
=ql
->Objectives
[loc_idx
];
441 if (ql
->EndText
.size() > loc_idx
&& !ql
->EndText
[loc_idx
].empty())
442 EndText
=ql
->EndText
[loc_idx
];
446 data
<< uint64(npcGUID
);
447 data
<< uint64(0); // wotlk, something todo with quest sharing?
448 data
<< uint32(pQuest
->GetQuestId());
452 data
<< uint32(ActivateAccept
);
453 data
<< uint32(pQuest
->GetSuggestedPlayers());
454 data
<< uint8(0); // new wotlk
455 data
<< uint8(0); // new 3.1
457 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
459 data
<< uint32(0); // Rewarded chosen items hidden
460 data
<< uint32(0); // Rewarded items hidden
461 data
<< uint32(0); // Rewarded money hidden
465 ItemPrototype
const* IProto
;
467 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
468 for (uint32 i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
470 if ( !pQuest
->RewChoiceItemId
[i
] ) continue;
471 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
472 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
473 IProto
= objmgr
.GetItemPrototype(pQuest
->RewChoiceItemId
[i
]);
475 data
<< uint32(IProto
->DisplayInfoID
);
477 data
<< uint32( 0x00 );
480 data
<< uint32(pQuest
->GetRewItemsCount());
481 for (uint32 i
=0; i
< QUEST_REWARDS_COUNT
; ++i
)
483 if ( !pQuest
->RewItemId
[i
] ) continue;
484 data
<< uint32(pQuest
->RewItemId
[i
]);
485 data
<< uint32(pQuest
->RewItemCount
[i
]);
486 IProto
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
488 data
<< uint32(IProto
->DisplayInfoID
);
493 data
<< uint32(pQuest
->GetRewOrReqMoney());
496 // rewarded honor points. Multiply with 10 to satisfy client
497 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
498 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
499 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
500 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
501 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
503 data
<< uint32(QUEST_EMOTE_COUNT
);
504 for (uint32 i
=0; i
< QUEST_EMOTE_COUNT
; ++i
)
506 data
<< uint32(pQuest
->DetailsEmote
[i
]);
507 data
<< uint32(pQuest
->DetailsEmoteDelay
[i
]); // DetailsEmoteDelay (in ms)
509 pSession
->SendPacket( &data
);
511 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId());
514 void PlayerMenu::SendQuestQueryResponse( Quest
const *pQuest
)
516 std::string Title
,Details
,Objectives
,EndText
;
517 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
518 Title
= pQuest
->GetTitle();
519 Details
= pQuest
->GetDetails();
520 Objectives
= pQuest
->GetObjectives();
521 EndText
= pQuest
->GetEndText();
522 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;++i
)
523 ObjectiveText
[i
]=pQuest
->ObjectiveText
[i
];
525 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
528 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
531 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
532 Title
=ql
->Title
[loc_idx
];
533 if (ql
->Details
.size() > loc_idx
&& !ql
->Details
[loc_idx
].empty())
534 Details
=ql
->Details
[loc_idx
];
535 if (ql
->Objectives
.size() > loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
536 Objectives
=ql
->Objectives
[loc_idx
];
537 if (ql
->EndText
.size() > loc_idx
&& !ql
->EndText
[loc_idx
].empty())
538 EndText
=ql
->EndText
[loc_idx
];
540 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;++i
)
541 if (ql
->ObjectiveText
[i
].size() > loc_idx
&& !ql
->ObjectiveText
[i
][loc_idx
].empty())
542 ObjectiveText
[i
]=ql
->ObjectiveText
[i
][loc_idx
];
546 WorldPacket
data( SMSG_QUEST_QUERY_RESPONSE
, 100 ); // guess size
548 data
<< uint32(pQuest
->GetQuestId());
549 data
<< uint32(pQuest
->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
550 data
<< uint32(pQuest
->GetQuestLevel()); // may be 0, static data, in other cases must be used dynamic level: Player::GetQuestLevel
551 data
<< uint32(pQuest
->GetZoneOrSort()); // zone or sort to display in quest log
553 data
<< uint32(pQuest
->GetType());
554 data
<< uint32(pQuest
->GetSuggestedPlayers());
556 data
<< uint32(pQuest
->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
557 data
<< uint32(pQuest
->GetRepObjectiveValue()); // shown in quest log as part of quest objective
559 data
<< uint32(0); // RequiredOpositeRepFaction
560 data
<< uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
562 data
<< uint32(pQuest
->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
564 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
565 data
<< uint32(0); // Hide money rewarded
567 data
<< uint32(pQuest
->GetRewOrReqMoney());
569 data
<< uint32(pQuest
->GetRewMoneyMaxLevel()); // used in XP calculation at client
570 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
571 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
573 // rewarded honor points
574 data
<< uint32(MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
575 data
<< uint32(pQuest
->GetSrcItemId());
576 data
<< uint32(pQuest
->GetFlags() & 0xFFFF);
577 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
578 data
<< uint32(pQuest
->GetPlayersSlain()); // players slain
579 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
583 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
585 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
586 data
<< uint32(0) << uint32(0);
587 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
588 data
<< uint32(0) << uint32(0);
592 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
594 data
<< uint32(pQuest
->RewItemId
[iI
]);
595 data
<< uint32(pQuest
->RewItemCount
[iI
]);
597 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
599 data
<< uint32(pQuest
->RewChoiceItemId
[iI
]);
600 data
<< uint32(pQuest
->RewChoiceItemCount
[iI
]);
604 data
<< pQuest
->GetPointMapId();
605 data
<< pQuest
->GetPointX();
606 data
<< pQuest
->GetPointY();
607 data
<< pQuest
->GetPointOpt();
614 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
616 if (pQuest
->ReqCreatureOrGOId
[iI
] < 0)
618 // client expected gameobject template id in form (id|0x80000000)
619 data
<< uint32((pQuest
->ReqCreatureOrGOId
[iI
]*(-1))|0x80000000);
623 data
<< uint32(pQuest
->ReqCreatureOrGOId
[iI
]);
625 data
<< uint32(pQuest
->ReqCreatureOrGOCount
[iI
]);
626 data
<< uint32(pQuest
->ReqSourceId
[iI
]);
629 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
631 data
<< uint32(pQuest
->ReqItemId
[iI
]);
632 data
<< uint32(pQuest
->ReqItemCount
[iI
]);
635 data
<< uint32(0); // TODO: 5 item objective
638 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
639 data
<< ObjectiveText
[iI
];
641 pSession
->SendPacket( &data
);
642 sLog
.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest
->GetQuestId() );
645 void PlayerMenu::SendQuestGiverOfferReward( Quest
const* pQuest
, uint64 npcGUID
, bool EnableNext
)
647 std::string Title
= pQuest
->GetTitle();
648 std::string OfferRewardText
= pQuest
->GetOfferRewardText();
650 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
653 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
656 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
657 Title
=ql
->Title
[loc_idx
];
658 if (ql
->OfferRewardText
.size() > loc_idx
&& !ql
->OfferRewardText
[loc_idx
].empty())
659 OfferRewardText
=ql
->OfferRewardText
[loc_idx
];
663 WorldPacket
data( SMSG_QUESTGIVER_OFFER_REWARD
, 50 ); // guess size
666 data
<< pQuest
->GetQuestId();
668 data
<< OfferRewardText
;
670 data
<< uint32( EnableNext
);
671 data
<< uint32(0); // unk
673 uint32 EmoteCount
= 0;
674 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
676 if(pQuest
->OfferRewardEmote
[i
] <= 0)
681 data
<< EmoteCount
; // Emote Count
682 for (uint32 i
= 0; i
< EmoteCount
; ++i
)
684 data
<< uint32(pQuest
->OfferRewardEmoteDelay
[i
]); // Delay Emote
685 data
<< uint32(pQuest
->OfferRewardEmote
[i
]);
688 ItemPrototype
const *pItem
;
690 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
691 for (uint32 i
=0; i
< pQuest
->GetRewChoiceItemsCount(); ++i
)
693 pItem
= objmgr
.GetItemPrototype( pQuest
->RewChoiceItemId
[i
] );
695 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
696 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
699 data
<< uint32(pItem
->DisplayInfoID
);
704 data
<< uint32(pQuest
->GetRewItemsCount());
705 for (uint16 i
=0; i
< pQuest
->GetRewItemsCount(); ++i
)
707 pItem
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
708 data
<< uint32(pQuest
->RewItemId
[i
]);
709 data
<< uint32(pQuest
->RewItemCount
[i
]);
712 data
<< uint32(pItem
->DisplayInfoID
);
717 data
<< uint32(pQuest
->GetRewOrReqMoney());
719 // rewarded honor points. Multiply with 10 to satisfy client
720 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
721 data
<< uint32(0x08); // unused by client?
722 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
723 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
724 data
<< uint32(0); // unknown
725 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
726 pSession
->SendPacket( &data
);
727 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );
730 void PlayerMenu::SendQuestGiverRequestItems( Quest
const *pQuest
, uint64 npcGUID
, bool Completable
, bool CloseOnCancel
)
732 // We can always call to RequestItems, but this packet only goes out if there are actually
733 // items. Otherwise, we'll skip straight to the OfferReward
735 std::string Title
= pQuest
->GetTitle();
736 std::string RequestItemsText
= pQuest
->GetRequestItemsText();
738 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
741 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
744 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
745 Title
=ql
->Title
[loc_idx
];
746 if (ql
->RequestItemsText
.size() > loc_idx
&& !ql
->RequestItemsText
[loc_idx
].empty())
747 RequestItemsText
=ql
->RequestItemsText
[loc_idx
];
751 if (!pQuest
->GetReqItemsCount() && Completable
)
753 SendQuestGiverOfferReward(pQuest
, npcGUID
, true);
757 WorldPacket
data( SMSG_QUESTGIVER_REQUEST_ITEMS
, 50 ); // guess size
759 data
<< pQuest
->GetQuestId();
761 data
<< RequestItemsText
;
763 data
<< uint32(0x00); // unknown
766 data
<< pQuest
->GetCompleteEmote();
768 data
<< pQuest
->GetIncompleteEmote();
770 // Close Window after cancel
772 data
<< uint32(0x01);
774 data
<< uint32(0x00);
776 data
<< uint32(0x00); // unknown
779 data
<< uint32(pQuest
->GetRewOrReqMoney() < 0 ? -pQuest
->GetRewOrReqMoney() : 0);
781 data
<< uint32( pQuest
->GetReqItemsCount() );
782 ItemPrototype
const *pItem
;
783 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
785 if ( !pQuest
->ReqItemId
[i
] ) continue;
786 pItem
= objmgr
.GetItemPrototype(pQuest
->ReqItemId
[i
]);
787 data
<< uint32(pQuest
->ReqItemId
[i
]);
788 data
<< uint32(pQuest
->ReqItemCount
[i
]);
791 data
<< uint32(pItem
->DisplayInfoID
);
797 data
<< uint32(0x00);
799 data
<< uint32(0x03);
801 data
<< uint32(0x04);
802 data
<< uint32(0x08);
803 data
<< uint32(0x10);
805 pSession
->SendPacket( &data
);
806 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );