Core/Conditions: Add type QUEST_OBJECTIVE_PROGRESS_BAR to CONDITION_QUEST_OBJECTIVE_COMPLETE (#19488)

This commit is contained in:
Arog
2017-04-24 15:29:24 -04:00
committed by Shauren
parent 8df72afb73
commit 2e7a3a8fd6
2 changed files with 21 additions and 0 deletions

View File

@@ -6609,6 +6609,19 @@ bool Player::HasCurrency(uint32 id, uint32 count) const
return itr != _currencyStorage.end() && itr->second.Quantity >= count;
}
bool Player::IsQuestObjectiveProgressComplete(Quest const* quest) const
{
float progress = 0;
for (QuestObjective const& obj : quest->GetObjectives())
if (obj.Flags & QUEST_OBJECTIVE_FLAG_PART_OF_PROGRESS_BAR)
{
progress += GetQuestObjectiveData(quest, obj.StorageIndex) * obj.ProgressBarWeight;
if (progress >= 100)
return true;
}
return false;
}
void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bool ignoreMultipliers/* = false*/)
{
if (!count)
@@ -16761,6 +16774,9 @@ bool Player::IsQuestObjectiveComplete(QuestObjective const& objective) const
Quest const* quest = sObjectMgr->GetQuestTemplate(objective.QuestID);
ASSERT(quest);
if (objective.Flags & QUEST_OBJECTIVE_FLAG_PART_OF_PROGRESS_BAR)
return true;
switch (objective.Type)
{
case QUEST_OBJECTIVE_MONSTER:
@@ -16798,6 +16814,10 @@ bool Player::IsQuestObjectiveComplete(QuestObjective const& objective) const
if (!HasCurrency(objective.ObjectID, objective.Amount))
return false;
break;
case QUEST_OBJECTIVE_PROGRESS_BAR:
if (!IsQuestObjectiveProgressComplete(quest))
return false;
break;
default:
TC_LOG_ERROR("entities.player.quest", "Player::CanCompleteQuest: Player '%s' (%s) tried to complete a quest (ID: %u) with an unknown objective type %u",
GetName().c_str(), GetGUID().ToString().c_str(), objective.QuestID, objective.Type);

View File

@@ -1630,6 +1630,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
int32 GetQuestObjectiveData(Quest const* quest, int8 storageIndex) const;
bool IsQuestObjectiveComplete(QuestObjective const& objective) const;
void SetQuestObjectiveData(Quest const* quest, int8 storageIndex, int32 data);
bool IsQuestObjectiveProgressComplete(Quest const* quest) const;
void SendQuestComplete(Quest const* quest) const;
void SendQuestReward(Quest const* quest, uint32 XP) const;
void SendQuestFailed(uint32 questID, InventoryResult reason = EQUIP_ERR_OK) const;