OregonCore  revision fb2a440-git
Your Favourite TBC server
QuestDef.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 OREGONCORE_QUEST_H
19 #define OREGONCORE_QUEST_H
20 
21 #include "Platform/Define.h"
22 #include "Database/DatabaseEnv.h"
23 
24 #include <string>
25 #include <vector>
26 
27 class Player;
28 
29 class ObjectMgr;
30 
31 #define MAX_QUEST_LOG_SIZE 25
32 
33 #define QUEST_OBJECTIVES_COUNT 4
34 #define QUEST_SOURCE_ITEM_IDS_COUNT 4
35 #define QUEST_REWARD_CHOICES_COUNT 6
36 #define QUEST_REWARDS_COUNT 4
37 #define QUEST_DEPLINK_COUNT 10
38 #define QUEST_REPUTATIONS_COUNT 5
39 #define QUEST_EMOTE_COUNT 4
40 
42 {
44  INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1, //You are not high enough level for that quest.
45  INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6, //That quest is not available to your race.
46  INVALIDREASON_QUEST_ALREADY_DONE = 7, //You have completed that quest.
47  INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12, //You can only be on one timed quest at a time.
48  INVALIDREASON_QUEST_ALREADY_ON = 13, //You are already on that quest
49  INVALIDREASON_QUEST_FAILED_EXPANSION = 16, //This quest requires an expansion enabled account.
50  INVALIDREASON_QUEST_ALREADY_ON2 = 18, //You are already on that quest
51  INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 21, //You don't have the required items with you. Check storage.
52  INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 23, //You don't have enough money for that quest.
53  INVALIDREASON_DAILY_QUESTS_REMAINING = 26, //You have already completed 10 daily quests today
54  INVALIDREASON_QUEST_FAILED_CAIS = 27, //You cannot complete quests once you have reached tired time
55 };
56 
58 {
68 };
69 
71 {
87 };
88 
90 {
98 };
99 
101 {
109  DIALOG_STATUS_REWARD2 = 7, // not yellow dot on minimap
110  DIALOG_STATUS_REWARD = 8, // yellow dot on minimap
111 
112  // Custom value meaning that script call did not return any valid quest status
114 };
115 
117 {
118  // Flags used at server and sent to client
119  QUEST_FLAGS_STAY_ALIVE = 0x00000001, // Not used currently
120  QUEST_FLAGS_PARTY_ACCEPT = 0x00000002, // If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT
121  QUEST_FLAGS_EXPLORATION = 0x00000004, // Not used currently
122  QUEST_FLAGS_SHARABLE = 0x00000008, // Can be shared: Player::CanShareQuest()
123  //QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently
124  QUEST_FLAGS_EPIC = 0x00000020, // Not used currently: Unsure of content
125  QUEST_FLAGS_RAID = 0x00000040, // Not used currently
126  QUEST_FLAGS_TBC = 0x00000080, // Not used currently: Available if TBC expansion enabled only
127  QUEST_FLAGS_UNK2 = 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
128  QUEST_FLAGS_HIDDEN_REWARDS = 0x00000200, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE))
129  QUEST_FLAGS_AUTO_REWARDED = 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
130  QUEST_FLAGS_TBC_RACES = 0x00000800, // Not used currently: Blood elf/Draenei starting zone quests
131  QUEST_FLAGS_DAILY = 0x00001000, // Used to know quest is Daily one
132 
133 };
134 
136 {
138  // Oregon flags for set SpecialFlags in DB if required but used only at server
139  QUEST_SPECIAL_FLAGS_REPEATABLE = 0x001, // Set by 1 in SpecialFlags from DB
140  QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT = 0x002, // Set by 2 in SpecialFlags from DB (if required area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script DLL)
141  QUEST_SPECIAL_FLAGS_AUTO_ACCEPT = 0x004, // Set by 4 in SpecialFlags in DB if the quest is to be auto-accepted.
142  QUEST_SPECIAL_FLAGS_CAST = 0x020, // Set by 32 in SpecialFlags in DB if the quest requires RequiredOrNpcGo killcredit but NOT kill (a spell cast)
143 
145 
146  // Oregon flags for internal use only
147  QUEST_SPECIAL_FLAGS_DELIVER = 0x080, // Internal flag computed only
148  QUEST_SPECIAL_FLAGS_SPEAKTO = 0x100, // Internal flag computed only
149  QUEST_SPECIAL_FLAGS_KILL = 0x200, // Internal flag computed only
150  QUEST_SPECIAL_FLAGS_TIMED = 0x400, // Internal flag computed only
151 };
152 
154 {
156  {
158  }
159 
160  std::vector<std::string> Title;
161  std::vector<std::string> Details;
162  std::vector<std::string> Objectives;
163  std::vector<std::string> OfferRewardText;
164  std::vector<std::string> RequestItemsText;
165  std::vector<std::string> EndText;
166  std::vector< std::vector<std::string> > ObjectiveText;
167 };
168 
169 // This Quest class provides a convenient way to access a few pretotaled (cached) quest details,
170 // all base quest information, and any utility functions such as generating the amount of
171 // xp to give
172 class Quest
173 {
174  friend class ObjectMgr;
175  public:
176  Quest(Field* questRecord);
177  uint32 XPValue(Player* pPlayer) const;
178 
179  bool HasFlag(uint32 flag) const { return (QuestFlags & flag) != 0; }
180  void SetFlag(uint32 flag) { QuestFlags |= flag; }
181 
182  bool HasSpecialFlag(uint32 flag) const { return (SpecialFlags & flag) != 0; }
183  void SetSpecialFlag(uint32 flag) { SpecialFlags |= flag; }
184 
185  // table data accessors:
186  uint32 GetQuestId() const { return QuestId; }
187  uint32 GetQuestMethod() const { return QuestMethod; }
188 
190  {
191  return ZoneOrSort;
192  }
194  {
195  return MinLevel;
196  }
198  {
199  return QuestLevel;
200  }
201  uint32 GetType() const
202  {
203  return Type;
204  }
206  {
207  return RequiredClasses;
208  }
210  {
211  return RequiredRaces;
212  }
214  {
215  return RequiredSkill;
216  }
218  {
219  return RequiredSkillValue;
220  }
222  {
223  return RepObjectiveFaction;
224  }
226  {
227  return RepObjectiveValue;
228  }
230  {
231  return RequiredMinRepFaction;
232  }
234  {
235  return RequiredMinRepValue;
236  }
238  {
239  return RequiredMaxRepFaction;
240  }
242  {
243  return RequiredMaxRepValue;
244  }
246  {
247  return SuggestedPlayers;
248  }
250  {
251  return LimitTime;
252  }
254  {
255  return PrevQuestId;
256  }
258  {
259  return NextQuestId;
260  }
262  {
263  return ExclusiveGroup;
264  }
266  {
267  return NextQuestInChain;
268  }
270  {
271  return CharTitleId;
272  }
274  {
275  return SrcItemId;
276  }
278  {
279  return SrcItemCount;
280  }
282  {
283  return SrcSpell;
284  }
285  std::string GetTitle() const
286  {
287  return Title;
288  }
289  std::string GetDetails() const
290  {
291  return Details;
292  }
293  std::string GetObjectives() const
294  {
295  return Objectives;
296  }
297  std::string GetOfferRewardText() const
298  {
299  return OfferRewardText;
300  }
301  std::string GetRequestItemsText() const
302  {
303  return RequestItemsText;
304  }
305  std::string GetEndText() const
306  {
307  return EndText;
308  }
309  int32 GetRewOrReqMoney() const;
311  {
312  return RewHonorableKills;
313  }
315  {
316  return RewMoneyMaxLevel;
317  }
318  // use in XP calculation at client
320  {
321  return RewSpell;
322  }
324  {
325  return RewSpellCast;
326  }
328  {
329  return RewMailTemplateId;
330  }
332  {
333  return RewMailDelaySecs;
334  }
336  {
337  return PointMapId;
338  }
339  float GetPointX() const
340  {
341  return PointX;
342  }
343  float GetPointY() const
344  {
345  return PointY;
346  }
348  {
349  return PointOpt;
350  }
352  {
353  return IncompleteEmote;
354  }
356  {
357  return CompleteEmote;
358  }
360  {
361  return QuestStartScript;
362  }
364  {
365  return QuestCompleteScript;
366  }
367 
368  bool IsRepeatable() const { return SpecialFlags & QUEST_SPECIAL_FLAGS_REPEATABLE; }
369 
370  bool IsAutoComplete() const
371  {
372  return QuestMethod ? false : true;
373  }
374  uint32 GetFlags() const
375  {
376  return QuestFlags;
377  }
378  bool IsDaily() const
379  {
380  return QuestFlags & QUEST_FLAGS_DAILY;
381  }
382 
383  // multiple values
389  int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject
390  uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT];
393  uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT];
398  uint32 DetailsEmote[QUEST_EMOTE_COUNT];
399  uint32 OfferRewardEmote[QUEST_EMOTE_COUNT];
400 
401  uint32 GetReqItemsCount() const { return _reqItemsCount; }
402  uint32 GetReqCreatureOrGOcount() const { return _reqCreatureOrGOcount; }
403  uint32 GetRewChoiceItemsCount() const { return _rewChoiceItemsCount; }
404  uint32 GetRewItemsCount() const { return _rewItemsCount; }
405 
406  typedef std::vector<int32> PrevQuests;
407  PrevQuests prevQuests;
408  typedef std::vector<uint32> PrevChainQuests;
409  PrevChainQuests prevChainQuests;
410 
411  // cached data
412  private:
417 
418  // table data
419  protected:
447  std::string Title;
448  std::string Details;
449  std::string Objectives;
450  std::string OfferRewardText;
451  std::string RequestItemsText;
452  std::string EndText;
461  float PointX;
462  float PointY;
468 
469  uint32 SpecialFlags; // custom flags, not sniffed/WDB
470 };
471 
473 {
477 };
478 
480 {
482  : m_status(QUEST_STATUS_NONE), m_rewarded(false),
483  m_explored(false), m_timer(0), uState(QUEST_NEW)
484  {
485  memset(m_itemcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
486  memset(m_creatureOrGOcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
487  }
488 
494 
496  uint32 m_creatureOrGOcount[ QUEST_OBJECTIVES_COUNT ];
497 };
498 #endif
499 
std::vector< std::string > OfferRewardText
Definition: QuestDef.h:163
uint32 GetRewChoiceItemsCount() const
Definition: QuestDef.h:403
QuestSpecialFlags
Definition: QuestDef.h:135
uint32 GetRequiredSkill() const
Definition: QuestDef.h:213
bool IsAutoComplete() const
Definition: QuestDef.h:370
uint32 RewSpellCast
Definition: QuestDef.h:457
__QuestTradeSkill
Definition: QuestDef.h:70
uint32 SpecialFlags
Definition: QuestDef.h:469
uint32 CompleteEmote
Definition: QuestDef.h:465
std::vector< std::string > Details
Definition: QuestDef.h:161
float PointX
Definition: QuestDef.h:461
uint32 PointMapId
Definition: QuestDef.h:460
uint32 RewSpell
Definition: QuestDef.h:456
uint32 CharTitleId
Definition: QuestDef.h:439
QuestUpdateState
Definition: QuestDef.h:472
std::string GetTitle() const
Definition: QuestDef.h:285
uint32 MinLevel
Definition: QuestDef.h:423
uint32 QuestCompleteScript
Definition: QuestDef.h:467
uint32 GetSuggestedPlayers() const
Definition: QuestDef.h:245
uint32 GetIncompleteEmote() const
Definition: QuestDef.h:351
uint32 RewMoneyMaxLevel
Definition: QuestDef.h:455
std::string OfferRewardText
Definition: QuestDef.h:450
int32 GetZoneOrSort() const
Definition: QuestDef.h:189
uint32 RewMailDelaySecs
Definition: QuestDef.h:459
QuestStatus m_status
Definition: QuestDef.h:489
uint32 GetRewItemsCount() const
Definition: QuestDef.h:404
uint32 SrcItemId
Definition: QuestDef.h:444
#define QUEST_EMOTE_COUNT
Definition: QuestDef.h:39
Definition: Field.h:24
uint32 RequiredMaxRepFaction
Definition: QuestDef.h:434
uint32 RequiredRaces
Definition: QuestDef.h:427
uint32 GetFlags() const
Definition: QuestDef.h:374
uint32 GetRequiredMinRepFaction() const
Definition: QuestDef.h:229
uint32 GetPointMapId() const
Definition: QuestDef.h:335
QuestStatus
Definition: QuestDef.h:89
uint32 GetNextQuestInChain() const
Definition: QuestDef.h:265
std::string GetEndText() const
Definition: QuestDef.h:305
std::vector< std::string > Objectives
Definition: QuestDef.h:162
uint32 QuestMethod
Definition: QuestDef.h:421
std::vector< std::string > Title
Definition: QuestDef.h:160
ACE_INT32 int32
Definition: Define.h:67
NULL Dbg ErrDB Arena Chat Char Map MMap false
Definition: Log.cpp:556
int32 GetRepObjectiveValue() const
Definition: QuestDef.h:225
uint32 GetQuestStartScript() const
Definition: QuestDef.h:359
float GetPointY() const
Definition: QuestDef.h:343
uint32 QuestStartScript
Definition: QuestDef.h:466
uint32 GetSrcSpell() const
Definition: QuestDef.h:281
int32 GetRequiredMaxRepValue() const
Definition: QuestDef.h:241
bool IsDaily() const
Definition: QuestDef.h:378
uint32 GetRewHonorableKills() const
Definition: QuestDef.h:310
uint32 GetReqCreatureOrGOcount() const
Definition: QuestDef.h:402
uint32 GetCharTitleId() const
Definition: QuestDef.h:269
void SetFlag(uint32 flag)
Definition: QuestDef.h:180
std::string Details
Definition: QuestDef.h:448
uint32 GetSrcItemCount() const
Definition: QuestDef.h:277
float PointY
Definition: QuestDef.h:462
std::string GetObjectives() const
Definition: QuestDef.h:293
std::string EndText
Definition: QuestDef.h:452
int32 ZoneOrSort
Definition: QuestDef.h:422
uint32 RequiredMinRepFaction
Definition: QuestDef.h:432
std::string GetRequestItemsText() const
Definition: QuestDef.h:301
bool IsRepeatable() const
Definition: QuestDef.h:368
uint32 GetSrcItemId() const
Definition: QuestDef.h:273
uint32 GetRequiredSkillValue() const
Definition: QuestDef.h:217
QuestFailedReasons
Definition: QuestDef.h:41
uint32 QuestId
Definition: QuestDef.h:420
PrevChainQuests prevChainQuests
Definition: QuestDef.h:409
uint32 GetQuestId() const
Definition: QuestDef.h:186
int32 RequiredMinRepValue
Definition: QuestDef.h:433
uint32 GetLimitTime() const
Definition: QuestDef.h:249
uint32 GetRewMailDelaySecs() const
Definition: QuestDef.h:331
bool HasSpecialFlag(uint32 flag) const
Definition: QuestDef.h:182
uint32 RequiredSkill
Definition: QuestDef.h:428
std::string RequestItemsText
Definition: QuestDef.h:451
uint32 GetCompleteEmote() const
Definition: QuestDef.h:355
std::vector< uint32 > PrevChainQuests
Definition: QuestDef.h:408
__QuestGiverStatus
Definition: QuestDef.h:100
uint32 GetRewSpell() const
Definition: QuestDef.h:319
int32 ExclusiveGroup
Definition: QuestDef.h:442
uint32 _reqCreatureOrGOcount
Definition: QuestDef.h:414
float GetPointX() const
Definition: QuestDef.h:339
uint32 RewHonorableKills
Definition: QuestDef.h:453
uint32 GetRequiredClasses() const
Definition: QuestDef.h:205
std::string Title
Definition: QuestDef.h:447
uint32 SuggestedPlayers
Definition: QuestDef.h:436
QuestShareMessages
Definition: QuestDef.h:57
uint32 GetQuestMethod() const
Definition: QuestDef.h:187
uint32 GetReqItemsCount() const
Definition: QuestDef.h:401
QuestUpdateState uState
Definition: QuestDef.h:493
uint32 GetType() const
Definition: QuestDef.h:201
uint32 GetRewSpellCast() const
Definition: QuestDef.h:323
int32 QuestLevel
Definition: QuestDef.h:424
uint32 _rewChoiceItemsCount
Definition: QuestDef.h:415
uint32 RequiredSkillValue
Definition: QuestDef.h:429
uint32 QuestFlags
Definition: QuestDef.h:438
void SetSpecialFlag(uint32 flag)
Definition: QuestDef.h:183
std::vector< int32 > PrevQuests
Definition: QuestDef.h:406
uint32 LimitTime
Definition: QuestDef.h:437
uint32 GetRequiredMaxRepFaction() const
Definition: QuestDef.h:237
uint32 GetQuestCompleteScript() const
Definition: QuestDef.h:363
int32 PrevQuestId
Definition: QuestDef.h:440
int32 NextQuestId
Definition: QuestDef.h:441
uint32 IncompleteEmote
Definition: QuestDef.h:464
uint32 _reqItemsCount
Definition: QuestDef.h:413
uint32 SrcSpell
Definition: QuestDef.h:446
std::string GetDetails() const
Definition: QuestDef.h:289
#define QUEST_REWARD_CHOICES_COUNT
Definition: QuestDef.h:35
std::vector< std::vector< std::string > > ObjectiveText
Definition: QuestDef.h:166
uint32 PointOpt
Definition: QuestDef.h:463
bool HasFlag(uint32 flag) const
Definition: QuestDef.h:179
int32 GetNextQuestId() const
Definition: QuestDef.h:257
int32 GetRequiredMinRepValue() const
Definition: QuestDef.h:233
std::vector< std::string > RequestItemsText
Definition: QuestDef.h:164
uint32 GetRewMailTemplateId() const
Definition: QuestDef.h:327
std::string GetOfferRewardText() const
Definition: QuestDef.h:297
#define QUEST_REWARDS_COUNT
Definition: QuestDef.h:36
int32 RequiredMaxRepValue
Definition: QuestDef.h:435
uint32 RewMailTemplateId
Definition: QuestDef.h:458
uint32 GetRepObjectiveFaction() const
Definition: QuestDef.h:221
uint32 SrcItemCount
Definition: QuestDef.h:445
int32 RewOrReqMoney
Definition: QuestDef.h:454
int32 GetQuestLevel() const
Definition: QuestDef.h:197
int32 RepObjectiveValue
Definition: QuestDef.h:431
ACE_UINT32 uint32
Definition: Define.h:71
int32 GetExclusiveGroup() const
Definition: QuestDef.h:261
uint32 NextQuestInChain
Definition: QuestDef.h:443
uint32 GetPointOpt() const
Definition: QuestDef.h:347
uint32 RepObjectiveFaction
Definition: QuestDef.h:430
PrevQuests prevQuests
Definition: QuestDef.h:407
uint32 _rewItemsCount
Definition: QuestDef.h:416
int32 GetPrevQuestId() const
Definition: QuestDef.h:253
#define QUEST_SOURCE_ITEM_IDS_COUNT
Definition: QuestDef.h:34
uint32 GetRequiredRaces() const
Definition: QuestDef.h:209
Definition: Player.h:922
QuestFlags
Definition: QuestDef.h:116
uint32 m_timer
Definition: QuestDef.h:492
#define QUEST_OBJECTIVES_COUNT
Definition: QuestDef.h:33
uint32 GetMinLevel() const
Definition: QuestDef.h:193
uint32 RequiredClasses
Definition: QuestDef.h:426
std::vector< std::string > EndText
Definition: QuestDef.h:165
uint32 GetRewMoneyMaxLevel() const
Definition: QuestDef.h:314
std::string Objectives
Definition: QuestDef.h:449
uint32 Type
Definition: QuestDef.h:425
#define QUEST_REPUTATIONS_COUNT
Definition: QuestDef.h:38