OregonCore  revision 3611e8a-git
Your Favourite TBC server
QuestDef.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "QuestDef.h"
19 #include "Player.h"
20 #include "World.h"
21 
22 Quest::Quest(Field* questRecord)
23 {
24  QuestId = questRecord[0].GetUInt32();
25  QuestMethod = questRecord[1].GetUInt32();
26  ZoneOrSort = questRecord[2].GetInt32();
27  MinLevel = questRecord[3].GetUInt32();
28  QuestLevel = questRecord[4].GetInt32();
29  Type = questRecord[5].GetUInt32();
30  RequiredClasses = questRecord[6].GetUInt32();
31  RequiredRaces = questRecord[7].GetUInt32();
32  RequiredSkill = questRecord[8].GetUInt32();
33  RequiredSkillValue = questRecord[9].GetUInt32();
34  RepObjectiveFaction = questRecord[10].GetUInt32();
35  RepObjectiveValue = questRecord[11].GetInt32();
36  RequiredMinRepFaction = questRecord[12].GetUInt32();
37  RequiredMinRepValue = questRecord[13].GetInt32();
38  RequiredMaxRepFaction = questRecord[14].GetUInt32();
39  RequiredMaxRepValue = questRecord[15].GetInt32();
40  SuggestedPlayers = questRecord[16].GetUInt32();
41  LimitTime = questRecord[17].GetUInt32();
42  QuestFlags = questRecord[18].GetUInt16();
43  SpecialFlags = questRecord[19].GetUInt8();
44  CharTitleId = questRecord[20].GetUInt32();
45  PrevQuestId = questRecord[21].GetInt32();
46  NextQuestId = questRecord[22].GetInt32();
47  ExclusiveGroup = questRecord[23].GetInt32();
48  NextQuestInChain = questRecord[24].GetUInt32();
49  SrcItemId = questRecord[25].GetUInt32();
50  SrcItemCount = questRecord[26].GetUInt32();
51  SrcSpell = questRecord[27].GetUInt32();
52  Title = questRecord[28].GetCppString();
53  Details = questRecord[29].GetCppString();
54  Objectives = questRecord[30].GetCppString();
55  OfferRewardText = questRecord[31].GetCppString();
56  RequestItemsText = questRecord[32].GetCppString();
57  EndText = questRecord[33].GetCppString();
58 
59  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
60  ObjectiveText[i] = questRecord[34 + i].GetCppString();
61 
62  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
63  ReqItemId[i] = questRecord[38 + i].GetUInt32();
64 
65  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
66  ReqItemCount[i] = questRecord[42 + i].GetUInt32();
67 
68  for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
69  ReqSourceId[i] = questRecord[46 + i].GetUInt32();
70 
71  for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
72  ReqSourceCount[i] = questRecord[50 + i].GetUInt32();
73 
74  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
75  ReqCreatureOrGOId[i] = questRecord[54 + i].GetInt32();
76 
77  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
78  ReqCreatureOrGOCount[i] = questRecord[58 + i].GetUInt32();
79 
80  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
81  ReqSpell[i] = questRecord[62 + i].GetUInt32();
82 
83  for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
84  RewChoiceItemId[i] = questRecord[66 + i].GetUInt32();
85 
86  for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
87  RewChoiceItemCount[i] = questRecord[72 + i].GetUInt32();
88 
89  for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
90  RewItemId[i] = questRecord[78 + i].GetUInt32();
91 
92  for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
93  RewItemCount[i] = questRecord[82 + i].GetUInt32();
94 
95  for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
96  RewRepFaction[i] = questRecord[86 + i].GetUInt32();
97 
98  for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
99  RewRepValue[i] = questRecord[91 + i].GetInt32();
100 
101  RewHonorableKills = questRecord[96].GetUInt32();
102  RewOrReqMoney = questRecord[97].GetInt32();
103  RewMoneyMaxLevel = questRecord[98].GetUInt32();
104  RewSpell = questRecord[99].GetUInt32();
105  RewSpellCast = questRecord[100].GetUInt32();
106  RewMailTemplateId = questRecord[101].GetUInt32();
107  RewMailDelaySecs = questRecord[102].GetUInt32();
108  PointMapId = questRecord[103].GetUInt32();
109  PointX = questRecord[104].GetFloat();
110  PointY = questRecord[105].GetFloat();
111  PointOpt = questRecord[106].GetUInt32();
112 
113  for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
114  DetailsEmote[i] = questRecord[107 + i].GetUInt32();
115 
116  IncompleteEmote = questRecord[111].GetUInt32();
117  CompleteEmote = questRecord[112].GetUInt32();
118 
119  for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
120  OfferRewardEmote[i] = questRecord[113 + i].GetInt32();
121 
122  QuestStartScript = questRecord[117].GetUInt32();
123  QuestCompleteScript = questRecord[118].GetUInt32();
124 
125  _reqItemsCount = 0;
127  _rewItemsCount = 0;
129 
130  for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
131  {
132  if (ReqItemId[i])
133  ++_reqItemsCount;
134  if (ReqCreatureOrGOId[i])
136  }
137 
138  for (int i = 0; i < QUEST_REWARDS_COUNT; i++)
139  {
140  if (RewItemId[i])
141  ++_rewItemsCount;
142  }
143 
144  for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; i++)
145  {
146  if (RewChoiceItemId[i])
148  }
149 }
150 
151 uint32 Quest::XPValue (Player* pPlayer) const
152 {
153  if (pPlayer)
154  {
155  if (RewMoneyMaxLevel > 0)
156  {
157  uint32 pLevel = pPlayer->getLevel();
158  uint32 qLevel = QuestLevel > 0 ? (uint32)QuestLevel : 0;
159  float fullxp = 0;
160  if (qLevel >= 65)
161  fullxp = RewMoneyMaxLevel / 6.0f;
162  else if (qLevel == 64)
163  fullxp = RewMoneyMaxLevel / 4.8f;
164  else if (qLevel == 63)
165  fullxp = RewMoneyMaxLevel / 3.6f;
166  else if (qLevel == 62)
167  fullxp = RewMoneyMaxLevel / 2.4f;
168  else if (qLevel == 61)
169  fullxp = RewMoneyMaxLevel / 1.2f;
170  else if (qLevel > 0 && qLevel <= 60)
171  fullxp = RewMoneyMaxLevel / 0.6f;
172 
173  if (pLevel <= qLevel + 5)
174  return uint32(ceilf(fullxp));
175  else if (pLevel == qLevel + 6)
176  return uint32(ceilf(fullxp * 0.8f));
177  else if (pLevel == qLevel + 7)
178  return uint32(ceilf(fullxp * 0.6f));
179  else if (pLevel == qLevel + 8)
180  return uint32(ceilf(fullxp * 0.4f));
181  else if (pLevel == qLevel + 9)
182  return uint32(ceilf(fullxp * 0.2f));
183  else
184  return uint32(ceilf(fullxp * 0.1f));
185  }
186  }
187  return 0;
188 }
189 
191 {
192  if (RewOrReqMoney <= 0)
193  return RewOrReqMoney;
194 
195  return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY));
196 }
197 
uint32 RewSpellCast
Definition: QuestDef.h:457
uint32 SpecialFlags
Definition: QuestDef.h:469
uint32 CompleteEmote
Definition: QuestDef.h:465
float PointX
Definition: QuestDef.h:461
uint32 PointMapId
Definition: QuestDef.h:460
uint32 RewSpell
Definition: QuestDef.h:456
uint32 CharTitleId
Definition: QuestDef.h:439
uint32 DetailsEmote[QUEST_EMOTE_COUNT]
Definition: QuestDef.h:398
uint32 MinLevel
Definition: QuestDef.h:423
uint32 QuestCompleteScript
Definition: QuestDef.h:467
uint32 RewMoneyMaxLevel
Definition: QuestDef.h:455
std::string OfferRewardText
Definition: QuestDef.h:450
uint32 RewMailDelaySecs
Definition: QuestDef.h:459
uint32 SrcItemId
Definition: QuestDef.h:444
#define QUEST_EMOTE_COUNT
Definition: QuestDef.h:39
Definition: Field.h:24
uint32 RequiredMaxRepFaction
Definition: QuestDef.h:434
uint32 RequiredRaces
Definition: QuestDef.h:427
uint32 ReqItemId[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:385
int32 RewRepValue[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:397
int32 ReqCreatureOrGOId[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:389
uint32 QuestMethod
Definition: QuestDef.h:421
ACE_INT32 int32
Definition: Define.h:67
uint32 QuestStartScript
Definition: QuestDef.h:466
uint32 ReqSpell[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:391
std::string Details
Definition: QuestDef.h:448
float PointY
Definition: QuestDef.h:462
std::string EndText
Definition: QuestDef.h:452
int32 ZoneOrSort
Definition: QuestDef.h:422
std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:384
uint32 RequiredMinRepFaction
Definition: QuestDef.h:432
Quest(Field *questRecord)
Definition: QuestDef.cpp:22
std::string GetCppString() const
Definition: Field.h:52
uint32 QuestId
Definition: QuestDef.h:420
int32 RequiredMinRepValue
Definition: QuestDef.h:433
uint32 RewChoiceItemCount[QUEST_REWARD_CHOICES_COUNT]
Definition: QuestDef.h:393
uint32 ReqSourceCount[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition: QuestDef.h:388
uint32 RequiredSkill
Definition: QuestDef.h:428
std::string RequestItemsText
Definition: QuestDef.h:451
uint32 RewChoiceItemId[QUEST_REWARD_CHOICES_COUNT]
Definition: QuestDef.h:392
int32 ExclusiveGroup
Definition: QuestDef.h:442
uint32 _reqCreatureOrGOcount
Definition: QuestDef.h:414
uint32 RewHonorableKills
Definition: QuestDef.h:453
std::string Title
Definition: QuestDef.h:447
uint32 SuggestedPlayers
Definition: QuestDef.h:436
uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT]
Definition: QuestDef.h:396
uint32 ReqItemCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:386
int32 QuestLevel
Definition: QuestDef.h:424
uint32 _rewChoiceItemsCount
Definition: QuestDef.h:415
uint32 RequiredSkillValue
Definition: QuestDef.h:429
uint32 LimitTime
Definition: QuestDef.h:437
int32 PrevQuestId
Definition: QuestDef.h:440
int32 NextQuestId
Definition: QuestDef.h:441
uint32 IncompleteEmote
Definition: QuestDef.h:464
uint32 _reqItemsCount
Definition: QuestDef.h:413
uint32 SrcSpell
Definition: QuestDef.h:446
int32 GetRewOrReqMoney() const
Definition: QuestDef.cpp:190
#define QUEST_REWARD_CHOICES_COUNT
Definition: QuestDef.h:35
uint32 PointOpt
Definition: QuestDef.h:463
#define QUEST_REWARDS_COUNT
Definition: QuestDef.h:36
int32 RequiredMaxRepValue
Definition: QuestDef.h:435
uint32 ReqSourceId[QUEST_SOURCE_ITEM_IDS_COUNT]
Definition: QuestDef.h:387
uint32 RewMailTemplateId
Definition: QuestDef.h:458
uint32 RewItemId[QUEST_REWARDS_COUNT]
Definition: QuestDef.h:394
uint32 RewItemCount[QUEST_REWARDS_COUNT]
Definition: QuestDef.h:395
#define sWorld
Definition: World.h:860
uint32 SrcItemCount
Definition: QuestDef.h:445
int32 RewOrReqMoney
Definition: QuestDef.h:454
int32 RepObjectiveValue
Definition: QuestDef.h:431
ACE_UINT32 uint32
Definition: Define.h:71
uint32 NextQuestInChain
Definition: QuestDef.h:443
uint32 RepObjectiveFaction
Definition: QuestDef.h:430
uint32 getLevel() const
Definition: Unit.h:1029
uint32 _rewItemsCount
Definition: QuestDef.h:416
#define QUEST_SOURCE_ITEM_IDS_COUNT
Definition: QuestDef.h:34
Definition: Player.h:922
QuestFlags
Definition: QuestDef.h:116
#define QUEST_OBJECTIVES_COUNT
Definition: QuestDef.h:33
uint32 ReqCreatureOrGOCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:390
uint32 XPValue(Player *pPlayer) const
Definition: QuestDef.cpp:151
uint32 RequiredClasses
Definition: QuestDef.h:426
uint32 OfferRewardEmote[QUEST_EMOTE_COUNT]
Definition: QuestDef.h:399
std::string Objectives
Definition: QuestDef.h:449
uint32 Type
Definition: QuestDef.h:425
#define QUEST_REPUTATIONS_COUNT
Definition: QuestDef.h:38