From c256d8da55214dac7610e7abea8023e9747a3f70 Mon Sep 17 00:00:00 2001 From: Grimgravy Date: Fri, 11 Aug 2023 19:17:06 -0300 Subject: [PATCH] fix(Scripts/Spell): Improve Inoculation quest (#15759) * fix(Core/Quest): Improve Inoculation * update fix * . * .. --- .../rev_1680343313995182400.sql | 9 ++++ .../scripts/Kalimdor/zone_azuremyst_isle.cpp | 52 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1680343313995182400.sql diff --git a/data/sql/updates/pending_db_world/rev_1680343313995182400.sql b/data/sql/updates/pending_db_world/rev_1680343313995182400.sql new file mode 100644 index 000000000..9c6852e6e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1680343313995182400.sql @@ -0,0 +1,9 @@ +-- +DELETE FROM `spell_script_names` WHERE `ScriptName`='spell_inoculate_nestlewood_owlkin'; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(29528, 'spell_inoculate_nestlewood_owlkin'); + +UPDATE `creature_template` SET `AIName` = '' WHERE `entry` = 16518; + +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 16518); +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 1651800) AND (`source_type` = 9) AND (`id` IN (0, 1, 2, 3, 4, 5, 6, 7, 8)); diff --git a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp index 3bc60dbe4..dc7bb1607 100644 --- a/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_azuremyst_isle.cpp @@ -39,6 +39,8 @@ EndContentData */ #include "ScriptedCreature.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" +#include "SpellAuras.h" +#include "SpellScript.h" /*###### ## npc_draenei_survivor @@ -522,6 +524,55 @@ public: } }; +enum NestlewoodOwlkin +{ + NPC_NESTLEWOOD_OWLKIN_ENTRY = 16518, + NPC_INOCULATED_OWLKIN_ENTRY = 16534, + + TALK_OWLKIN = 0 +}; + +class spell_inoculate_nestlewood_owlkin : public AuraScript +{ +public: + PrepareAuraScript(spell_inoculate_nestlewood_owlkin) + + void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (Creature* owlkin = GetTarget()->ToCreature()) + if (owlkin->GetEntry() == NPC_NESTLEWOOD_OWLKIN_ENTRY) + owlkin->SetFacingToObject(GetCaster()); + } + + void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) + { + if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + return; + + if (Creature* owlkin = GetTarget()->ToCreature()) + { + if (owlkin->GetEntry() == NPC_NESTLEWOOD_OWLKIN_ENTRY) + { + Player* caster = GetCaster()->ToPlayer(); + if (owlkin->UpdateEntry(NPC_INOCULATED_OWLKIN_ENTRY)) + { + owlkin->AI()->Talk(TALK_OWLKIN); + owlkin->GetMotionMaster()->MoveRandom(15.0f); + owlkin->SetUnitFlag(UnitFlags(UNIT_FLAG_IMMUNE_TO_PC)); + owlkin->DespawnOrUnsummon(15s, 0s); + caster->RewardPlayerAndGroupAtEvent(NPC_INOCULATED_OWLKIN_ENTRY, caster); + } + } + } + } + + void Register() override + { + OnEffectApply += AuraEffectApplyFn(spell_inoculate_nestlewood_owlkin::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + AfterEffectRemove += AuraEffectRemoveFn(spell_inoculate_nestlewood_owlkin::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL); + } +}; + void AddSC_azuremyst_isle() { new npc_draenei_survivor(); @@ -531,4 +582,5 @@ void AddSC_azuremyst_isle() new go_ravager_cage(); new npc_stillpine_capitive(); new go_bristlelimb_cage(); + RegisterSpellScript(spell_inoculate_nestlewood_owlkin); }