diff --git a/data/sql/updates/pending_db_world/rev_1561127338947558444.sql b/data/sql/updates/pending_db_world/rev_1561127338947558444.sql new file mode 100644 index 000000000..892adc5bf --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1561127338947558444.sql @@ -0,0 +1,4 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1561127338947558444'); + +DELETE FROM `spell_script_names` WHERE `spell_id` = 53768; +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES (53768,'spell_gen_haunted'); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 12b720bfd..1858a8cf6 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -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();