From 60296dd934e740a86ba139f250defe3ea9c5ec0b Mon Sep 17 00:00:00 2001 From: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Date: Sat, 10 May 2025 13:38:46 -0400 Subject: [PATCH] fix(Scripts/Paladin): Add cast check to Hand of Protection for casting spell on non-self targets. (#22077) Hand of Protection no longer can be used if the caster it's stunned or confused. --- .../sql/updates/pending_db_world/bop-ally.sql | 3 ++ src/server/scripts/Spells/spell_paladin.cpp | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 data/sql/updates/pending_db_world/bop-ally.sql diff --git a/data/sql/updates/pending_db_world/bop-ally.sql b/data/sql/updates/pending_db_world/bop-ally.sql new file mode 100644 index 000000000..55ef4c95a --- /dev/null +++ b/data/sql/updates/pending_db_world/bop-ally.sql @@ -0,0 +1,3 @@ +DELETE FROM `spell_script_names` WHERE `spell_id` = -1022; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(-1022, 'spell_pal_hand_of_protection'); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index e2350a2c8..941af7f4f 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -1150,6 +1150,36 @@ class spell_pal_seal_of_vengeance : public SpellScript } }; +// 1022 - Hand of Protection +class spell_pal_hand_of_protection : public SpellScript +{ + PrepareSpellScript(spell_pal_hand_of_protection); + + SpellCastResult CheckCast() + { + Unit* caster = GetCaster(); + + if (!caster->GetTarget() || caster->GetTarget() == caster->GetGUID()) + return SPELL_CAST_OK; + + if (caster->HasStunAura()) + return SPELL_FAILED_STUNNED; + + if (caster->HasConfuseAura()) + return SPELL_FAILED_CONFUSED; + + if (caster->GetUnitFlags() & UNIT_FLAG_FLEEING) + return SPELL_FAILED_FLEEING; + + return SPELL_CAST_OK; + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_pal_hand_of_protection::CheckCast); + } +}; + void AddSC_paladin_spell_scripts() { RegisterSpellAndAuraScriptPair(spell_pal_seal_of_command, spell_pal_seal_of_command_aura); @@ -1178,4 +1208,5 @@ void AddSC_paladin_spell_scripts() RegisterSpellScript(spell_pal_righteous_defense); RegisterSpellScript(spell_pal_seal_of_righteousness); RegisterSpellScript(spell_pal_seal_of_vengeance); + RegisterSpellScript(spell_pal_hand_of_protection); }