From 7400338ecb5b300dada30da2b8ae895b65c541ae Mon Sep 17 00:00:00 2001 From: Grimgravy Date: Sun, 25 Sep 2022 10:46:24 -0300 Subject: [PATCH] fix(core/quest): improved egg collection (#12640) * fix(core/quest): improved egg collection * . * Update rev_1659836460796753400.sql * update --- .../rev_1659836460796753400.sql | 4 ++ .../game/Spells/SpellInfoCorrections.cpp | 6 +++ src/server/scripts/Spells/spell_quest.cpp | 46 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1659836460796753400.sql diff --git a/data/sql/updates/pending_db_world/rev_1659836460796753400.sql b/data/sql/updates/pending_db_world/rev_1659836460796753400.sql new file mode 100644 index 000000000..0b8d0795e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1659836460796753400.sql @@ -0,0 +1,4 @@ +-- +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_q4735_collect_rookery_egg'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(15958, 'spell_q4735_collect_rookery_egg'); diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index 4545c377a..bf62dbaec 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -4391,6 +4391,12 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->SpellFamilyName = SPELLFAMILY_POTION; }); + // Collect Rookery Egg + ApplySpellFix({ 15958 }, [](SpellInfo* spellInfo) + { + spellInfo->Effects[EFFECT_1].Effect = 0; + }); + for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) { SpellInfo* spellInfo = mSpellInfoMap[i]; diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 140731a6d..6d091c141 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -2403,6 +2403,51 @@ class spell_q5056_summon_shy_rotam : public SpellScript } }; +enum RookeryEgg +{ + ITEM_COLLECTED_DRAGON_EGG = 12241, + QUEST_EGG_COLLECTION = 4735, + GO_ROOKERY_EGG = 175124 +}; + +class spell_q4735_collect_rookery_egg : public SpellScript +{ + PrepareSpellScript(spell_q4735_collect_rookery_egg); + + SpellCastResult CheckCast() + { + if (GameObject* rookery = GetCaster()->FindNearestGameObject(GO_ROOKERY_EGG, 5.0f, true)) + { + if (rookery->GetGoState() != GO_STATE_ACTIVE_ALTERNATIVE) + return SPELL_FAILED_BAD_TARGETS; + } + return SPELL_CAST_OK; + } + + SpellCastResult CheckQuest() + { + if (Player* playerCaster = GetCaster()->ToPlayer()) + { + if (playerCaster->GetQuestStatus(QUEST_EGG_COLLECTION) == QUEST_STATUS_INCOMPLETE) + return SPELL_CAST_OK; + } + return SPELL_FAILED_DONT_REPORT; + } + + void HandleActiveObject(SpellEffIndex /*effIndex*/) + { + if (Player* playerCaster = GetCaster()->ToPlayer()) + playerCaster->AddItem(ITEM_COLLECTED_DRAGON_EGG, 1); + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_q4735_collect_rookery_egg::CheckQuest); + OnCheckCast += SpellCheckCastFn(spell_q4735_collect_rookery_egg::CheckCast); + OnEffectHit += SpellEffectFn(spell_q4735_collect_rookery_egg::HandleActiveObject, EFFECT_0, SPELL_EFFECT_ACTIVATE_OBJECT); + } +}; + void AddSC_quest_spell_scripts() { RegisterSpellAndAuraScriptPair(spell_q11065_wrangle_some_aether_rays, spell_q11065_wrangle_some_aether_rays_aura); @@ -2473,4 +2518,5 @@ void AddSC_quest_spell_scripts() RegisterSpellScript(spell_q12919_gymers_grab); RegisterSpellScript(spell_q12919_gymers_throw); RegisterSpellScript(spell_q5056_summon_shy_rotam); + RegisterSpellScript(spell_q4735_collect_rookery_egg); }