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