fix(Core/Spell): Haunted Memento (#1992)

This commit is contained in:
Stoabrogga
2019-06-26 23:43:58 +02:00
committed by Francesco Borzì
parent eae2214d7c
commit 9f3c0267bc
2 changed files with 91 additions and 0 deletions

View File

@@ -1408,6 +1408,92 @@ class spell_gen_throw_back : public SpellScriptLoader
}
};
enum eHaunted
{
NPC_SCOURGE_HAUNT = 29238
};
class spell_gen_haunted : public SpellScriptLoader
{
public:
spell_gen_haunted() : SpellScriptLoader("spell_gen_haunted") { }
class spell_gen_haunted_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_haunted_AuraScript);
void HandleEffectCalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
isPeriodic = true;
amplitude = urand(120,300) * IN_MILLISECONDS;
}
void HandleEffectPeriodic(AuraEffect const * /*aurEff*/)
{
if (Unit* caster = GetCaster())
{
Position pos;
caster->GetRandomNearPosition(pos, 5.0f);
if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10,20) * IN_MILLISECONDS))
{
haunt->SetSpeed(MOVE_RUN, 0.5, true);
haunt->GetMotionMaster()->MoveFollow(caster, 1, M_PI);
}
}
}
void HandleOnEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
if (Creature* haunt = caster->FindNearestCreature(NPC_SCOURGE_HAUNT, 5.0f, true))
haunt->DespawnOrUnsummon();
}
void Register()
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_haunted_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_DUMMY);
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_gen_haunted_AuraScript::HandleEffectCalcPeriodic, EFFECT_1, SPELL_AURA_DUMMY);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_haunted_AuraScript::HandleOnEffectRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const
{
return new spell_gen_haunted_AuraScript();
}
class spell_gen_haunted_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_haunted_SpellScript);
void HandleOnEffectHit(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Unit* caster = GetCaster())
{
Position pos;
caster->GetRandomNearPosition(pos, 5.0f);
if (Creature* haunt = caster->SummonCreature(NPC_SCOURGE_HAUNT, pos, TEMPSUMMON_TIMED_DESPAWN, urand(10,20) * IN_MILLISECONDS))
{
haunt->SetSpeed(MOVE_RUN, 0.5, true);
haunt->GetMotionMaster()->MoveFollow(caster, 1, M_PI);
}
}
}
void Register()
{
OnEffectHit += SpellEffectFn(spell_gen_haunted_SpellScript::HandleOnEffectHit, EFFECT_0, SPELL_EFFECT_SUMMON);
}
};
SpellScript* GetSpellScript() const
{
return new spell_gen_haunted_SpellScript();
}
};
// Theirs
class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader
@@ -4965,6 +5051,7 @@ void AddSC_generic_spell_scripts()
new spell_gen_focused_bursts();
new spell_gen_flurry_of_claws();
new spell_gen_throw_back();
new spell_gen_haunted();
// theirs:
new spell_gen_absorb0_hitlimit1();