From 1c22cdcab2c2eb0b6223bae79d7c27642908c23f Mon Sep 17 00:00:00 2001 From: avarishd <46330494+avarishd@users.noreply.github.com> Date: Mon, 4 Nov 2024 22:09:10 +0200 Subject: [PATCH] fix(Core/Spells): Luffa removing bleeds over level 60 (#20411) * fix(Core/Spells): Luffa * Update spell_item.cpp * Update spell_item.cpp * Update spell_item.cpp --- .../rev_1730488634123195500.sql | 3 ++ .../game/Spells/SpellInfoCorrections.cpp | 6 --- src/server/scripts/Spells/spell_item.cpp | 50 +++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1730488634123195500.sql diff --git a/data/sql/updates/pending_db_world/rev_1730488634123195500.sql b/data/sql/updates/pending_db_world/rev_1730488634123195500.sql new file mode 100644 index 000000000..7e2f1eae0 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1730488634123195500.sql @@ -0,0 +1,3 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id`=23595 AND `ScriptName`='spell_item_luffa'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (23595, 'spell_item_luffa'); diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index 2177f9171..2f9d29bdc 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -4000,12 +4000,6 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->Effects[EFFECT_0].TargetB = SpellImplicitTargetInfo(); }); - // Luffa - ApplySpellFix({ 23595 }, [](SpellInfo* spellInfo) - { - spellInfo->Effects[EFFECT_0].BasePoints = 1; // Remove only 1 bleed effect - }); - // Eye of Kilrogg Passive (DND) ApplySpellFix({ 2585 }, [](SpellInfo* spellInfo) { diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 11ac17708..90d8ceb03 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -4092,6 +4092,55 @@ class spell_item_skyguard_blasting_charges : public SpellScript } }; +// 23595 - Luffa +class spell_item_luffa : public SpellScript +{ + PrepareSpellScript(spell_item_luffa); + + SpellCastResult CheckCast() + { + if (GetCaster()) + { + Unit::AuraApplicationMap const& auras = GetCaster()->GetAppliedAuras(); + for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + Aura const* aura = itr->second->GetBase(); + if (!(aura->GetSpellInfo()->GetAllEffectsMechanicMask() & (1 << MECHANIC_BLEED)) || aura->GetCasterLevel() > 60 || aura->GetSpellInfo()->IsPositive()) + continue; + + return SPELL_CAST_OK; + } + } + + return SPELL_FAILED_NOTHING_TO_DISPEL; + } + + void HandleEffect(SpellEffIndex effIndex) + { + PreventHitDefaultEffect(effIndex); + + if (Player* player = GetCaster()->ToPlayer()) + { + Unit::AuraApplicationMap const& auras = player->GetAppliedAuras(); + for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + Aura const* aura = itr->second->GetBase(); + if (!(aura->GetSpellInfo()->GetAllEffectsMechanicMask() & (1 << MECHANIC_BLEED)) || aura->GetCasterLevel() > 60 || aura->GetSpellInfo()->IsPositive()) + continue; + + player->RemoveAurasDueToSpell(aura->GetId(), aura->GetCasterGUID()); + return; + } + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_item_luffa::CheckCast); + OnEffectHitTarget += SpellEffectFn(spell_item_luffa::HandleEffect, EFFECT_0, SPELL_EFFECT_DISPEL_MECHANIC); + } +}; + void AddSC_item_spell_scripts() { RegisterSpellScript(spell_item_massive_seaforium_charge); @@ -4217,4 +4266,5 @@ void AddSC_item_spell_scripts() RegisterSpellScript(spell_item_fel_mana_potion); RegisterSpellScript(spell_item_gor_dreks_ointment); RegisterSpellScript(spell_item_skyguard_blasting_charges); + RegisterSpellScript(spell_item_luffa); }