TrinityCore
Loading...
Searching...
No Matches
GossipDef.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYCORE_GOSSIP_H
19#define TRINITYCORE_GOSSIP_H
20
21#include "Common.h"
22#include "Duration.h"
23#include "ObjectGuid.h"
24#include "Optional.h"
25#include <variant>
26
27class Object;
28class Quest;
29class WorldSession;
30struct GossipMenuItems;
31enum class PlayerInteractionType : int32;
32enum class QuestGiverStatus : uint64;
33
34#define GOSSIP_MAX_MENU_ITEMS 32
35#define DEFAULT_GOSSIP_MESSAGE 0xffffff
36
38{
39 None = 0, // White chat bubble. Default
40 Vendor = 1, // Brown bag
41 Taxinode = 2, // White wing
42 Trainer = 3, // Brown book
43 SpiritHealer = 4, // Golden interaction wheel (with red center)
44 Binder = 5, // Golden interaction wheel
45 Banker = 6, // Brown bag (with gold coin in lower corner)
46 PetitionVendor = 7, // White chat bubble (with "..." inside)
47 GuildTabardVendor = 8, // White tabard
48 Battlemaster = 9, // Two crossed swords
49 Auctioneer = 10, // Stack of gold coins
50 TalentMaster = 11, // White chat bubble
51 Stablemaster = 12, // White chat bubble
52 PetSpecializationMaster = 13, /*DEPRECATED*/ // White chat bubble
53 GuildBanker = 14, // White chat bubble
54 Spellclick = 15, // White chat bubble
55 DisableXPGain = 16, // White chat bubble
56 EnableXPGain = 17, // White chat bubble
57 Mailbox = 18, // White chat bubble
58 WorldPvPQueue = 19, /*NYI*/ // White chat bubble
59 LFGDungeon = 20, /*NYI*/ // White chat bubble
60 ArtifactRespec = 21, /*NYI*/ // White chat bubble
61 CemeterySelect = 22, /*DEPRECATED*/ // White chat bubble
62 SpecializationMaster = 23, /*DEPRECATED*/ // White chat bubble
63 GlyphMaster = 24, /*DEPRECATED*/ // White chat bubble
64 QueueScenario = 25, /*NYI*/ // White chat bubble
65 GarrisonArchitect = 26, /*NYI*/ // White chat bubble
66 GarrisonMissionNpc = 27, /*NYI*/ // White chat bubble
67 ShipmentCrafter = 28, /*NYI*/ // Brown document
68 GarrisonTradeskillNpc = 29, /*NYI*/ // White chat bubble
69 GarrisonRecruitment = 30, /*NYI*/ // White chat bubble
70 AdventureMap = 31, /*NYI*/ // White chat bubble
71 GarrisonTalent = 32, // White chat bubble
72 ContributionCollector = 33, /*NYI*/ // White chat bubble
73 Transmogrify = 34, // Purple helm
74 AzeriteRespec = 35, // White chat bubble
75 IslandsMissionNpc = 36, /*NYI*/ // White chat bubble
76 UIItemInteraction = 37, /*NYI*/ // White chat bubble
77 WorldMap = 38, /*NYI*/ // White chat bubble
78 Soulbind = 39, /*NYI*/ // White chat bubble
79 ChromieTimeNpc = 40, /*NYI*/ // White chat bubble
80 CovenantPreviewNpc = 41, /*NYI*/ // White chat bubble
81 RuneforgeLegendaryCrafting = 42, /*NYI*/ // White chat bubble
82 NewPlayerGuide = 43, /*NYI*/ // White chat bubble
83 RuneforgeLegendaryUpgrade = 44, /*NYI*/ // White chat bubble
84 CovenantRenownNpc = 45, /*NYI*/ // White chat bubble
88 ProfessionsOpen = 49,
90 TraitSystem = 51,
91 BarbersChoice = 52,
94 ForgeMaster = 55,
95 CharacterBanker = 56,
96 AccountBanker = 57,
101 GuildRename = 62,
103 ItemUpgrade = 64,
104 HouseFinder = 65,
105 Placeholder6 = 66,
106
107 Count
108};
109
111{
112 Available = 0,
113 Unavailable = 1,
114 Locked = 2,
116};
117
119{
120 Item = 0,
121 Currency = 1
122};
123
125{
126 None = 0x0,
127 QuestLabelPrepend = 0x1,
130};
131
155
156// need an ordered container
157typedef std::vector<GossipMenuItem> GossipMenuItemContainer;
158
164
165typedef std::vector<QuestMenuItem> QuestMenuItemList;
166
168{
169 public:
170 GossipMenu();
171 GossipMenu(GossipMenu const&) = delete;
173 GossipMenu& operator=(GossipMenu const&) = delete;
176
177 uint32 AddMenuItem(int32 gossipOptionId, int32 orderIndex, GossipOptionNpc optionNpc, std::string optionText, uint32 language, GossipOptionFlags flags,
178 Optional<int32> gossipNpcOptionId, uint32 actionMenuId, uint32 actionPoiId, bool boxCoded, uint64 boxMoney,
179 std::string boxText, Optional<int32> spellId, Optional<int32> overrideIconId, uint32 sender, uint32 action);
180 void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
181 void AddMenuItem(GossipMenuItems const& menuItem, uint32 sender, uint32 action);
182
183 void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
184 uint32 GetMenuId() const { return _menuId; }
185 void SetLocale(LocaleConstant locale) { _locale = locale; }
186 LocaleConstant GetLocale() const { return _locale; }
187
189 {
190 return _menuItems.size();
191 }
192
193 bool Empty() const
194 {
195 return _menuItems.empty();
196 }
197
198 GossipMenuItem const* GetItem(int32 gossipOptionId) const;
199 GossipMenuItem const* GetItemByIndex(uint32 orderIndex) const;
200
201 uint32 GetMenuItemSender(uint32 orderIndex) const;
202 uint32 GetMenuItemAction(uint32 orderIndex) const;
203 bool IsMenuItemCoded(uint32 orderIndex) const;
204
205 void ClearMenu();
206
208 {
209 return _menuItems;
210 }
211
212 private:
216};
217
219{
220 public:
221 QuestMenu();
222 QuestMenu(QuestMenu const&) = delete;
223 QuestMenu(QuestMenu&&) = delete;
224 QuestMenu& operator=(QuestMenu const&) = delete;
227
228 void AddMenuItem(uint32 QuestId, uint8 Icon);
229 void ClearMenu();
230 uint8 GetMenuItemCount() const{ return uint8(_questMenuItems.size()); }
231 bool Empty() const { return _questMenuItems.empty(); }
232 bool HasItem(uint32 questId) const;
233 QuestMenuItem const& GetItem(uint16 index) const { return _questMenuItems[index]; }
234
235 private:
237};
238
240{
241public:
242 PlayerChoiceData() = default;
243 explicit PlayerChoiceData(uint32 choiceId) : _choiceId(choiceId) { }
244
245 uint32 GetChoiceId() const { return _choiceId; }
246 void SetChoiceId(uint32 choiceId) { _choiceId = choiceId; }
247
248 Optional<uint32> FindIdByClientIdentifier(uint16 clientIdentifier) const;
249 void AddResponse(uint32 id, uint16 clientIdentifier);
250
252 void SetExpireTime(Optional<SystemTimePoint> expireTime) { _expireTime = expireTime; }
253
254private:
255 struct Response
256 {
259 };
260
262 std::vector<Response> _responses;
264};
265
267{
268 template <typename>
269 struct TaggedId
270 {
271 TaggedId() = default;
272 explicit TaggedId(uint32 id) : Id(id) { }
273
274 uint32 Id = 0;
275 };
276
277 struct TrainerTag;
279
280public:
287
288 void StartInteraction(ObjectGuid target, PlayerInteractionType type);
289 bool IsInteractingWith(ObjectGuid target, PlayerInteractionType type) const { return SourceGuid == target && Type == type; }
290 void Reset();
291
294
295 TrainerData* GetTrainer() { return std::holds_alternative<TrainerData>(_data) ? &std::get<TrainerData>(_data) : nullptr; }
296
297 PlayerChoiceData* GetPlayerChoice() { return std::holds_alternative<PlayerChoiceData>(_data) ? &std::get<PlayerChoiceData>(_data) : nullptr; }
298
300 {
301 std::get<PlayerChoiceData>(_data).AddResponse(responseId, ++_playerChoiceResponseIdentifierGenerator);
302 return _playerChoiceResponseIdentifierGenerator;
303 }
304
305 bool IsLaunchedByQuest = false;
306
307private:
308 uint16 _playerChoiceResponseIdentifierGenerator = 0; // not reset between interactions
309 std::variant<std::monostate, TrainerData, PlayerChoiceData> _data;
310};
311
313{
314 public:
315 explicit PlayerMenu(WorldSession* session);
316 PlayerMenu(PlayerMenu const&) = delete;
318 PlayerMenu& operator=(PlayerMenu const&) = delete;
321
322 GossipMenu& GetGossipMenu() { return _gossipMenu; }
323 QuestMenu& GetQuestMenu() { return _questMenu; }
324 InteractionData& GetInteractionData() { return _interactionData; }
325
326 bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
327
328 void ClearMenus();
329 uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
330 uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
331 bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
332
333 void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID);
334 void SendCloseGossip();
335 void SendPointOfInterest(uint32 poiId) const;
336
337 /*********************************************************/
338 /*** QUEST SYSTEM ***/
339 /*********************************************************/
340 void SendQuestGiverStatus(QuestGiverStatus questStatus, ObjectGuid npcGUID) const;
341
342 void SendQuestGiverQuestListMessage(Object* questgiver);
343
344 void SendQuestQueryResponse(Quest const* quest) const;
345 void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool autoLaunched, bool displayPopup);
346
347 void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool autoLaunched);
348 void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool autoLaunched);
349
350 private:
355};
356#endif
LocaleConstant
Definition Common.h:51
PlayerInteractionType
Definition DBCEnums.h:2211
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
uint16 flags
std::vector< GossipMenuItem > GossipMenuItemContainer
Definition GossipDef.h:157
std::vector< QuestMenuItem > QuestMenuItemList
Definition GossipDef.h:165
GossipOptionNpc
Definition GossipDef.h:38
@ HousingOpenCharterConfirmation
@ HousingGetNeighborhoodCharter
@ HousingCreateGuildNeighborhood
GossipOptionRewardType
Definition GossipDef.h:119
GossipOptionStatus
Definition GossipDef.h:111
GossipOptionFlags
Definition GossipDef.h:125
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
QuestGiverStatus
Definition QuestDef.h:158
bool Empty() const
Definition GossipDef.h:193
void SetMenuId(uint32 menu_id)
Definition GossipDef.h:183
GossipMenu(GossipMenu &&)=delete
uint32 GetMenuItemCount() const
Definition GossipDef.h:188
GossipMenuItemContainer _menuItems
Definition GossipDef.h:213
void SetLocale(LocaleConstant locale)
Definition GossipDef.h:185
LocaleConstant GetLocale() const
Definition GossipDef.h:186
uint32 GetMenuId() const
Definition GossipDef.h:184
GossipMenu(GossipMenu const &)=delete
LocaleConstant _locale
Definition GossipDef.h:215
GossipMenuItemContainer const & GetMenuItems() const
Definition GossipDef.h:207
GossipMenu & operator=(GossipMenu const &)=delete
uint32 _menuId
Definition GossipDef.h:214
GossipMenu & operator=(GossipMenu &&)=delete
PlayerChoiceData * GetPlayerChoice()
Definition GossipDef.h:297
InteractionData(InteractionData const &other)
ObjectGuid SourceGuid
Definition GossipDef.h:292
uint16 AddPlayerChoiceResponse(uint32 responseId)
Definition GossipDef.h:299
InteractionData & operator=(InteractionData &&other) noexcept
InteractionData(InteractionData &&other) noexcept
InteractionData & operator=(InteractionData const &other)
bool IsInteractingWith(ObjectGuid target, PlayerInteractionType type) const
Definition GossipDef.h:289
TrainerData * GetTrainer()
Definition GossipDef.h:295
std::variant< std::monostate, TrainerData, PlayerChoiceData > _data
Definition GossipDef.h:309
Definition Item.h:179
void AddResponse(uint32 id, uint16 clientIdentifier)
PlayerChoiceData()=default
std::vector< Response > _responses
Definition GossipDef.h:262
void SetChoiceId(uint32 choiceId)
Definition GossipDef.h:246
Optional< uint32 > FindIdByClientIdentifier(uint16 clientIdentifier) const
void SetExpireTime(Optional< SystemTimePoint > expireTime)
Definition GossipDef.h:252
uint32 GetChoiceId() const
Definition GossipDef.h:245
Optional< SystemTimePoint > GetExpireTime() const
Definition GossipDef.h:251
Optional< SystemTimePoint > _expireTime
Definition GossipDef.h:263
PlayerChoiceData(uint32 choiceId)
Definition GossipDef.h:243
QuestMenu _questMenu
Definition GossipDef.h:352
PlayerMenu & operator=(PlayerMenu const &)=delete
InteractionData _interactionData
Definition GossipDef.h:354
PlayerMenu(PlayerMenu &&)=delete
QuestMenu & GetQuestMenu()
Definition GossipDef.h:323
bool IsGossipOptionCoded(uint32 selection) const
Definition GossipDef.h:331
GossipMenu _gossipMenu
Definition GossipDef.h:351
bool Empty() const
Definition GossipDef.h:326
InteractionData & GetInteractionData()
Definition GossipDef.h:324
PlayerMenu & operator=(PlayerMenu &&)=delete
WorldSession * _session
Definition GossipDef.h:353
uint32 GetGossipOptionSender(uint32 selection) const
Definition GossipDef.h:329
GossipMenu & GetGossipMenu()
Definition GossipDef.h:322
PlayerMenu(PlayerMenu const &)=delete
uint32 GetGossipOptionAction(uint32 selection) const
Definition GossipDef.h:330
QuestMenu(QuestMenu &&)=delete
QuestMenuItem const & GetItem(uint16 index) const
Definition GossipDef.h:233
bool Empty() const
Definition GossipDef.h:231
uint8 GetMenuItemCount() const
Definition GossipDef.h:230
QuestMenuItemList _questMenuItems
Definition GossipDef.h:236
QuestMenu & operator=(QuestMenu &&)=delete
QuestMenu(QuestMenu const &)=delete
QuestMenu & operator=(QuestMenu const &)=delete
Player session in the World.
uint32 Language
Definition GossipDef.h:138
Optional< int32 > GossipNpcOptionID
Definition GossipDef.h:140
uint32 OrderIndex
Definition GossipDef.h:135
GossipOptionNpc OptionNpc
Definition GossipDef.h:136
Optional< int32 > OverrideIconID
Definition GossipDef.h:145
uint32 ActionPoiID
Definition GossipDef.h:149
std::string OptionText
Definition GossipDef.h:137
uint32 ActionMenuID
Definition GossipDef.h:148
uint64 BoxMoney
Definition GossipDef.h:142
GossipOptionFlags Flags
Definition GossipDef.h:139
std::string BoxText
Definition GossipDef.h:143
int32 GossipOptionID
Definition GossipDef.h:134
Optional< int32 > SpellID
Definition GossipDef.h:144
uint32 QuestId
Definition GossipDef.h:161
uint8 QuestIcon
Definition GossipDef.h:162