diff options
Diffstat (limited to 'src/server/game/Quests/QuestDef.cpp')
| -rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 206 |
1 files changed, 95 insertions, 111 deletions
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 61f7694c724..6c3b15436e7 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -26,78 +26,70 @@ Quest::Quest(Field* questRecord) { - EmoteOnIncomplete = 0; - EmoteOnComplete = 0; - _reqItemsCount = 0; - _reqCreatureOrGOcount = 0; - _rewItemsCount = 0; - _rewChoiceItemsCount = 0; - _eventIdForQuest = 0; - - Id = questRecord[0].GetUInt32(); - Method = questRecord[1].GetUInt8(); - Level = questRecord[2].GetInt16(); - MinLevel = questRecord[3].GetUInt8(); - ZoneOrSort = questRecord[4].GetInt16(); - Type = questRecord[5].GetUInt16(); - SuggestedPlayers = questRecord[6].GetUInt8(); - TimeAllowed = questRecord[7].GetUInt32(); - AllowableRaces = questRecord[8].GetUInt16(); - RequiredFactionId1 = questRecord[9].GetUInt16(); - RequiredFactionId2 = questRecord[10].GetUInt16(); - RequiredFactionValue1 = questRecord[11].GetInt32(); - RequiredFactionValue2 = questRecord[12].GetInt32(); - RewardNextQuest = questRecord[13].GetUInt32(); - RewardXPDifficulty = questRecord[14].GetUInt8(); - RewardMoney = questRecord[15].GetInt32(); - RewardBonusMoney = questRecord[16].GetUInt32(); - RewardDisplaySpell = questRecord[17].GetUInt32(); - RewardSpell = questRecord[18].GetInt32(); - RewardHonor = questRecord[19].GetUInt32(); - RewardKillHonor = questRecord[20].GetFloat(); - StartItem = questRecord[21].GetUInt32(); - Flags = questRecord[22].GetUInt32(); - RewardTitleId = questRecord[23].GetUInt8(); - RequiredPlayerKills = questRecord[24].GetUInt8(); - RewardTalents = questRecord[25].GetUInt8(); - RewardArenaPoints = questRecord[26].GetUInt16(); - - for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) + _id = questRecord[0].GetUInt32(); + _method = questRecord[1].GetUInt8(); + _level = questRecord[2].GetInt16(); + _minLevel = questRecord[3].GetUInt8(); + _zoneOrSort = questRecord[4].GetInt16(); + _type = questRecord[5].GetUInt16(); + _suggestedPlayers = questRecord[6].GetUInt8(); + _timeAllowed = questRecord[7].GetUInt32(); + _allowableRaces = questRecord[8].GetUInt16(); + _requiredFactionId1 = questRecord[9].GetUInt16(); + _requiredFactionId2 = questRecord[10].GetUInt16(); + _requiredFactionValue1 = questRecord[11].GetInt32(); + _requiredFactionValue2 = questRecord[12].GetInt32(); + _rewardNextQuest = questRecord[13].GetUInt32(); + _rewardXPDifficulty = questRecord[14].GetUInt8(); + _rewardMoney = questRecord[15].GetInt32(); + _rewardBonusMoney = questRecord[16].GetUInt32(); + _rewardDisplaySpell = questRecord[17].GetUInt32(); + _rewardSpell = questRecord[18].GetInt32(); + _rewardHonor = questRecord[19].GetUInt32(); + _rewardKillHonor = questRecord[20].GetFloat(); + _startItem = questRecord[21].GetUInt32(); + _flags = questRecord[22].GetUInt32(); + _rewardTitleId = questRecord[23].GetUInt8(); + _requiredPlayerKills = questRecord[24].GetUInt8(); + _rewardTalents = questRecord[25].GetUInt8(); + _rewardArenaPoints = questRecord[26].GetUInt16(); + + for (uint32 i = 0; i < QUEST_REWARDS_COUNT; ++i) { - RewardItemId[i] = questRecord[27+i*2].GetUInt32(); - RewardItemIdCount[i] = questRecord[28+i*2].GetUInt16(); + RewardItemId[i] = questRecord[27 + i * 2].GetUInt32(); + RewardItemIdCount[i] = questRecord[28 + i * 2].GetUInt16(); if (RewardItemId[i]) ++_rewItemsCount; } - for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (uint32 i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { - RewardChoiceItemId[i] = questRecord[35+i*2].GetUInt32(); - RewardChoiceItemCount[i] = questRecord[36+i*2].GetUInt16(); + RewardChoiceItemId[i] = questRecord[35 + i * 2].GetUInt32(); + RewardChoiceItemCount[i] = questRecord[36 + i * 2].GetUInt16(); if (RewardChoiceItemId[i]) ++_rewChoiceItemsCount; } - for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) { - RewardFactionId[i] = questRecord[47+i*3].GetUInt16(); - RewardFactionValueId[i] = questRecord[48+i*3].GetInt32(); - RewardFactionValueIdOverride[i] = questRecord[49+i*3].GetInt32(); + RewardFactionId[i] = questRecord[47 + i * 3].GetUInt16(); + RewardFactionValueId[i] = questRecord[48 + i * 3].GetInt32(); + RewardFactionValueIdOverride[i] = questRecord[49 + i * 3].GetInt32(); } - POIContinent = questRecord[62].GetUInt16(); - POIx = questRecord[63].GetFloat(); - POIy = questRecord[64].GetFloat(); - POIPriority = questRecord[65].GetUInt32(); - Title = questRecord[66].GetString(); - Objectives = questRecord[67].GetString(); - Details = questRecord[68].GetString(); - AreaDescription = questRecord[69].GetString(); - CompletedText = questRecord[70].GetString(); - - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + _poiContinent = questRecord[62].GetUInt16(); + _poiX = questRecord[63].GetFloat(); + _poiY = questRecord[64].GetFloat(); + _poiPriority = questRecord[65].GetUInt32(); + _title = questRecord[66].GetString(); + _objectives = questRecord[67].GetString(); + _details = questRecord[68].GetString(); + _areaDescription = questRecord[69].GetString(); + _completedText = questRecord[70].GetString(); + + for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { RequiredNpcOrGo[i] = questRecord[71+i].GetInt32(); RequiredNpcOrGoCount[i] = questRecord[75+i].GetUInt16(); @@ -107,13 +99,13 @@ Quest::Quest(Field* questRecord) ++_reqCreatureOrGOcount; } - for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) + for (uint32 i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) { ItemDrop[i] = questRecord[79+i].GetUInt32(); ItemDropQuantity[i] = questRecord[83+i].GetUInt16(); } - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (uint32 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { RequiredItemId[i] = questRecord[87+i].GetUInt32(); RequiredItemCount[i] = questRecord[93+i].GetUInt16(); @@ -124,14 +116,6 @@ Quest::Quest(Field* questRecord) // int8 Unknown0 = questRecord[99].GetUInt8(); // int32 VerifiedBuild = questRecord[104].GetInt32(); - - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - { - DetailsEmote[i] = 0; - DetailsEmoteDelay[i] = 0; - OfferRewardEmote[i] = 0; - OfferRewardEmoteDelay[i] = 0; - } } void Quest::LoadQuestDetails(Field* fields) @@ -153,67 +137,67 @@ void Quest::LoadQuestDetails(Field* fields) void Quest::LoadQuestRequestItems(Field* fields) { - EmoteOnComplete = fields[1].GetUInt16(); - EmoteOnIncomplete = fields[2].GetUInt16(); + _emoteOnComplete = fields[1].GetUInt16(); + _emoteOnIncomplete = fields[2].GetUInt16(); - if (!sEmotesStore.LookupEntry(EmoteOnComplete)) - TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnComplete (%u) set for quest %u.", EmoteOnComplete, fields[0].GetUInt32()); + if (!sEmotesStore.LookupEntry(_emoteOnComplete)) + TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnComplete (%u) set for quest %u.", _emoteOnComplete, fields[0].GetUInt32()); - if (!sEmotesStore.LookupEntry(EmoteOnIncomplete)) - TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnIncomplete (%u) set for quest %u.", EmoteOnIncomplete, fields[0].GetUInt32()); + if (!sEmotesStore.LookupEntry(_emoteOnIncomplete)) + TC_LOG_ERROR("sql.sql", "Table `quest_request_items` has non-existing EmoteOnIncomplete (%u) set for quest %u.", _emoteOnIncomplete, fields[0].GetUInt32()); - RequestItemsText = fields[3].GetString(); + _requestItemsText = fields[3].GetString(); } void Quest::LoadQuestOfferReward(Field* fields) { - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) + for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) { - if (!sEmotesStore.LookupEntry(fields[1+i].GetUInt16())) + if (!sEmotesStore.LookupEntry(fields[1 + i].GetUInt16())) { - TC_LOG_ERROR("sql.sql", "Table `quest_offer_reward` has non-existing Emote%i (%u) set for quest %u. Skipped.", 1+i, fields[1+i].GetUInt16(), fields[0].GetUInt32()); + TC_LOG_ERROR("sql.sql", "Table `quest_offer_reward` has non-existing Emote%i (%u) set for quest %u. Skipped.", 1 + i, fields[1 + i].GetUInt16(), fields[0].GetUInt32()); continue; } - OfferRewardEmote[i] = fields[1+i].GetUInt16(); + OfferRewardEmote[i] = fields[1 + i].GetUInt16(); } - for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmoteDelay[i] = fields[5+i].GetUInt32(); + for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) + OfferRewardEmoteDelay[i] = fields[5 + i].GetUInt32(); - OfferRewardText = fields[9].GetString(); + _offerRewardText = fields[9].GetString(); } void Quest::LoadQuestTemplateAddon(Field* fields) { - MaxLevel = fields[1].GetUInt8(); - RequiredClasses = fields[2].GetUInt32(); - SourceSpellid = fields[3].GetUInt32(); - PrevQuestId = fields[4].GetInt32(); - NextQuestId = fields[5].GetInt32(); - ExclusiveGroup = fields[6].GetInt32(); - RewardMailTemplateId = fields[7].GetUInt32(); - RewardMailDelay = fields[8].GetUInt32(); - RequiredSkillId = fields[9].GetUInt16(); - RequiredSkillPoints = fields[10].GetUInt16(); - RequiredMinRepFaction = fields[11].GetUInt16(); - RequiredMaxRepFaction = fields[12].GetUInt16(); - RequiredMinRepValue = fields[13].GetInt32(); - RequiredMaxRepValue = fields[14].GetInt32(); - StartItemCount = fields[15].GetUInt8(); - RewardMailSenderEntry = fields[16].GetUInt32(); - SpecialFlags = fields[17].GetUInt8(); - - if (SpecialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT) - Flags |= QUEST_FLAGS_AUTO_ACCEPT; + _maxLevel = fields[1].GetUInt8(); + _requiredClasses = fields[2].GetUInt32(); + _sourceSpellid = fields[3].GetUInt32(); + _prevQuestId = fields[4].GetInt32(); + _nextQuestId = fields[5].GetInt32(); + _exclusiveGroup = fields[6].GetInt32(); + _rewardMailTemplateId = fields[7].GetUInt32(); + _rewardMailDelay = fields[8].GetUInt32(); + _requiredSkillId = fields[9].GetUInt16(); + _requiredSkillPoints = fields[10].GetUInt16(); + _requiredMinRepFaction = fields[11].GetUInt16(); + _requiredMaxRepFaction = fields[12].GetUInt16(); + _requiredMinRepValue = fields[13].GetInt32(); + _requiredMaxRepValue = fields[14].GetInt32(); + _startItemCount = fields[15].GetUInt8(); + _rewardMailSenderEntry = fields[16].GetUInt32(); + _specialFlags = fields[17].GetUInt8(); + + if (_specialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT) + _flags |= QUEST_FLAGS_AUTO_ACCEPT; } uint32 Quest::XPValue(Player* player) const { if (player) { - int32 quest_level = (Level == -1 ? player->getLevel() : Level); - const QuestXPEntry* xpentry = sQuestXPStore.LookupEntry(quest_level); + int32 quest_level = (_level == -1 ? player->getLevel() : _level); + QuestXPEntry const* xpentry = sQuestXPStore.LookupEntry(quest_level); if (!xpentry) return 0; @@ -223,7 +207,7 @@ uint32 Quest::XPValue(Player* player) const else if (diffFactor > 10) diffFactor = 10; - uint32 xp = diffFactor * xpentry->Exp[RewardXPDifficulty] / 10; + uint32 xp = diffFactor * xpentry->Exp[_rewardXPDifficulty] / 10; if (xp <= 100) xp = 5 * ((xp + 2) / 5); else if (xp <= 500) @@ -242,11 +226,11 @@ uint32 Quest::XPValue(Player* player) const int32 Quest::GetRewOrReqMoney() const { // RequiredMoney: the amount is the negative copper sum. - if (RewardMoney <= 0) - return RewardMoney; + if (_rewardMoney <= 0) + return _rewardMoney; // RewardMoney: the positive amount - return int32(RewardMoney * sWorld->getRate(RATE_MONEY_QUEST)); + return int32(_rewardMoney * sWorld->getRate(RATE_MONEY_QUEST)); } uint32 Quest::GetRewMoneyMaxLevel() const @@ -256,7 +240,7 @@ uint32 Quest::GetRewMoneyMaxLevel() const return 0; // Else, return the rewarded copper sum modified by the rate - return uint32(RewardBonusMoney * sWorld->getRate(RATE_MONEY_MAX_LEVEL_QUEST)); + return uint32(_rewardBonusMoney * sWorld->getRate(RATE_MONEY_MAX_LEVEL_QUEST)); } bool Quest::IsAutoAccept() const @@ -266,12 +250,12 @@ bool Quest::IsAutoAccept() const bool Quest::IsAutoComplete() const { - return !sWorld->getBoolConfig(CONFIG_QUEST_IGNORE_AUTO_COMPLETE) && (Method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE)); + return !sWorld->getBoolConfig(CONFIG_QUEST_IGNORE_AUTO_COMPLETE) && (_method == 0 || HasFlag(QUEST_FLAGS_AUTOCOMPLETE)); } bool Quest::IsRaidQuest(Difficulty difficulty) const { - switch (Type) + switch (_type) { case QUEST_TYPE_RAID: return true; @@ -283,7 +267,7 @@ bool Quest::IsRaidQuest(Difficulty difficulty) const break; } - if ((Flags & QUEST_FLAGS_RAID) != 0) + if ((_flags & QUEST_FLAGS_RAID) != 0) return true; return false; |
