TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GossipDef.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITYCORE_GOSSIP_H
20 #define TRINITYCORE_GOSSIP_H
21 
22 #include "Common.h"
23 #include "ObjectGuid.h"
24 #include "QuestDef.h"
25 #include "NPCHandler.h"
26 
27 class WorldSession;
28 
29 #define GOSSIP_MAX_MENU_ITEMS 32
30 #define DEFAULT_GOSSIP_MESSAGE 0xffffff
31 
33 {
34  GOSSIP_OPTION_NONE = 0, //UNIT_NPC_FLAG_NONE (0)
35  GOSSIP_OPTION_GOSSIP = 1, //UNIT_NPC_FLAG_GOSSIP (1)
36  GOSSIP_OPTION_QUESTGIVER = 2, //UNIT_NPC_FLAG_QUESTGIVER (2)
37  GOSSIP_OPTION_VENDOR = 3, //UNIT_NPC_FLAG_VENDOR (128)
38  GOSSIP_OPTION_TAXIVENDOR = 4, //UNIT_NPC_FLAG_TAXIVENDOR (8192)
39  GOSSIP_OPTION_TRAINER = 5, //UNIT_NPC_FLAG_TRAINER (16)
40  GOSSIP_OPTION_SPIRITHEALER = 6, //UNIT_NPC_FLAG_SPIRITHEALER (16384)
41  GOSSIP_OPTION_SPIRITGUIDE = 7, //UNIT_NPC_FLAG_SPIRITGUIDE (32768)
42  GOSSIP_OPTION_INNKEEPER = 8, //UNIT_NPC_FLAG_INNKEEPER (65536)
43  GOSSIP_OPTION_BANKER = 9, //UNIT_NPC_FLAG_BANKER (131072)
44  GOSSIP_OPTION_PETITIONER = 10, //UNIT_NPC_FLAG_PETITIONER (262144)
45  GOSSIP_OPTION_TABARDDESIGNER = 11, //UNIT_NPC_FLAG_TABARDDESIGNER (524288)
46  GOSSIP_OPTION_BATTLEFIELD = 12, //UNIT_NPC_FLAG_BATTLEFIELDPERSON (1048576)
47  GOSSIP_OPTION_AUCTIONEER = 13, //UNIT_NPC_FLAG_AUCTIONEER (2097152)
48  GOSSIP_OPTION_STABLEPET = 14, //UNIT_NPC_FLAG_STABLE (4194304)
49  GOSSIP_OPTION_ARMORER = 15, //UNIT_NPC_FLAG_ARMORER (4096)
50  GOSSIP_OPTION_UNLEARNTALENTS = 16, //UNIT_NPC_FLAG_TRAINER (16) (bonus option for GOSSIP_OPTION_TRAINER)
51  GOSSIP_OPTION_UNLEARNPETTALENTS = 17, //UNIT_NPC_FLAG_TRAINER (16) (bonus option for GOSSIP_OPTION_TRAINER)
52  GOSSIP_OPTION_LEARNDUALSPEC = 18, //UNIT_NPC_FLAG_TRAINER (16) (bonus option for GOSSIP_OPTION_TRAINER)
53  GOSSIP_OPTION_OUTDOORPVP = 19, //added by code (option for outdoor pvp creatures)
55 };
56 
58 {
59  GOSSIP_ICON_CHAT = 0, // white chat bubble
60  GOSSIP_ICON_VENDOR = 1, // brown bag
61  GOSSIP_ICON_TAXI = 2, // flightmarker (paperplane)
62  GOSSIP_ICON_TRAINER = 3, // brown book (trainer)
63  GOSSIP_ICON_INTERACT_1 = 4, // golden interaction wheel
64  GOSSIP_ICON_INTERACT_2 = 5, // golden interaction wheel
65  GOSSIP_ICON_MONEY_BAG = 6, // brown bag (with gold coin in lower corner)
66  GOSSIP_ICON_TALK = 7, // white chat bubble (with "..." inside)
67  GOSSIP_ICON_TABARD = 8, // white tabard
68  GOSSIP_ICON_BATTLE = 9, // two crossed swords
69  GOSSIP_ICON_DOT = 10, // yellow dot/point
70  GOSSIP_ICON_CHAT_11 = 11, // white chat bubble
71  GOSSIP_ICON_CHAT_12 = 12, // white chat bubble
72  GOSSIP_ICON_CHAT_13 = 13, // white chat bubble
73  GOSSIP_ICON_UNK_14 = 14, // INVALID - DO NOT USE
74  GOSSIP_ICON_UNK_15 = 15, // INVALID - DO NOT USE
75  GOSSIP_ICON_CHAT_16 = 16, // white chat bubble
76  GOSSIP_ICON_CHAT_17 = 17, // white chat bubble
77  GOSSIP_ICON_CHAT_18 = 18, // white chat bubble
78  GOSSIP_ICON_CHAT_19 = 19, // white chat bubble
79  GOSSIP_ICON_CHAT_20 = 20, // white chat bubble
80  GOSSIP_ICON_CHAT_21 = 21, // transmogrifier?
82 };
83 
84 //POI icons. Many more exist, list not complete.
86 {
87  ICON_POI_BLANK = 0, // Blank (not visible)
88  ICON_POI_GREY_AV_MINE = 1, // Grey mine lorry
89  ICON_POI_RED_AV_MINE = 2, // Red mine lorry
90  ICON_POI_BLUE_AV_MINE = 3, // Blue mine lorry
91  ICON_POI_BWTOMB = 4, // Blue and White Tomb Stone
92  ICON_POI_SMALL_HOUSE = 5, // Small house
93  ICON_POI_GREYTOWER = 6, // Grey Tower
94  ICON_POI_REDFLAG = 7, // Red Flag w/Yellow !
95  ICON_POI_TOMBSTONE = 8, // Normal tomb stone (brown)
96  ICON_POI_BWTOWER = 9, // Blue and White Tower
97  ICON_POI_REDTOWER = 10, // Red Tower
98  ICON_POI_BLUETOWER = 11, // Blue Tower
99  ICON_POI_RWTOWER = 12, // Red and White Tower
100  ICON_POI_REDTOMB = 13, // Red Tomb Stone
101  ICON_POI_RWTOMB = 14, // Red and White Tomb Stone
102  ICON_POI_BLUETOMB = 15, // Blue Tomb Stone
103  ICON_POI_16 = 16, // Grey ?
104  ICON_POI_17 = 17, // Blue/White ?
105  ICON_POI_18 = 18, // Blue ?
106  ICON_POI_19 = 19, // Red and White ?
107  ICON_POI_20 = 20, // Red ?
108  ICON_POI_GREYLOGS = 21, // Grey Wood Logs
109  ICON_POI_BWLOGS = 22, // Blue and White Wood Logs
110  ICON_POI_BLUELOGS = 23, // Blue Wood Logs
111  ICON_POI_RWLOGS = 24, // Red and White Wood Logs
112  ICON_POI_REDLOGS = 25, // Red Wood Logs
113  ICON_POI_26 = 26, // Grey ?
114  ICON_POI_27 = 27, // Blue and White ?
115  ICON_POI_28 = 28, // Blue ?
116  ICON_POI_29 = 29, // Red and White ?
117  ICON_POI_30 = 30, // Red ?
118  ICON_POI_GREYHOUSE = 31, // Grey House
119  ICON_POI_BWHOUSE = 32, // Blue and White House
120  ICON_POI_BLUEHOUSE = 33, // Blue House
121  ICON_POI_RWHOUSE = 34, // Red and White House
122  ICON_POI_REDHOUSE = 35, // Red House
123  ICON_POI_GREYHORSE = 36, // Grey Horse
124  ICON_POI_BWHORSE = 37, // Blue and White Horse
125  ICON_POI_BLUEHORSE = 38, // Blue Horse
126  ICON_POI_RWHORSE = 39, // Red and White Horse
127  ICON_POI_REDHORSE = 40 // Red Horse
128 };
129 
131 {
133  bool IsCoded;
134  std::string Message;
137  std::string BoxMessage;
139 };
140 
141 // need an ordered container
142 typedef std::map<uint32, GossipMenuItem> GossipMenuItemContainer;
143 
145 {
146  uint32 GossipActionMenuId; // MenuId of the gossip triggered by this action
148 };
149 
150 // need an ordered container
151 typedef std::map<uint32, GossipMenuItemData> GossipMenuItemDataContainer;
152 
154 {
157 };
158 
159 typedef std::vector<QuestMenuItem> QuestMenuItemList;
160 
162 {
163  public:
164  GossipMenu();
165  ~GossipMenu();
166 
167  void AddMenuItem(int32 menuItemId, uint8 icon, std::string const& message, uint32 sender, uint32 action, std::string const& boxMessage, uint32 boxMoney, bool coded = false);
168  void AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, uint32 action);
169 
170  void SetMenuId(uint32 menu_id) { _menuId = menu_id; }
171  uint32 GetMenuId() const { return _menuId; }
172  void SetSenderGUID(ObjectGuid guid) { _senderGUID = guid; }
173  ObjectGuid GetSenderGUID() const { return _senderGUID; }
174  void SetLocale(LocaleConstant locale) { _locale = locale; }
175  LocaleConstant GetLocale() const { return _locale; }
176 
177  void AddGossipMenuItemData(uint32 menuItemId, uint32 gossipActionMenuId, uint32 gossipActionPoi);
178 
179  uint32 GetMenuItemCount() const { return uint32(_menuItems.size()); }
180  bool Empty() const { return _menuItems.empty(); }
181 
182  GossipMenuItem const* GetItem(uint32 id) const
183  {
184  GossipMenuItemContainer::const_iterator itr = _menuItems.find(id);
185  if (itr != _menuItems.end())
186  return &itr->second;
187 
188  return NULL;
189  }
190 
191  GossipMenuItemData const* GetItemData(uint32 indexId) const
192  {
193  GossipMenuItemDataContainer::const_iterator itr = _menuItemData.find(indexId);
194  if (itr != _menuItemData.end())
195  return &itr->second;
196 
197  return NULL;
198  }
199 
200  uint32 GetMenuItemSender(uint32 menuItemId) const;
201  uint32 GetMenuItemAction(uint32 menuItemId) const;
202  bool IsMenuItemCoded(uint32 menuItemId) const;
203 
204  void ClearMenu();
205 
207  {
208  return _menuItems;
209  }
210 
211  private:
217 };
218 
220 {
221  public:
222  QuestMenu();
223  ~QuestMenu();
224 
225  void AddMenuItem(uint32 QuestId, uint8 Icon);
226  void ClearMenu();
227  uint8 GetMenuItemCount() const{ return uint8(_questMenuItems.size()); }
228  bool Empty() const { return _questMenuItems.empty(); }
229  bool HasItem(uint32 questId) const;
230  QuestMenuItem const& GetItem(uint16 index) const { return _questMenuItems[index]; }
231 
232  private:
234 };
235 
237 {
238  public:
239  explicit PlayerMenu(WorldSession* session);
240  ~PlayerMenu();
241 
242  GossipMenu& GetGossipMenu() { return _gossipMenu; }
243  QuestMenu& GetQuestMenu() { return _questMenu; }
244 
245  bool Empty() const { return _gossipMenu.Empty() && _questMenu.Empty(); }
246 
247  void ClearMenus();
248  uint32 GetGossipOptionSender(uint32 selection) const { return _gossipMenu.GetMenuItemSender(selection); }
249  uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
250  bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
251 
252  void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID);
253  void SendCloseGossip();
254  void SendPointOfInterest(uint32 poiId) const;
255 
256  /*********************************************************/
257  /*** QUEST SYSTEM ***/
258  /*********************************************************/
259  void SendQuestGiverStatus(uint32 questStatus, ObjectGuid npcGUID) const;
260 
261  void SendQuestGiverQuestList(ObjectGuid npcGUID);
262 
263  void SendQuestQueryResponse(Quest const* quest) const;
264  void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const;
265 
266  void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const;
267  void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const;
268 
269  static void AddQuestLevelToTitle(std::string &title, int32 level);
270 
271  private:
275 };
276 #endif
bool Empty() const
Definition: GossipDef.h:245
GossipMenuItem const * GetItem(uint32 id) const
Definition: GossipDef.h:182
Definition: GossipDef.h:42
std::string BoxMessage
Definition: GossipDef.h:137
Definition: GossipDef.h:96
Definition: GossipDef.h:88
Definition: GossipDef.h:70
Definition: GossipDef.h:45
Definition: GossipDef.h:153
Definition: GossipDef.h:101
uint32 OptionType
Definition: GossipDef.h:136
ObjectGuid GetSenderGUID() const
Definition: GossipDef.h:173
Definition: GossipDef.h:121
Definition: GossipDef.h:54
Definition: GossipDef.h:36
GossipMenuItemDataContainer _menuItemData
Definition: GossipDef.h:213
Definition: GossipDef.h:68
std::map< uint32, GossipMenuItem > GossipMenuItemContainer
Definition: GossipDef.h:142
Definition: GossipDef.h:236
Definition: GossipDef.h:161
Definition: GossipDef.h:98
Definition: QuestDef.h:279
Definition: GossipDef.h:127
Definition: GossipDef.h:104
Definition: GossipDef.h:69
uint32 GossipActionMenuId
Definition: GossipDef.h:146
bool IsCoded
Definition: GossipDef.h:133
Definition: GossipDef.h:62
Definition: GossipDef.h:126
Definition: GossipDef.h:93
Definition: GossipDef.h:52
uint32 GossipActionPoi
Definition: GossipDef.h:147
Definition: GossipDef.h:95
Definition: GossipDef.h:114
Definition: GossipDef.h:112
Poi_Icon
Definition: GossipDef.h:85
Definition: GossipDef.h:80
bool Empty() const
Definition: GossipDef.h:228
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GossipDef.h:74
Definition: GossipDef.h:113
Definition: GossipDef.h:71
Definition: GossipDef.h:92
void SetSenderGUID(ObjectGuid guid)
Definition: GossipDef.h:172
Definition: GossipDef.h:81
Definition: GossipDef.h:63
Definition: GossipDef.h:94
Definition: GossipDef.h:75
uint32 GetGossipOptionSender(uint32 selection) const
Definition: GossipDef.h:248
Definition: GossipDef.h:102
uint8 MenuItemIcon
Definition: GossipDef.h:132
Definition: GossipDef.h:115
Definition: GossipDef.h:89
void SetLocale(LocaleConstant locale)
Definition: GossipDef.h:174
Definition: GossipDef.h:103
Definition: GossipDef.h:40
uint32 GetMenuItemCount() const
Definition: GossipDef.h:179
LocaleConstant GetLocale() const
Definition: GossipDef.h:175
Definition: GossipDef.h:64
Definition: GossipDef.h:76
Definition: GossipDef.h:117
Definition: GossipDef.h:125
Definition: GossipDef.h:34
Definition: GossipDef.h:38
Definition: GossipDef.h:78
Definition: GossipDef.h:100
GossipMenu & GetGossipMenu()
Definition: GossipDef.h:242
std::vector< QuestMenuItem > QuestMenuItemList
Definition: GossipDef.h:159
Definition: GossipDef.h:118
Definition: GossipDef.h:119
QuestMenu & GetQuestMenu()
Definition: GossipDef.h:243
GossipMenuItemData const * GetItemData(uint32 indexId) const
Definition: GossipDef.h:191
uint32 _menuId
Definition: GossipDef.h:214
Definition: GossipDef.h:65
LocaleConstant
Definition: Common.h:115
Definition: GossipDef.h:66
uint32 Sender
Definition: GossipDef.h:135
QuestMenu _questMenu
Definition: GossipDef.h:273
Definition: GossipDef.h:60
Definition: GossipDef.h:110
Definition: GossipDef.h:35
GossipMenuItemContainer _menuItems
Definition: GossipDef.h:212
Definition: GossipDef.h:48
GossipMenuItemContainer const & GetMenuItems() const
Definition: GossipDef.h:206
Definition: GossipDef.h:43
int32_t int32
Definition: Define.h:146
Definition: GossipDef.h:130
uint32_t uint32
Definition: Define.h:150
Definition: GossipDef.h:67
Definition: GossipDef.h:50
uint16_t uint16
Definition: Define.h:151
Definition: GossipDef.h:108
uint32 GetGossipOptionAction(uint32 selection) const
Definition: GossipDef.h:249
Definition: GossipDef.h:99
Definition: GossipDef.h:46
void SetMenuId(uint32 menu_id)
Definition: GossipDef.h:170
Gossip_Option
Definition: GossipDef.h:32
Definition: GossipDef.h:123
Definition: GossipDef.h:116
Definition: GossipDef.h:72
Definition: GossipDef.h:53
Definition: GossipDef.h:39
bool IsGossipOptionCoded(uint32 selection) const
Definition: GossipDef.h:250
uint8_t uint8
Definition: g3dmath.h:164
Definition: GossipDef.h:87
Definition: GossipDef.h:41
uint8 QuestIcon
Definition: GossipDef.h:156
Definition: GossipDef.h:120
Definition: GossipDef.h:90
ObjectGuid _senderGUID
Definition: GossipDef.h:215
bool Empty() const
Definition: GossipDef.h:180
Definition: GossipDef.h:59
#define TC_GAME_API
Definition: Define.h:134
WorldSession * _session
Definition: GossipDef.h:274
uint8_t uint8
Definition: Define.h:152
Definition: GossipDef.h:105
GossipMenu _gossipMenu
Definition: GossipDef.h:272
Definition: GossipDef.h:37
Definition: GossipDef.h:122
Definition: GossipDef.h:144
Player session in the World.
Definition: WorldSession.h:882
Definition: GossipDef.h:47
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
QuestMenuItemList _questMenuItems
Definition: GossipDef.h:233
Definition: GossipDef.h:77
uint32 QuestId
Definition: GossipDef.h:155
std::string Message
Definition: GossipDef.h:134
Definition: GossipDef.h:109
Definition: GossipDef.h:107
uint32 GetMenuId() const
Definition: GossipDef.h:171
Definition: GossipDef.h:44
Definition: GossipDef.h:91
Definition: GossipDef.h:51
QuestMenuItem const & GetItem(uint16 index) const
Definition: GossipDef.h:230
Definition: GossipDef.h:219
Definition: GossipDef.h:111
Definition: GossipDef.h:73
LocaleConstant _locale
Definition: GossipDef.h:216
Definition: GossipDef.h:49
Definition: GossipDef.h:61
Definition: GossipDef.h:106
Definition: GossipDef.h:124
Definition: GossipDef.h:97
std::map< uint32, GossipMenuItemData > GossipMenuItemDataContainer
Definition: GossipDef.h:151
uint8 GetMenuItemCount() const
Definition: GossipDef.h:227
Definition: GossipDef.h:79
uint32 BoxMoney
Definition: GossipDef.h:138
GossipOptionIcon
Definition: GossipDef.h:57