[37] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[37] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[37] | 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 |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[37] | 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 |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[37] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "QuestDef.h" |
---|
| 22 | #include "Player.h" |
---|
| 23 | #include "World.h" |
---|
| 24 | |
---|
| 25 | Quest::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 | RewOrReqMoney = questRecord[99].GetInt32(); |
---|
| 107 | RewMoneyMaxLevel = questRecord[100].GetUInt32(); |
---|
| 108 | RewSpell = questRecord[101].GetUInt32(); |
---|
| 109 | RewSpellCast = questRecord[102].GetUInt32(); |
---|
| 110 | RewMailTemplateId = questRecord[103].GetUInt32(); |
---|
| 111 | RewMailDelaySecs = questRecord[104].GetUInt32(); |
---|
| 112 | PointMapId = questRecord[105].GetUInt32(); |
---|
| 113 | PointX = questRecord[106].GetFloat(); |
---|
| 114 | PointY = questRecord[107].GetFloat(); |
---|
| 115 | PointOpt = questRecord[108].GetUInt32(); |
---|
| 116 | |
---|
| 117 | for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) |
---|
| 118 | DetailsEmote[i] = questRecord[109+i].GetUInt32(); |
---|
| 119 | |
---|
| 120 | IncompleteEmote = questRecord[113].GetUInt32(); |
---|
| 121 | CompleteEmote = questRecord[114].GetUInt32(); |
---|
| 122 | |
---|
| 123 | for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) |
---|
| 124 | OfferRewardEmote[i] = questRecord[115+i].GetInt32(); |
---|
| 125 | |
---|
| 126 | QuestStartScript = questRecord[119].GetUInt32(); |
---|
| 127 | QuestCompleteScript = questRecord[120].GetUInt32(); |
---|
| 128 | |
---|
| 129 | QuestFlags |= SpecialFlags << 16; |
---|
| 130 | |
---|
| 131 | m_reqitemscount = 0; |
---|
| 132 | m_reqCreatureOrGOcount = 0; |
---|
| 133 | m_rewitemscount = 0; |
---|
| 134 | m_rewchoiceitemscount = 0; |
---|
| 135 | |
---|
| 136 | for (int i=0; i < QUEST_OBJECTIVES_COUNT; i++) |
---|
| 137 | { |
---|
| 138 | if ( ReqItemId[i] ) |
---|
| 139 | ++m_reqitemscount; |
---|
| 140 | if ( ReqCreatureOrGOId[i] ) |
---|
| 141 | ++m_reqCreatureOrGOcount; |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | for (int i=0; i < QUEST_REWARDS_COUNT; i++) |
---|
| 145 | { |
---|
| 146 | if ( RewItemId[i] ) |
---|
| 147 | ++m_rewitemscount; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; i++) |
---|
| 151 | { |
---|
| 152 | if (RewChoiceItemId[i]) |
---|
| 153 | ++m_rewchoiceitemscount; |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | uint32 Quest::XPValue( Player *pPlayer ) const |
---|
| 158 | { |
---|
| 159 | if( pPlayer ) |
---|
| 160 | { |
---|
| 161 | if( RewMoneyMaxLevel > 0 ) |
---|
| 162 | { |
---|
| 163 | uint32 pLevel = pPlayer->getLevel(); |
---|
| 164 | uint32 qLevel = QuestLevel; |
---|
| 165 | float fullxp = 0; |
---|
| 166 | if (qLevel >= 65) |
---|
| 167 | fullxp = RewMoneyMaxLevel / 6.0f; |
---|
| 168 | else if (qLevel == 64) |
---|
| 169 | fullxp = RewMoneyMaxLevel / 4.8f; |
---|
| 170 | else if (qLevel == 63) |
---|
| 171 | fullxp = RewMoneyMaxLevel / 3.6f; |
---|
| 172 | else if (qLevel == 62) |
---|
| 173 | fullxp = RewMoneyMaxLevel / 2.4f; |
---|
| 174 | else if (qLevel == 61) |
---|
| 175 | fullxp = RewMoneyMaxLevel / 1.2f; |
---|
| 176 | else if (qLevel > 0 && qLevel <= 60) |
---|
| 177 | fullxp = RewMoneyMaxLevel / 0.6f; |
---|
| 178 | |
---|
| 179 | if( pLevel <= qLevel + 5 ) |
---|
| 180 | return (uint32)fullxp; |
---|
| 181 | else if( pLevel == qLevel + 6 ) |
---|
| 182 | return (uint32)(fullxp * 0.8f); |
---|
| 183 | else if( pLevel == qLevel + 7 ) |
---|
| 184 | return (uint32)(fullxp * 0.6f); |
---|
| 185 | else if( pLevel == qLevel + 8 ) |
---|
| 186 | return (uint32)(fullxp * 0.4f); |
---|
| 187 | else if( pLevel == qLevel + 9 ) |
---|
| 188 | return (uint32)(fullxp * 0.2f); |
---|
| 189 | else |
---|
| 190 | return (uint32)(fullxp * 0.1f); |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | return 0; |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | int32 Quest::GetRewOrReqMoney() const |
---|
| 197 | { |
---|
| 198 | if(RewOrReqMoney <=0) |
---|
| 199 | return RewOrReqMoney; |
---|
| 200 | |
---|
| 201 | return int32(RewOrReqMoney * sWorld.getRate(RATE_DROP_MONEY)); |
---|
| 202 | } |
---|