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

Revision 102, 7.1 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "QuestDef.h"
22#include "Player.h"
23#include "World.h"
24
25Quest::Quest(Field * questRecord)
26{
27    QuestId = questRecord[0].GetUInt32();
28    QuestMethod = questRecord[1].GetUInt32();
29    ZoneOrSort = questRecord[2].GetInt32();
30    SkillOrClass = questRecord[3].GetInt32();
31    MinLevel = questRecord[4].GetUInt32();
32    QuestLevel = questRecord[5].GetUInt32();
33    Type = questRecord[6].GetUInt32();
34    RequiredRaces = questRecord[7].GetUInt32();
35    RequiredSkillValue = questRecord[8].GetUInt32();
36    RepObjectiveFaction = questRecord[9].GetUInt32();
37    RepObjectiveValue = questRecord[10].GetInt32();
38    RequiredMinRepFaction = questRecord[11].GetUInt32();
39    RequiredMinRepValue = questRecord[12].GetInt32();
40    RequiredMaxRepFaction = questRecord[13].GetUInt32();
41    RequiredMaxRepValue = questRecord[14].GetInt32();
42    SuggestedPlayers = questRecord[15].GetUInt32();
43    LimitTime = questRecord[16].GetUInt32();
44    QuestFlags = questRecord[17].GetUInt16();
45    uint32 SpecialFlags = questRecord[18].GetUInt16();
46    CharTitleId = questRecord[19].GetUInt32();
47    PrevQuestId = questRecord[20].GetInt32();
48    NextQuestId = questRecord[21].GetInt32();
49    ExclusiveGroup = questRecord[22].GetInt32();
50    NextQuestInChain = questRecord[23].GetUInt32();
51    SrcItemId = questRecord[24].GetUInt32();
52    SrcItemCount = questRecord[25].GetUInt32();
53    SrcSpell = questRecord[26].GetUInt32();
54    Title = questRecord[27].GetCppString();
55    Details = questRecord[28].GetCppString();
56    Objectives = questRecord[29].GetCppString();
57    OfferRewardText = questRecord[30].GetCppString();
58    RequestItemsText = questRecord[31].GetCppString();
59    EndText = questRecord[32].GetCppString();
60
61    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
62        ObjectiveText[i] = questRecord[33+i].GetCppString();
63
64    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
65        ReqItemId[i] = questRecord[37+i].GetUInt32();
66
67    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
68        ReqItemCount[i] = questRecord[41+i].GetUInt32();
69
70    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
71        ReqSourceId[i] = questRecord[45+i].GetUInt32();
72
73    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
74        ReqSourceCount[i] = questRecord[49+i].GetUInt32();
75
76    for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
77        ReqSourceRef[i] = questRecord[53+i].GetUInt32();
78
79    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
80        ReqCreatureOrGOId[i] = questRecord[57+i].GetInt32();
81
82    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
83        ReqCreatureOrGOCount[i] = questRecord[61+i].GetUInt32();
84
85    for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
86        ReqSpell[i] = questRecord[65+i].GetUInt32();
87
88    for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
89        RewChoiceItemId[i] = questRecord[69+i].GetUInt32();
90
91    for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
92        RewChoiceItemCount[i] = questRecord[75+i].GetUInt32();
93
94    for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
95        RewItemId[i] = questRecord[81+i].GetUInt32();
96
97    for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
98        RewItemCount[i] = questRecord[85+i].GetUInt32();
99
100    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
101        RewRepFaction[i] = questRecord[89+i].GetUInt32();
102
103    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
104        RewRepValue[i] = questRecord[94+i].GetInt32();
105
106    RewHonorableKills = questRecord[99].GetUInt32();
107    RewOrReqMoney = questRecord[100].GetInt32();
108    RewMoneyMaxLevel = questRecord[101].GetUInt32();
109    RewSpell = questRecord[102].GetUInt32();
110    RewSpellCast = questRecord[103].GetUInt32();
111    RewMailTemplateId = questRecord[104].GetUInt32();
112    RewMailDelaySecs = questRecord[105].GetUInt32();
113    PointMapId = questRecord[106].GetUInt32();
114    PointX = questRecord[107].GetFloat();
115    PointY = questRecord[108].GetFloat();
116    PointOpt = questRecord[109].GetUInt32();
117
118    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
119        DetailsEmote[i] = questRecord[110+i].GetUInt32();
120
121    IncompleteEmote = questRecord[114].GetUInt32();
122    CompleteEmote = questRecord[115].GetUInt32();
123
124    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
125        OfferRewardEmote[i] = questRecord[116+i].GetInt32();
126
127    QuestStartScript = questRecord[120].GetUInt32();
128    QuestCompleteScript = questRecord[121].GetUInt32();
129
130    QuestFlags |= SpecialFlags << 16;
131
132    m_reqitemscount = 0;
133    m_reqCreatureOrGOcount = 0;
134    m_rewitemscount = 0;
135    m_rewchoiceitemscount = 0;
136
137    for (int i=0; i < QUEST_OBJECTIVES_COUNT; i++)
138    {
139        if ( ReqItemId[i] )
140            ++m_reqitemscount;
141        if ( ReqCreatureOrGOId[i] )
142            ++m_reqCreatureOrGOcount;
143    }
144
145    for (int i=0; i < QUEST_REWARDS_COUNT; i++)
146    {
147        if ( RewItemId[i] )
148            ++m_rewitemscount;
149    }
150
151    for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; i++)
152    {
153        if (RewChoiceItemId[i])
154            ++m_rewchoiceitemscount;
155    }
156}
157
158uint32 Quest::XPValue( Player *pPlayer ) const
159{
160    if( pPlayer )
161    {
162        if( RewMoneyMaxLevel > 0 )
163        {
164            uint32 pLevel = pPlayer->getLevel();
165            uint32 qLevel = QuestLevel;
166            float fullxp = 0;
167            if (qLevel >= 65)
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;
179
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);
190            else
191                return (uint32)(fullxp * 0.1f);
192        }
193    }
194    return 0;
195}
196
197int32  Quest::GetRewOrReqMoney() const
198{
199    if(RewOrReqMoney <=0)
200        return RewOrReqMoney;
201
202    return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));
203}
Note: See TracBrowser for help on using the browser.