From cb2da345c7b553d5b8b2c607f8b5b96937b285d3 Mon Sep 17 00:00:00 2001 From: treeston Date: Fri, 9 Sep 2016 17:14:34 +0200 Subject: [PATCH] =?UTF-8?q?Core/Conditions:=20New=20CONDITION=5FQUESTSTATE?= =?UTF-8?q?=20(47).=20It's=20the=20existing=20que=E2=80=A6=20=E2=80=A6st?= =?UTF-8?q?=20conditions=20collapsed=20into=20a=20bitmask=20value2=20becau?= =?UTF-8?q?se=20I'm=20a=20lazy=20person=20that=20doesn't=20like=20having?= =?UTF-8?q?=20long=20SQL=20queries.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Then use this new condition to fix Sniffing out the Perpetrator for Horde. --- .../world/3.3.5/2016_09_09_02_world.sql | 7 +++++ src/server/game/Conditions/ConditionMgr.cpp | 28 ++++++++++++++++++- src/server/game/Conditions/ConditionMgr.h | 5 ++-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 sql/updates/world/3.3.5/2016_09_09_02_world.sql diff --git a/sql/updates/world/3.3.5/2016_09_09_02_world.sql b/sql/updates/world/3.3.5/2016_09_09_02_world.sql new file mode 100644 index 00000000000..2f0395782b4 --- /dev/null +++ b/sql/updates/world/3.3.5/2016_09_09_02_world.sql @@ -0,0 +1,7 @@ +-- fix Sniffing out the Perpetrator (Horde side), issue #17914 +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=1 AND `SourceGroup`=29695 AND `SourceEntry`=40971; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`Comment`) VALUES + (1,29695,40971,0,47,12855,(2|8|64),0,0,"Brann's Communicator - Only drop if player has 'Sniffing out the Perpetrator' (12855) completed or rewarded."), + (1,29695,40971,0, 2,40971, 1,1,1,"Brann's Communicator - Only drop if player does not have 1 Brann's Communicator in their inventory or bank."), + (1,29695,40971,1,47,12910,(2|8|64),0,0,"Brann's Communicator - Only drop if player has 'Sniffing out the Perpetrator' (12910) completed or rewarded."), + (1,29695,40971,1, 2,40971, 1,1,1,"Brann's Communicator - Only drop if player does not have 1 Brann's Communicator in their inventory or bank."); diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index dcd2643c066..5a0c87b0ac7 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -108,7 +108,8 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND { "Daily Quest Completed",true, false, false }, { "Charmed", false, false, false }, { "Pet type", true, false, false }, - { "On Taxi", false, false, false } + { "On Taxi", false, false, false }, + { "Quest state mask", true, true, false } }; // Checks if object meets the condition @@ -483,6 +484,21 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const condMeets = player->IsInFlight(); break; } + case CONDITION_QUESTSTATE: + { + if (Player* player = object->ToPlayer()) + { + if ( + ((ConditionValue2 & (1 << QUEST_STATUS_NONE)) && (player->GetQuestStatus(ConditionValue1) == QUEST_STATUS_NONE)) || + ((ConditionValue2 & (1 << QUEST_STATUS_COMPLETE)) && (player->GetQuestStatus(ConditionValue1) == QUEST_STATUS_COMPLETE)) || + ((ConditionValue2 & (1 << QUEST_STATUS_INCOMPLETE)) && (player->GetQuestStatus(ConditionValue1) == QUEST_STATUS_INCOMPLETE)) || + ((ConditionValue2 & (1 << QUEST_STATUS_FAILED)) && (player->GetQuestStatus(ConditionValue1) == QUEST_STATUS_FAILED)) || + ((ConditionValue2 & (1 << QUEST_STATUS_REWARDED)) && player->GetQuestRewardStatus(ConditionValue1)) + ) + condMeets = true; + } + break; + } default: condMeets = false; break; @@ -676,6 +692,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const case CONDITION_TAXI: mask |= GRID_MAP_TYPE_MASK_PLAYER; break; + case CONDITION_QUESTSTATE: + mask |= GRID_MAP_TYPE_MASK_PLAYER; + break; default: ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!"); break; @@ -1906,6 +1925,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const } break; } + case CONDITION_QUESTSTATE: + if (cond->ConditionValue2 >= (1 << MAX_QUEST_STATUS)) + { + TC_LOG_ERROR("sql.sql", "%s has invalid state mask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2); + return false; + } + // intentional missing break case CONDITION_QUESTREWARDED: case CONDITION_QUESTTAKEN: case CONDITION_QUEST_NONE: diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 5b8209b396a..f0be2f62ee7 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -77,8 +77,9 @@ enum ConditionTypes CONDITION_CHARMED = 44, // 0 0 0 true if unit is currently charmed CONDITION_PET_TYPE = 45, // mask 0 0 true if player has a pet of given type(s) CONDITION_TAXI = 46, // 0 0 0 true if player is on taxi - CONDITION_MAX = 47 // MAX -}; + CONDITION_QUESTSTATE = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded) + CONDITION_MAX = 48 // MAX +}; /*! Documentation on implementing a new ConditionSourceType: Step 1: Check for the lowest free ID. Look for CONDITION_SOURCE_TYPE_UNUSED_XX in the enum.