From 16fdfde22a938cf526e3b713c6c42066a7be4f49 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 13 Jan 2024 15:40:55 +0100 Subject: [PATCH] Warlock: Move Haunt to Spell Scripts Closes https://github.com/cmangos/mangos-wotlk/pull/489 --- sql/scriptdev2/spell.sql | 6 +++- .../Scripting/ClassScripts/Warlock.cpp | 31 +++++++++++++++++++ src/game/Spells/Spell.cpp | 7 ----- src/game/Spells/SpellAuras.cpp | 14 --------- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/sql/scriptdev2/spell.sql b/sql/scriptdev2/spell.sql index 7ae740eb299..a70f57d55e0 100644 --- a/sql/scriptdev2/spell.sql +++ b/sql/scriptdev2/spell.sql @@ -1397,7 +1397,11 @@ INSERT INTO spell_scripts(Id, ScriptName) VALUES (48020,'spell_demonic_circle_teleport'), (63320,'spell_glyph_of_life_tap'), (63310,'spell_glyph_of_shadowflame'), -(6358,'spell_seduction_succubus'); +(6358,'spell_seduction_succubus'), +(48181,'spell_haunt'), +(59161,'spell_haunt'), +(59163,'spell_haunt'), +(59164,'spell_haunt'); -- Pet Scaling INSERT INTO spell_scripts(Id, ScriptName) VALUES diff --git a/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp b/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp index c45bdea411e..4f093ac500e 100644 --- a/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp +++ b/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp @@ -640,6 +640,36 @@ struct SeductionSuccubus : public AuraScript } }; +// 48181, 59161, 59163, 59164 - Haunt +struct Haunt : public AuraScript, public SpellScript +{ + enum + { + SPELL_HAUNT_HEAL = 48210, + }; + void OnApply(Aura* aura, bool apply) const override + { + if (apply) + { + aura->SetScriptValue(0); + return; + } + Unit* caster = aura->GetCaster(); + Unit* target = aura->GetTarget(); + if (!caster) + return; + int32 bp0 = aura->GetScriptValue(); + target->CastCustomSpell(caster, SPELL_HAUNT_HEAL, &bp0, nullptr, nullptr, TRIGGERED_OLD_TRIGGERED, nullptr, aura); + } + + void OnHit(Spell* spell, SpellMissInfo missInfo) const override + { + Unit* target = spell->GetUnitTarget(); + if (Aura* dummy = target->GetDummyAura(spell->m_spellInfo->Id)) + dummy->SetScriptValue(spell->GetTotalTargetDamage()); + } +}; + void LoadWarlockScripts() { RegisterSpellScript("spell_unstable_affliction"); @@ -665,4 +695,5 @@ void LoadWarlockScripts() RegisterSpellScript("spell_glyph_of_life_tap"); RegisterSpellScript("spell_glyph_of_shadowflame"); RegisterSpellScript("spell_seduction_succubus"); + RegisterSpellScript("spell_haunt"); } diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index e48d09fbfee..1b5f4cf0dac 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -1450,13 +1450,6 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // Do triggers for unit (reflect triggers passed on hit phase for correct drop charge) if (m_canTrigger && missInfo != SPELL_MISS_REFLECT) Unit::ProcDamageAndSpell(ProcSystemArguments(affectiveCaster, unitTarget, affectiveCaster ? procAttacker : uint32(PROC_FLAG_NONE), procVictim, procEx, spellDamageInfo.damage, spellDamageInfo.absorb, m_attackType, m_spellInfo, this)); - - // Haunt (NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%) - // apply before deal damage because aura can be removed at target kill - if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellIconID == 3172 && - (m_spellInfo->SpellFamilyFlags & uint64(0x0004000000000000))) - if (Aura* dummy = unitTarget->GetDummyAura(m_spellInfo->Id)) - dummy->GetModifier()->m_amount = spellDamageInfo.damage; } // Passive spell hits/misses or active spells only misses (only triggers if proc flags set) else if (procAttacker || procVictim) diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 990c25641d7..404c71bce20 100755 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -3539,20 +3539,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real) break; case SPELLFAMILY_WARLOCK: { - // Haunt - if (GetSpellProto()->SpellIconID == 3172 && (GetSpellProto()->SpellFamilyFlags & uint64(0x0004000000000000))) - { - // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100% - if (apply) - m_modifier.m_amount = 0; // use value as damage counter instead redundant 100% percent - else - { - int32 bp0 = m_modifier.m_amount; - - if (Unit* caster = GetCaster()) - target->CastCustomSpell(caster, 48210, &bp0, nullptr, nullptr, TRIGGERED_OLD_TRIGGERED, nullptr, this); - } - } break; } case SPELLFAMILY_DRUID: