From b3f21d909ae83617c599de1f02a619fd200e3b5c Mon Sep 17 00:00:00 2001 From: sudlud Date: Sat, 22 Jun 2024 08:04:56 +0200 Subject: [PATCH] =?UTF-8?q?fix(Core/PlayerQuest):=20Introduce=20flag=20QUE?= =?UTF-8?q?ST=5FSPECIAL=5FFLAGS=5FCAN=5FFAIL=5FIN=E2=80=A6=20(#19116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Core/PlayerQuest): Introduce flag QUEST_SPECIAL_FLAGS_CAN_FAIL_IN_ANY_STATE - this allows flagging quests so that they are allowed to fail in Player::FailQuest() independant of their current state - update quest 853 accordingly as a first use case --- .../rev_1718999602991537300.sql | 2 ++ .../game/Entities/Player/PlayerQuest.cpp | 2 +- src/server/game/Quests/QuestDef.h | 28 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1718999602991537300.sql diff --git a/data/sql/updates/pending_db_world/rev_1718999602991537300.sql b/data/sql/updates/pending_db_world/rev_1718999602991537300.sql new file mode 100644 index 000000000..ad9483be0 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1718999602991537300.sql @@ -0,0 +1,2 @@ +-- make Quest 'Apothecary Zamah' failable in any state +UPDATE `quest_template_addon` SET `SpecialFlags` = (`SpecialFlags` | 128) WHERE (`ID` = 853); diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index f71d8a6f7..13e08dab6 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -883,7 +883,7 @@ void Player::FailQuest(uint32 questId) { QuestStatus qStatus = GetQuestStatus(questId); // xinef: if quest is marked as failed, dont do it again - if ((qStatus != QUEST_STATUS_INCOMPLETE) && (!quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED))) + if ((qStatus != QUEST_STATUS_INCOMPLETE) && (!quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_CAN_FAIL_IN_ANY_STATE))) return; SetQuestStatus(questId, QUEST_STATUS_FAILED); diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index e2f62c3ff..84bbec84b 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -157,23 +157,25 @@ enum QuestSpecialFlags { QUEST_SPECIAL_FLAGS_NONE = 0x000, // Trinity flags for set SpecialFlags in DB if required but used only at server - QUEST_SPECIAL_FLAGS_REPEATABLE = 0x001, // Set by 1 in SpecialFlags from DB - QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT = 0x002, // Set by 2 in SpecialFlags from DB (if required area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `FECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script) - QUEST_SPECIAL_FLAGS_AUTO_ACCEPT = 0x004, // Set by 4 in SpecialFlags in DB if the quest is to be auto-accepted. - QUEST_SPECIAL_FLAGS_DF_QUEST = 0x008, // Set by 8 in SpecialFlags in DB if the quest is used by Dungeon Finder. - QUEST_SPECIAL_FLAGS_MONTHLY = 0x010, // Set by 16 in SpecialFlags in DB if the quest is reset at the begining of the month - QUEST_SPECIAL_FLAGS_CAST = 0x020, // Set by 32 in SpecialFlags in DB if the quest requires RequiredOrNpcGo killcredit but NOT kill (a spell cast) - QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER = 0x040, // Set by 64 in SpecialFlags in DB if the quest does not share rewarded reputation with other allied factions + QUEST_SPECIAL_FLAGS_REPEATABLE = 0x0001, // Set by 1 in SpecialFlags from DB + QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT = 0x0002, // Set by 2 in SpecialFlags from DB (if required area explore, spell SPELL_EFFECT_QUEST_COMPLETE casting, table `FECT_QUEST_COMPLETE casting, table `*_script` command SCRIPT_COMMAND_QUEST_EXPLORED use, set from script) + QUEST_SPECIAL_FLAGS_AUTO_ACCEPT = 0x0004, // Set by 4 in SpecialFlags in DB if the quest is to be auto-accepted. + QUEST_SPECIAL_FLAGS_DF_QUEST = 0x0008, // Set by 8 in SpecialFlags in DB if the quest is used by Dungeon Finder. + QUEST_SPECIAL_FLAGS_MONTHLY = 0x0010, // Set by 16 in SpecialFlags in DB if the quest is reset at the begining of the month + QUEST_SPECIAL_FLAGS_CAST = 0x0020, // Set by 32 in SpecialFlags in DB if the quest requires RequiredOrNpcGo killcredit but NOT kill (a spell cast) + QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER = 0x0040, // Set by 64 in SpecialFlags in DB if the quest does not share rewarded reputation with other allied factions + QUEST_SPECIAL_FLAGS_CAN_FAIL_IN_ANY_STATE = 0x0080, // Set by 128 in SpecialFlags in DB if the quest is allowed to fail in Player::FailQuest() independant of its current state // room for more custom flags QUEST_SPECIAL_FLAGS_DB_ALLOWED = QUEST_SPECIAL_FLAGS_REPEATABLE | QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT | QUEST_SPECIAL_FLAGS_AUTO_ACCEPT | - QUEST_SPECIAL_FLAGS_DF_QUEST | QUEST_SPECIAL_FLAGS_MONTHLY | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER, + QUEST_SPECIAL_FLAGS_DF_QUEST | QUEST_SPECIAL_FLAGS_MONTHLY | QUEST_SPECIAL_FLAGS_CAST | QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER | + QUEST_SPECIAL_FLAGS_CAN_FAIL_IN_ANY_STATE, - QUEST_SPECIAL_FLAGS_DELIVER = 0x080, // Internal flag computed only - QUEST_SPECIAL_FLAGS_SPEAKTO = 0x100, // Internal flag computed only - QUEST_SPECIAL_FLAGS_KILL = 0x200, // Internal flag computed only - QUEST_SPECIAL_FLAGS_TIMED = 0x400, // Internal flag computed only - QUEST_SPECIAL_FLAGS_PLAYER_KILL = 0x800 // Internal flag computed only + QUEST_SPECIAL_FLAGS_DELIVER = 0x0100, // Internal flag computed only + QUEST_SPECIAL_FLAGS_SPEAKTO = 0x0200, // Internal flag computed only + QUEST_SPECIAL_FLAGS_KILL = 0x0400, // Internal flag computed only + QUEST_SPECIAL_FLAGS_TIMED = 0x0800, // Internal flag computed only + QUEST_SPECIAL_FLAGS_PLAYER_KILL = 0x1000 // Internal flag computed only }; struct QuestLocale