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
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_SOURCE_ITEM_IDS_COUNT
; ++i
)
77 ReqSourceRef
[i
] = questRecord
[55+i
].GetUInt32();
79 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
80 ReqCreatureOrGOId
[i
] = questRecord
[59+i
].GetInt32();
82 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
83 ReqCreatureOrGOCount
[i
] = questRecord
[63+i
].GetUInt32();
85 for (int i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
86 ReqSpell
[i
] = questRecord
[67+i
].GetUInt32();
88 for (int i
= 0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
89 RewChoiceItemId
[i
] = questRecord
[71+i
].GetUInt32();
91 for (int i
= 0; i
< QUEST_REWARD_CHOICES_COUNT
; ++i
)
92 RewChoiceItemCount
[i
] = questRecord
[77+i
].GetUInt32();
94 for (int i
= 0; i
< QUEST_REWARDS_COUNT
; ++i
)
95 RewItemId
[i
] = questRecord
[83+i
].GetUInt32();
97 for (int i
= 0; i
< QUEST_REWARDS_COUNT
; ++i
)
98 RewItemCount
[i
] = questRecord
[87+i
].GetUInt32();
100 for (int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
)
101 RewRepFaction
[i
] = questRecord
[91+i
].GetUInt32();
103 for (int i
= 0; i
< QUEST_REPUTATIONS_COUNT
; ++i
)
104 RewRepValue
[i
] = questRecord
[96+i
].GetInt32();
106 RewHonorableKills
= questRecord
[101].GetUInt32();
107 RewOrReqMoney
= questRecord
[102].GetInt32();
108 RewMoneyMaxLevel
= questRecord
[103].GetUInt32();
109 RewSpell
= questRecord
[104].GetUInt32();
110 RewSpellCast
= questRecord
[105].GetUInt32();
111 RewMailTemplateId
= questRecord
[106].GetUInt32();
112 RewMailDelaySecs
= questRecord
[107].GetUInt32();
113 PointMapId
= questRecord
[108].GetUInt32();
114 PointX
= questRecord
[109].GetFloat();
115 PointY
= questRecord
[110].GetFloat();
116 PointOpt
= questRecord
[111].GetUInt32();
118 for (int i
= 0; i
< QUEST_EMOTE_COUNT
; ++i
)
119 DetailsEmote
[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 QuestStartScript
= questRecord
[122].GetUInt32();
128 QuestCompleteScript
= questRecord
[123].GetUInt32();
130 QuestFlags
|= SpecialFlags
<< 16;
133 m_reqCreatureOrGOcount
= 0;
135 m_rewchoiceitemscount
= 0;
137 for (int i
=0; i
< QUEST_OBJECTIVES_COUNT
; i
++)
141 if ( ReqCreatureOrGOId
[i
] )
142 ++m_reqCreatureOrGOcount
;
145 for (int i
=0; i
< QUEST_REWARDS_COUNT
; i
++)
151 for (int i
=0; i
< QUEST_REWARD_CHOICES_COUNT
; i
++)
153 if (RewChoiceItemId
[i
])
154 ++m_rewchoiceitemscount
;
158 uint32
Quest::XPValue( Player
*pPlayer
) const
162 if( RewMoneyMaxLevel
> 0 )
164 uint32 pLevel
= pPlayer
->getLevel();
165 uint32 qLevel
= QuestLevel
;
168 fullxp
= RewMoneyMaxLevel
/ 6.0f
;
169 else if (qLevel
== 64)
170 fullxp
= RewMoneyMaxLevel
/ 4.8f
;
171 else if (qLevel
== 63)
172 fullxp
= RewMoneyMaxLevel
/ 3.6f
;
173 else if (qLevel
== 62)
174 fullxp
= RewMoneyMaxLevel
/ 2.4f
;
175 else if (qLevel
== 61)
176 fullxp
= RewMoneyMaxLevel
/ 1.2f
;
177 else if (qLevel
> 0 && qLevel
<= 60)
178 fullxp
= RewMoneyMaxLevel
/ 0.6f
;
180 if( pLevel
<= qLevel
+ 5 )
181 return (uint32
)fullxp
;
182 else if( pLevel
== qLevel
+ 6 )
183 return (uint32
)(fullxp
* 0.8f
);
184 else if( pLevel
== qLevel
+ 7 )
185 return (uint32
)(fullxp
* 0.6f
);
186 else if( pLevel
== qLevel
+ 8 )
187 return (uint32
)(fullxp
* 0.4f
);
188 else if( pLevel
== qLevel
+ 9 )
189 return (uint32
)(fullxp
* 0.2f
);
191 return (uint32
)(fullxp
* 0.1f
);
197 int32
Quest::GetRewOrReqMoney() const
199 if(RewOrReqMoney
<=0)
200 return RewOrReqMoney
;
202 return int32(RewOrReqMoney
* sWorld
.getRate(RATE_DROP_MONEY
));