[6922] Whitespace and newline fixes
[getmangos.git] / src / game / QuestDef.cpp
blob06a7ed2b4fb440997ee0e0eb4eda17d6f5bbe437
1 /*
2 * Copyright (C) 2005-2008 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 PrevQuestId = questRecord[20].GetInt32();
46 NextQuestId = questRecord[21].GetInt32();
47 ExclusiveGroup = questRecord[22].GetInt32();
48 NextQuestInChain = questRecord[23].GetUInt32();
49 SrcItemId = questRecord[24].GetUInt32();
50 SrcItemCount = questRecord[25].GetUInt32();
51 SrcSpell = questRecord[26].GetUInt32();
52 Title = questRecord[27].GetCppString();
53 Details = questRecord[28].GetCppString();
54 Objectives = questRecord[29].GetCppString();
55 OfferRewardText = questRecord[30].GetCppString();
56 RequestItemsText = questRecord[31].GetCppString();
57 EndText = questRecord[32].GetCppString();
59 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
60 ObjectiveText[i] = questRecord[33+i].GetCppString();
62 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
63 ReqItemId[i] = questRecord[37+i].GetUInt32();
65 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
66 ReqItemCount[i] = questRecord[41+i].GetUInt32();
68 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
69 ReqSourceId[i] = questRecord[45+i].GetUInt32();
71 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
72 ReqSourceCount[i] = questRecord[49+i].GetUInt32();
74 for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
75 ReqSourceRef[i] = questRecord[53+i].GetUInt32();
77 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
78 ReqCreatureOrGOId[i] = questRecord[57+i].GetInt32();
80 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
81 ReqCreatureOrGOCount[i] = questRecord[61+i].GetUInt32();
83 for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
84 ReqSpell[i] = questRecord[65+i].GetUInt32();
86 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
87 RewChoiceItemId[i] = questRecord[69+i].GetUInt32();
89 for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
90 RewChoiceItemCount[i] = questRecord[75+i].GetUInt32();
92 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
93 RewItemId[i] = questRecord[81+i].GetUInt32();
95 for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
96 RewItemCount[i] = questRecord[85+i].GetUInt32();
98 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
99 RewRepFaction[i] = questRecord[89+i].GetUInt32();
101 for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
102 RewRepValue[i] = questRecord[94+i].GetInt32();
104 RewHonorableKills = questRecord[99].GetUInt32();
105 RewOrReqMoney = questRecord[100].GetInt32();
106 RewMoneyMaxLevel = questRecord[101].GetUInt32();
107 RewSpell = questRecord[102].GetUInt32();
108 RewSpellCast = questRecord[103].GetUInt32();
109 RewMailTemplateId = questRecord[104].GetUInt32();
110 RewMailDelaySecs = questRecord[105].GetUInt32();
111 PointMapId = questRecord[106].GetUInt32();
112 PointX = questRecord[107].GetFloat();
113 PointY = questRecord[108].GetFloat();
114 PointOpt = questRecord[109].GetUInt32();
116 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
117 DetailsEmote[i] = questRecord[110+i].GetUInt32();
119 IncompleteEmote = questRecord[114].GetUInt32();
120 CompleteEmote = questRecord[115].GetUInt32();
122 for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
123 OfferRewardEmote[i] = questRecord[116+i].GetInt32();
125 QuestStartScript = questRecord[120].GetUInt32();
126 QuestCompleteScript = questRecord[121].GetUInt32();
128 QuestFlags |= SpecialFlags << 16;
130 m_reqitemscount = 0;
131 m_reqCreatureOrGOcount = 0;
132 m_rewitemscount = 0;
133 m_rewchoiceitemscount = 0;
135 for (int i=0; i < QUEST_OBJECTIVES_COUNT; i++)
137 if ( ReqItemId[i] )
138 ++m_reqitemscount;
139 if ( ReqCreatureOrGOId[i] )
140 ++m_reqCreatureOrGOcount;
143 for (int i=0; i < QUEST_REWARDS_COUNT; i++)
145 if ( RewItemId[i] )
146 ++m_rewitemscount;
149 for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; i++)
151 if (RewChoiceItemId[i])
152 ++m_rewchoiceitemscount;
156 uint32 Quest::XPValue( Player *pPlayer ) const
158 if( pPlayer )
160 if( RewMoneyMaxLevel > 0 )
162 uint32 pLevel = pPlayer->getLevel();
163 uint32 qLevel = QuestLevel;
164 float fullxp = 0;
165 if (qLevel >= 65)
166 fullxp = RewMoneyMaxLevel / 6.0f;
167 else if (qLevel == 64)
168 fullxp = RewMoneyMaxLevel / 4.8f;
169 else if (qLevel == 63)
170 fullxp = RewMoneyMaxLevel / 3.6f;
171 else if (qLevel == 62)
172 fullxp = RewMoneyMaxLevel / 2.4f;
173 else if (qLevel == 61)
174 fullxp = RewMoneyMaxLevel / 1.2f;
175 else if (qLevel > 0 && qLevel <= 60)
176 fullxp = RewMoneyMaxLevel / 0.6f;
178 if( pLevel <= qLevel + 5 )
179 return (uint32)fullxp;
180 else if( pLevel == qLevel + 6 )
181 return (uint32)(fullxp * 0.8f);
182 else if( pLevel == qLevel + 7 )
183 return (uint32)(fullxp * 0.6f);
184 else if( pLevel == qLevel + 8 )
185 return (uint32)(fullxp * 0.4f);
186 else if( pLevel == qLevel + 9 )
187 return (uint32)(fullxp * 0.2f);
188 else
189 return (uint32)(fullxp * 0.1f);
192 return 0;
195 int32 Quest::GetRewOrReqMoney() const
197 if(RewOrReqMoney <=0)
198 return RewOrReqMoney;
200 return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));