Skip to content

Commit

Permalink
Warlock: Move Haunt to Spell Scripts
Browse files Browse the repository at this point in the history
Closes #489
  • Loading branch information
insunaa authored and killerwife committed Jul 5, 2024
1 parent 5d58b48 commit 16fdfde
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
6 changes: 5 additions & 1 deletion sql/scriptdev2/spell.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnstableAffliction>("spell_unstable_affliction");
Expand All @@ -665,4 +695,5 @@ void LoadWarlockScripts()
RegisterSpellScript<GlyphOfLifeTap>("spell_glyph_of_life_tap");
RegisterSpellScript<GlyphOfShadowflame>("spell_glyph_of_shadowflame");
RegisterSpellScript<SeductionSuccubus>("spell_seduction_succubus");
RegisterSpellScript<Haunt>("spell_haunt");
}
7 changes: 0 additions & 7 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 0 additions & 14 deletions src/game/Spells/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 16fdfde

Please sign in to comment.