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 0x0F
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
456 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
458 data
<< uint32(0); // Rewarded chosen items hidden
459 data
<< uint32(0); // Rewarded items hidden
460 data
<< uint32(0); // Rewarded money hidden
464 ItemPrototype
const* IProto
;
466 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
467 for (uint32 i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
469 if ( !pQuest
->RewChoiceItemId
[i
] ) continue;
470 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
471 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
472 IProto
= objmgr
.GetItemPrototype(pQuest
->RewChoiceItemId
[i
]);
474 data
<< uint32(IProto
->DisplayInfoID
);
476 data
<< uint32( 0x00 );
479 data
<< uint32(pQuest
->GetRewItemsCount());
480 for (uint32 i
=0; i
< QUEST_REWARDS_COUNT
; ++i
)
482 if ( !pQuest
->RewItemId
[i
] ) continue;
483 data
<< uint32(pQuest
->RewItemId
[i
]);
484 data
<< uint32(pQuest
->RewItemCount
[i
]);
485 IProto
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
487 data
<< uint32(IProto
->DisplayInfoID
);
492 data
<< uint32(pQuest
->GetRewOrReqMoney());
495 // rewarded honor points. Multiply with 10 to satisfy client
496 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
497 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
498 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
499 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
500 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
502 data
<< uint32(QUEST_EMOTE_COUNT
);
503 for (uint32 i
=0; i
< QUEST_EMOTE_COUNT
; ++i
)
505 data
<< uint32(pQuest
->DetailsEmote
[i
]);
506 data
<< uint32(0); // DetailsEmoteDelay
508 pSession
->SendPacket( &data
);
510 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId());
513 void PlayerMenu::SendQuestQueryResponse( Quest
const *pQuest
)
515 std::string Title
,Details
,Objectives
,EndText
;
516 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
517 Title
= pQuest
->GetTitle();
518 Details
= pQuest
->GetDetails();
519 Objectives
= pQuest
->GetObjectives();
520 EndText
= pQuest
->GetEndText();
521 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;++i
)
522 ObjectiveText
[i
]=pQuest
->ObjectiveText
[i
];
524 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
527 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
530 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
531 Title
=ql
->Title
[loc_idx
];
532 if (ql
->Details
.size() > loc_idx
&& !ql
->Details
[loc_idx
].empty())
533 Details
=ql
->Details
[loc_idx
];
534 if (ql
->Objectives
.size() > loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
535 Objectives
=ql
->Objectives
[loc_idx
];
536 if (ql
->EndText
.size() > loc_idx
&& !ql
->EndText
[loc_idx
].empty())
537 EndText
=ql
->EndText
[loc_idx
];
539 for (int i
=0;i
<QUEST_OBJECTIVES_COUNT
;++i
)
540 if (ql
->ObjectiveText
[i
].size() > loc_idx
&& !ql
->ObjectiveText
[i
][loc_idx
].empty())
541 ObjectiveText
[i
]=ql
->ObjectiveText
[i
][loc_idx
];
545 WorldPacket
data( SMSG_QUEST_QUERY_RESPONSE
, 100 ); // guess size
547 data
<< uint32(pQuest
->GetQuestId());
548 data
<< uint32(pQuest
->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
549 data
<< uint32(pQuest
->GetQuestLevel()); // may be 0, static data, in other cases must be used dynamic level: Player::GetQuestLevel
550 data
<< uint32(pQuest
->GetZoneOrSort()); // zone or sort to display in quest log
552 data
<< uint32(pQuest
->GetType());
553 data
<< uint32(pQuest
->GetSuggestedPlayers());
555 data
<< uint32(pQuest
->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
556 data
<< uint32(pQuest
->GetRepObjectiveValue()); // shown in quest log as part of quest objective
558 data
<< uint32(0); // RequiredOpositeRepFaction
559 data
<< uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
561 data
<< uint32(pQuest
->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
563 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
564 data
<< uint32(0); // Hide money rewarded
566 data
<< uint32(pQuest
->GetRewOrReqMoney());
568 data
<< uint32(pQuest
->GetRewMoneyMaxLevel()); // used in XP calculation at client
569 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
570 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
572 // rewarded honor points
573 data
<< uint32(MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
574 data
<< uint32(pQuest
->GetSrcItemId());
575 data
<< uint32(pQuest
->GetFlags() & 0xFFFF);
576 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
577 data
<< uint32(pQuest
->GetPlayersSlain()); // players slain
578 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
582 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
584 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
585 data
<< uint32(0) << uint32(0);
586 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
587 data
<< uint32(0) << uint32(0);
591 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
593 data
<< uint32(pQuest
->RewItemId
[iI
]);
594 data
<< uint32(pQuest
->RewItemCount
[iI
]);
596 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
598 data
<< uint32(pQuest
->RewChoiceItemId
[iI
]);
599 data
<< uint32(pQuest
->RewChoiceItemCount
[iI
]);
603 data
<< pQuest
->GetPointMapId();
604 data
<< pQuest
->GetPointX();
605 data
<< pQuest
->GetPointY();
606 data
<< pQuest
->GetPointOpt();
613 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
615 if (pQuest
->ReqCreatureOrGOId
[iI
] < 0)
617 // client expected gameobject template id in form (id|0x80000000)
618 data
<< uint32((pQuest
->ReqCreatureOrGOId
[iI
]*(-1))|0x80000000);
622 data
<< uint32(pQuest
->ReqCreatureOrGOId
[iI
]);
624 data
<< uint32(pQuest
->ReqCreatureOrGOCount
[iI
]);
625 data
<< uint32(pQuest
->ReqSourceId
[iI
]);
628 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
630 data
<< uint32(pQuest
->ReqItemId
[iI
]);
631 data
<< uint32(pQuest
->ReqItemCount
[iI
]);
634 data
<< uint32(0); // TODO: 5 item objective
637 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
638 data
<< ObjectiveText
[iI
];
640 pSession
->SendPacket( &data
);
641 sLog
.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest
->GetQuestId() );
644 void PlayerMenu::SendQuestGiverOfferReward( Quest
const* pQuest
, uint64 npcGUID
, bool EnbleNext
)
646 std::string Title
= pQuest
->GetTitle();
647 std::string OfferRewardText
= pQuest
->GetOfferRewardText();
649 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
652 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
655 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
656 Title
=ql
->Title
[loc_idx
];
657 if (ql
->OfferRewardText
.size() > loc_idx
&& !ql
->OfferRewardText
[loc_idx
].empty())
658 OfferRewardText
=ql
->OfferRewardText
[loc_idx
];
662 WorldPacket
data( SMSG_QUESTGIVER_OFFER_REWARD
, 50 ); // guess size
665 data
<< pQuest
->GetQuestId();
667 data
<< OfferRewardText
;
669 data
<< uint32( EnbleNext
);
670 data
<< uint32(0); // unk
672 uint32 EmoteCount
= 0;
673 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
675 if(pQuest
->OfferRewardEmote
[i
] <= 0)
680 data
<< EmoteCount
; // Emote Count
681 for (uint32 i
= 0; i
< EmoteCount
; ++i
)
683 data
<< uint32(0); // Delay Emote
684 data
<< pQuest
->OfferRewardEmote
[i
];
687 ItemPrototype
const *pItem
;
689 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
690 for (uint32 i
=0; i
< pQuest
->GetRewChoiceItemsCount(); ++i
)
692 pItem
= objmgr
.GetItemPrototype( pQuest
->RewChoiceItemId
[i
] );
694 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
695 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
698 data
<< uint32(pItem
->DisplayInfoID
);
703 data
<< uint32(pQuest
->GetRewItemsCount());
704 for (uint16 i
=0; i
< pQuest
->GetRewItemsCount(); ++i
)
706 pItem
= objmgr
.GetItemPrototype(pQuest
->RewItemId
[i
]);
707 data
<< uint32(pQuest
->RewItemId
[i
]);
708 data
<< uint32(pQuest
->RewItemCount
[i
]);
711 data
<< uint32(pItem
->DisplayInfoID
);
716 data
<< uint32(pQuest
->GetRewOrReqMoney());
718 // rewarded honor points. Multiply with 10 to satisfy client
719 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorableKills()));
720 data
<< uint32(0x08); // unused by client?
721 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
722 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
723 data
<< uint32(0); // unknown
724 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
725 pSession
->SendPacket( &data
);
726 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );
729 void PlayerMenu::SendQuestGiverRequestItems( Quest
const *pQuest
, uint64 npcGUID
, bool Completable
, bool CloseOnCancel
)
731 // We can always call to RequestItems, but this packet only goes out if there are actually
732 // items. Otherwise, we'll skip straight to the OfferReward
734 std::string Title
= pQuest
->GetTitle();
735 std::string RequestItemsText
= pQuest
->GetRequestItemsText();
737 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
740 QuestLocale
const *ql
= objmgr
.GetQuestLocale(pQuest
->GetQuestId());
743 if (ql
->Title
.size() > loc_idx
&& !ql
->Title
[loc_idx
].empty())
744 Title
=ql
->Title
[loc_idx
];
745 if (ql
->RequestItemsText
.size() > loc_idx
&& !ql
->RequestItemsText
[loc_idx
].empty())
746 RequestItemsText
=ql
->RequestItemsText
[loc_idx
];
750 // We may wish a better check, perhaps checking the real quest requirements
751 if (RequestItemsText
.empty())
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() );