2 * Copyright (C) 2005-2010 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
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].GetInt32();
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 RewXPId
= questRecord
[26].GetUInt32();
52 SrcItemId
= questRecord
[27].GetUInt32();
53 SrcItemCount
= questRecord
[28].GetUInt32();
54 SrcSpell
= questRecord
[29].GetUInt32();
55 Title
= questRecord
[30].GetCppString();
56 Details
= questRecord
[31].GetCppString();
57 Objectives
= questRecord
[32].GetCppString();
58 OfferRewardText
= questRecord
[33].GetCppString();
59 RequestItemsText
= questRecord
[34].GetCppString();
60 EndText
= questRecord
[35].GetCppString();
61 CompletedText
= questRecord
[36].GetCppString();
63 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
64 ObjectiveText
[i
] = questRecord
[37+i
].GetCppString();
66 for (int i
= 0; i
< QUEST_ITEM_OBJECTIVES_COUNT
; ++i
)
67 ReqItemId
[i
] = questRecord
[41+i
].GetUInt32();
69 for (int i
= 0; i
< QUEST_ITEM_OBJECTIVES_COUNT
; ++i
)
70 ReqItemCount
[i
] = questRecord
[47+i
].GetUInt32();
72 for (int i
= 0; i
< QUEST_SOURCE_ITEM_IDS_COUNT
; ++i
)
73 ReqSourceId
[i
] = questRecord
[53+i
].GetUInt32();
75 for (int i
= 0; i
< QUEST_SOURCE_ITEM_IDS_COUNT
; ++i
)
76 ReqSourceCount
[i
] = questRecord
[57+i
].GetUInt32();
78 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
79 ReqCreatureOrGOId
[i
] = questRecord
[61+i
].GetInt32();
81 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
82 ReqCreatureOrGOCount
[i
] = questRecord
[65+i
].GetUInt32();
84 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
85 ReqSpell
[i
] = questRecord
[69+i
].GetUInt32();
87 for (int i
= 0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
88 RewChoiceItemId
[i
] = questRecord
[73+i
].GetUInt32();
90 for (int i
= 0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
91 RewChoiceItemCount
[i
] = questRecord
[79+i
].GetUInt32();
93 for (int i
= 0; i
< QUEST_REWARDS_COUNT
; ++i
)
94 RewItemId
[i
] = questRecord
[85+i
].GetUInt32();
96 for (int i
= 0; i
< QUEST_REWARDS_COUNT
; ++i
)
97 RewItemCount
[i
] = questRecord
[89+i
].GetUInt32();
99 for (int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
)
100 RewRepFaction
[i
] = questRecord
[93+i
].GetUInt32();
102 for (int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
)
103 RewRepValueId
[i
] = questRecord
[98+i
].GetInt32();
105 for (int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
)
106 RewRepValue
[i
] = questRecord
[103+i
].GetInt32();
108 RewHonorAddition
= questRecord
[108].GetUInt32();
109 RewHonorMultiplier
= questRecord
[109].GetFloat();
110 RewOrReqMoney
= questRecord
[110].GetInt32();
111 RewMoneyMaxLevel
= questRecord
[111].GetUInt32();
112 RewSpell
= questRecord
[112].GetUInt32();
113 RewSpellCast
= questRecord
[113].GetUInt32();
114 RewMailTemplateId
= questRecord
[114].GetUInt32();
115 RewMailDelaySecs
= questRecord
[115].GetUInt32();
116 PointMapId
= questRecord
[116].GetUInt32();
117 PointX
= questRecord
[117].GetFloat();
118 PointY
= questRecord
[118].GetFloat();
119 PointOpt
= questRecord
[119].GetUInt32();
121 for (int i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
122 DetailsEmote
[i
] = questRecord
[120+i
].GetUInt32();
124 for (int i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
125 DetailsEmoteDelay
[i
] = questRecord
[124+i
].GetUInt32();
127 IncompleteEmote
= questRecord
[128].GetUInt32();
128 CompleteEmote
= questRecord
[129].GetUInt32();
130 for (int i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
131 OfferRewardEmote
[i
] = questRecord
[130+i
].GetInt32();
133 for (int i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
134 OfferRewardEmoteDelay
[i
] = questRecord
[134+i
].GetInt32();
136 QuestStartScript
= questRecord
[138].GetUInt32();
137 QuestCompleteScript
= questRecord
[139].GetUInt32();
139 QuestFlags
|= SpecialFlags
<< 24;
142 m_reqCreatureOrGOcount
= 0;
144 m_rewchoiceitemscount
= 0;
146 for (int i
=0; i
< QUEST_ITEM_OBJECTIVES_COUNT
; ++i
)
152 for (int i
=0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
154 if ( ReqCreatureOrGOId
[i
] )
155 ++m_reqCreatureOrGOcount
;
158 for (int i
=0; i
< QUEST_REWARDS_COUNT
; ++i
)
164 for (int i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
166 if (RewChoiceItemId
[i
])
167 ++m_rewchoiceitemscount
;
171 uint32
Quest::XPValue(Player
*pPlayer
) const
176 uint32 xpMultiplier
= 0;
178 int32 playerLevel
= pPlayer
->getLevel();
180 // formula can possibly be organized better, using less if's and simplify some.
182 if (QuestLevel
!= -1)
183 baseLevel
= QuestLevel
;
185 if (((baseLevel
- playerLevel
) + 10)*2 > 10)
187 baseLevel
= playerLevel
;
189 if (QuestLevel
!= -1)
190 baseLevel
= QuestLevel
;
192 if (((baseLevel
- playerLevel
) + 10)*2 <= 10)
194 if (QuestLevel
== -1)
195 baseLevel
= playerLevel
;
197 xpMultiplier
= 2 * (baseLevel
- playerLevel
) + 20;
206 baseLevel
= playerLevel
;
208 if (QuestLevel
!= -1)
209 baseLevel
= QuestLevel
;
211 if (((baseLevel
- playerLevel
) + 10)*2 >= 1)
213 baseLevel
= playerLevel
;
215 if (QuestLevel
!= -1)
216 baseLevel
= QuestLevel
;
218 if (((baseLevel
- playerLevel
) + 10)*2 <= 10)
220 if (QuestLevel
== -1)
221 baseLevel
= playerLevel
;
223 xpMultiplier
= 2 * (baseLevel
- playerLevel
) + 20;
236 // not possible to reward XP when baseLevel does not exist in dbc
237 if (const QuestXPLevel
* pXPData
= sQuestXPLevelStore
.LookupEntry(baseLevel
))
239 uint32 rawXP
= xpMultiplier
* pXPData
->xpIndex
[RewXPId
] / 10;
243 realXP
= ((rawXP
+ 25) / 50 * 50);
244 else if (rawXP
> 500)
245 realXP
= ((rawXP
+ 12) / 25 * 25);
246 else if (rawXP
> 100)
247 realXP
= ((rawXP
+ 5) / 10 * 10);
249 realXP
= ((rawXP
+ 2) / 5 * 5);
258 int32
Quest::GetRewOrReqMoney() const
260 if(RewOrReqMoney
<=0)
261 return RewOrReqMoney
;
263 return int32(RewOrReqMoney
* sWorld
.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY
));