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() )
86 return m_gItems
[ ItemId
].m_gSender
;
89 uint32
GossipMenu::MenuItemAction( unsigned int ItemId
)
91 if ( ItemId
>= m_gItems
.size() )
94 return m_gItems
[ ItemId
].m_gOptionId
;
97 bool GossipMenu::MenuItemCoded( unsigned int ItemId
)
99 if ( ItemId
>= m_gItems
.size() )
102 return m_gItems
[ ItemId
].m_gCoded
;
105 void GossipMenu::ClearMenu()
108 m_gItemsData
.clear();
112 PlayerMenu::PlayerMenu( WorldSession
*session
) : pSession(session
)
116 PlayerMenu::~PlayerMenu()
121 void PlayerMenu::ClearMenus()
123 mGossipMenu
.ClearMenu();
124 mQuestMenu
.ClearMenu();
127 uint32
PlayerMenu::GossipOptionSender( unsigned int Selection
)
129 return mGossipMenu
.MenuItemSender( Selection
);
132 uint32
PlayerMenu::GossipOptionAction( unsigned int Selection
)
134 return mGossipMenu
.MenuItemAction( Selection
);
137 bool PlayerMenu::GossipOptionCoded( unsigned int Selection
)
139 return mGossipMenu
.MenuItemCoded( Selection
);
142 void PlayerMenu::SendGossipMenu(uint32 TitleTextId
, uint64 objectGUID
)
144 WorldPacket
data(SMSG_GOSSIP_MESSAGE
, (100)); // guess size
145 data
<< uint64(objectGUID
);
146 data
<< uint32(mGossipMenu
.GetMenuId()); // new 2.4.0
147 data
<< uint32(TitleTextId
);
148 data
<< uint32(mGossipMenu
.MenuItemCount()); // max count 0x20
150 for (uint32 iI
= 0; iI
< mGossipMenu
.MenuItemCount(); ++iI
)
152 GossipMenuItem
const& gItem
= mGossipMenu
.GetItem(iI
);
153 data
<< uint32( iI
);
154 data
<< uint8( gItem
.m_gIcon
);
155 data
<< uint8( gItem
.m_gCoded
); // makes pop up box password
156 data
<< uint32(gItem
.m_gBoxMoney
); // money required to open menu, 2.0.3
157 data
<< gItem
.m_gMessage
; // text for gossip item, max 0x800
158 data
<< gItem
.m_gBoxMessage
; // accept text (related to money) pop up box, 2.0.3, max 0x800
161 data
<< uint32( mQuestMenu
.MenuItemCount() ); // max count 0x20
163 for (uint32 iI
= 0; iI
< mQuestMenu
.MenuItemCount(); ++iI
)
165 QuestMenuItem
const& qItem
= mQuestMenu
.GetItem(iI
);
166 uint32 questID
= qItem
.m_qId
;
167 Quest
const* pQuest
= sObjectMgr
.GetQuestTemplate(questID
);
169 data
<< uint32(questID
);
170 data
<< uint32(qItem
.m_qIcon
);
171 data
<< int32(pQuest
->GetQuestLevel());
172 data
<< uint32(pQuest
->GetFlags()); // 3.3.3 quest flags
173 data
<< uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
174 std::string Title
= pQuest
->GetTitle();
176 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
178 if (QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(questID
))
179 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
180 Title
= ql
->Title
[loc_idx
];
181 data
<< Title
; // max 0x200
184 pSession
->SendPacket( &data
);
185 //DEBUG_LOG( "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 //DEBUG_LOG( "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
200 data
<< uint32(Flags
);
203 data
<< uint32(Icon
);
204 data
<< uint32(Data
);
207 pSession
->SendPacket( &data
);
208 //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI");
211 void PlayerMenu::SendPointOfInterest( uint32 poi_id
)
213 PointOfInterest
const* poi
= sObjectMgr
.GetPointOfInterest(poi_id
);
216 sLog
.outErrorDb("Requested send not existed POI (Id: %u), ignore.",poi_id
);
220 std::string icon_name
= poi
->icon_name
;
222 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
224 if (PointOfInterestLocale
const *pl
= sObjectMgr
.GetPointOfInterestLocale(poi_id
))
225 if (pl
->IconName
.size() > size_t(loc_idx
) && !pl
->IconName
[loc_idx
].empty())
226 icon_name
= pl
->IconName
[loc_idx
];
228 WorldPacket
data( SMSG_GOSSIP_POI
, (4+4+4+4+4+10) ); // guess size
229 data
<< uint32(poi
->flags
);
230 data
<< float(poi
->x
);
231 data
<< float(poi
->y
);
232 data
<< uint32(poi
->icon
);
233 data
<< uint32(poi
->data
);
236 pSession
->SendPacket( &data
);
237 //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI");
240 void PlayerMenu::SendTalking( uint32 textID
)
242 GossipText
const* pGossip
= sObjectMgr
.GetGossipText(textID
);
244 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 100 ); // guess size
245 data
<< textID
; // can be < 0
249 for(uint32 i
= 0; i
< 8; ++i
)
252 data
<< "Greetings $N";
253 data
<< "Greetings $N";
265 std::string Text_0
[8], Text_1
[8];
266 for (int i
= 0; i
< 8; ++i
)
268 Text_0
[i
] = pGossip
->Options
[i
].Text_0
;
269 Text_1
[i
] = pGossip
->Options
[i
].Text_1
;
271 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
274 if (NpcTextLocale
const *nl
= sObjectMgr
.GetNpcTextLocale(textID
))
276 for (int i
= 0; i
< 8; ++i
)
278 if (nl
->Text_0
[i
].size() > (size_t)loc_idx
&& !nl
->Text_0
[i
][loc_idx
].empty())
279 Text_0
[i
] = nl
->Text_0
[i
][loc_idx
];
280 if (nl
->Text_1
[i
].size() > (size_t)loc_idx
&& !nl
->Text_1
[i
][loc_idx
].empty())
281 Text_1
[i
] = nl
->Text_1
[i
][loc_idx
];
285 for (int i
= 0; i
< 8; ++i
)
287 data
<< pGossip
->Options
[i
].Probability
;
289 if ( Text_0
[i
].empty() )
294 if ( Text_1
[i
].empty() )
299 data
<< pGossip
->Options
[i
].Language
;
301 for(int j
= 0; j
< 3; ++j
)
303 data
<< pGossip
->Options
[i
].Emotes
[j
]._Delay
;
304 data
<< pGossip
->Options
[i
].Emotes
[j
]._Emote
;
308 pSession
->SendPacket( &data
);
310 DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
313 void PlayerMenu::SendTalking( char const * title
, char const * text
)
315 WorldPacket
data( SMSG_NPC_TEXT_UPDATE
, 50 ); // guess size
317 for(uint32 i
= 0; i
< 8; ++i
)
331 pSession
->SendPacket( &data
);
333 DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " );
336 /*********************************************************/
337 /*** QUEST SYSTEM ***/
338 /*********************************************************/
340 QuestMenu::QuestMenu()
342 m_qItems
.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use
345 QuestMenu::~QuestMenu()
350 void QuestMenu::AddMenuItem( uint32 QuestId
, uint8 Icon
)
352 Quest
const* qinfo
= sObjectMgr
.GetQuestTemplate(QuestId
);
356 ASSERT( m_qItems
.size() <= GOSSIP_MAX_MENU_ITEMS
);
360 qItem
.m_qId
= QuestId
;
361 qItem
.m_qIcon
= Icon
;
363 m_qItems
.push_back(qItem
);
366 bool QuestMenu::HasItem( uint32 questid
)
368 for (QuestMenuItemList::const_iterator i
= m_qItems
.begin(); i
!= m_qItems
.end(); ++i
)
369 if(i
->m_qId
== questid
)
374 void QuestMenu::ClearMenu()
379 void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote
, const std::string
& Title
, uint64 npcGUID
)
381 WorldPacket
data( SMSG_QUESTGIVER_QUEST_LIST
, 100 ); // guess size
382 data
<< uint64(npcGUID
);
384 data
<< uint32(eEmote
._Delay
); // player emote
385 data
<< uint32(eEmote
._Emote
); // NPC emote
387 size_t count_pos
= data
.wpos();
388 data
<< uint8 ( mQuestMenu
.MenuItemCount() );
390 for (; count
< mQuestMenu
.MenuItemCount(); ++count
)
392 QuestMenuItem
const& qmi
= mQuestMenu
.GetItem(count
);
394 uint32 questID
= qmi
.m_qId
;
396 if(Quest
const *pQuest
= sObjectMgr
.GetQuestTemplate(questID
))
398 std::string title
= pQuest
->GetTitle();
400 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
403 if(QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(questID
))
405 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
406 title
= ql
->Title
[loc_idx
];
410 data
<< uint32(questID
);
411 data
<< uint32(qmi
.m_qIcon
);
412 data
<< int32(pQuest
->GetQuestLevel());
413 data
<< uint32(pQuest
->GetFlags()); // 3.3.3 quest flags
414 data
<< uint8(0); // 3.3.3 changes icon: blue question or yellow exclamation
418 data
.put
<uint8
>(count_pos
, count
);
419 pSession
->SendPacket( &data
);
420 DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID
));
423 void PlayerMenu::SendQuestGiverStatus( uint8 questStatus
, uint64 npcGUID
)
425 WorldPacket
data( SMSG_QUESTGIVER_STATUS
, 9 );
426 data
<< uint64(npcGUID
);
427 data
<< uint8(questStatus
);
429 pSession
->SendPacket( &data
);
430 DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID
), questStatus
);
433 void PlayerMenu::SendQuestGiverQuestDetails( Quest
const *pQuest
, uint64 npcGUID
, bool ActivateAccept
)
435 std::string Title
= pQuest
->GetTitle();
436 std::string Details
= pQuest
->GetDetails();
437 std::string Objectives
= pQuest
->GetObjectives();
439 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
442 if (QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId()))
444 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
445 Title
= ql
->Title
[loc_idx
];
446 if (ql
->Details
.size() > (size_t)loc_idx
&& !ql
->Details
[loc_idx
].empty())
447 Details
= ql
->Details
[loc_idx
];
448 if (ql
->Objectives
.size() > (size_t)loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
449 Objectives
= ql
->Objectives
[loc_idx
];
453 WorldPacket
data(SMSG_QUESTGIVER_QUEST_DETAILS
, 100); // guess size
454 data
<< uint64(npcGUID
);
455 data
<< uint64(0); // wotlk, something todo with quest sharing?
456 data
<< uint32(pQuest
->GetQuestId());
460 data
<< uint8(ActivateAccept
? 1 : 0); // auto finish
461 data
<< uint32(pQuest
->GetFlags()); // 3.3.3 questFlags
462 data
<< uint32(pQuest
->GetSuggestedPlayers());
463 data
<< uint8(0); // IsFinished? value is sent back to server in quest accept packet
465 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
467 data
<< uint32(0); // Rewarded chosen items hidden
468 data
<< uint32(0); // Rewarded items hidden
469 data
<< uint32(0); // Rewarded money hidden
470 data
<< uint32(0); // Rewarded XP hidden
474 ItemPrototype
const* IProto
;
476 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
478 for (uint32 i
= 0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
480 if (!pQuest
->RewChoiceItemId
[i
])
483 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
484 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
486 IProto
= ObjectMgr::GetItemPrototype(pQuest
->RewChoiceItemId
[i
]);
489 data
<< uint32(IProto
->DisplayInfoID
);
491 data
<< uint32(0x00);
494 data
<< uint32(pQuest
->GetRewItemsCount());
496 for (uint32 i
= 0; i
< QUEST_REWARDS_COUNT
; ++i
)
498 if (!pQuest
->RewItemId
[i
])
501 data
<< uint32(pQuest
->RewItemId
[i
]);
502 data
<< uint32(pQuest
->RewItemCount
[i
]);
504 IProto
= ObjectMgr::GetItemPrototype(pQuest
->RewItemId
[i
]);
507 data
<< uint32(IProto
->DisplayInfoID
);
512 // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
513 if (pSession
->GetPlayer()->getLevel() >= sWorld
.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL
))
514 data
<< uint32(pQuest
->GetRewMoneyMaxLevel());
516 data
<< uint32(pQuest
->GetRewOrReqMoney());
518 data
<< uint32(pQuest
->XPValue(pSession
->GetPlayer()));
521 // TODO: fixme. rewarded honor points
522 data
<< uint32(pQuest
->GetRewHonorAddition());
523 data
<< float(pQuest
->GetRewHonorMultiplier()); // new 3.3.0
525 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
526 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
527 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
528 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
529 data
<< uint32(0); // bonus arena points
530 data
<< uint32(0); // rep reward show mask?
532 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
533 data
<< uint32(pQuest
->RewRepFaction
[i
]);
535 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
536 data
<< int32(pQuest
->RewRepValueId
[i
]);
538 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward reputation override. No bonus is expected given
540 //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
542 data
<< uint32(QUEST_EMOTE_COUNT
);
544 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
546 data
<< uint32(pQuest
->DetailsEmote
[i
]);
547 data
<< uint32(pQuest
->DetailsEmoteDelay
[i
]); // DetailsEmoteDelay (in ms)
550 pSession
->SendPacket( &data
);
552 DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId());
555 // send only static data in this packet!
556 void PlayerMenu::SendQuestQueryResponse( Quest
const *pQuest
)
558 std::string Title
, Details
, Objectives
, EndText
, CompletedText
;
559 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
560 Title
= pQuest
->GetTitle();
561 Details
= pQuest
->GetDetails();
562 Objectives
= pQuest
->GetObjectives();
563 EndText
= pQuest
->GetEndText();
564 CompletedText
= pQuest
->GetCompletedText();
566 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
567 ObjectiveText
[i
] = pQuest
->ObjectiveText
[i
];
569 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
572 if (QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId()))
574 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
575 Title
= ql
->Title
[loc_idx
];
576 if (ql
->Details
.size() > (size_t)loc_idx
&& !ql
->Details
[loc_idx
].empty())
577 Details
= ql
->Details
[loc_idx
];
578 if (ql
->Objectives
.size() > (size_t)loc_idx
&& !ql
->Objectives
[loc_idx
].empty())
579 Objectives
= ql
->Objectives
[loc_idx
];
580 if (ql
->EndText
.size() > (size_t)loc_idx
&& !ql
->EndText
[loc_idx
].empty())
581 EndText
= ql
->EndText
[loc_idx
];
582 if (ql
->CompletedText
.size() > (size_t)loc_idx
&& !ql
->CompletedText
[loc_idx
].empty())
583 CompletedText
= ql
->CompletedText
[loc_idx
];
585 for (int i
= 0;i
< QUEST_OBJECTIVES_COUNT
; ++i
)
586 if (ql
->ObjectiveText
[i
].size() > (size_t)loc_idx
&& !ql
->ObjectiveText
[i
][loc_idx
].empty())
587 ObjectiveText
[i
] = ql
->ObjectiveText
[i
][loc_idx
];
591 WorldPacket
data( SMSG_QUEST_QUERY_RESPONSE
, 100 ); // guess size
593 data
<< uint32(pQuest
->GetQuestId()); // quest id
594 data
<< uint32(pQuest
->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
595 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)
596 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)
597 data
<< uint32(pQuest
->GetZoneOrSort()); // zone or sort to display in quest log
599 data
<< uint32(pQuest
->GetType()); // quest type
600 data
<< uint32(pQuest
->GetSuggestedPlayers()); // suggested players count
602 data
<< uint32(pQuest
->GetRepObjectiveFaction()); // shown in quest log as part of quest objective
603 data
<< uint32(pQuest
->GetRepObjectiveValue()); // shown in quest log as part of quest objective
605 data
<< uint32(0); // RequiredOpositeRepFaction
606 data
<< uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective)
608 data
<< uint32(pQuest
->GetNextQuestInChain()); // client will request this quest from NPC, if not 0
609 data
<< uint32(pQuest
->GetRewXPId()); // column index in QuestXP.dbc (row based on quest level)
611 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
612 data
<< uint32(0); // Hide money rewarded
614 data
<< uint32(pQuest
->GetRewOrReqMoney()); // reward money (below max lvl)
616 data
<< uint32(pQuest
->GetRewMoneyMaxLevel()); // used in XP calculation at client
617 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
618 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
620 // rewarded honor points
621 data
<< uint32(pQuest
->GetRewHonorAddition());
622 data
<< float(pQuest
->GetRewHonorMultiplier()); // new reward honor (multiplied by ~62 at client side)
624 data
<< uint32(pQuest
->GetSrcItemId()); // source item id
625 data
<< uint32(pQuest
->GetFlags() & 0xFFFF); // quest flags
626 data
<< uint32(pQuest
->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
627 data
<< uint32(pQuest
->GetPlayersSlain()); // players slain
628 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
629 data
<< uint32(0); // bonus arena points
630 data
<< uint32(0); // rew rep show mask?
634 if (pQuest
->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS
))
636 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
637 data
<< uint32(0) << uint32(0);
638 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
639 data
<< uint32(0) << uint32(0);
643 for (iI
= 0; iI
< QUEST_REWARDS_COUNT
; ++iI
)
645 data
<< uint32(pQuest
->RewItemId
[iI
]);
646 data
<< uint32(pQuest
->RewItemCount
[iI
]);
648 for (iI
= 0; iI
< QUEST_REWARD_CHOICES_COUNT
; ++iI
)
650 data
<< uint32(pQuest
->RewChoiceItemId
[iI
]);
651 data
<< uint32(pQuest
->RewChoiceItemCount
[iI
]);
655 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
656 data
<< uint32(pQuest
->RewRepFaction
[i
]);
658 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
659 data
<< int32(pQuest
->RewRepValueId
[i
]);
661 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward reputation override. No bonus is expected given
663 //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
665 data
<< pQuest
->GetPointMapId();
666 data
<< pQuest
->GetPointX();
667 data
<< pQuest
->GetPointY();
668 data
<< pQuest
->GetPointOpt();
674 data
<< CompletedText
; // display in quest objectives window once all objectives are completed
676 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
678 if (pQuest
->ReqCreatureOrGOId
[iI
] < 0)
680 // client expected gameobject template id in form (id|0x80000000)
681 data
<< uint32((pQuest
->ReqCreatureOrGOId
[iI
]*(-1))|0x80000000);
685 data
<< uint32(pQuest
->ReqCreatureOrGOId
[iI
]);
687 data
<< uint32(pQuest
->ReqCreatureOrGOCount
[iI
]);
688 data
<< uint32(pQuest
->ReqSourceId
[iI
]);
689 data
<< uint32(0); // req source count?
692 for (iI
= 0; iI
< QUEST_ITEM_OBJECTIVES_COUNT
; ++iI
)
694 data
<< uint32(pQuest
->ReqItemId
[iI
]);
695 data
<< uint32(pQuest
->ReqItemCount
[iI
]);
698 for (iI
= 0; iI
< QUEST_OBJECTIVES_COUNT
; ++iI
)
699 data
<< ObjectiveText
[iI
];
701 pSession
->SendPacket( &data
);
702 DEBUG_LOG( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest
->GetQuestId() );
705 void PlayerMenu::SendQuestGiverOfferReward( Quest
const* pQuest
, uint64 npcGUID
, bool EnableNext
)
707 std::string Title
= pQuest
->GetTitle();
708 std::string OfferRewardText
= pQuest
->GetOfferRewardText();
710 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
713 if (QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId()))
715 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
716 Title
= ql
->Title
[loc_idx
];
717 if (ql
->OfferRewardText
.size() > (size_t)loc_idx
&& !ql
->OfferRewardText
[loc_idx
].empty())
718 OfferRewardText
= ql
->OfferRewardText
[loc_idx
];
722 WorldPacket
data( SMSG_QUESTGIVER_OFFER_REWARD
, 50 ); // guess size
724 data
<< uint64(npcGUID
);
725 data
<< uint32(pQuest
->GetQuestId());
727 data
<< OfferRewardText
;
729 data
<< uint8(EnableNext
? 1 : 0); // Auto Finish
730 data
<< uint32(pQuest
->GetFlags()); // 3.3.3 questFlags
731 data
<< uint32(pQuest
->GetSuggestedPlayers()); // SuggestedGroupNum
733 uint32 EmoteCount
= 0;
734 for (uint32 i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
736 if(pQuest
->OfferRewardEmote
[i
] <= 0)
741 data
<< EmoteCount
; // Emote Count
742 for (uint32 i
= 0; i
< EmoteCount
; ++i
)
744 data
<< uint32(pQuest
->OfferRewardEmoteDelay
[i
]); // Delay Emote
745 data
<< uint32(pQuest
->OfferRewardEmote
[i
]);
748 ItemPrototype
const *pItem
;
750 data
<< uint32(pQuest
->GetRewChoiceItemsCount());
751 for (uint32 i
= 0; i
< pQuest
->GetRewChoiceItemsCount(); ++i
)
753 pItem
= ObjectMgr::GetItemPrototype( pQuest
->RewChoiceItemId
[i
] );
755 data
<< uint32(pQuest
->RewChoiceItemId
[i
]);
756 data
<< uint32(pQuest
->RewChoiceItemCount
[i
]);
759 data
<< uint32(pItem
->DisplayInfoID
);
764 data
<< uint32(pQuest
->GetRewItemsCount());
765 for (uint32 i
= 0; i
< pQuest
->GetRewItemsCount(); ++i
)
767 pItem
= ObjectMgr::GetItemPrototype(pQuest
->RewItemId
[i
]);
768 data
<< uint32(pQuest
->RewItemId
[i
]);
769 data
<< uint32(pQuest
->RewItemCount
[i
]);
772 data
<< uint32(pItem
->DisplayInfoID
);
777 // send rewMoneyMaxLevel explicit for max player level, else send RewOrReqMoney
778 if (pSession
->GetPlayer()->getLevel() >= sWorld
.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL
))
779 data
<< uint32(pQuest
->GetRewMoneyMaxLevel());
781 data
<< uint32(pQuest
->GetRewOrReqMoney());
783 data
<< uint32(pQuest
->XPValue(pSession
->GetPlayer())); // xp
785 // TODO: fixme. rewarded honor points. Multiply with 10 to satisfy client
786 data
<< uint32(10*MaNGOS::Honor::hk_honor_at_level(pSession
->GetPlayer()->getLevel(), pQuest
->GetRewHonorAddition()));
787 data
<< float(pQuest
->GetRewHonorMultiplier());
789 data
<< uint32(0x08); // unused by client?
790 data
<< uint32(pQuest
->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
791 data
<< uint32(pQuest
->GetRewSpellCast()); // casted spell
792 data
<< uint32(pQuest
->GetCharTitleId()); // character title
793 data
<< uint32(pQuest
->GetBonusTalents()); // bonus talents
794 data
<< uint32(0); // bonus arena points
795 data
<< uint32(0); // rew rep show mask?
797 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // reward factions ids
798 data
<< uint32(pQuest
->RewRepFaction
[i
]);
800 for(int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
) // columnid in QuestFactionReward.dbc (if negative, from second row)
801 data
<< int32(pQuest
->RewRepValueId
[i
]);
803 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
805 //data << int32(pQuest->RewRepValue[i]);
807 pSession
->SendPacket( &data
);
808 DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );
811 void PlayerMenu::SendQuestGiverRequestItems( Quest
const *pQuest
, uint64 npcGUID
, bool Completable
, bool CloseOnCancel
)
813 // We can always call to RequestItems, but this packet only goes out if there are actually
814 // items. Otherwise, we'll skip straight to the OfferReward
816 std::string Title
= pQuest
->GetTitle();
817 std::string RequestItemsText
= pQuest
->GetRequestItemsText();
819 int loc_idx
= pSession
->GetSessionDbLocaleIndex();
822 if (QuestLocale
const *ql
= sObjectMgr
.GetQuestLocale(pQuest
->GetQuestId()))
824 if (ql
->Title
.size() > (size_t)loc_idx
&& !ql
->Title
[loc_idx
].empty())
825 Title
= ql
->Title
[loc_idx
];
826 if (ql
->RequestItemsText
.size() > (size_t)loc_idx
&& !ql
->RequestItemsText
[loc_idx
].empty())
827 RequestItemsText
= ql
->RequestItemsText
[loc_idx
];
831 if (!pQuest
->GetReqItemsCount() && Completable
)
833 SendQuestGiverOfferReward(pQuest
, npcGUID
, true);
837 WorldPacket
data( SMSG_QUESTGIVER_REQUEST_ITEMS
, 50 ); // guess size
838 data
<< uint64(npcGUID
);
839 data
<< uint32(pQuest
->GetQuestId());
841 data
<< RequestItemsText
;
843 data
<< uint32(0x00); // emote delay
846 data
<< pQuest
->GetCompleteEmote(); // emote id
848 data
<< pQuest
->GetIncompleteEmote();
850 // Close Window after cancel
852 data
<< uint32(0x01); // auto finish
854 data
<< uint32(0x00);
856 data
<< uint32(pQuest
->GetFlags()); // 3.3.3 questFlags
857 data
<< uint32(pQuest
->GetSuggestedPlayers()); // SuggestedGroupNum
860 data
<< uint32(pQuest
->GetRewOrReqMoney() < 0 ? -pQuest
->GetRewOrReqMoney() : 0);
862 data
<< uint32( pQuest
->GetReqItemsCount() );
863 ItemPrototype
const *pItem
;
864 for (int i
= 0; i
< QUEST_ITEM_OBJECTIVES_COUNT
; ++i
)
866 if ( !pQuest
->ReqItemId
[i
] )
868 pItem
= ObjectMgr::GetItemPrototype(pQuest
->ReqItemId
[i
]);
869 data
<< uint32(pQuest
->ReqItemId
[i
]);
870 data
<< uint32(pQuest
->ReqItemCount
[i
]);
873 data
<< uint32(pItem
->DisplayInfoID
);
878 if ( !Completable
) // Completable = flags1 && flags2 && flags3 && flags4
879 data
<< uint32(0x00); // flags1
881 data
<< uint32(0x03);
883 data
<< uint32(0x04); // flags2
884 data
<< uint32(0x08); // flags3
885 data
<< uint32(0x10); // flags4
887 pSession
->SendPacket( &data
);
888 DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID
), pQuest
->GetQuestId() );