From dd0b964a2af8248ce0ff29bf8e59f1207d648b2b Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:50:42 +0200 Subject: [PATCH] fix(Scripts/Spells): Unlit Torches cannot be used too far away from the bonfire (#7644) - Closes #6551 --- src/server/scripts/Events/midsummer.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index cb2fc42fb..b3e34e646 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -389,15 +389,23 @@ public: bool handled; bool Load() override { handled = false; return true; } + SpellCastResult CheckCast() + { + GetCaster()->GetCreaturesWithEntryInRange(_crList, 100.0f, NPC_TORCH_TARGET); + if (_crList.empty()) + { + return SPELL_FAILED_NOT_HERE; + } + + return SPELL_CAST_OK; + } + void ThrowNextTorch(Unit* caster) { - std::list crList; - caster->GetCreaturesWithEntryInRange(crList, 100.0f, NPC_TORCH_TARGET); - - uint8 rand = urand(0, crList.size() - 1); + uint8 rand = urand(0, _crList.size() - 1); Position pos; pos.Relocate(0.0f, 0.0f, 0.0f); - for (std::list::const_iterator itr = crList.begin(); itr != crList.end(); ++itr, --rand) + for (std::list::const_iterator itr = _crList.begin(); itr != _crList.end(); ++itr, --rand) { if (caster->GetDistance(*itr) < 5) { @@ -473,8 +481,14 @@ public: { AfterCast += SpellCastFn(spell_midsummer_fling_torch_SpellScript::HandleFinish); if (m_scriptSpellId == 45671) + { + OnCheckCast += SpellCheckCastFn(spell_midsummer_fling_torch_SpellScript::CheckCast); OnEffectHitTarget += SpellEffectFn(spell_midsummer_fling_torch_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); + } } + + private: + std::list _crList; }; SpellScript* GetSpellScript() const override