[7160] Implement (un-)learning skill level dependent spells at skill level change.
[getmangos.git] / src / game / QuestDef.h
blobf29168a491a34ddddf7820e24e09b7452916bec4
1 /*
2 * Copyright (C) 2005-2009 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
19 #ifndef MANGOSSERVER_QUEST_H
20 #define MANGOSSERVER_QUEST_H
22 #include "Platform/Define.h"
23 #include "Database/DatabaseEnv.h"
25 #include <string>
26 #include <vector>
28 class Player;
30 class ObjectMgr;
32 #define MAX_QUEST_LOG_SIZE 25
34 #define QUEST_OBJECTIVES_COUNT 4
35 #define QUEST_SOURCE_ITEM_IDS_COUNT 4
36 #define QUEST_REWARD_CHOICES_COUNT 6
37 #define QUEST_REWARDS_COUNT 4
38 #define QUEST_DEPLINK_COUNT 10
39 #define QUEST_REPUTATIONS_COUNT 5
40 #define QUEST_EMOTE_COUNT 4
42 enum QuestFailedReasons
44 INVALIDREASON_DONT_HAVE_REQ = 0,
45 INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1, // You are not high enough level for that quest.
46 INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6, // That quest is not available to your race.
47 INVALIDREASON_QUEST_ALREADY_DONE = 7, // You have completed that quest.
48 INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12, // You can only be on one timed quest at a time.
49 INVALIDREASON_QUEST_ALREADY_ON = 13, // You are already on that quest.
50 INVALIDREASON_QUEST_FAILED_EXPANSION = 16, // This quest requires an expansion enabled account.
51 INVALIDREASON_QUEST_ALREADY_ON2 = 18, // You are already on that quest.
52 INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 21, // You don't have the required items with you. Check storage.
53 INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 23, // You don't have enough money for that quest.
54 INVALIDREASON_DAILY_QUESTS_REMAINING = 26, // You have already completed 25 daily quests today.
55 INVALIDREASON_QUEST_FAILED_CAIS = 27, // You cannot complete quests once you have reached tired time.
56 INVALIDREASON_DAILY_QUEST_COMPLETED_TODAY = 29 // You have completed that daily quest today.
59 enum QuestShareMessages
61 QUEST_PARTY_MSG_SHARING_QUEST = 0,
62 QUEST_PARTY_MSG_CANT_TAKE_QUEST = 1,
63 QUEST_PARTY_MSG_ACCEPT_QUEST = 2,
64 QUEST_PARTY_MSG_DECLINE_QUEST = 3,
65 QUEST_PARTY_MSG_BUSY = 4,
66 QUEST_PARTY_MSG_LOG_FULL = 5,
67 QUEST_PARTY_MSG_HAVE_QUEST = 6,
68 QUEST_PARTY_MSG_FINISH_QUEST = 7,
69 QUEST_PARTY_MSG_CANT_BE_SHARED_TODAY = 8,
70 QUEST_PARTY_MSG_SHARING_TIMER_EXPIRED = 9,
71 QUEST_PARTY_MSG_NOT_IN_PARTY = 10
74 enum __QuestTradeSkill
76 QUEST_TRSKILL_NONE = 0,
77 QUEST_TRSKILL_ALCHEMY = 1,
78 QUEST_TRSKILL_BLACKSMITHING = 2,
79 QUEST_TRSKILL_COOKING = 3,
80 QUEST_TRSKILL_ENCHANTING = 4,
81 QUEST_TRSKILL_ENGINEERING = 5,
82 QUEST_TRSKILL_FIRSTAID = 6,
83 QUEST_TRSKILL_HERBALISM = 7,
84 QUEST_TRSKILL_LEATHERWORKING = 8,
85 QUEST_TRSKILL_POISONS = 9,
86 QUEST_TRSKILL_TAILORING = 10,
87 QUEST_TRSKILL_MINING = 11,
88 QUEST_TRSKILL_FISHING = 12,
89 QUEST_TRSKILL_SKINNING = 13,
90 QUEST_TRSKILL_JEWELCRAFTING = 14,
93 enum QuestStatus
95 QUEST_STATUS_NONE = 0,
96 QUEST_STATUS_COMPLETE = 1,
97 QUEST_STATUS_UNAVAILABLE = 2,
98 QUEST_STATUS_INCOMPLETE = 3,
99 QUEST_STATUS_AVAILABLE = 4,
100 MAX_QUEST_STATUS
103 enum __QuestGiverStatus
105 DIALOG_STATUS_NONE = 0,
106 DIALOG_STATUS_UNAVAILABLE = 1,
107 DIALOG_STATUS_CHAT = 2,
108 DIALOG_STATUS_INCOMPLETE = 3,
109 DIALOG_STATUS_REWARD_REP = 4,
110 DIALOG_STATUS_AVAILABLE_REP = 5,
111 DIALOG_STATUS_AVAILABLE = 6,
112 DIALOG_STATUS_REWARD2 = 7, // not yellow dot on minimap
113 DIALOG_STATUS_REWARD = 8 // yellow dot on minimap
116 enum __QuestFlags
118 // Flags used at server and sent to client
119 QUEST_FLAGS_STAY_ALIVE = 0x00000001, // Not used currently
120 QUEST_FLAGS_PARTY_ACCEPT = 0x00000002, // Not used currently. 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 expension 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
133 // Mangos flags for set SpecialFlags in DB if required but used only at server
134 QUEST_MANGOS_FLAGS_REPEATABLE = 0x010000, // Set by 1 in SpecialFlags from DB
135 QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT = 0x020000, // 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)
136 QUEST_MANGOS_FLAGS_DB_ALLOWED = 0xFFFF | QUEST_MANGOS_FLAGS_REPEATABLE | QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT,
138 // Mangos flags for internal use only
139 QUEST_MANGOS_FLAGS_DELIVER = 0x040000, // Internal flag computed only
140 QUEST_MANGOS_FLAGS_SPEAKTO = 0x080000, // Internal flag computed only
141 QUEST_MANGOS_FLAGS_KILL_OR_CAST = 0x100000, // Internal flag computed only
142 QUEST_MANGOS_FLAGS_TIMED = 0x200000, // Internal flag computed only
145 struct QuestLocale
147 QuestLocale() { ObjectiveText.resize(QUEST_OBJECTIVES_COUNT); }
149 std::vector<std::string> Title;
150 std::vector<std::string> Details;
151 std::vector<std::string> Objectives;
152 std::vector<std::string> OfferRewardText;
153 std::vector<std::string> RequestItemsText;
154 std::vector<std::string> EndText;
155 std::vector< std::vector<std::string> > ObjectiveText;
158 // This Quest class provides a convenient way to access a few pretotaled (cached) quest details,
159 // all base quest information, and any utility functions such as generating the amount of
160 // xp to give
161 class Quest
163 friend class ObjectMgr;
164 public:
165 Quest(Field * questRecord);
166 uint32 XPValue( Player *pPlayer ) const;
168 bool HasFlag( uint32 flag ) const { return ( QuestFlags & flag ) != 0; }
169 void SetFlag( uint32 flag ) { QuestFlags |= flag; }
171 // table data accessors:
172 uint32 GetQuestId() const { return QuestId; }
173 uint32 GetQuestMethod() const { return QuestMethod; }
174 int32 GetZoneOrSort() const { return ZoneOrSort; }
175 int32 GetSkillOrClass() const { return SkillOrClass; }
176 uint32 GetMinLevel() const { return MinLevel; }
177 uint32 GetQuestLevel() const { return QuestLevel; }
178 uint32 GetType() const { return Type; }
179 uint32 GetRequiredRaces() const { return RequiredRaces; }
180 uint32 GetRequiredSkillValue() const { return RequiredSkillValue; }
181 uint32 GetRepObjectiveFaction() const { return RepObjectiveFaction; }
182 int32 GetRepObjectiveValue() const { return RepObjectiveValue; }
183 uint32 GetRequiredMinRepFaction() const { return RequiredMinRepFaction; }
184 int32 GetRequiredMinRepValue() const { return RequiredMinRepValue; }
185 uint32 GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction; }
186 int32 GetRequiredMaxRepValue() const { return RequiredMaxRepValue; }
187 uint32 GetSuggestedPlayers() const { return SuggestedPlayers; }
188 uint32 GetLimitTime() const { return LimitTime; }
189 int32 GetPrevQuestId() const { return PrevQuestId; }
190 int32 GetNextQuestId() const { return NextQuestId; }
191 int32 GetExclusiveGroup() const { return ExclusiveGroup; }
192 uint32 GetNextQuestInChain() const { return NextQuestInChain; }
193 uint32 GetCharTitleId() const { return CharTitleId; }
194 uint32 GetPlayersSlain() const { return PlayersSlain; }
195 uint32 GetBonusTalents() const { return BonusTalents; }
196 uint32 GetSrcItemId() const { return SrcItemId; }
197 uint32 GetSrcItemCount() const { return SrcItemCount; }
198 uint32 GetSrcSpell() const { return SrcSpell; }
199 std::string GetTitle() const { return Title; }
200 std::string GetDetails() const { return Details; }
201 std::string GetObjectives() const { return Objectives; }
202 std::string GetOfferRewardText() const { return OfferRewardText; }
203 std::string GetRequestItemsText() const { return RequestItemsText; }
204 std::string GetEndText() const { return EndText; }
205 int32 GetRewOrReqMoney() const;
206 uint32 GetRewHonorableKills() const { return RewHonorableKills; }
207 uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; }
208 // use in XP calculation at client
209 uint32 GetRewSpell() const { return RewSpell; }
210 uint32 GetRewSpellCast() const { return RewSpellCast; }
211 uint32 GetRewMailTemplateId() const { return RewMailTemplateId; }
212 uint32 GetRewMailDelaySecs() const { return RewMailDelaySecs; }
213 uint32 GetPointMapId() const { return PointMapId; }
214 float GetPointX() const { return PointX; }
215 float GetPointY() const { return PointY; }
216 uint32 GetPointOpt() const { return PointOpt; }
217 uint32 GetIncompleteEmote() const { return IncompleteEmote; }
218 uint32 GetCompleteEmote() const { return CompleteEmote; }
219 uint32 GetQuestStartScript() const { return QuestStartScript; }
220 uint32 GetQuestCompleteScript() const { return QuestCompleteScript; }
221 bool IsRepeatable() const { return QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE; }
222 bool IsAutoComplete() const { return QuestMethod ? false : true; }
223 uint32 GetFlags() const { return QuestFlags; }
224 bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; }
226 // multiple values
227 std::string ObjectiveText[QUEST_OBJECTIVES_COUNT];
228 uint32 ReqItemId[QUEST_OBJECTIVES_COUNT];
229 uint32 ReqItemCount[QUEST_OBJECTIVES_COUNT];
230 uint32 ReqSourceId[QUEST_SOURCE_ITEM_IDS_COUNT];
231 uint32 ReqSourceCount[QUEST_SOURCE_ITEM_IDS_COUNT];
232 uint32 ReqSourceRef[QUEST_SOURCE_ITEM_IDS_COUNT];
233 int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject
234 uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT];
235 uint32 ReqSpell[QUEST_OBJECTIVES_COUNT];
236 uint32 RewChoiceItemId[QUEST_REWARD_CHOICES_COUNT];
237 uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT];
238 uint32 RewItemId[QUEST_REWARDS_COUNT];
239 uint32 RewItemCount[QUEST_REWARDS_COUNT];
240 uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT];
241 int32 RewRepValue[QUEST_REPUTATIONS_COUNT];
242 uint32 DetailsEmote[QUEST_EMOTE_COUNT];
243 uint32 OfferRewardEmote[QUEST_EMOTE_COUNT];
245 uint32 GetReqItemsCount() const { return m_reqitemscount; }
246 uint32 GetReqCreatureOrGOcount() const { return m_reqCreatureOrGOcount; }
247 uint32 GetRewChoiceItemsCount() const { return m_rewchoiceitemscount; }
248 uint32 GetRewItemsCount() const { return m_rewitemscount; }
250 typedef std::vector<int32> PrevQuests;
251 PrevQuests prevQuests;
252 typedef std::vector<uint32> PrevChainQuests;
253 PrevChainQuests prevChainQuests;
255 // cached data
256 private:
257 uint32 m_reqitemscount;
258 uint32 m_reqCreatureOrGOcount;
259 uint32 m_rewchoiceitemscount;
260 uint32 m_rewitemscount;
262 // table data
263 protected:
264 uint32 QuestId;
265 uint32 QuestMethod;
266 int32 ZoneOrSort;
267 int32 SkillOrClass;
268 uint32 MinLevel;
269 uint32 QuestLevel;
270 uint32 Type;
271 uint32 RequiredRaces;
272 uint32 RequiredSkillValue;
273 uint32 RepObjectiveFaction;
274 int32 RepObjectiveValue;
275 uint32 RequiredMinRepFaction;
276 int32 RequiredMinRepValue;
277 uint32 RequiredMaxRepFaction;
278 int32 RequiredMaxRepValue;
279 uint32 SuggestedPlayers;
280 uint32 LimitTime;
281 uint32 QuestFlags;
282 uint32 CharTitleId;
283 uint32 PlayersSlain;
284 uint32 BonusTalents;
285 int32 PrevQuestId;
286 int32 NextQuestId;
287 int32 ExclusiveGroup;
288 uint32 NextQuestInChain;
289 uint32 SrcItemId;
290 uint32 SrcItemCount;
291 uint32 SrcSpell;
292 std::string Title;
293 std::string Details;
294 std::string Objectives;
295 std::string OfferRewardText;
296 std::string RequestItemsText;
297 std::string EndText;
298 uint32 RewHonorableKills;
299 int32 RewOrReqMoney;
300 uint32 RewMoneyMaxLevel;
301 uint32 RewSpell;
302 uint32 RewSpellCast;
303 uint32 RewMailTemplateId;
304 uint32 RewMailDelaySecs;
305 uint32 PointMapId;
306 float PointX;
307 float PointY;
308 uint32 PointOpt;
309 uint32 IncompleteEmote;
310 uint32 CompleteEmote;
311 uint32 QuestStartScript;
312 uint32 QuestCompleteScript;
315 enum QuestUpdateState
317 QUEST_UNCHANGED = 0,
318 QUEST_CHANGED = 1,
319 QUEST_NEW = 2
322 struct QuestStatusData
324 QuestStatusData()
325 : m_status(QUEST_STATUS_NONE),m_rewarded(false),
326 m_explored(false), m_timer(0), uState(QUEST_NEW)
328 memset(m_itemcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
329 memset(m_creatureOrGOcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32));
332 QuestStatus m_status;
333 bool m_rewarded;
334 bool m_explored;
335 uint32 m_timer;
336 QuestUpdateState uState;
338 uint32 m_itemcount[ QUEST_OBJECTIVES_COUNT ];
339 uint32 m_creatureOrGOcount[ QUEST_OBJECTIVES_COUNT ];
341 #endif