[7916] Fixed pet action bar setup.
[getmangos.git] / src / game / QuestDef.cpp
blob2f0ed421cddb009dcc489121a6753b6cb75a6dba
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 #include "QuestDef.h"
20 #include "Player.h"
21 #include "World.h"
23 Quest::Quest(Field * questRecord)
25 QuestId = questRecord[0].GetUInt32();
26 QuestMethod = questRecord[1].GetUInt32();
27 ZoneOrSort = questRecord[2].GetInt32();
28 SkillOrClass = questRecord[3].GetInt32();
29 MinLevel = questRecord[4].GetUInt32();
30 QuestLevel = questRecord[5].GetUInt32();
31 Type = questRecord[6].GetUInt32();
32 RequiredRaces = questRecord[7].GetUInt32();
33 RequiredSkillValue = questRecord[8].GetUInt32();
34 RepObjectiveFaction = questRecord[9].GetUInt32();
35 RepObjectiveValue = questRecord[10].GetInt32();
36 RequiredMinRepFaction = questRecord[11].GetUInt32();
37 RequiredMinRepValue = questRecord[12].GetInt32();
38 RequiredMaxRepFaction = questRecord[13].GetUInt32();
39 RequiredMaxRepValue = questRecord[14].GetInt32();
40 SuggestedPlayers = questRecord[15].GetUInt32();
41 LimitTime = questRecord[16].GetUInt32();
42 QuestFlags = questRecord[17].GetUInt16();
43 uint32 SpecialFlags = questRecord[18].GetUInt16();
44 CharTitleId = questRecord[19].GetUInt32();
45 PlayersSlain = questRecord[20].GetUInt32();
46 BonusTalents = questRecord[21].GetUInt32();
47 PrevQuestId = questRecord[22].GetInt32();
48 NextQuestId = questRecord[23].GetInt32();
49 ExclusiveGroup = questRecord[24].GetInt32();
50 NextQuestInChain = questRecord[25].GetUInt32();
51 SrcItemId = questRecord[26].GetUInt32();
52 SrcItemCount = questRecord[27].GetUInt32();
53 SrcSpell = questRecord[28].GetUInt32();
54 Title = questRecord[29].GetCppString();
55 Details = questRecord[30].GetCppString();
56 Objectives = questRecord[31].GetCppString();
57 OfferRewardText = questRecord[32].GetCppString();
58 RequestItemsText = questRecord[33].GetCppString();
59 EndText = questRecord[34].GetCppString();
61 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
62 ObjectiveText[i] = questRecord[35+i].GetCppString();
64 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
65 ReqItemId[i] = questRecord[39+i].GetUInt32();
67 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
68 ReqItemCount[i] = questRecord[43+i].GetUInt32();
70 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
71 ReqSourceId[i] = questRecord[47+i].GetUInt32();
73 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
74 ReqSourceCount[i] = questRecord[51+i].GetUInt32();
76 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
77 ReqCreatureOrGOId[i] = questRecord[55+i].GetInt32();
79 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
80 ReqCreatureOrGOCount[i] = questRecord[59+i].GetUInt32();
82 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
83 ReqSpell[i] = questRecord[63+i].GetUInt32();
85 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
86 RewChoiceItemId[i] = questRecord[67+i].GetUInt32();
88 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
89 RewChoiceItemCount[i] = questRecord[73+i].GetUInt32();
91 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
92 RewItemId[i] = questRecord[79+i].GetUInt32();
94 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
95 RewItemCount[i] = questRecord[83+i].GetUInt32();
97 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
98 RewRepFaction[i] = questRecord[87+i].GetUInt32();
100 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
101 RewRepValue[i] = questRecord[92+i].GetInt32();
103 RewHonorableKills = questRecord[97].GetUInt32();
104 RewOrReqMoney = questRecord[98].GetInt32();
105 RewMoneyMaxLevel = questRecord[99].GetUInt32();
106 RewSpell = questRecord[100].GetUInt32();
107 RewSpellCast = questRecord[101].GetUInt32();
108 RewMailTemplateId = questRecord[102].GetUInt32();
109 RewMailDelaySecs = questRecord[103].GetUInt32();
110 PointMapId = questRecord[104].GetUInt32();
111 PointX = questRecord[105].GetFloat();
112 PointY = questRecord[106].GetFloat();
113 PointOpt = questRecord[107].GetUInt32();
115 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
116 DetailsEmote[i] = questRecord[108+i].GetUInt32();
118 IncompleteEmote = questRecord[112].GetUInt32();
119 CompleteEmote = questRecord[113].GetUInt32();
121 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
122 OfferRewardEmote[i] = questRecord[114+i].GetInt32();
124 QuestStartScript = questRecord[118].GetUInt32();
125 QuestCompleteScript = questRecord[119].GetUInt32();
127 QuestFlags |= SpecialFlags << 16;
129 m_reqitemscount = 0;
130 m_reqCreatureOrGOcount = 0;
131 m_rewitemscount = 0;
132 m_rewchoiceitemscount = 0;
134 for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i)
136 if ( ReqItemId[i] )
137 ++m_reqitemscount;
138 if ( ReqCreatureOrGOId[i] )
139 ++m_reqCreatureOrGOcount;
142 for (int i=0; i < QUEST_REWARDS_COUNT; ++i)
144 if ( RewItemId[i] )
145 ++m_rewitemscount;
148 for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
150 if (RewChoiceItemId[i])
151 ++m_rewchoiceitemscount;
155 uint32 Quest::XPValue( Player *pPlayer ) const
157 if( pPlayer )
159 if( RewMoneyMaxLevel > 0 )
161 uint32 pLevel = pPlayer->getLevel();
162 uint32 qLevel = QuestLevel;
163 float fullxp = 0;
164 if (qLevel >= 15)
165 fullxp = RewMoneyMaxLevel / 6.0f;
166 else if (qLevel == 14)
167 fullxp = RewMoneyMaxLevel / 4.8f;
168 else if (qLevel == 13)
169 fullxp = RewMoneyMaxLevel / 3.666f;
170 else if (qLevel == 12)
171 fullxp = RewMoneyMaxLevel / 2.4f;
172 else if (qLevel == 11)
173 fullxp = RewMoneyMaxLevel / 1.2f;
174 else if (qLevel >= 1 && qLevel <= 10)
175 fullxp = RewMoneyMaxLevel / 0.6f;
176 else if (qLevel == 0)
177 fullxp = RewMoneyMaxLevel;
179 if( pLevel <= qLevel + 5 )
180 return (uint32)fullxp;
181 else if( pLevel == qLevel + 6 )
182 return (uint32)(fullxp * 0.8f);
183 else if( pLevel == qLevel + 7 )
184 return (uint32)(fullxp * 0.6f);
185 else if( pLevel == qLevel + 8 )
186 return (uint32)(fullxp * 0.4f);
187 else if( pLevel == qLevel + 9 )
188 return (uint32)(fullxp * 0.2f);
189 else
190 return (uint32)(fullxp * 0.1f);
193 return 0;
196 int32 Quest::GetRewOrReqMoney() const
198 if(RewOrReqMoney <=0)
199 return RewOrReqMoney;
201 return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));