[37] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[37] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[37] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[37] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[37] | 19 | */ |
---|
| 20 | |
---|
[44] | 21 | #ifndef TRINITYCORE_QUEST_H |
---|
| 22 | #define TRINITYCORE_QUEST_H |
---|
[37] | 23 | |
---|
| 24 | #include "Platform/Define.h" |
---|
| 25 | #include "Database/DatabaseEnv.h" |
---|
| 26 | |
---|
| 27 | #include <string> |
---|
| 28 | #include <vector> |
---|
| 29 | |
---|
| 30 | class Player; |
---|
| 31 | |
---|
| 32 | class ObjectMgr; |
---|
| 33 | |
---|
| 34 | #define MAX_QUEST_LOG_SIZE 25 |
---|
| 35 | |
---|
| 36 | #define QUEST_OBJECTIVES_COUNT 4 |
---|
| 37 | #define QUEST_SOURCE_ITEM_IDS_COUNT 4 |
---|
| 38 | #define QUEST_REWARD_CHOICES_COUNT 6 |
---|
| 39 | #define QUEST_REWARDS_COUNT 4 |
---|
| 40 | #define QUEST_DEPLINK_COUNT 10 |
---|
| 41 | #define QUEST_REPUTATIONS_COUNT 5 |
---|
| 42 | #define QUEST_EMOTE_COUNT 4 |
---|
| 43 | |
---|
| 44 | enum QuestFailedReasons |
---|
| 45 | { |
---|
| 46 | INVALIDREASON_DONT_HAVE_REQ = 0, |
---|
| 47 | INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1, //You are not high enough level for that quest. |
---|
| 48 | INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6, //That quest is not available to your race. |
---|
| 49 | INVALIDREASON_QUEST_ALREADY_DONE = 7, //You have completed that quest. |
---|
| 50 | INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12, //You can only be on one timed quest at a time. |
---|
| 51 | INVALIDREASON_QUEST_ALREADY_ON = 13, //You are already on that quest |
---|
| 52 | INVALIDREASON_QUEST_FAILED_EXPANSION = 16, //This quest requires an expansion enabled account. |
---|
| 53 | INVALIDREASON_QUEST_ALREADY_ON2 = 18, //You are already on that quest |
---|
| 54 | INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 21, //You don't have the required items with you. Check storage. |
---|
| 55 | INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 23, //You don't have enough money for that quest. |
---|
| 56 | INVALIDREASON_DAILY_QUESTS_REMAINING = 26, //You have already completed 10 daily quests today |
---|
| 57 | INVALIDREASON_QUEST_FAILED_CAIS = 27, //You cannot complete quests once you have reached tired time |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | enum QuestShareMessages |
---|
| 61 | { |
---|
| 62 | QUEST_PARTY_MSG_SHARING_QUEST = 0, |
---|
| 63 | QUEST_PARTY_MSG_CANT_TAKE_QUEST = 1, |
---|
| 64 | QUEST_PARTY_MSG_ACCEPT_QUEST = 2, |
---|
| 65 | QUEST_PARTY_MSG_REFUSE_QUEST = 3, |
---|
| 66 | QUEST_PARTY_MSG_TOO_FAR = 4, |
---|
| 67 | QUEST_PARTY_MSG_BUSY = 5, |
---|
| 68 | QUEST_PARTY_MSG_LOG_FULL = 6, |
---|
| 69 | QUEST_PARTY_MSG_HAVE_QUEST = 7, |
---|
| 70 | QUEST_PARTY_MSG_FINISH_QUEST = 8, |
---|
| 71 | }; |
---|
| 72 | |
---|
| 73 | enum __QuestTradeSkill |
---|
| 74 | { |
---|
| 75 | QUEST_TRSKILL_NONE = 0, |
---|
| 76 | QUEST_TRSKILL_ALCHEMY = 1, |
---|
| 77 | QUEST_TRSKILL_BLACKSMITHING = 2, |
---|
| 78 | QUEST_TRSKILL_COOKING = 3, |
---|
| 79 | QUEST_TRSKILL_ENCHANTING = 4, |
---|
| 80 | QUEST_TRSKILL_ENGINEERING = 5, |
---|
| 81 | QUEST_TRSKILL_FIRSTAID = 6, |
---|
| 82 | QUEST_TRSKILL_HERBALISM = 7, |
---|
| 83 | QUEST_TRSKILL_LEATHERWORKING = 8, |
---|
| 84 | QUEST_TRSKILL_POISONS = 9, |
---|
| 85 | QUEST_TRSKILL_TAILORING = 10, |
---|
| 86 | QUEST_TRSKILL_MINING = 11, |
---|
| 87 | QUEST_TRSKILL_FISHING = 12, |
---|
| 88 | QUEST_TRSKILL_SKINNING = 13, |
---|
| 89 | QUEST_TRSKILL_JEWELCRAFTING = 14, |
---|
| 90 | }; |
---|
| 91 | |
---|
| 92 | enum QuestStatus |
---|
| 93 | { |
---|
| 94 | QUEST_STATUS_NONE = 0, |
---|
| 95 | QUEST_STATUS_COMPLETE = 1, |
---|
| 96 | QUEST_STATUS_UNAVAILABLE = 2, |
---|
| 97 | QUEST_STATUS_INCOMPLETE = 3, |
---|
| 98 | QUEST_STATUS_AVAILABLE = 4, |
---|
| 99 | MAX_QUEST_STATUS |
---|
| 100 | }; |
---|
| 101 | |
---|
| 102 | enum __QuestGiverStatus |
---|
| 103 | { |
---|
| 104 | DIALOG_STATUS_NONE = 0, |
---|
| 105 | DIALOG_STATUS_UNAVAILABLE = 1, |
---|
| 106 | DIALOG_STATUS_CHAT = 2, |
---|
| 107 | DIALOG_STATUS_INCOMPLETE = 3, |
---|
| 108 | DIALOG_STATUS_REWARD_REP = 4, |
---|
| 109 | DIALOG_STATUS_AVAILABLE_REP = 5, |
---|
| 110 | DIALOG_STATUS_AVAILABLE = 6, |
---|
| 111 | DIALOG_STATUS_REWARD2 = 7, // not yellow dot on minimap |
---|
| 112 | DIALOG_STATUS_REWARD = 8 // yellow dot on minimap |
---|
| 113 | }; |
---|
| 114 | |
---|
| 115 | enum __QuestFlags |
---|
| 116 | { |
---|
| 117 | // Flags used at server and sended to client |
---|
| 118 | QUEST_FLAGS_STAY_ALIVE = 1, // Not used currently |
---|
| 119 | QUEST_FLAGS_PARTY_ACCEPT = 2, // 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 |
---|
| 120 | QUEST_FLAGS_EXPLORATION = 4, // Not used currently |
---|
| 121 | QUEST_FLAGS_SHARABLE = 8, // Can be shared: Player::CanShareQuest() |
---|
| 122 | //QUEST_FLAGS_NONE2 = 16, // Not used currently |
---|
| 123 | QUEST_FLAGS_EPIC = 32, // Not used currently: Unsure of content |
---|
| 124 | QUEST_FLAGS_RAID = 64, // Not used currently |
---|
| 125 | QUEST_FLAGS_TBC = 128, // Not used currently: Available if TBC expension enabled only |
---|
| 126 | QUEST_FLAGS_UNK2 = 256, // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs |
---|
| 127 | QUEST_FLAGS_HIDDEN_REWARDS = 512, // 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)) |
---|
| 128 | QUEST_FLAGS_AUTO_REWARDED = 1024, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side. |
---|
| 129 | QUEST_FLAGS_TBC_RACES = 2048, // Not used currently: Bloodelf/draenei starting zone quests |
---|
| 130 | QUEST_FLAGS_DAILY = 4096, // Used to know quest is Daily one |
---|
| 131 | |
---|
[44] | 132 | // Trinity flags for set SpecialFlags in DB if required but used only at server |
---|
| 133 | QUEST_TRINITY_FLAGS_REPEATABLE = 0x010000, // Set by 1 in SpecialFlags from DB |
---|
| 134 | QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT = 0x020000, // Set by 2 in SpecialFlags from DB (if reequired area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script DLL) |
---|
| 135 | QUEST_TRINITY_FLAGS_DB_ALLOWED = 0xFFFF | QUEST_TRINITY_FLAGS_REPEATABLE | QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT, |
---|
[37] | 136 | |
---|
[44] | 137 | // Trinity flags for internal use only |
---|
| 138 | QUEST_TRINITY_FLAGS_DELIVER = 0x040000, // Internal flag computed only |
---|
| 139 | QUEST_TRINITY_FLAGS_SPEAKTO = 0x080000, // Internal flag computed only |
---|
| 140 | QUEST_TRINITY_FLAGS_KILL_OR_CAST = 0x100000, // Internal flag computed only |
---|
| 141 | QUEST_TRINITY_FLAGS_TIMED = 0x200000, // Internal flag computed only |
---|
[37] | 142 | }; |
---|
| 143 | |
---|
| 144 | struct QuestLocale |
---|
| 145 | { |
---|
| 146 | QuestLocale() { ObjectiveText.resize(QUEST_OBJECTIVES_COUNT); } |
---|
| 147 | |
---|
| 148 | std::vector<std::string> Title; |
---|
| 149 | std::vector<std::string> Details; |
---|
| 150 | std::vector<std::string> Objectives; |
---|
| 151 | std::vector<std::string> OfferRewardText; |
---|
| 152 | std::vector<std::string> RequestItemsText; |
---|
| 153 | std::vector<std::string> EndText; |
---|
| 154 | std::vector< std::vector<std::string> > ObjectiveText; |
---|
| 155 | }; |
---|
| 156 | |
---|
| 157 | // This Quest class provides a convenient way to access a few pretotaled (cached) quest details, |
---|
| 158 | // all base quest information, and any utility functions such as generating the amount of |
---|
| 159 | // xp to give |
---|
| 160 | class Quest |
---|
| 161 | { |
---|
| 162 | friend class ObjectMgr; |
---|
| 163 | public: |
---|
| 164 | Quest(Field * questRecord); |
---|
| 165 | uint32 XPValue( Player *pPlayer ) const; |
---|
| 166 | |
---|
| 167 | bool HasFlag( uint32 flag ) const { return ( QuestFlags & flag ) != 0; } |
---|
| 168 | void SetFlag( uint32 flag ) { QuestFlags |= flag; } |
---|
| 169 | |
---|
| 170 | // table data accessors: |
---|
| 171 | uint32 GetQuestId() const { return QuestId; } |
---|
| 172 | uint32 GetQuestMethod() const { return QuestMethod; } |
---|
| 173 | int32 GetZoneOrSort() const { return ZoneOrSort; } |
---|
| 174 | int32 GetSkillOrClass() const { return SkillOrClass; } |
---|
| 175 | uint32 GetMinLevel() const { return MinLevel; } |
---|
| 176 | uint32 GetQuestLevel() const { return QuestLevel; } |
---|
| 177 | uint32 GetType() const { return Type; } |
---|
| 178 | uint32 GetRequiredRaces() const { return RequiredRaces; } |
---|
| 179 | uint32 GetRequiredSkillValue() const { return RequiredSkillValue; } |
---|
| 180 | uint32 GetRepObjectiveFaction() const { return RepObjectiveFaction; } |
---|
| 181 | int32 GetRepObjectiveValue() const { return RepObjectiveValue; } |
---|
| 182 | uint32 GetRequiredMinRepFaction() const { return RequiredMinRepFaction; } |
---|
| 183 | int32 GetRequiredMinRepValue() const { return RequiredMinRepValue; } |
---|
| 184 | uint32 GetRequiredMaxRepFaction() const { return RequiredMaxRepFaction; } |
---|
| 185 | int32 GetRequiredMaxRepValue() const { return RequiredMaxRepValue; } |
---|
| 186 | uint32 GetSuggestedPlayers() const { return SuggestedPlayers; } |
---|
| 187 | uint32 GetLimitTime() const { return LimitTime; } |
---|
| 188 | int32 GetPrevQuestId() const { return PrevQuestId; } |
---|
| 189 | int32 GetNextQuestId() const { return NextQuestId; } |
---|
| 190 | int32 GetExclusiveGroup() const { return ExclusiveGroup; } |
---|
| 191 | uint32 GetNextQuestInChain() const { return NextQuestInChain; } |
---|
| 192 | uint32 GetCharTitleId() const { return CharTitleId; } |
---|
| 193 | uint32 GetSrcItemId() const { return SrcItemId; } |
---|
| 194 | uint32 GetSrcItemCount() const { return SrcItemCount; } |
---|
| 195 | uint32 GetSrcSpell() const { return SrcSpell; } |
---|
| 196 | std::string GetTitle() const { return Title; } |
---|
| 197 | std::string GetDetails() const { return Details; } |
---|
| 198 | std::string GetObjectives() const { return Objectives; } |
---|
| 199 | std::string GetOfferRewardText() const { return OfferRewardText; } |
---|
| 200 | std::string GetRequestItemsText() const { return RequestItemsText; } |
---|
| 201 | std::string GetEndText() const { return EndText; } |
---|
| 202 | int32 GetRewOrReqMoney() const; |
---|
| 203 | uint32 GetRewMoneyMaxLevel() const { return RewMoneyMaxLevel; } |
---|
| 204 | // use in XP calculation at client |
---|
| 205 | uint32 GetRewSpell() const { return RewSpell; } |
---|
| 206 | uint32 GetRewSpellCast() const { return RewSpellCast; } |
---|
| 207 | uint32 GetRewMailTemplateId() const { return RewMailTemplateId; } |
---|
| 208 | uint32 GetRewMailDelaySecs() const { return RewMailDelaySecs; } |
---|
| 209 | uint32 GetPointMapId() const { return PointMapId; } |
---|
| 210 | float GetPointX() const { return PointX; } |
---|
| 211 | float GetPointY() const { return PointY; } |
---|
| 212 | uint32 GetPointOpt() const { return PointOpt; } |
---|
| 213 | uint32 GetIncompleteEmote() const { return IncompleteEmote; } |
---|
| 214 | uint32 GetCompleteEmote() const { return CompleteEmote; } |
---|
| 215 | uint32 GetQuestStartScript() const { return QuestStartScript; } |
---|
| 216 | uint32 GetQuestCompleteScript() const { return QuestCompleteScript; } |
---|
[44] | 217 | bool IsRepeatable() const { return QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE; } |
---|
[37] | 218 | bool IsAutoComplete() const { return QuestMethod ? false : true; } |
---|
| 219 | uint32 GetFlags() const { return QuestFlags; } |
---|
| 220 | bool IsDaily() const { return QuestFlags & QUEST_FLAGS_DAILY; } |
---|
| 221 | |
---|
| 222 | // multiple values |
---|
| 223 | std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; |
---|
| 224 | uint32 ReqItemId[QUEST_OBJECTIVES_COUNT]; |
---|
| 225 | uint32 ReqItemCount[QUEST_OBJECTIVES_COUNT]; |
---|
| 226 | uint32 ReqSourceId[QUEST_SOURCE_ITEM_IDS_COUNT]; |
---|
| 227 | uint32 ReqSourceCount[QUEST_SOURCE_ITEM_IDS_COUNT]; |
---|
| 228 | uint32 ReqSourceRef[QUEST_SOURCE_ITEM_IDS_COUNT]; |
---|
| 229 | int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]; // >0 Creature <0 Gameobject |
---|
| 230 | uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT]; |
---|
| 231 | uint32 ReqSpell[QUEST_OBJECTIVES_COUNT]; |
---|
| 232 | uint32 RewChoiceItemId[QUEST_REWARD_CHOICES_COUNT]; |
---|
| 233 | uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]; |
---|
| 234 | uint32 RewItemId[QUEST_REWARDS_COUNT]; |
---|
| 235 | uint32 RewItemCount[QUEST_REWARDS_COUNT]; |
---|
| 236 | uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT]; |
---|
| 237 | int32 RewRepValue[QUEST_REPUTATIONS_COUNT]; |
---|
| 238 | uint32 DetailsEmote[QUEST_EMOTE_COUNT]; |
---|
| 239 | uint32 OfferRewardEmote[QUEST_EMOTE_COUNT]; |
---|
| 240 | |
---|
| 241 | uint32 GetReqItemsCount() const { return m_reqitemscount; } |
---|
| 242 | uint32 GetReqCreatureOrGOcount() const { return m_reqCreatureOrGOcount; } |
---|
| 243 | uint32 GetRewChoiceItemsCount() const { return m_rewchoiceitemscount; } |
---|
| 244 | uint32 GetRewItemsCount() const { return m_rewitemscount; } |
---|
| 245 | |
---|
| 246 | typedef std::vector<int32> PrevQuests; |
---|
| 247 | PrevQuests prevQuests; |
---|
| 248 | typedef std::vector<uint32> PrevChainQuests; |
---|
| 249 | PrevChainQuests prevChainQuests; |
---|
| 250 | |
---|
| 251 | // cached data |
---|
| 252 | private: |
---|
| 253 | uint32 m_reqitemscount; |
---|
| 254 | uint32 m_reqCreatureOrGOcount; |
---|
| 255 | uint32 m_rewchoiceitemscount; |
---|
| 256 | uint32 m_rewitemscount; |
---|
| 257 | |
---|
| 258 | // table data |
---|
| 259 | protected: |
---|
| 260 | uint32 QuestId; |
---|
| 261 | uint32 QuestMethod; |
---|
| 262 | int32 ZoneOrSort; |
---|
| 263 | int32 SkillOrClass; |
---|
| 264 | uint32 MinLevel; |
---|
| 265 | uint32 QuestLevel; |
---|
| 266 | uint32 Type; |
---|
| 267 | uint32 RequiredRaces; |
---|
| 268 | uint32 RequiredSkillValue; |
---|
| 269 | uint32 RepObjectiveFaction; |
---|
| 270 | int32 RepObjectiveValue; |
---|
| 271 | uint32 RequiredMinRepFaction; |
---|
| 272 | int32 RequiredMinRepValue; |
---|
| 273 | uint32 RequiredMaxRepFaction; |
---|
| 274 | int32 RequiredMaxRepValue; |
---|
| 275 | uint32 SuggestedPlayers; |
---|
| 276 | uint32 LimitTime; |
---|
| 277 | uint32 QuestFlags; |
---|
| 278 | uint32 CharTitleId; |
---|
| 279 | int32 PrevQuestId; |
---|
| 280 | int32 NextQuestId; |
---|
| 281 | int32 ExclusiveGroup; |
---|
| 282 | uint32 NextQuestInChain; |
---|
| 283 | uint32 SrcItemId; |
---|
| 284 | uint32 SrcItemCount; |
---|
| 285 | uint32 SrcSpell; |
---|
| 286 | std::string Title; |
---|
| 287 | std::string Details; |
---|
| 288 | std::string Objectives; |
---|
| 289 | std::string OfferRewardText; |
---|
| 290 | std::string RequestItemsText; |
---|
| 291 | std::string EndText; |
---|
| 292 | int32 RewOrReqMoney; |
---|
| 293 | uint32 RewMoneyMaxLevel; |
---|
| 294 | uint32 RewSpell; |
---|
| 295 | uint32 RewSpellCast; |
---|
| 296 | uint32 RewMailTemplateId; |
---|
| 297 | uint32 RewMailDelaySecs; |
---|
| 298 | uint32 PointMapId; |
---|
| 299 | float PointX; |
---|
| 300 | float PointY; |
---|
| 301 | uint32 PointOpt; |
---|
| 302 | uint32 IncompleteEmote; |
---|
| 303 | uint32 CompleteEmote; |
---|
| 304 | uint32 QuestStartScript; |
---|
| 305 | uint32 QuestCompleteScript; |
---|
| 306 | }; |
---|
| 307 | |
---|
| 308 | enum QuestUpdateState |
---|
| 309 | { |
---|
| 310 | QUEST_UNCHANGED = 0, |
---|
| 311 | QUEST_CHANGED = 1, |
---|
| 312 | QUEST_NEW = 2 |
---|
| 313 | }; |
---|
| 314 | |
---|
| 315 | struct QuestStatusData |
---|
| 316 | { |
---|
| 317 | QuestStatusData() |
---|
| 318 | : m_status(QUEST_STATUS_NONE),m_rewarded(false), |
---|
| 319 | m_explored(false), m_timer(0), uState(QUEST_NEW) |
---|
| 320 | { |
---|
| 321 | memset(m_itemcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32)); |
---|
| 322 | memset(m_creatureOrGOcount, 0, QUEST_OBJECTIVES_COUNT * sizeof(uint32)); |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | QuestStatus m_status; |
---|
| 326 | bool m_rewarded; |
---|
| 327 | bool m_explored; |
---|
| 328 | uint32 m_timer; |
---|
| 329 | QuestUpdateState uState; |
---|
| 330 | |
---|
| 331 | uint32 m_itemcount[ QUEST_OBJECTIVES_COUNT ]; |
---|
| 332 | uint32 m_creatureOrGOcount[ QUEST_OBJECTIVES_COUNT ]; |
---|
| 333 | }; |
---|
| 334 | #endif |
---|