[8483] Implement glyph 43361.
[getmangos.git] / src / game / QuestDef.cpp
blob8c71d83ac31f635411341427a3e8d0506c8af194
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 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
119 DetailsEmoteDelay[i] = questRecord[112+i].GetUInt32();
121 IncompleteEmote = questRecord[116].GetUInt32();
122 CompleteEmote = questRecord[117].GetUInt32();
124 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
125 OfferRewardEmote[i] = questRecord[118+i].GetInt32();
127 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
128 OfferRewardEmoteDelay[i] = questRecord[122+i].GetInt32();
130 QuestStartScript = questRecord[126].GetUInt32();
131 QuestCompleteScript = questRecord[127].GetUInt32();
133 QuestFlags |= SpecialFlags << 16;
135 m_reqitemscount = 0;
136 m_reqCreatureOrGOcount = 0;
137 m_rewitemscount = 0;
138 m_rewchoiceitemscount = 0;
140 for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i)
142 if ( ReqItemId[i] )
143 ++m_reqitemscount;
144 if ( ReqCreatureOrGOId[i] )
145 ++m_reqCreatureOrGOcount;
148 for (int i=0; i < QUEST_REWARDS_COUNT; ++i)
150 if ( RewItemId[i] )
151 ++m_rewitemscount;
154 for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
156 if (RewChoiceItemId[i])
157 ++m_rewchoiceitemscount;
161 uint32 Quest::XPValue( Player *pPlayer ) const
163 if( pPlayer )
165 if( RewMoneyMaxLevel > 0 )
167 uint32 pLevel = pPlayer->getLevel();
168 uint32 qLevel = QuestLevel;
169 float fullxp = 0;
170 if (qLevel >= 15)
171 fullxp = RewMoneyMaxLevel / 6.0f;
172 else if (qLevel == 14)
173 fullxp = RewMoneyMaxLevel / 4.8f;
174 else if (qLevel == 13)
175 fullxp = RewMoneyMaxLevel / 3.666f;
176 else if (qLevel == 12)
177 fullxp = RewMoneyMaxLevel / 2.4f;
178 else if (qLevel == 11)
179 fullxp = RewMoneyMaxLevel / 1.2f;
180 else if (qLevel >= 1 && qLevel <= 10)
181 fullxp = RewMoneyMaxLevel / 0.6f;
182 else if (qLevel == 0)
183 fullxp = RewMoneyMaxLevel;
185 if( pLevel <= qLevel + 5 )
186 return (uint32)fullxp;
187 else if( pLevel == qLevel + 6 )
188 return (uint32)(fullxp * 0.8f);
189 else if( pLevel == qLevel + 7 )
190 return (uint32)(fullxp * 0.6f);
191 else if( pLevel == qLevel + 8 )
192 return (uint32)(fullxp * 0.4f);
193 else if( pLevel == qLevel + 9 )
194 return (uint32)(fullxp * 0.2f);
195 else
196 return (uint32)(fullxp * 0.1f);
199 return 0;
202 int32 Quest::GetRewOrReqMoney() const
204 if(RewOrReqMoney <=0)
205 return RewOrReqMoney;
207 return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));