From 6990a1d2a43b085cccf83a1cfe23c03675a69c88 Mon Sep 17 00:00:00 2001 From: Grimgravy Date: Sun, 24 Sep 2023 16:23:58 -0300 Subject: [PATCH] fix(Scripts/Quest): improve Catch the Wild Wolpertinger! (#17333) --- .../rev_1695559726583951400.sql | 7 ++++ .../game/Spells/SpellInfoCorrections.cpp | 6 --- src/server/scripts/Events/brewfest.cpp | 39 +++++++++---------- 3 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1695559726583951400.sql diff --git a/data/sql/updates/pending_db_world/rev_1695559726583951400.sql b/data/sql/updates/pending_db_world/rev_1695559726583951400.sql new file mode 100644 index 000000000..58555e35f --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1695559726583951400.sql @@ -0,0 +1,7 @@ +-- +DELETE FROM `conditions` WHERE (`SourceTypeOrReferenceId` = 17) AND (`SourceGroup` = 0) AND (`SourceEntry` = 41621) AND (`SourceId` = 0) AND (`ElseGroup` = 0) AND (`ConditionTypeOrReference` = 31) AND (`ConditionTarget` = 1) AND (`ConditionValue1` = 3) AND (`ConditionValue2` = 23487) AND (`ConditionValue3` = 0); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(17, 0, 41621, 0, 0, 31, 1, 3, 23487, 0, 0, 0, 0, '', 'Throw a net at a wild wolpertinger, which will allow you to capture it and place it in your pack.'); + +-- both missions are for the horde and alliance factions +UPDATE `spell_script_names` SET `ScriptName`='spell_catch_the_wild_wolpertinger' WHERE `spell_id`=41621 AND `ScriptName`='spell_q11117_catch_the_wild_wolpertinger'; diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index 3aff2bee8..d55a5505d 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -3922,12 +3922,6 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->ExcludeCasterAuraSpell = 42299; }); - // Catch the Wild Wolpertinger! - ApplySpellFix({ 41621 }, [](SpellInfo* spellInfo) - { - spellInfo->Effects[EFFECT_0].Effect = SPELL_EFFECT_DUMMY; - }); - // Brewfest quests ApplySpellFix({ 47134, 51798 }, [](SpellInfo* spellInfo) { diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index badf22dd9..b202673cd 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -1031,35 +1031,32 @@ class spell_brewfest_apple_trap : public SpellScript } }; -class spell_q11117_catch_the_wild_wolpertinger : public SpellScript +enum Catch { - PrepareSpellScript(spell_q11117_catch_the_wild_wolpertinger); + NPC_WILD_WOLPERTINGER = 23487, - SpellCastResult CheckTarget() + ITEM_STUNNED_WOLPERTINGER = 32906 +}; + +class spell_catch_the_wild_wolpertinger : public AuraScript +{ + PrepareAuraScript(spell_catch_the_wild_wolpertinger); + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (Unit* caster = GetCaster()) - if (caster->ToPlayer()) - if (Unit* target = caster->ToPlayer()->GetSelectedUnit()) - if (target->GetEntry() == 23487 && target->IsAlive()) - return SPELL_CAST_OK; - - return SPELL_FAILED_BAD_TARGETS; - } - - void HandleDummyEffect(SpellEffIndex /*effIndex*/) - { - if (GetCaster() && GetCaster()->ToPlayer()) + if (Creature* wild = GetTarget()->ToCreature()) { - GetCaster()->ToPlayer()->AddItem(32906, 1); - if (Unit* target = GetCaster()->ToPlayer()->GetSelectedUnit()) - target->ToCreature()->DespawnOrUnsummon(500); + if (wild->GetEntry() == NPC_WILD_WOLPERTINGER) + { + wild->ToCreature()->DespawnOrUnsummon(1s, 0s); + GetCaster()->ToPlayer()->AddItem(ITEM_STUNNED_WOLPERTINGER, 1); + } } } void Register() override { - OnCheckCast += SpellCheckCastFn(spell_q11117_catch_the_wild_wolpertinger::CheckTarget); - OnEffectHitTarget += SpellEffectFn(spell_q11117_catch_the_wild_wolpertinger::HandleDummyEffect, EFFECT_0, SPELL_EFFECT_DUMMY); + OnEffectApply += AuraEffectApplyFn(spell_catch_the_wild_wolpertinger::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_PACIFY_SILENCE, AURA_EFFECT_HANDLE_REAL); } }; @@ -2072,7 +2069,7 @@ void AddSC_event_brewfest_scripts() RegisterSpellScript(spell_brewfest_ram_fatigue); RegisterSpellScript(spell_brewfest_apple_trap); // other - RegisterSpellScript(spell_q11117_catch_the_wild_wolpertinger); + RegisterSpellScript(spell_catch_the_wild_wolpertinger); RegisterSpellScript(spell_brewfest_fill_keg); RegisterSpellScript(spell_brewfest_unfill_keg); RegisterSpellScript(spell_brewfest_toss_mug);