From 79c5d21d367cfcdbd8a83d42fb8415ddafb6e928 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Wed, 20 Jul 2016 19:40:21 +0200 Subject: [PATCH] =?UTF-8?q?Core/Conditions:=20implement=20CONDITION=5FDAIL?= =?UTF-8?q?Y=5FQUEST=5FDONE=20to=20check=20whethe=E2=80=A6=20=E2=80=A6r=20?= =?UTF-8?q?or=20not=20a=20daily=20quest=20has=20been=20completed=20by=20a?= =?UTF-8?q?=20player=20in=20that=20day.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use it to fix two quest chains broken in commit 7905651. Should be the only ones of their kind. --- src/server/game/Conditions/ConditionMgr.cpp | 13 ++++++++++++- src/server/game/Conditions/ConditionMgr.h | 3 ++- src/server/game/Entities/Player/Player.cpp | 18 ++++++++++++++++++ src/server/game/Entities/Player/Player.h | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 0e15855cc5..c4eaad2947 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -103,7 +103,8 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND { "Realm Achievement", true, false, false }, { "In Water", false, false, false }, { "Terrain Swap", true, false, false }, - { "Sit/stand state", true, true, false } + { "Sit/stand state", true, true, false }, + { "Daily Quest Completed",true, false, false } }; // Checks if object meets the condition @@ -453,6 +454,12 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const } break; } + case CONDITION_DAILY_QUEST_DONE: + { + if (Player* player = object->ToPlayer()) + condMeets = player->IsDailyQuestDone(ConditionValue1); + break; + } default: condMeets = false; break; @@ -634,6 +641,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const case CONDITION_STAND_STATE: mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER; break; + case CONDITION_DAILY_QUEST_DONE: + mask |= GRID_MAP_TYPE_MASK_PLAYER; + break; default: ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!"); break; @@ -1868,6 +1878,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const case CONDITION_QUESTTAKEN: case CONDITION_QUEST_NONE: case CONDITION_QUEST_COMPLETE: + case CONDITION_DAILY_QUEST_DONE: { if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1)) { diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 5b95876911..4992c44259 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -73,7 +73,8 @@ enum ConditionTypes CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water CONDITION_TERRAIN_SWAP = 41, // terrainSwap 0 0 true if object is in terrainswap CONDITION_STAND_STATE = 42, // stateType state 0 true if unit matches specified sitstate (0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;) - CONDITION_MAX = 43 // MAX + CONDITION_DAILY_QUEST_DONE = 43, // quest id 0 0 true if daily quest has been completed for the day + CONDITION_MAX = 44 // MAX }; /*! Documentation on implementing a new ConditionSourceType: diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5d85b66b07..99fd2326b7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -23527,6 +23527,24 @@ void Player::SetDailyQuestStatus(uint32 quest_id) } } +bool Player::IsDailyQuestDone(uint32 quest_id) +{ + bool found = false; + if (Quest const* qQuest = sObjectMgr->GetQuestTemplate(quest_id)) + { + for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + { + if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx) == quest_id) + { + found = true; + break; + } + } + } + + return found; +} + void Player::SetWeeklyQuestStatus(uint32 quest_id) { m_weeklyquests.insert(quest_id); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index bc5bf88f00..ce8a8137a3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1568,6 +1568,7 @@ class Player : public Unit, public GridObject QuestGiverStatus GetQuestDialogStatus(Object* questGiver); void SetDailyQuestStatus(uint32 quest_id); + bool IsDailyQuestDone(uint32 quest_id); void SetWeeklyQuestStatus(uint32 quest_id); void SetMonthlyQuestStatus(uint32 quest_id); void SetSeasonalQuestStatus(uint32 quest_id);