root/trunk/src/game/QuestDef.cpp @ 2

Revision 2, 7.0 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include "QuestDef.h"
20#include "Player.h"
21#include "World.h"
22
23Quest::Quest(Field * questRecord)
24{
25    QuestId = questRecord[0].GetUInt32();
26    ZoneOrSort = questRecord[1].GetInt32();
27    SkillOrClass = questRecord[2].GetInt32();
28    MinLevel = questRecord[3].GetUInt32();
29    QuestLevel = questRecord[4].GetUInt32();
30    Type = questRecord[5].GetUInt32();
31    RequiredRaces = questRecord[6].GetUInt32();
32    RequiredSkillValue = questRecord[7].GetUInt32();
33    RepObjectiveFaction = questRecord[8].GetUInt32();
34    RepObjectiveValue = questRecord[9].GetInt32();
35    RequiredMinRepFaction = questRecord[10].GetUInt32();
36    RequiredMinRepValue = questRecord[11].GetInt32();
37    RequiredMaxRepFaction = questRecord[12].GetUInt32();
38    RequiredMaxRepValue = questRecord[13].GetInt32();
39    SuggestedPlayers = questRecord[14].GetUInt32();
40    LimitTime = questRecord[15].GetUInt32();
41    QuestFlags = questRecord[16].GetUInt16();
42    uint32 SpecialFlags = questRecord[17].GetUInt16();
43    CharTitleId = questRecord[18].GetUInt32();
44    PrevQuestId = questRecord[19].GetInt32();
45    NextQuestId = questRecord[20].GetInt32();
46    ExclusiveGroup = questRecord[21].GetInt32();
47    NextQuestInChain = questRecord[22].GetUInt32();
48    SrcItemId = questRecord[23].GetUInt32();
49    SrcItemCount = questRecord[24].GetUInt32();
50    SrcSpell = questRecord[25].GetUInt32();
51    Title = questRecord[26].GetCppString();
52    Details = questRecord[27].GetCppString();
53    Objectives = questRecord[28].GetCppString();
54    OfferRewardText = questRecord[29].GetCppString();
55    RequestItemsText = questRecord[30].GetCppString();
56    EndText = questRecord[31].GetCppString();
57
58    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
59        ObjectiveText[i] = questRecord[32+i].GetCppString();
60
61    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
62        ReqItemId[i] = questRecord[36+i].GetUInt32();
63
64    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
65        ReqItemCount[i] = questRecord[40+i].GetUInt32();
66
67    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
68        ReqSourceId[i] = questRecord[44+i].GetUInt32();
69
70    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
71        ReqSourceCount[i] = questRecord[48+i].GetUInt32();
72
73    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
74        ReqSourceRef[i] = questRecord[52+i].GetUInt32();
75
76    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
77        ReqCreatureOrGOId[i] = questRecord[56+i].GetInt32();
78
79    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
80        ReqCreatureOrGOCount[i] = questRecord[60+i].GetUInt32();
81
82    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
83        ReqSpell[i] = questRecord[64+i].GetUInt32();
84
85    for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
86        RewChoiceItemId[i] = questRecord[68+i].GetUInt32();
87
88    for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
89        RewChoiceItemCount[i] = questRecord[74+i].GetUInt32();
90
91    for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
92        RewItemId[i] = questRecord[80+i].GetUInt32();
93
94    for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
95        RewItemCount[i] = questRecord[84+i].GetUInt32();
96
97    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
98        RewRepFaction[i] = questRecord[88+i].GetUInt32();
99
100    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
101        RewRepValue[i] = questRecord[93+i].GetInt32();
102
103    RewOrReqMoney = questRecord[98].GetInt32();
104    RewMoneyMaxLevel = questRecord[99].GetUInt32();
105    RewSpell = questRecord[100].GetUInt32();
106    RewSpellCast = questRecord[101].GetUInt32();
107    RewMailTemplateId = questRecord[102].GetUInt32();
108    RewMailDelaySecs = questRecord[103].GetUInt32();
109    PointMapId = questRecord[104].GetUInt32();
110    PointX = questRecord[105].GetFloat();
111    PointY = questRecord[106].GetFloat();
112    PointOpt = questRecord[107].GetUInt32();
113
114    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
115        DetailsEmote[i] = questRecord[108+i].GetUInt32();
116
117    IncompleteEmote = questRecord[112].GetUInt32();
118    CompleteEmote = questRecord[113].GetUInt32();
119
120    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
121        OfferRewardEmote[i] = questRecord[114+i].GetInt32();
122
123    QuestStartScript = questRecord[118].GetUInt32();
124    QuestCompleteScript = questRecord[119].GetUInt32();
125
126    QuestFlags |= SpecialFlags << 16;
127
128    m_reqitemscount = 0;
129    m_reqCreatureOrGOcount = 0;
130    m_rewitemscount = 0;
131    m_rewchoiceitemscount = 0;
132
133    for (int i=0; i < QUEST_OBJECTIVES_COUNT; i++)
134    {
135        if ( ReqItemId[i] )
136            ++m_reqitemscount;
137        if ( ReqCreatureOrGOId[i] )
138            ++m_reqCreatureOrGOcount;
139    }
140
141    for (int i=0; i < QUEST_REWARDS_COUNT; i++)
142    {
143        if ( RewItemId[i] )
144            ++m_rewitemscount;
145    }
146
147    for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; i++)
148    {
149        if (RewChoiceItemId[i])
150            ++m_rewchoiceitemscount;
151    }
152}
153
154uint32 Quest::XPValue( Player *pPlayer ) const
155{
156    if( pPlayer )
157    {
158        if( RewMoneyMaxLevel > 0 )
159        {
160            uint32 pLevel = pPlayer->getLevel();
161            uint32 qLevel = QuestLevel;
162            float fullxp = 0;
163            if (qLevel >= 65)
164                fullxp = RewMoneyMaxLevel / 6.0f;
165            else if (qLevel == 64)
166                fullxp = RewMoneyMaxLevel / 4.8f;
167            else if (qLevel == 63)
168                fullxp = RewMoneyMaxLevel / 3.6f;
169            else if (qLevel == 62)
170                fullxp = RewMoneyMaxLevel / 2.4f;
171            else if (qLevel == 61)
172                fullxp = RewMoneyMaxLevel / 1.2f;
173            else if (qLevel > 0 && qLevel <= 60)
174                fullxp = RewMoneyMaxLevel / 0.6f;
175
176            if( pLevel <= qLevel +  5 )
177                return (uint32)fullxp;
178            else if( pLevel == qLevel +  6 )
179                return (uint32)(fullxp * 0.8f);
180            else if( pLevel == qLevel +  7 )
181                return (uint32)(fullxp * 0.6f);
182            else if( pLevel == qLevel +  8 )
183                return (uint32)(fullxp * 0.4f);
184            else if( pLevel == qLevel +  9 )
185                return (uint32)(fullxp * 0.2f);
186            else
187                return (uint32)(fullxp * 0.1f);
188        }
189    }
190    return 0;
191}
192
193int32  Quest::GetRewOrReqMoney() const
194{
195    if(RewOrReqMoney <=0)
196        return RewOrReqMoney;
197
198    return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));
199}
Note: See TracBrowser for help on using the browser.