From a69d02e51394377139b5644fd00205df6f0d1a67 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Sat, 13 Jul 2024 17:38:59 +0200 Subject: [PATCH] fix(Scripts/Spells): warlock demonic pact (#19386) * add Demonic Pact Aura script https://github.com/TrinityCore/TrinityCore/commit/2ff855054f52bf2dcf81aa7a7da7bab7f8a99686#diff-ea612aafadff90005e88b243eb000369be9e5cb6f8dc85a008d31e42b156e0ec Co-authored-by: ariel- * spell_warlock aura:spell_warl_demonic_pact_aura * fixup! spell_warlock aura:spell_warl_demonic_pact_aura * remove not needed spell correction, flag is already set * subtract current proc bonus before calculating new bonus * also increase healing done * remove Demonic Pact handling in Unit * refactor indent, remove bonus from spell group effects e.g. totem of wrath * Revert "refactor indent, remove bonus from spell group effects e.g. totem of wrath" This reverts commit 104041172d34f542cc934e9f468407c36912cc7f. * refactor indent * manually set proc cooldown --------- Co-authored-by: ariel- --- .../rev_1720633619992216684.sql | 5 ++ src/server/game/Entities/Unit/Unit.cpp | 24 --------- .../game/Spells/SpellInfoCorrections.cpp | 6 --- src/server/scripts/Spells/spell_warlock.cpp | 53 ++++++++++++++++++- 4 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1720633619992216684.sql diff --git a/data/sql/updates/pending_db_world/rev_1720633619992216684.sql b/data/sql/updates/pending_db_world/rev_1720633619992216684.sql new file mode 100644 index 000000000..eff1ca20a --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1720633619992216684.sql @@ -0,0 +1,5 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id` IN (53646, 54909); +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(53646, 'spell_warl_demonic_pact_aura'), +(54909, 'spell_warl_demonic_pact_aura'); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 0a48b0a2c..0b4c13dea 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9692,30 +9692,6 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg return false; break; } - // Demonic Pact - case 48090: - { - // Get talent aura from owner - if (IsPet()) - if (Unit* owner = GetOwner()) - { - if (HasSpellCooldown(trigger_spell_id)) - return false; - AddSpellCooldown(trigger_spell_id, 0, cooldown); - - if (AuraEffect* aurEff = owner->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 3220, 0)) - { - int32 spellPower = owner->SpellBaseDamageBonusDone(SpellSchoolMask(SPELL_SCHOOL_MASK_MAGIC)); - if (AuraEffect const* demonicAuraEffect = GetAuraEffect(trigger_spell_id, EFFECT_0)) - spellPower -= demonicAuraEffect->GetAmount(); - - basepoints0 = int32((aurEff->GetAmount() * spellPower + 100.0f) / 100.0f); - CastCustomSpell(this, trigger_spell_id, &basepoints0, &basepoints0, nullptr, true, castItem, triggeredByAura); - return true; - } - } - break; - } case 46916: // Slam! (Bloodsurge proc) case 52437: // Sudden Death { diff --git a/src/server/game/Spells/SpellInfoCorrections.cpp b/src/server/game/Spells/SpellInfoCorrections.cpp index e0387de8f..13b146f35 100644 --- a/src/server/game/Spells/SpellInfoCorrections.cpp +++ b/src/server/game/Spells/SpellInfoCorrections.cpp @@ -4699,12 +4699,6 @@ void SpellMgr::LoadSpellInfoCorrections() spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT; }); - // Demonic Pact - ApplySpellFix({ 48090 }, [](SpellInfo* spellInfo) - { - spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT; - }); - // Ancestral Awakening ApplySpellFix({ 52759 }, [](SpellInfo* spellInfo) { diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 73d053a3d..d9601ebef 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -65,12 +65,14 @@ enum WarlockSpells SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC = 18371, SPELL_WARLOCK_EYE_OF_KILROGG_FLY = 58083, SPELL_WARLOCK_PET_VOID_STAR_TALISMAN = 37386, // Void Star Talisman + SPELL_WARLOCK_DEMONIC_PACT_PROC = 48090, }; enum WarlockSpellIcons { WARLOCK_ICON_ID_IMPROVED_LIFE_TAP = 208, - WARLOCK_ICON_ID_MANA_FEED = 1982 + WARLOCK_ICON_ID_MANA_FEED = 1982, + WARLOCK_ICON_ID_DEMONIC_PACT = 3220 }; class spell_warl_eye_of_kilrogg : public AuraScript @@ -1321,6 +1323,54 @@ class spell_warl_glyph_of_voidwalker : public AuraScript } }; +// 54909, 53646 - Demonic Pact +class spell_warl_demonic_pact_aura : public AuraScript +{ + PrepareAuraScript(spell_warl_demonic_pact_aura); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WARLOCK_DEMONIC_PACT_PROC }); + } + + bool AfterCheckProc(ProcEventInfo& eventInfo, bool isTriggeredAtSpellProcEvent) + { + return isTriggeredAtSpellProcEvent && eventInfo.GetActor() && eventInfo.GetActor()->IsPet(); + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + if (eventInfo.GetActor()->HasSpellCooldown(aurEff->GetId())) + return; + + if (Unit* owner = eventInfo.GetActor()->GetOwner()) + { + int32 currentBonus = 0; + if (AuraEffect* demonicAurEff = owner->GetAuraEffect(SPELL_WARLOCK_DEMONIC_PACT_PROC, EFFECT_0)) + { + currentBonus = demonicAurEff->GetAmount(); + } + + if (AuraEffect* talentAurEff = owner->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, WARLOCK_ICON_ID_DEMONIC_PACT, EFFECT_0)) + { + int32 spellDamageMinusBonus = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_MAGIC) - currentBonus; + if (spellDamageMinusBonus < 0) + return; + int32 bp = int32((talentAurEff->GetAmount() / 100.0f) * spellDamageMinusBonus); + owner->CastCustomSpell((Unit*)nullptr, SPELL_WARLOCK_DEMONIC_PACT_PROC, &bp, &bp, 0, true, nullptr, talentAurEff); + eventInfo.GetActor()->AddSpellCooldown(aurEff->GetId(), 0, eventInfo.GetProcCooldown()); + } + } + } + + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_warl_demonic_pact_aura::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL); + } +}; + void AddSC_warlock_spell_scripts() { RegisterSpellScript(spell_warl_eye_of_kilrogg); @@ -1354,5 +1404,6 @@ void AddSC_warlock_spell_scripts() RegisterSpellScript(spell_warl_shadowburn); RegisterSpellScript(spell_warl_glyph_of_felguard); RegisterSpellScript(spell_warl_glyph_of_voidwalker); + RegisterSpellScript(spell_warl_demonic_pact_aura); }