2 * Copyright (C) 2005-2010 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
33 GossipMenu::~GossipMenu()
38 void GossipMenu::AddMenuItem(uint8 Icon
, const std::string
& Message
, uint32 dtSender
, uint32 dtAction
, const std::string
& BoxMessage
, uint32 BoxMoney
, bool Coded
)
40 ASSERT( m_gItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
45 gItem
.m_gMessage
= Message
;
46 gItem
.m_gCoded
= Coded
;
47 gItem
.m_gSender
= dtSender
;
48 gItem
.m_gOptionId
= dtAction
;
49 gItem
.m_gBoxMessage
= BoxMessage
;
50 gItem
.m_gBoxMoney
= BoxMoney
;
52 m_gItems
.push_back(gItem
);
55 void GossipMenu::AddGossipMenuItemData(uint32 action_menu
, uint32 action_poi
, uint32 action_script
)
57 GossipMenuItemData pItemData
;
59 pItemData
.m_gAction_menu
= action_menu
;
60 pItemData
.m_gAction_poi
= action_poi
;
61 pItemData
.m_gAction_script
= action_script
;
63 m_gItemsData
.push_back(pItemData
);
66 void GossipMenu::AddMenuItem(uint8 Icon
, const std::string
& Message
, bool Coded
)
68 AddMenuItem( Icon
, Message
, 0, 0, "", 0, Coded
);
71 void GossipMenu::AddMenuItem(uint8 Icon
, char const* Message
, bool Coded
)
73 AddMenuItem(Icon
, std::string(Message
? Message
: ""),Coded
);
76 void GossipMenu::AddMenuItem(uint8 Icon
, char const* Message
, uint32 dtSender
, uint32 dtAction
, char const* BoxMessage
, uint32 BoxMoney
, bool Coded
)
78 AddMenuItem(Icon
, std::string(Message
? Message
: ""), dtSender
, dtAction
, std::string(BoxMessage
? BoxMessage
: ""), BoxMoney
, Coded
);
81 uint32
GossipMenu::MenuItemSender( unsigned int ItemId
)
83 if ( ItemId
>= m_gItems
.size() ) return 0;
85 return m_gItems
[ ItemId
].m_gSender
;
88 uint32
GossipMenu::MenuItemAction( unsigned int ItemId
)
90 if ( ItemId
>= m_gItems
.size() ) return 0;
92 return m_gItems
[ ItemId
].m_gOptionId
;
95 bool GossipMenu::MenuItemCoded( unsigned int ItemId
)
97 if ( ItemId
>= m_gItems
.size() ) return 0;
99 return m_gItems
[ ItemId
].m_gCoded
;
102 void GossipMenu::ClearMenu()
105 m_gItemsData
.clear();
109 PlayerMenu::PlayerMenu( WorldSession
*session
) : pSession(session
)
113 PlayerMenu::~PlayerMenu()
118 void PlayerMenu::ClearMenus()
120 mGossipMenu
.ClearMenu();
121 mQuestMenu
.ClearMenu();
124 uint32
PlayerMenu::GossipOptionSender( unsigned int Selection
)
126 return mGossipMenu
.MenuItemSender( Selection
);
129 uint32
PlayerMenu::GossipOptionAction( unsigned int Selection
)
131 return mGossipMenu
.MenuItemAction( Selection
);
134 bool PlayerMenu::GossipOptionCoded( unsigned int Selection
)
136 return mGossipMenu
.MenuItemCoded( Selection
);
139 void PlayerMenu::SendGossipMenu(uint32 TitleTextId
, uint64 objectGUID
)
141 WorldPacket
data(SMSG_GOSSIP_MESSAGE
, (100)); // guess size
142 data
<< uint64(objectGUID
);
143 data
<< uint32(mGossipMenu
.GetMenuId()); // new 2.4.0
144 data
<< uint32(TitleTextId
);
145 data
<< uint32(mGossipMenu
.MenuItemCount()); // max count 0x10
147 for (uint32 iI
= 0; iI
< mGossipMenu
.MenuItemCount(); ++iI
)
149 GossipMenuItem
const& gItem
= mGossipMenu
.GetItem(iI
);
150 data
<< uint32( iI
);
151 data
<< uint8( gItem
.m_gIcon
);
152 data
<< uint8( gItem
.m_gCoded
); // makes pop up box password
153 data
<< uint32(gItem
.m_gBoxMoney
); // money required to open menu, 2.0.3
154 data
<< gItem
.m_gMessage
; // text for gossip item
155 data
<< gItem
.m_gBoxMessage
; // accept text (related to money) pop up box, 2.0.3
158 data
<< uint32( mQuestMenu
.MenuItemCount() ); // max count 0x20
160 for (uint32 iI
= 0; iI
< mQuestMenu
.MenuItemCount(); ++iI
)
162 QuestMenuItem
const& qItem
= mQuestMenu
.GetItem(iI
);
163 uint32 questID
= qItem
.m_qId
;
164 Quest
const* pQuest
= sObjectMgr
.GetQuestTemplate(questID
);
166 data
<< uint32(questID
);
167 data
<< uint32(qItem
.m_qIcon
);
168 data
<< int32(pQuest
->GetQuestLevel());
169 std::string Title
= pQuest
->GetTitle();
171 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
174 QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(questID
);
177 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
178 Title
=ql
->Title
[loc_idx
];
184 pSession
->SendPacket( &data
);
185 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) );
188 void PlayerMenu::CloseGossip()
190 WorldPacket
data( SMSG_GOSSIP_COMPLETE
, 0 );
191 pSession
->SendPacket( &data
);
193 //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_COMPLETE" );
197 void PlayerMenu::SendPointOfInterest( float X
, float Y
, uint32 Icon
, uint32 Flags
, uint32 Data
, char const * locName
)
199 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
202 data
<< uint32(Icon
);
203 data
<< uint32(Data
);
206 pSession
->SendPacket( &data
);
207 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
210 void PlayerMenu::SendPointOfInterest( uint32 poi_id
)
212 PointOfInterest
const* poi
= sObjectMgr
.GetPointOfInterest(poi_id
);
215 sLog
.outErrorDb("Requested send not existed POI (Id: %u), ignore.",poi_id
);
219 std::string icon_name
= poi
->icon_name
;
221 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
224 PointOfInterestLocale
const *pl
= sObjectMgr
.GetPointOfInterestLocale(poi_id
);
227 if (pl
->IconName
.size() > size_t(loc_idx
) && !pl
->IconName
[loc_idx
].empty())
228 icon_name
= pl
->IconName
[loc_idx
];
232 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
233 data
<< uint32(poi
->flags
);
234 data
<< float(poi
->x
);
235 data
<< float(poi
->y
);
236 data
<< uint32(poi
->icon
);
237 data
<< uint32(poi
->data
);
240 pSession
->SendPacket( &data
);
241 //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI");
244 void PlayerMenu::SendTalking( uint32 textID
)
246 GossipText
const* pGossip
= sObjectMgr
.GetGossipText(textID
);
248 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 100 ); // guess size
249 data
<< textID
; // can be < 0
253 for(uint32 i
= 0; i
< 8; ++i
)
256 data
<< "Greetings $N";
257 data
<< "Greetings $N";
269 std::string Text_0
[8],Text_1
[8];
270 for (int i
=0;i
<8;++i
)
272 Text_0
[i
]=pGossip
->Options
[i
].Text_0
;
273 Text_1
[i
]=pGossip
->Options
[i
].Text_1
;
275 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
278 NpcTextLocale
const *nl
= sObjectMgr
.GetNpcTextLocale(textID
);
281 for (int i
=0;i
<8;++i
)
283 if (nl
->Text_0
[i
].size() > (size_t)loc_idx
&& !nl
->Text_0
[i
][loc_idx
].empty())
284 Text_0
[i
]=nl
->Text_0
[i
][loc_idx
];
285 if (nl
->Text_1
[i
].size() > (size_t)loc_idx
&& !nl
->Text_1
[i
][loc_idx
].empty())
286 Text_1
[i
]=nl
->Text_1
[i
][loc_idx
];
290 for (int i
=0; i
<8; ++i
)
292 data
<< pGossip
->Options
[i
].Probability
;
294 if ( Text_0
[i
].empty() )
299 if ( Text_1
[i
].empty() )
304 data
<< pGossip
->Options
[i
].Language
;
306 for(int j
= 0; j
< 3; ++j
)
308 data
<< pGossip
->Options
[i
].Emotes
[j
]._Delay
;
309 data
<< pGossip
->Options
[i
].Emotes
[j
]._Emote
;
313 pSession
->SendPacket( &data
);
315 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
318 void PlayerMenu::SendTalking( char const * title
, char const * text
)
320 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 50 ); // guess size
322 for(uint32 i
= 0; i
< 8; ++i
)
336 pSession
->SendPacket( &data
);
338 sLog
.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
341 /*********************************************************/
342 /*** QUEST SYSTEM ***/
343 /*********************************************************/
345 QuestMenu::QuestMenu()
347 m_qItems
.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
350 QuestMenu::~QuestMenu()
355 void QuestMenu::AddMenuItem( uint32 QuestId
, uint8 Icon
)
357 Quest
const* qinfo
= sObjectMgr
.GetQuestTemplate(QuestId
);
360 ASSERT( m_qItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
364 qItem
.m_qId
= QuestId
;
365 qItem
.m_qIcon
= Icon
;
367 m_qItems
.push_back(qItem
);
370 bool QuestMenu::HasItem( uint32 questid
)
372 for (QuestMenuItemList::const_iterator i
= m_qItems
.begin(); i
!= m_qItems
.end(); ++i
)
374 if(i
->m_qId
==questid
)
382 void QuestMenu::ClearMenu()
387 void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote
, const std::string
& Title
, uint64 npcGUID
)
389 WorldPacket
data( SMSG_QUESTGIVER_QUEST_LIST
, 100 ); // guess size
390 data
<< uint64(npcGUID
);
392 data
<< uint32(eEmote
._Delay
); // player emote
393 data
<< uint32(eEmote
._Emote
); // NPC emote
395 size_t count_pos
= data
.wpos();
396 data
<< uint8 ( mQuestMenu
.MenuItemCount() );
398 for (; count
< mQuestMenu
.MenuItemCount(); ++count
)
400 QuestMenuItem
const& qmi
= mQuestMenu
.GetItem(count
);
402 uint32 questID
= qmi
.m_qId
;
403 Quest
const *pQuest
= sObjectMgr
.GetQuestTemplate(questID
);
406 std::string title
= pQuest
->GetTitle();
408 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
411 if(QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(questID
))
413 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
414 title
=ql
->Title
[loc_idx
];
418 data
<< uint32(questID
);
419 data
<< uint32(qmi
.m_qIcon
);
420 data
<< int32(pQuest
->GetQuestLevel());
424 data
.put
<uint8
>(count_pos
,count
);
425 pSession
->SendPacket( &data
);
426 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID
));
429 void PlayerMenu::SendQuestGiverStatus( uint8 questStatus
, uint64 npcGUID
)
431 WorldPacket
data( SMSG_QUESTGIVER_STATUS
, 9 );
432 data
<< uint64(npcGUID
);
433 data
<< uint8(questStatus
);
435 pSession
->SendPacket( &data
);
436 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID
), questStatus
);
439 void PlayerMenu::SendQuestGiverQuestDetails( Quest
const *pQuest
, uint64 npcGUID
, bool ActivateAccept
)
441 std::string Title
= pQuest
->GetTitle();
442 std::string Details
= pQuest
->GetDetails();
443 std::string Objectives
= pQuest
->GetObjectives();
445 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
448 QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId());
451 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
452 Title
=ql
->Title
[loc_idx
];
453 if (ql
->Details
.size() > (size_t)loc_idx
&& !ql
->Details
[loc_idx
].empty())
454 Details
=ql
->Details
[loc_idx
];
455 if (ql
->Objectives
.size() > (size_t)loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
456 Objectives
=ql
->Objectives
[loc_idx
];
460 WorldPacket
data(SMSG_QUESTGIVER_QUEST_DETAILS
, 100); // guess size
461 data
<< uint64(npcGUID
);
462 data
<< uint64(0); // wotlk, something todo with quest sharing?
463 data
<< uint32(pQuest
->GetQuestId());
467 data
<< uint8(ActivateAccept
? 1 : 0); // auto finish?
468 data
<< uint32(pQuest
->GetSuggestedPlayers());
469 data
<< uint8(0); // flags PvP
470 data
<< uint8(0); // value is sent back to server in quest accept packet
471 data
<< uint8(0); // auto accept?
473 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
475 data
<< uint32(0); // Rewarded chosen items hidden
476 data
<< uint32(0); // Rewarded items hidden
477 data
<< uint32(0); // Rewarded money hidden
478 data
<< uint32(0); // Rewarded XP hidden
482 ItemPrototype
const* IProto
;
484 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
486 for (uint32 i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
488 if (!pQuest
->RewChoiceItemId
[i
])
491 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
492 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
494 IProto
= ObjectMgr::GetItemPrototype(pQuest
->RewChoiceItemId
[i
]);
497 data
<< uint32(IProto
->DisplayInfoID
);
499 data
<< uint32(0x00);
502 data
<< uint32(pQuest
->GetRewItemsCount());
504 for (uint32 i
=0; i
< QUEST_REWARDS_COUNT
; ++i
)
506 if (!pQuest
->RewItemId
[i
])
509 data
<< uint32(pQuest
->RewItemId
[i
]);
510 data
<< uint32(pQuest
->RewItemCount
[i
]);
512 IProto
= ObjectMgr::GetItemPrototype(pQuest
->RewItemId
[i
]);
515 data
<< uint32(IProto
->DisplayInfoID
);
520 // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
521 if (pSession
->GetPlayer()->getLevel() >= sWorld
.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL
))
522 data
<< uint32(pQuest
->GetRewMoneyMaxLevel());
524 data
<< uint32(pQuest
->GetRewOrReqMoney());
526 data
<< uint32(pQuest
->XPValue(pSession
->GetPlayer()));
529 // TODO: fixme. rewarded honor points
530 data
<< uint32(pQuest
->GetRewHonorAddition());
531 data
<< float(pQuest
->GetRewHonorMultiplier()); // new 3.3.0
533 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
534 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
535 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
536 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
537 data
<< uint32(0); // bonus arena points
538 data
<< uint32(0); // rep reward show mask?
540 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
541 data
<< uint32(pQuest
->RewRepFaction
[i
]);
543 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
544 data
<< int32(pQuest
->RewRepValueId
[i
]);
546 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward reputation override. No bonus is expected given
548 //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
550 data
<< uint32(QUEST_EMOTE_COUNT
);
552 for (uint32 i
=0; i
< QUEST_EMOTE_COUNT
; ++i
)
554 data
<< uint32(pQuest
->DetailsEmote
[i
]);
555 data
<< uint32(pQuest
->DetailsEmoteDelay
[i
]); // DetailsEmoteDelay (in ms)
558 pSession
->SendPacket( &data
);
560 sLog
.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId());
563 // send only static data in this packet!
564 void PlayerMenu::SendQuestQueryResponse( Quest
const *pQuest
)
566 std::string Title
, Details
, Objectives
, EndText
, CompletedText
;
567 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
568 Title
= pQuest
->GetTitle();
569 Details
= pQuest
->GetDetails();
570 Objectives
= pQuest
->GetObjectives();
571 EndText
= pQuest
->GetEndText();
572 CompletedText
= pQuest
->GetCompletedText();
574 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
575 ObjectiveText
[i
] = pQuest
->ObjectiveText
[i
];
577 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
580 QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId());
583 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
584 Title
=ql
->Title
[loc_idx
];
585 if (ql
->Details
.size() > (size_t)loc_idx
&& !ql
->Details
[loc_idx
].empty())
586 Details
=ql
->Details
[loc_idx
];
587 if (ql
->Objectives
.size() > (size_t)loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
588 Objectives
=ql
->Objectives
[loc_idx
];
589 if (ql
->EndText
.size() > (size_t)loc_idx
&& !ql
->EndText
[loc_idx
].empty())
590 EndText
=ql
->EndText
[loc_idx
];
591 if (ql
->CompletedText
.size() > (size_t)loc_idx
&& !ql
->CompletedText
[loc_idx
].empty())
592 CompletedText
=ql
->CompletedText
[loc_idx
];
594 for (int i
= 0;i
< QUEST_OBJECTIVES_COUNT
; ++i
)
595 if (ql
->ObjectiveText
[i
].size() > (size_t)loc_idx
&& !ql
->ObjectiveText
[i
][loc_idx
].empty())
596 ObjectiveText
[i
] = ql
->ObjectiveText
[i
][loc_idx
];
600 WorldPacket
data( SMSG_QUEST_QUERY_RESPONSE
, 100 ); // guess size
602 data
<< uint32(pQuest
->GetQuestId()); // quest id
603 data
<< uint32(pQuest
->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
604 data
<< int32(pQuest
->GetQuestLevel()); // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevelForPlayer (0 is not known, but assuming this is no longer valid for quest intended for client)
605 data
<< uint32(pQuest
->GetMinLevel()); // min required level to obtain (added for 3.3). Assumed allowed (database) range is -1 to 255 (still using uint32, since negative value would not be of any known use for client)
606 data
<< uint32(pQuest
->GetZoneOrSort()); // zone or sort to display in quest log
608 data
<< uint32(pQuest
->GetType()); // quest type
609 data
<< uint32(pQuest
->GetSuggestedPlayers()); // suggested players count
611 data
<< uint32(pQuest
->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
612 data
<< uint32(pQuest
->GetRepObjectiveValue()); // shown in quest log as part of quest objective
614 data
<< uint32(0); // RequiredOpositeRepFaction
615 data
<< uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
617 data
<< uint32(pQuest
->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
618 data
<< uint32(pQuest
->GetRewXPId()); // column index in QuestXP.dbc (row based on quest level)
620 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
621 data
<< uint32(0); // Hide money rewarded
623 data
<< uint32(pQuest
->GetRewOrReqMoney()); // reward money (below max lvl)
625 data
<< uint32(pQuest
->GetRewMoneyMaxLevel()); // used in XP calculation at client
626 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
627 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
629 // rewarded honor points
630 data
<< uint32(pQuest
->GetRewHonorAddition());
631 data
<< float(pQuest
->GetRewHonorMultiplier()); // new reward honor (multipled by ~62 at client side)
633 data
<< uint32(pQuest
->GetSrcItemId()); // source item id
634 data
<< uint32(pQuest
->GetFlags() & 0xFFFF); // quest flags
635 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
636 data
<< uint32(pQuest
->GetPlayersSlain()); // players slain
637 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
638 data
<< uint32(0); // bonus arena points
639 data
<< uint32(0); // rew rep show mask?
643 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
645 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
646 data
<< uint32(0) << uint32(0);
647 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
648 data
<< uint32(0) << uint32(0);
652 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
654 data
<< uint32(pQuest
->RewItemId
[iI
]);
655 data
<< uint32(pQuest
->RewItemCount
[iI
]);
657 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
659 data
<< uint32(pQuest
->RewChoiceItemId
[iI
]);
660 data
<< uint32(pQuest
->RewChoiceItemCount
[iI
]);
664 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
665 data
<< uint32(pQuest
->RewRepFaction
[i
]);
667 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
668 data
<< int32(pQuest
->RewRepValueId
[i
]);
670 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward reputation override. No bonus is expected given
672 //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
674 data
<< pQuest
->GetPointMapId();
675 data
<< pQuest
->GetPointX();
676 data
<< pQuest
->GetPointY();
677 data
<< pQuest
->GetPointOpt();
683 data
<< CompletedText
; // display in quest objectives window once all objectives are completed
685 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
687 if (pQuest
->ReqCreatureOrGOId
[iI
] < 0)
689 // client expected gameobject template id in form (id|0x80000000)
690 data
<< uint32((pQuest
->ReqCreatureOrGOId
[iI
]*(-1))|0x80000000);
694 data
<< uint32(pQuest
->ReqCreatureOrGOId
[iI
]);
696 data
<< uint32(pQuest
->ReqCreatureOrGOCount
[iI
]);
697 data
<< uint32(pQuest
->ReqSourceId
[iI
]);
698 data
<< uint32(0); // req source count?
701 for (iI
= 0; iI
< QUEST_ITEM_OBJECTIVES_COUNT
; ++iI
)
703 data
<< uint32(pQuest
->ReqItemId
[iI
]);
704 data
<< uint32(pQuest
->ReqItemCount
[iI
]);
707 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
708 data
<< ObjectiveText
[iI
];
710 pSession
->SendPacket( &data
);
711 sLog
.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest
->GetQuestId() );
714 void PlayerMenu::SendQuestGiverOfferReward( Quest
const* pQuest
, uint64 npcGUID
, bool EnableNext
)
716 std::string Title
= pQuest
->GetTitle();
717 std::string OfferRewardText
= pQuest
->GetOfferRewardText();
719 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
722 QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId());
725 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
726 Title
=ql
->Title
[loc_idx
];
727 if (ql
->OfferRewardText
.size() > (size_t)loc_idx
&& !ql
->OfferRewardText
[loc_idx
].empty())
728 OfferRewardText
=ql
->OfferRewardText
[loc_idx
];
732 WorldPacket
data( SMSG_QUESTGIVER_OFFER_REWARD
, 50 ); // guess size
734 data
<< uint64(npcGUID
);
735 data
<< uint32(pQuest
->GetQuestId());
737 data
<< OfferRewardText
;
739 data
<< uint8(EnableNext
? 1 : 0); // Auto Finish?
740 data
<< uint32(0); // SuggestedGroupNum
742 uint32 EmoteCount
= 0;
743 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
745 if(pQuest
->OfferRewardEmote
[i
] <= 0)
750 data
<< EmoteCount
; // Emote Count
751 for (uint32 i
= 0; i
< EmoteCount
; ++i
)
753 data
<< uint32(pQuest
->OfferRewardEmoteDelay
[i
]); // Delay Emote
754 data
<< uint32(pQuest
->OfferRewardEmote
[i
]);
757 ItemPrototype
const *pItem
;
759 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
760 for (uint32 i
=0; i
< pQuest
->GetRewChoiceItemsCount(); ++i
)
762 pItem
= ObjectMgr::GetItemPrototype( pQuest
->RewChoiceItemId
[i
] );
764 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
765 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
768 data
<< uint32(pItem
->DisplayInfoID
);
773 data
<< uint32(pQuest
->GetRewItemsCount());
774 for (uint16 i
=0; i
< pQuest
->GetRewItemsCount(); ++i
)
776 pItem
= ObjectMgr::GetItemPrototype(pQuest
->RewItemId
[i
]);
777 data
<< uint32(pQuest
->RewItemId
[i
]);
778 data
<< uint32(pQuest
->RewItemCount
[i
]);
781 data
<< uint32(pItem
->DisplayInfoID
);
786 // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
787 if (pSession
->GetPlayer()->getLevel() >= sWorld
.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL
))
788 data
<< uint32(pQuest
->GetRewMoneyMaxLevel());
790 data
<< uint32(pQuest
->GetRewOrReqMoney());
792 data
<< uint32(pQuest
->XPValue(pSession
->GetPlayer())); // xp
794 // TODO: fixme. rewarded honor points. Multiply with 10 to satisfy client
795 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorAddition()));
796 data
<< float(pQuest
->GetRewHonorMultiplier());
798 data
<< uint32(0x08); // unused by client?
799 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
800 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
801 data
<< uint32(pQuest
->GetCharTitleId()); // character title
802 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
803 data
<< uint32(0); // bonus arena points
804 data
<< uint32(0); // rew rep show mask?
806 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
807 data
<< uint32(pQuest
->RewRepFaction
[i
]);
809 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
810 data
<< int32(pQuest
->RewRepValueId
[i
]);
812 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward reputation override. No diplomacy bonus is expected given, reward also does not display in chat window
814 //data << int32(pQuest->RewRepValue[i]);
816 pSession
->SendPacket( &data
);
817 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );
820 void PlayerMenu::SendQuestGiverRequestItems( Quest
const *pQuest
, uint64 npcGUID
, bool Completable
, bool CloseOnCancel
)
822 // We can always call to RequestItems, but this packet only goes out if there are actually
823 // items. Otherwise, we'll skip straight to the OfferReward
825 std::string Title
= pQuest
->GetTitle();
826 std::string RequestItemsText
= pQuest
->GetRequestItemsText();
828 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
831 QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId());
834 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
835 Title
=ql
->Title
[loc_idx
];
836 if (ql
->RequestItemsText
.size() > (size_t)loc_idx
&& !ql
->RequestItemsText
[loc_idx
].empty())
837 RequestItemsText
=ql
->RequestItemsText
[loc_idx
];
841 if (!pQuest
->GetReqItemsCount() && Completable
)
843 SendQuestGiverOfferReward(pQuest
, npcGUID
, true);
847 WorldPacket
data( SMSG_QUESTGIVER_REQUEST_ITEMS
, 50 ); // guess size
849 data
<< pQuest
->GetQuestId();
851 data
<< RequestItemsText
;
853 data
<< uint32(0x00); // emote delay
856 data
<< pQuest
->GetCompleteEmote(); // emote id
858 data
<< pQuest
->GetIncompleteEmote();
860 // Close Window after cancel
862 data
<< uint32(0x01); // auto finish?
864 data
<< uint32(0x00);
866 data
<< uint32(0x00); // SuggestedGroupNum
869 data
<< uint32(pQuest
->GetRewOrReqMoney() < 0 ? -pQuest
->GetRewOrReqMoney() : 0);
871 data
<< uint32( pQuest
->GetReqItemsCount() );
872 ItemPrototype
const *pItem
;
873 for (int i
= 0; i
< QUEST_ITEM_OBJECTIVES_COUNT
; ++i
)
875 if ( !pQuest
->ReqItemId
[i
] )
877 pItem
= ObjectMgr::GetItemPrototype(pQuest
->ReqItemId
[i
]);
878 data
<< uint32(pQuest
->ReqItemId
[i
]);
879 data
<< uint32(pQuest
->ReqItemCount
[i
]);
882 data
<< uint32(pItem
->DisplayInfoID
);
888 data
<< uint32(0x00);
890 data
<< uint32(0x03);
892 data
<< uint32(0x04);
893 data
<< uint32(0x08);
894 data
<< uint32(0x10);
896 pSession
->SendPacket( &data
);
897 sLog
.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );