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
19 #ifndef MANGOSSERVER_QUEST_H
20 #define MANGOSSERVER_QUEST_H
22 #include "Platform/Define.h"
23 #include "Database/DatabaseEnv.h"
32 #define MAX_QUEST_LOG_SIZE 25
34 #define QUEST_OBJECTIVES_COUNT 4
35 #define QUEST_ITEM_OBJECTIVES_COUNT 6
36 #define QUEST_SOURCE_ITEM_IDS_COUNT 4
37 #define QUEST_REWARD_CHOICES_COUNT 6
38 #define QUEST_REWARDS_COUNT 4
39 #define QUEST_DEPLINK_COUNT 10
40 #define QUEST_REPUTATIONS_COUNT 5
41 #define QUEST_EMOTE_COUNT 4
43 enum QuestFailedReasons
45 INVALIDREASON_DONT_HAVE_REQ
= 0,
46 INVALIDREASON_QUEST_FAILED_LOW_LEVEL
= 1, // You are not high enough level for that quest.
47 INVALIDREASON_QUEST_FAILED_WRONG_RACE
= 6, // That quest is not available to your race.
48 INVALIDREASON_QUEST_ALREADY_DONE
= 7, // You have completed that quest.
49 INVALIDREASON_QUEST_ONLY_ONE_TIMED
= 12, // You can only be on one timed quest at a time.
50 INVALIDREASON_QUEST_ALREADY_ON
= 13, // You are already on that quest.
51 INVALIDREASON_QUEST_FAILED_EXPANSION
= 16, // This quest requires an expansion enabled account.
52 INVALIDREASON_QUEST_ALREADY_ON2
= 18, // You are already on that quest.
53 INVALIDREASON_QUEST_FAILED_MISSING_ITEMS
= 21, // You don't have the required items with you. Check storage.
54 INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY
= 23, // You don't have enough money for that quest.
55 INVALIDREASON_DAILY_QUESTS_REMAINING
= 26, // You have already completed 25 daily quests today.
56 INVALIDREASON_QUEST_FAILED_CAIS
= 27, // You cannot complete quests once you have reached tired time.
57 INVALIDREASON_DAILY_QUEST_COMPLETED_TODAY
= 29 // You have completed that daily quest today.
60 enum QuestShareMessages
62 QUEST_PARTY_MSG_SHARING_QUEST
= 0, // ERR_QUEST_PUSH_SUCCESS_S
63 QUEST_PARTY_MSG_CANT_TAKE_QUEST
= 1, // ERR_QUEST_PUSH_INVALID_S
64 QUEST_PARTY_MSG_ACCEPT_QUEST
= 2, // ERR_QUEST_PUSH_ACCEPTED_S
65 QUEST_PARTY_MSG_DECLINE_QUEST
= 3, // ERR_QUEST_PUSH_DECLINED_S
66 QUEST_PARTY_MSG_BUSY
= 4, // ERR_QUEST_PUSH_BUSY_S
67 QUEST_PARTY_MSG_LOG_FULL
= 5, // ERR_QUEST_PUSH_LOG_FULL_S
68 QUEST_PARTY_MSG_HAVE_QUEST
= 6, // ERR_QUEST_PUSH_ONQUEST_S
69 QUEST_PARTY_MSG_FINISH_QUEST
= 7, // ERR_QUEST_PUSH_ALREADY_DONE_S
70 QUEST_PARTY_MSG_CANT_BE_SHARED_TODAY
= 8, // ERR_QUEST_PUSH_NOT_DAILY_S
71 QUEST_PARTY_MSG_SHARING_TIMER_EXPIRED
= 9, // ERR_QUEST_PUSH_TIMER_EXPIRED_S
72 QUEST_PARTY_MSG_NOT_IN_PARTY
= 10, // ERR_QUEST_PUSH_NOT_IN_PARTY_S
73 QUESY_PARTY_MSG_DIFFERENT_SERVER_DAILY
= 11 // ERR_QUEST_PUSH_DIFFERENT_SERVER_DAILY_S
76 enum __QuestTradeSkill
78 QUEST_TRSKILL_NONE
= 0,
79 QUEST_TRSKILL_ALCHEMY
= 1,
80 QUEST_TRSKILL_BLACKSMITHING
= 2,
81 QUEST_TRSKILL_COOKING
= 3,
82 QUEST_TRSKILL_ENCHANTING
= 4,
83 QUEST_TRSKILL_ENGINEERING
= 5,
84 QUEST_TRSKILL_FIRSTAID
= 6,
85 QUEST_TRSKILL_HERBALISM
= 7,
86 QUEST_TRSKILL_LEATHERWORKING
= 8,
87 QUEST_TRSKILL_POISONS
= 9,
88 QUEST_TRSKILL_TAILORING
= 10,
89 QUEST_TRSKILL_MINING
= 11,
90 QUEST_TRSKILL_FISHING
= 12,
91 QUEST_TRSKILL_SKINNING
= 13,
92 QUEST_TRSKILL_JEWELCRAFTING
= 14,
97 QUEST_STATUS_NONE
= 0,
98 QUEST_STATUS_COMPLETE
= 1,
99 QUEST_STATUS_UNAVAILABLE
= 2,
100 QUEST_STATUS_INCOMPLETE
= 3,
101 QUEST_STATUS_AVAILABLE
= 4,
102 QUEST_STATUS_FAILED
= 5,
106 enum __QuestGiverStatus
108 DIALOG_STATUS_NONE
= 0,
109 DIALOG_STATUS_UNAVAILABLE
= 1,
110 DIALOG_STATUS_CHAT
= 2, // 3.1 - may be changed
111 DIALOG_STATUS_UNK1
= 3, // 3.1
112 DIALOG_STATUS_UNK2
= 4, // 3.1
113 DIALOG_STATUS_INCOMPLETE
= 5,
114 DIALOG_STATUS_REWARD_REP
= 6,
115 DIALOG_STATUS_AVAILABLE_REP
= 7,
116 DIALOG_STATUS_AVAILABLE
= 8,
117 DIALOG_STATUS_REWARD2
= 9, // no yellow dot on minimap
118 DIALOG_STATUS_REWARD
= 10 // yellow dot on minimap
123 // Flags used at server and sent to client
124 QUEST_FLAGS_NONE
= 0x00000000,
125 QUEST_FLAGS_STAY_ALIVE
= 0x00000001, // Not used currently
126 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
127 QUEST_FLAGS_EXPLORATION
= 0x00000004, // Not used currently
128 QUEST_FLAGS_SHARABLE
= 0x00000008, // Can be shared: Player::CanShareQuest()
129 //QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently
130 QUEST_FLAGS_EPIC
= 0x00000020, // Not used currently - 1 quest in 3.3
131 QUEST_FLAGS_RAID
= 0x00000040, // Not used currently
132 QUEST_FLAGS_TBC
= 0x00000080, // Not used currently: Available if TBC expansion enabled only
133 QUEST_FLAGS_UNK2
= 0x00000100, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
134 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))
135 QUEST_FLAGS_AUTO_REWARDED
= 0x00000400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
136 QUEST_FLAGS_TBC_RACES
= 0x00000800, // Not used currently: Blood elf/Draenei starting zone quests
137 QUEST_FLAGS_DAILY
= 0x00001000, // Used to know quest is Daily one
138 QUEST_FLAGS_UNK3
= 0x00002000, // activates PvP?
139 QUEST_FLAGS_UNK4
= 0x00004000, // ? Membership Card Renewal
140 QUEST_FLAGS_WEEKLY
= 0x00008000, // Not used currently: Weekly quests
141 QUEST_FLAGS_AUTOCOMPLETE
= 0x00010000, // auto complete
142 QUEST_FLAGS_UNK5
= 0x00020000, // has something to do with ReqItemId and SrcItemId
143 QUEST_FLAGS_UNK6
= 0x00040000, // use Objective text as Complete text
144 QUEST_FLAGS_LOW_LEVEL
= 0x00080000, // quests in starting areas
146 // Mangos flags for set SpecialFlags in DB if required but used only at server
147 QUEST_MANGOS_FLAGS_REPEATABLE
= 0x01000000, // Set by 1 in SpecialFlags from DB
148 QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT
= 0x02000000, // 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)
149 QUEST_MANGOS_FLAGS_DB_ALLOWED
= 0xFFFFFF | QUEST_MANGOS_FLAGS_REPEATABLE
| QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT
,
151 // Mangos flags for internal use only
152 QUEST_MANGOS_FLAGS_DELIVER
= 0x04000000, // Internal flag computed only
153 QUEST_MANGOS_FLAGS_SPEAKTO
= 0x08000000, // Internal flag computed only
154 QUEST_MANGOS_FLAGS_KILL_OR_CAST
= 0x10000000, // Internal flag computed only
155 QUEST_MANGOS_FLAGS_TIMED
= 0x20000000, // Internal flag computed only
160 QuestLocale() { ObjectiveText
.resize(QUEST_OBJECTIVES_COUNT
); }
162 std::vector
<std::string
> Title
;
163 std::vector
<std::string
> Details
;
164 std::vector
<std::string
> Objectives
;
165 std::vector
<std::string
> OfferRewardText
;
166 std::vector
<std::string
> RequestItemsText
;
167 std::vector
<std::string
> EndText
;
168 std::vector
<std::string
> CompletedText
;
169 std::vector
< std::vector
<std::string
> > ObjectiveText
;
172 // This Quest class provides a convenient way to access a few pretotaled (cached) quest details,
173 // all base quest information, and any utility functions such as generating the amount of
177 friend class ObjectMgr
;
179 Quest(Field
* questRecord
);
180 uint32
XPValue( Player
*pPlayer
) const;
182 bool HasFlag( uint32 flag
) const { return ( QuestFlags
& flag
) != 0; }
183 void SetFlag( uint32 flag
) { QuestFlags
|= flag
; }
185 // table data accessors:
186 uint32
GetQuestId() const { return QuestId
; }
187 uint32
GetQuestMethod() const { return QuestMethod
; }
188 int32
GetZoneOrSort() const { return ZoneOrSort
; }
189 int32
GetSkillOrClass() const { return SkillOrClass
; }
190 uint32
GetMinLevel() const { return MinLevel
; }
191 int32
GetQuestLevel() const { return QuestLevel
; }
192 uint32
GetType() const { return Type
; }
193 uint32
GetRequiredRaces() const { return RequiredRaces
; }
194 uint32
GetRequiredSkillValue() const { return RequiredSkillValue
; }
195 uint32
GetRepObjectiveFaction() const { return RepObjectiveFaction
; }
196 int32
GetRepObjectiveValue() const { return RepObjectiveValue
; }
197 uint32
GetRequiredMinRepFaction() const { return RequiredMinRepFaction
; }
198 int32
GetRequiredMinRepValue() const { return RequiredMinRepValue
; }
199 uint32
GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction
; }
200 int32
GetRequiredMaxRepValue() const { return RequiredMaxRepValue
; }
201 uint32
GetSuggestedPlayers() const { return SuggestedPlayers
; }
202 uint32
GetLimitTime() const { return LimitTime
; }
203 int32
GetPrevQuestId() const { return PrevQuestId
; }
204 int32
GetNextQuestId() const { return NextQuestId
; }
205 int32
GetExclusiveGroup() const { return ExclusiveGroup
; }
206 uint32
GetNextQuestInChain() const { return NextQuestInChain
; }
207 uint32
GetRewXPId() const { return RewXPId
; }
208 uint32
GetCharTitleId() const { return CharTitleId
; }
209 uint32
GetPlayersSlain() const { return PlayersSlain
; }
210 uint32
GetBonusTalents() const { return BonusTalents
; }
211 uint32
GetSrcItemId() const { return SrcItemId
; }
212 uint32
GetSrcItemCount() const { return SrcItemCount
; }
213 uint32
GetSrcSpell() const { return SrcSpell
; }
214 std::string
GetTitle() const { return Title
; }
215 std::string
GetDetails() const { return Details
; }
216 std::string
GetObjectives() const { return Objectives
; }
217 std::string
GetOfferRewardText() const { return OfferRewardText
; }
218 std::string
GetRequestItemsText() const { return RequestItemsText
; }
219 std::string
GetEndText() const { return EndText
; }
220 std::string
GetCompletedText() const { return CompletedText
; }
221 int32
GetRewOrReqMoney() const;
222 uint32
GetRewHonorAddition() const { return RewHonorAddition
; }
223 float GetRewHonorMultiplier() const { return RewHonorMultiplier
; }
224 uint32
GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel
; }
225 // use in XP calculation at client
226 uint32
GetRewSpell() const { return RewSpell
; }
227 uint32
GetRewSpellCast() const { return RewSpellCast
; }
228 uint32
GetRewMailTemplateId() const { return RewMailTemplateId
; }
229 uint32
GetRewMailDelaySecs() const { return RewMailDelaySecs
; }
230 uint32
GetPointMapId() const { return PointMapId
; }
231 float GetPointX() const { return PointX
; }
232 float GetPointY() const { return PointY
; }
233 uint32
GetPointOpt() const { return PointOpt
; }
234 uint32
GetIncompleteEmote() const { return IncompleteEmote
; }
235 uint32
GetCompleteEmote() const { return CompleteEmote
; }
236 uint32
GetQuestStartScript() const { return QuestStartScript
; }
237 uint32
GetQuestCompleteScript() const { return QuestCompleteScript
; }
238 bool IsRepeatable() const { return QuestFlags
& QUEST_MANGOS_FLAGS_REPEATABLE
; }
239 bool IsAutoComplete() const { return QuestMethod
? false : true; }
240 uint32
GetFlags() const { return QuestFlags
; }
241 bool IsDaily() const { return QuestFlags
& QUEST_FLAGS_DAILY
; }
244 std::string ObjectiveText
[QUEST_OBJECTIVES_COUNT
];
245 uint32 ReqItemId
[QUEST_ITEM_OBJECTIVES_COUNT
];
246 uint32 ReqItemCount
[QUEST_ITEM_OBJECTIVES_COUNT
];
247 uint32 ReqSourceId
[QUEST_SOURCE_ITEM_IDS_COUNT
];
248 uint32 ReqSourceCount
[QUEST_SOURCE_ITEM_IDS_COUNT
];
249 int32 ReqCreatureOrGOId
[QUEST_OBJECTIVES_COUNT
]; // >0 Creature <0 Gameobject
250 uint32 ReqCreatureOrGOCount
[QUEST_OBJECTIVES_COUNT
];
251 uint32 ReqSpell
[QUEST_OBJECTIVES_COUNT
];
252 uint32 RewChoiceItemId
[QUEST_REWARD_CHOICES_COUNT
];
253 uint32 RewChoiceItemCount
[QUEST_REWARD_CHOICES_COUNT
];
254 uint32 RewItemId
[QUEST_REWARDS_COUNT
];
255 uint32 RewItemCount
[QUEST_REWARDS_COUNT
];
256 uint32 RewRepFaction
[QUEST_REPUTATIONS_COUNT
];
257 int32 RewRepValueId
[QUEST_REPUTATIONS_COUNT
];
258 int32 RewRepValue
[QUEST_REPUTATIONS_COUNT
];
259 uint32 DetailsEmote
[QUEST_EMOTE_COUNT
];
260 uint32 DetailsEmoteDelay
[QUEST_EMOTE_COUNT
];
261 uint32 OfferRewardEmote
[QUEST_EMOTE_COUNT
];
262 uint32 OfferRewardEmoteDelay
[QUEST_EMOTE_COUNT
];
264 uint32
GetReqItemsCount() const { return m_reqitemscount
; }
265 uint32
GetReqCreatureOrGOcount() const { return m_reqCreatureOrGOcount
; }
266 uint32
GetRewChoiceItemsCount() const { return m_rewchoiceitemscount
; }
267 uint32
GetRewItemsCount() const { return m_rewitemscount
; }
269 typedef std::vector
<int32
> PrevQuests
;
270 PrevQuests prevQuests
;
271 typedef std::vector
<uint32
> PrevChainQuests
;
272 PrevChainQuests prevChainQuests
;
276 uint32 m_reqitemscount
;
277 uint32 m_reqCreatureOrGOcount
;
278 uint32 m_rewchoiceitemscount
;
279 uint32 m_rewitemscount
;
290 uint32 RequiredRaces
;
291 uint32 RequiredSkillValue
;
292 uint32 RepObjectiveFaction
;
293 int32 RepObjectiveValue
;
294 uint32 RequiredMinRepFaction
;
295 int32 RequiredMinRepValue
;
296 uint32 RequiredMaxRepFaction
;
297 int32 RequiredMaxRepValue
;
298 uint32 SuggestedPlayers
;
306 int32 ExclusiveGroup
;
307 uint32 NextQuestInChain
;
314 std::string Objectives
;
315 std::string OfferRewardText
;
316 std::string RequestItemsText
;
318 std::string CompletedText
;
319 uint32 RewHonorAddition
;
320 float RewHonorMultiplier
;
322 uint32 RewMoneyMaxLevel
;
325 uint32 RewMailTemplateId
;
326 uint32 RewMailDelaySecs
;
331 uint32 IncompleteEmote
;
332 uint32 CompleteEmote
;
333 uint32 QuestStartScript
;
334 uint32 QuestCompleteScript
;
337 enum QuestUpdateState
344 struct QuestStatusData
347 : m_status(QUEST_STATUS_NONE
),m_rewarded(false),
348 m_explored(false), m_timer(0), uState(QUEST_NEW
)
350 memset(m_itemcount
, 0, QUEST_ITEM_OBJECTIVES_COUNT
* sizeof(uint32
));
351 memset(m_creatureOrGOcount
, 0, QUEST_OBJECTIVES_COUNT
* sizeof(uint32
));
354 QuestStatus m_status
;
358 QuestUpdateState uState
;
360 uint32 m_itemcount
[ QUEST_ITEM_OBJECTIVES_COUNT
];
361 uint32 m_creatureOrGOcount
[ QUEST_OBJECTIVES_COUNT
];