2008-10-11 14:16:25 -05:00
/*
2009-02-04 12:42:26 +01:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2009-02-04 12:04:12 +01:00
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
2008-10-11 14:16:25 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2008-10-14 11:57:03 -05:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-11 14:16:25 -05:00
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2008-10-14 11:57:03 -05:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2008-10-11 14:16:25 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
#ifndef TRINITYCORE_QUEST_H
#define TRINITYCORE_QUEST_H
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include "Platform/Define.h"
#include "Database/DatabaseEnv.h"
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include <string>
#include <vector>
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
class Player ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
class ObjectMgr ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#define MAX_QUEST_LOG_SIZE 25
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#define QUEST_OBJECTIVES_COUNT 4
2009-12-17 12:13:33 +01:00
#define QUEST_ITEM_OBJECTIVES_COUNT 6
2008-10-11 14:16:25 -05:00
#define QUEST_SOURCE_ITEM_IDS_COUNT 4
2009-02-17 16:41:45 +01:00
#define QUEST_REWARD_CHOICES_COUNT 6
2008-10-11 14:16:25 -05:00
#define QUEST_REWARDS_COUNT 4
#define QUEST_DEPLINK_COUNT 10
#define QUEST_REPUTATIONS_COUNT 5
#define QUEST_EMOTE_COUNT 4
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum QuestFailedReasons
{
INVALIDREASON_DONT_HAVE_REQ = 0 ,
2008-12-24 09:58:26 -06:00
INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1 , // You are not high enough level for that quest.
INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6 , // That quest is not available to your race.
INVALIDREASON_QUEST_ALREADY_DONE = 7 , // You have completed that quest.
INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12 , // You can only be on one timed quest at a time.
INVALIDREASON_QUEST_ALREADY_ON = 13 , // You are already on that quest.
INVALIDREASON_QUEST_FAILED_EXPANSION = 16 , // This quest requires an expansion enabled account.
INVALIDREASON_QUEST_ALREADY_ON2 = 18 , // You are already on that quest.
INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 21 , // You don't have the required items with you. Check storage.
INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 23 , // You don't have enough money for that quest.
INVALIDREASON_DAILY_QUESTS_REMAINING = 26 , // You have already completed 25 daily quests today.
INVALIDREASON_QUEST_FAILED_CAIS = 27 , // You cannot complete quests once you have reached tired time.
INVALIDREASON_DAILY_QUEST_COMPLETED_TODAY = 29 // You have completed that daily quest today.
2008-10-11 14:16:25 -05:00
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum QuestShareMessages
{
2008-12-24 09:58:26 -06:00
QUEST_PARTY_MSG_SHARING_QUEST = 0 ,
QUEST_PARTY_MSG_CANT_TAKE_QUEST = 1 ,
QUEST_PARTY_MSG_ACCEPT_QUEST = 2 ,
QUEST_PARTY_MSG_DECLINE_QUEST = 3 ,
QUEST_PARTY_MSG_BUSY = 4 ,
QUEST_PARTY_MSG_LOG_FULL = 5 ,
QUEST_PARTY_MSG_HAVE_QUEST = 6 ,
QUEST_PARTY_MSG_FINISH_QUEST = 7 ,
QUEST_PARTY_MSG_CANT_BE_SHARED_TODAY = 8 ,
QUEST_PARTY_MSG_SHARING_TIMER_EXPIRED = 9 ,
QUEST_PARTY_MSG_NOT_IN_PARTY = 10
2008-10-11 14:16:25 -05:00
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum __QuestTradeSkill
{
QUEST_TRSKILL_NONE = 0 ,
QUEST_TRSKILL_ALCHEMY = 1 ,
QUEST_TRSKILL_BLACKSMITHING = 2 ,
QUEST_TRSKILL_COOKING = 3 ,
QUEST_TRSKILL_ENCHANTING = 4 ,
QUEST_TRSKILL_ENGINEERING = 5 ,
QUEST_TRSKILL_FIRSTAID = 6 ,
QUEST_TRSKILL_HERBALISM = 7 ,
QUEST_TRSKILL_LEATHERWORKING = 8 ,
QUEST_TRSKILL_POISONS = 9 ,
QUEST_TRSKILL_TAILORING = 10 ,
QUEST_TRSKILL_MINING = 11 ,
QUEST_TRSKILL_FISHING = 12 ,
QUEST_TRSKILL_SKINNING = 13 ,
QUEST_TRSKILL_JEWELCRAFTING = 14 ,
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum QuestStatus
{
QUEST_STATUS_NONE = 0 ,
QUEST_STATUS_COMPLETE = 1 ,
2009-08-05 19:43:55 -05:00
//QUEST_STATUS_UNAVAILABLE = 2,
2008-10-11 14:16:25 -05:00
QUEST_STATUS_INCOMPLETE = 3 ,
2009-08-05 19:43:55 -05:00
//QUEST_STATUS_AVAILABLE = 4,
2009-08-12 20:57:35 -05:00
QUEST_STATUS_FAILED = 5 ,
2008-10-11 14:16:25 -05:00
MAX_QUEST_STATUS
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum __QuestGiverStatus
{
DIALOG_STATUS_NONE = 0 ,
DIALOG_STATUS_UNAVAILABLE = 1 ,
2009-06-11 00:45:59 -05:00
DIALOG_STATUS_CHAT = 2 , // 3.1 - may be changed
DIALOG_STATUS_UNK1 = 3 , // 3.1
DIALOG_STATUS_UNK2 = 4 , // 3.1
DIALOG_STATUS_INCOMPLETE = 5 ,
DIALOG_STATUS_REWARD_REP = 6 ,
DIALOG_STATUS_AVAILABLE_REP = 7 ,
DIALOG_STATUS_AVAILABLE = 8 ,
DIALOG_STATUS_REWARD2 = 9 , // no yellow dot on minimap
DIALOG_STATUS_REWARD = 10 // yellow dot on minimap
2008-10-11 14:16:25 -05:00
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum __QuestFlags
{
2008-12-12 11:21:28 -06:00
// Flags used at server and sent to client
QUEST_FLAGS_STAY_ALIVE = 0x00000001 , // Not used currently
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
QUEST_FLAGS_EXPLORATION = 0x00000004 , // Not used currently
QUEST_FLAGS_SHARABLE = 0x00000008 , // Can be shared: Player::CanShareQuest()
//QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently
QUEST_FLAGS_EPIC = 0x00000020 , // Not used currently: Unsure of content
QUEST_FLAGS_RAID = 0x00000040 , // Not used currently
2009-03-21 14:53:38 -06:00
QUEST_FLAGS_TBC = 0x00000080 , // Not used currently: Available if TBC expansion enabled only
2008-12-12 11:21:28 -06:00
QUEST_FLAGS_UNK2 = 0x00000100 , // Not used currently: _DELIVER_MORE Quest needs more than normal _q-item_ drops from mobs
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))
QUEST_FLAGS_AUTO_REWARDED = 0x00000400 , // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
QUEST_FLAGS_TBC_RACES = 0x00000800 , // Not used currently: Blood elf/Draenei starting zone quests
QUEST_FLAGS_DAILY = 0x00001000 , // Used to know quest is Daily one
2009-06-17 21:48:19 -05:00
QUEST_FLAGS_WEEKLY = 0x00008000 ,
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
// Trinity flags for set SpecialFlags in DB if required but used only at server
QUEST_TRINITY_FLAGS_REPEATABLE = 0x010000 , // Set by 1 in SpecialFlags from DB
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)
QUEST_TRINITY_FLAGS_DB_ALLOWED = 0xFFFF | QUEST_TRINITY_FLAGS_REPEATABLE | QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT ,
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
// Trinity flags for internal use only
QUEST_TRINITY_FLAGS_DELIVER = 0x040000 , // Internal flag computed only
QUEST_TRINITY_FLAGS_SPEAKTO = 0x080000 , // Internal flag computed only
QUEST_TRINITY_FLAGS_KILL_OR_CAST = 0x100000 , // Internal flag computed only
QUEST_TRINITY_FLAGS_TIMED = 0x200000 , // Internal flag computed only
2008-10-11 14:16:25 -05:00
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
struct QuestLocale
{
QuestLocale () { ObjectiveText . resize ( QUEST_OBJECTIVES_COUNT ); }
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: vector < std :: string > Title ;
std :: vector < std :: string > Details ;
std :: vector < std :: string > Objectives ;
std :: vector < std :: string > OfferRewardText ;
std :: vector < std :: string > RequestItemsText ;
std :: vector < std :: string > EndText ;
std :: vector < std :: vector < std :: string > > ObjectiveText ;
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// This Quest class provides a convenient way to access a few pretotaled (cached) quest details,
// all base quest information, and any utility functions such as generating the amount of
// xp to give
class Quest
{
friend class ObjectMgr ;
public :
Quest ( Field * questRecord );
uint32 XPValue ( Player * pPlayer ) const ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
bool HasFlag ( uint32 flag ) const { return ( QuestFlags & flag ) != 0 ; }
void SetFlag ( uint32 flag ) { QuestFlags |= flag ; }
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// table data accessors:
uint32 GetQuestId () const { return QuestId ; }
uint32 GetQuestMethod () const { return QuestMethod ; }
int32 GetZoneOrSort () const { return ZoneOrSort ; }
int32 GetSkillOrClass () const { return SkillOrClass ; }
uint32 GetMinLevel () const { return MinLevel ; }
uint32 GetQuestLevel () const { return QuestLevel ; }
uint32 GetType () const { return Type ; }
uint32 GetRequiredRaces () const { return RequiredRaces ; }
uint32 GetRequiredSkillValue () const { return RequiredSkillValue ; }
uint32 GetRepObjectiveFaction () const { return RepObjectiveFaction ; }
int32 GetRepObjectiveValue () const { return RepObjectiveValue ; }
uint32 GetRequiredMinRepFaction () const { return RequiredMinRepFaction ; }
int32 GetRequiredMinRepValue () const { return RequiredMinRepValue ; }
uint32 GetRequiredMaxRepFaction () const { return RequiredMaxRepFaction ; }
int32 GetRequiredMaxRepValue () const { return RequiredMaxRepValue ; }
uint32 GetSuggestedPlayers () const { return SuggestedPlayers ; }
uint32 GetLimitTime () const { return LimitTime ; }
int32 GetPrevQuestId () const { return PrevQuestId ; }
int32 GetNextQuestId () const { return NextQuestId ; }
int32 GetExclusiveGroup () const { return ExclusiveGroup ; }
uint32 GetNextQuestInChain () const { return NextQuestInChain ; }
uint32 GetCharTitleId () const { return CharTitleId ; }
2008-12-24 09:58:26 -06:00
uint32 GetPlayersSlain () const { return PlayersSlain ; }
uint32 GetBonusTalents () const { return BonusTalents ; }
2008-10-11 14:16:25 -05:00
uint32 GetSrcItemId () const { return SrcItemId ; }
uint32 GetSrcItemCount () const { return SrcItemCount ; }
uint32 GetSrcSpell () const { return SrcSpell ; }
std :: string GetTitle () const { return Title ; }
std :: string GetDetails () const { return Details ; }
std :: string GetObjectives () const { return Objectives ; }
std :: string GetOfferRewardText () const { return OfferRewardText ; }
std :: string GetRequestItemsText () const { return RequestItemsText ; }
std :: string GetEndText () const { return EndText ; }
int32 GetRewOrReqMoney () const ;
2008-10-22 07:02:05 -05:00
uint32 GetRewHonorableKills () const { return RewHonorableKills ; }
2008-10-11 14:16:25 -05:00
uint32 GetRewMoneyMaxLevel () const { return RewMoneyMaxLevel ; }
// use in XP calculation at client
uint32 GetRewSpell () const { return RewSpell ; }
uint32 GetRewSpellCast () const { return RewSpellCast ; }
uint32 GetRewMailTemplateId () const { return RewMailTemplateId ; }
uint32 GetRewMailDelaySecs () const { return RewMailDelaySecs ; }
uint32 GetPointMapId () const { return PointMapId ; }
float GetPointX () const { return PointX ; }
float GetPointY () const { return PointY ; }
uint32 GetPointOpt () const { return PointOpt ; }
uint32 GetIncompleteEmote () const { return IncompleteEmote ; }
uint32 GetCompleteEmote () const { return CompleteEmote ; }
uint32 GetQuestStartScript () const { return QuestStartScript ; }
uint32 GetQuestCompleteScript () const { return QuestCompleteScript ; }
2008-10-14 11:57:03 -05:00
bool IsRepeatable () const { return QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE ; }
2008-10-11 14:16:25 -05:00
bool IsAutoComplete () const { return QuestMethod ? false : true ; }
uint32 GetFlags () const { return QuestFlags ; }
2009-06-17 21:48:19 -05:00
bool IsDaily () const { return QuestFlags & ( QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY ); }
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// multiple values
std :: string ObjectiveText [ QUEST_OBJECTIVES_COUNT ];
2009-12-17 12:13:33 +01:00
uint32 ReqItemId [ QUEST_ITEM_OBJECTIVES_COUNT ];
uint32 ReqItemCount [ QUEST_ITEM_OBJECTIVES_COUNT ];
2008-10-11 14:16:25 -05:00
uint32 ReqSourceId [ QUEST_SOURCE_ITEM_IDS_COUNT ];
uint32 ReqSourceCount [ QUEST_SOURCE_ITEM_IDS_COUNT ];
int32 ReqCreatureOrGOId [ QUEST_OBJECTIVES_COUNT ]; // >0 Creature <0 Gameobject
uint32 ReqCreatureOrGOCount [ QUEST_OBJECTIVES_COUNT ];
uint32 ReqSpell [ QUEST_OBJECTIVES_COUNT ];
uint32 RewChoiceItemId [ QUEST_REWARD_CHOICES_COUNT ];
uint32 RewChoiceItemCount [ QUEST_REWARD_CHOICES_COUNT ];
uint32 RewItemId [ QUEST_REWARDS_COUNT ];
uint32 RewItemCount [ QUEST_REWARDS_COUNT ];
uint32 RewRepFaction [ QUEST_REPUTATIONS_COUNT ];
int32 RewRepValue [ QUEST_REPUTATIONS_COUNT ];
uint32 DetailsEmote [ QUEST_EMOTE_COUNT ];
2009-06-03 19:23:49 -05:00
uint32 DetailsEmoteDelay [ QUEST_EMOTE_COUNT ];
2008-10-11 14:16:25 -05:00
uint32 OfferRewardEmote [ QUEST_EMOTE_COUNT ];
2009-06-03 19:23:49 -05:00
uint32 OfferRewardEmoteDelay [ QUEST_EMOTE_COUNT ];
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 GetReqItemsCount () const { return m_reqitemscount ; }
uint32 GetReqCreatureOrGOcount () const { return m_reqCreatureOrGOcount ; }
uint32 GetRewChoiceItemsCount () const { return m_rewchoiceitemscount ; }
uint32 GetRewItemsCount () const { return m_rewitemscount ; }
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
typedef std :: vector < int32 > PrevQuests ;
PrevQuests prevQuests ;
typedef std :: vector < uint32 > PrevChainQuests ;
PrevChainQuests prevChainQuests ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// cached data
private :
uint32 m_reqitemscount ;
uint32 m_reqCreatureOrGOcount ;
uint32 m_rewchoiceitemscount ;
uint32 m_rewitemscount ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// table data
protected :
uint32 QuestId ;
uint32 QuestMethod ;
int32 ZoneOrSort ;
int32 SkillOrClass ;
uint32 MinLevel ;
uint32 QuestLevel ;
uint32 Type ;
uint32 RequiredRaces ;
uint32 RequiredSkillValue ;
uint32 RepObjectiveFaction ;
int32 RepObjectiveValue ;
uint32 RequiredMinRepFaction ;
int32 RequiredMinRepValue ;
uint32 RequiredMaxRepFaction ;
int32 RequiredMaxRepValue ;
uint32 SuggestedPlayers ;
uint32 LimitTime ;
uint32 QuestFlags ;
uint32 CharTitleId ;
2008-12-24 09:58:26 -06:00
uint32 PlayersSlain ;
uint32 BonusTalents ;
2008-10-11 14:16:25 -05:00
int32 PrevQuestId ;
int32 NextQuestId ;
int32 ExclusiveGroup ;
uint32 NextQuestInChain ;
uint32 SrcItemId ;
uint32 SrcItemCount ;
uint32 SrcSpell ;
std :: string Title ;
std :: string Details ;
std :: string Objectives ;
std :: string OfferRewardText ;
std :: string RequestItemsText ;
std :: string EndText ;
2008-10-22 07:02:05 -05:00
uint32 RewHonorableKills ;
2008-10-11 14:16:25 -05:00
int32 RewOrReqMoney ;
uint32 RewMoneyMaxLevel ;
uint32 RewSpell ;
uint32 RewSpellCast ;
uint32 RewMailTemplateId ;
uint32 RewMailDelaySecs ;
uint32 PointMapId ;
float PointX ;
float PointY ;
uint32 PointOpt ;
uint32 IncompleteEmote ;
uint32 CompleteEmote ;
uint32 QuestStartScript ;
uint32 QuestCompleteScript ;
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
enum QuestUpdateState
{
QUEST_UNCHANGED = 0 ,
QUEST_CHANGED = 1 ,
QUEST_NEW = 2
};
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
struct QuestStatusData
{
QuestStatusData ()
: m_status ( QUEST_STATUS_NONE ), m_rewarded ( false ),
m_explored ( false ), m_timer ( 0 ), uState ( QUEST_NEW )
{
2009-12-17 12:13:33 +01:00
memset ( m_itemcount , 0 , QUEST_ITEM_OBJECTIVES_COUNT * sizeof ( uint32 ));
2008-10-11 14:16:25 -05:00
memset ( m_creatureOrGOcount , 0 , QUEST_OBJECTIVES_COUNT * sizeof ( uint32 ));
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
QuestStatus m_status ;
bool m_rewarded ;
bool m_explored ;
uint32 m_timer ;
QuestUpdateState uState ;
2009-10-17 15:51:44 -07:00
2009-12-17 12:13:33 +01:00
uint32 m_itemcount [ QUEST_ITEM_OBJECTIVES_COUNT ];
2008-10-11 14:16:25 -05:00
uint32 m_creatureOrGOcount [ QUEST_OBJECTIVES_COUNT ];
};
#endif