refactor(Scripts/SCC): Update spell scripts to the new register model (#17726)

This commit is contained in:
Andrew
2023-11-16 14:01:13 -03:00
committed by GitHub
parent a5b5278929
commit 1f30a755dc
7 changed files with 330 additions and 678 deletions
@@ -78,13 +78,7 @@ const Position advisorsPosition[MAX_ADVISORS] =
struct boss_fathomlord_karathress : public BossAI struct boss_fathomlord_karathress : public BossAI
{ {
boss_fathomlord_karathress(Creature* creature) : BossAI(creature, DATA_FATHOM_LORD_KARATHRESS) boss_fathomlord_karathress(Creature* creature) : BossAI(creature, DATA_FATHOM_LORD_KARATHRESS) { }
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void Reset() override void Reset() override
{ {
@@ -192,7 +186,7 @@ struct boss_fathomguard_sharkkis : public ScriptedAI
{ {
_instance = creature->GetInstanceScript(); _instance = creature->GetInstanceScript();
_scheduler.SetValidator([this] scheduler.SetValidator([this]
{ {
return !me->HasUnitState(UNIT_STATE_CASTING); return !me->HasUnitState(UNIT_STATE_CASTING);
}); });
@@ -202,7 +196,7 @@ struct boss_fathomguard_sharkkis : public ScriptedAI
void Reset() override void Reset() override
{ {
_scheduler.CancelAll(); scheduler.CancelAll();
summons.DespawnAll(); summons.DespawnAll();
summons.clear(); summons.clear();
@@ -220,7 +214,8 @@ struct boss_fathomguard_sharkkis : public ScriptedAI
{ {
karathress->Attack(who, false); karathress->Attack(who, false);
} }
_scheduler.Schedule(2500ms, [this](TaskContext context)
scheduler.Schedule(2500ms, [this](TaskContext context)
{ {
DoCastRandomTarget(SPELL_HURL_TRIDENT); DoCastRandomTarget(SPELL_HURL_TRIDENT);
context.Repeat(5s); context.Repeat(5s);
@@ -267,13 +262,12 @@ struct boss_fathomguard_sharkkis : public ScriptedAI
return; return;
} }
_scheduler.Update(diff); scheduler.Update(diff);
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
private: private:
TaskScheduler _scheduler;
InstanceScript* _instance; InstanceScript* _instance;
}; };
@@ -250,101 +250,68 @@ private:
bool _recentlySpoken; bool _recentlySpoken;
}; };
class spell_hydross_cleansing_field_aura : public SpellScriptLoader class spell_hydross_cleansing_field_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_hydross_cleansing_field_aura);
spell_hydross_cleansing_field_aura() : SpellScriptLoader("spell_hydross_cleansing_field_aura") { }
class spell_hydross_cleansing_field_aura_AuraScript : public AuraScript void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_hydross_cleansing_field_aura_AuraScript) if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE)
if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true);
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE)
if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE)
if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hydross_cleansing_field_aura_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_hydross_cleansing_field_aura_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_hydross_cleansing_field_aura_AuraScript(); if (GetTarget()->GetEntry() == NPC_HYDROSS_THE_UNSTABLE)
if (Unit* caster = GetCaster())
caster->CastSpell(caster, SPELL_CLEANSING_FIELD, true);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_hydross_cleansing_field_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_hydross_cleansing_field_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
} }
}; };
class spell_hydross_cleansing_field_command : public SpellScriptLoader class spell_hydross_cleansing_field_command : public AuraScript
{ {
public: PrepareAuraScript(spell_hydross_cleansing_field_command);
spell_hydross_cleansing_field_command() : SpellScriptLoader("spell_hydross_cleansing_field_command") { }
class spell_hydross_cleansing_field_command_AuraScript : public AuraScript void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_hydross_cleansing_field_command_AuraScript) if (GetTarget()->HasUnitState(UNIT_STATE_CASTING))
GetTarget()->InterruptNonMeleeSpells(false);
else
GetTarget()->CastSpell(GetTarget(), SPELL_BLUE_BEAM, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void Register() override
{
if (GetTarget()->HasUnitState(UNIT_STATE_CASTING))
GetTarget()->InterruptNonMeleeSpells(false);
else
GetTarget()->CastSpell(GetTarget(), SPELL_BLUE_BEAM, true);
}
void Register() override
{
AfterEffectRemove += AuraEffectApplyFn(spell_hydross_cleansing_field_command_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_hydross_cleansing_field_command_AuraScript(); AfterEffectRemove += AuraEffectApplyFn(spell_hydross_cleansing_field_command::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
} }
}; };
class spell_hydross_mark_of_hydross : public SpellScriptLoader class spell_hydross_mark_of_hydross : public AuraScript
{ {
public: PrepareAuraScript(spell_hydross_mark_of_hydross);
spell_hydross_mark_of_hydross() : SpellScriptLoader("spell_hydross_mark_of_hydross") { }
class spell_hydross_mark_of_hydross_AuraScript : public AuraScript void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_hydross_mark_of_hydross_AuraScript) GetTarget()->RemoveAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetCasterGUID(), GetAura());
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void Register() override
{
GetTarget()->RemoveAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, GetCasterGUID(), GetAura());
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_hydross_mark_of_hydross_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_hydross_mark_of_hydross_AuraScript(); OnEffectApply += AuraEffectApplyFn(spell_hydross_mark_of_hydross::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
} }
}; };
void AddSC_boss_hydross_the_unstable() void AddSC_boss_hydross_the_unstable()
{ {
RegisterSerpentShrineAI(boss_hydross_the_unstable); RegisterSerpentShrineAI(boss_hydross_the_unstable);
new spell_hydross_cleansing_field_aura(); RegisterSpellScript(spell_hydross_cleansing_field_aura);
new spell_hydross_cleansing_field_command(); RegisterSpellScript(spell_hydross_cleansing_field_command);
new spell_hydross_mark_of_hydross(); RegisterSpellScript(spell_hydross_mark_of_hydross);
} }
@@ -286,226 +286,80 @@ private:
std::chrono::seconds _batTimer; std::chrono::seconds _batTimer;
}; };
/* class spell_lady_vashj_magic_barrier : public AuraScript
//Toxic Sporebat
//Toxic Spores: Used in Phase 3 by the Spore Bats, it creates a contaminated green patch of ground, dealing about 2775-3225 nature damage every second to anyone who stands in it.
//deprecated -- adds do work
class npc_toxic_sporebat : public CreatureScript
{ {
public: PrepareAuraScript(spell_lady_vashj_magic_barrier);
npc_toxic_sporebat() : CreatureScript("npc_toxic_sporebat") { }
CreatureAI* GetAI(Creature* creature) const void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
return GetInstanceAI<npc_toxic_sporebatAI>(creature); Unit::DealDamage(GetTarget(), GetTarget(), GetTarget()->CountPctFromMaxHealth(5));
} }
struct npc_toxic_sporebatAI : public ScriptedAI void Register() override
{ {
npc_toxic_sporebatAI(Creature* creature) : ScriptedAI(creature) AfterEffectRemove += AuraEffectRemoveFn(spell_lady_vashj_magic_barrier::HandleEffectRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL);
{
instance = creature->GetInstanceScript();
EnterEvadeMode();
}
InstanceScript* instance;
uint32 MovementTimer;
uint32 ToxicSporeTimer;
uint32 BoltTimer;
uint32 CheckTimer;
void Reset()
{
me->SetDisableGravity(true);
me->SetFaction(FACTION_MONSTER);
MovementTimer = 0;
ToxicSporeTimer = 5000;
BoltTimer = 5500;
CheckTimer = 1000;
}
void MoveInLineOfSight(Unit* who)
{
}
void MovementInform(uint32 type, uint32 id)
{
if (type != POINT_MOTION_TYPE)
return;
if (id == 1)
MovementTimer = 0;
}
void UpdateAI(uint32 diff)
{
// Random movement
if (MovementTimer <= diff)
{
uint32 rndpos = rand()%8;
me->GetMotionMaster()->MovePoint(1, SporebatWPPos[rndpos][0], SporebatWPPos[rndpos][1], SporebatWPPos[rndpos][2]);
MovementTimer = 6000;
} else MovementTimer -= diff;
// toxic spores
if (BoltTimer <= diff)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
if (Creature* trig = me->SummonCreature(TOXIC_SPORES_TRIGGER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000))
{
trig->SetFaction(FACTION_MONSTER);
trig->CastSpell(trig, SPELL_TOXIC_SPORES, true);
}
}
BoltTimer = 10000+rand()%5000;
}
else BoltTimer -= diff;
// CheckTimer
if (CheckTimer <= diff)
{
// check if vashj is death
Unit* Vashj = ObjectAccessor::GetUnit(*me, instance->GetGuidData(DATA_LADYVASHJ));
if (!Vashj || !Vashj->IsAlive() || CAST_AI(boss_lady_vashj::boss_lady_vashjAI, Vashj->ToCreature()->AI())->Phase != 3)
{
// remove
me->setDeathState(DeathState::Dead);
me->RemoveCorpse();
me->SetFaction(FACTION_FRIENDLY);
}
CheckTimer = 1000;
}
else
CheckTimer -= diff;
}
};
};
*/
class spell_lady_vashj_magic_barrier : public SpellScriptLoader
{
public:
spell_lady_vashj_magic_barrier() : SpellScriptLoader("spell_lady_vashj_magic_barrier") { }
class spell_lady_vashj_magic_barrier_AuraScript : public AuraScript
{
PrepareAuraScript(spell_lady_vashj_magic_barrier_AuraScript)
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit::DealDamage(GetTarget(), GetTarget(), GetTarget()->CountPctFromMaxHealth(5));
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_lady_vashj_magic_barrier_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_SCHOOL_IMMUNITY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_lady_vashj_magic_barrier_AuraScript();
} }
}; };
class spell_lady_vashj_remove_tainted_cores : public SpellScriptLoader class spell_lady_vashj_remove_tainted_cores : public SpellScript
{ {
public: PrepareSpellScript(spell_lady_vashj_remove_tainted_cores);
spell_lady_vashj_remove_tainted_cores() : SpellScriptLoader("spell_lady_vashj_remove_tainted_cores") { }
class spell_lady_vashj_remove_tainted_cores_SpellScript : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_lady_vashj_remove_tainted_cores_SpellScript); PreventHitDefaultEffect(effIndex);
if (Player* target = GetHitPlayer())
void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PreventHitDefaultEffect(effIndex); target->DestroyItemCount(ITEM_TAINTED_CORE, -1, true);
if (Player* target = GetHitPlayer())
{
target->DestroyItemCount(ITEM_TAINTED_CORE, -1, true);
}
} }
}
void Register() override void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_remove_tainted_cores_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_lady_vashj_remove_tainted_cores_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_remove_tainted_cores::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
class spell_lady_vashj_summon_sporebat : public SpellScriptLoader class spell_lady_vashj_summon_sporebat : public SpellScript
{ {
public: PrepareSpellScript(spell_lady_vashj_summon_sporebat);
spell_lady_vashj_summon_sporebat() : SpellScriptLoader("spell_lady_vashj_summon_sporebat") { }
class spell_lady_vashj_summon_sporebat_SpellScript : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_lady_vashj_summon_sporebat_SpellScript); PreventHitDefaultEffect(effIndex);
GetCaster()->CastSpell(GetCaster(), RAND(SPELL_SUMMON_SPOREBAT1, SPELL_SUMMON_SPOREBAT2, SPELL_SUMMON_SPOREBAT3, SPELL_SUMMON_SPOREBAT4), true);
}
void HandleScriptEffect(SpellEffIndex effIndex) void Register() override
{
PreventHitDefaultEffect(effIndex);
GetCaster()->CastSpell(GetCaster(), RAND(SPELL_SUMMON_SPOREBAT1, SPELL_SUMMON_SPOREBAT2, SPELL_SUMMON_SPOREBAT3, SPELL_SUMMON_SPOREBAT4), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_summon_sporebat_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_lady_vashj_summon_sporebat_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_summon_sporebat::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
class spell_lady_vashj_spore_drop_effect : public SpellScriptLoader class spell_lady_vashj_spore_drop_effect : public SpellScript
{ {
public: PrepareSpellScript(spell_lady_vashj_spore_drop_effect);
spell_lady_vashj_spore_drop_effect() : SpellScriptLoader("spell_lady_vashj_spore_drop_effect") { }
class spell_lady_vashj_spore_drop_effect_SpellScript : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_lady_vashj_spore_drop_effect_SpellScript); PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PreventHitDefaultEffect(effIndex); target->CastSpell(target, SPELL_TOXIC_SPORES, true, nullptr, nullptr, GetCaster()->GetGUID());
if (Unit* target = GetHitUnit())
{
target->CastSpell(target, SPELL_TOXIC_SPORES, true, nullptr, nullptr, GetCaster()->GetGUID());
}
} }
}
void Register() override void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_spore_drop_effect_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_lady_vashj_spore_drop_effect_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_lady_vashj_spore_drop_effect::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
void AddSC_boss_lady_vashj() void AddSC_boss_lady_vashj()
{ {
RegisterSerpentShrineAI(boss_lady_vashj); RegisterSerpentShrineAI(boss_lady_vashj);
new spell_lady_vashj_magic_barrier(); RegisterSpellScript(spell_lady_vashj_magic_barrier);
new spell_lady_vashj_remove_tainted_cores(); RegisterSpellScript(spell_lady_vashj_remove_tainted_cores);
new spell_lady_vashj_summon_sporebat(); RegisterSpellScript(spell_lady_vashj_summon_sporebat);
new spell_lady_vashj_spore_drop_effect(); RegisterSpellScript(spell_lady_vashj_spore_drop_effect);
} }
@@ -227,12 +227,10 @@ struct npc_inner_demon : public ScriptedAI
{ {
npc_inner_demon(Creature* creature) : ScriptedAI(creature) npc_inner_demon(Creature* creature) : ScriptedAI(creature)
{ {
_scheduler.SetValidator([this] scheduler.SetValidator([this]
{ {
return !me->HasUnitState(UNIT_STATE_CASTING); return !me->HasUnitState(UNIT_STATE_CASTING);
}); });
_instance = creature->GetInstanceScript();
} }
void IsSummonedBy(WorldObject* summoner) override void IsSummonedBy(WorldObject* summoner) override
@@ -247,8 +245,8 @@ struct npc_inner_demon : public ScriptedAI
me->Attack(affectedPlayer, true); me->Attack(affectedPlayer, true);
} }
_scheduler.CancelAll(); scheduler.CancelAll();
_scheduler.Schedule(4s, [this](TaskContext context) scheduler.Schedule(4s, [this](TaskContext context)
{ {
DoCastVictim(SPELL_SHADOW_BOLT); DoCastVictim(SPELL_SHADOW_BOLT);
context.Repeat(6s); context.Repeat(6s);
@@ -283,196 +281,134 @@ struct npc_inner_demon : public ScriptedAI
return; return;
} }
_scheduler.Update(diff); scheduler.Update(diff);
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
private: private:
TaskScheduler _scheduler;
InstanceScript* _instance;
ObjectGuid _affectedPlayerGUID; ObjectGuid _affectedPlayerGUID;
}; };
class spell_leotheras_whirlwind : public SpellScriptLoader class spell_leotheras_whirlwind : public SpellScript
{ {
public: PrepareSpellScript(spell_leotheras_whirlwind);
spell_leotheras_whirlwind() : SpellScriptLoader("spell_leotheras_whirlwind") { }
class spell_leotheras_whirlwind_SpellScript : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_leotheras_whirlwind_SpellScript); PreventHitDefaultEffect(effIndex);
GetCaster()->GetThreatMgr().ResetAllThreat();
void HandleScriptEffect(SpellEffIndex effIndex) if (roll_chance_i(33))
{ if (Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true))
PreventHitDefaultEffect(effIndex); target->CastSpell(GetCaster(), SPELL_TAUNT, true);
GetCaster()->GetThreatMgr().ResetAllThreat(); }
if (roll_chance_i(33)) void Register() override
if (Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true))
target->CastSpell(GetCaster(), SPELL_TAUNT, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_leotheras_whirlwind_SpellScript::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_leotheras_whirlwind_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_leotheras_whirlwind::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
class spell_leotheras_chaos_blast : public SpellScriptLoader class spell_leotheras_chaos_blast : public SpellScript
{ {
public: PrepareSpellScript(spell_leotheras_chaos_blast);
spell_leotheras_chaos_blast() : SpellScriptLoader("spell_leotheras_chaos_blast") { }
class spell_leotheras_chaos_blast_SpellScript : public SpellScript void HandleDummy(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_leotheras_chaos_blast_SpellScript); PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_CHAOS_BLAST_TRIGGER, true);
}
void HandleDummy(SpellEffIndex effIndex) void Register() override
{
PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_CHAOS_BLAST_TRIGGER, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_leotheras_chaos_blast_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_leotheras_chaos_blast_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_leotheras_chaos_blast::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
} }
}; };
class spell_leotheras_insidious_whisper : public SpellScriptLoader class spell_leotheras_insidious_whisper : public SpellScript
{ {
public: PrepareSpellScript(spell_leotheras_insidious_whisper);
spell_leotheras_insidious_whisper() : SpellScriptLoader("spell_leotheras_insidious_whisper") { }
class spell_leotheras_insidious_whisper_SpellScript : public SpellScript void FilterTargets(std::list<WorldObject*>& unitList)
{ {
PrepareSpellScript(spell_leotheras_insidious_whisper_SpellScript); if (Unit* victim = GetCaster()->GetVictim())
void FilterTargets(std::list<WorldObject*>& unitList)
{ {
if (Unit* victim = GetCaster()->GetVictim()) unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true));
{
unitList.remove_if(Acore::ObjectGUIDCheck(victim->GetGUID(), true));
}
} }
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_leotheras_insidious_whisper_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_leotheras_insidious_whisper_SpellScript();
} }
class spell_leotheras_insidious_whisper_AuraScript : public AuraScript void Register() override
{ {
PrepareAuraScript(spell_leotheras_insidious_whisper_AuraScript) OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_leotheras_insidious_whisper::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) class spell_leotheras_insidious_whisper_aura : public AuraScript
{ {
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_INNER_DEMON, true); PrepareAuraScript(spell_leotheras_insidious_whisper_aura);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SUMMON_INNER_DEMON, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT)
{ {
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT) if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript())
{ {
if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) if (Creature* leotheras = instance->GetCreature(DATA_LEOTHERAS_THE_BLIND))
{ {
if (Creature* leotheras = instance->GetCreature(DATA_LEOTHERAS_THE_BLIND)) leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true);
{
leotheras->CastSpell(GetUnitOwner(), SPELL_CONSUMING_MADNESS, true);
}
} }
} }
} }
}
void Register() override void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_leotheras_insidious_whisper_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_leotheras_insidious_whisper_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_leotheras_insidious_whisper_AuraScript(); AfterEffectApply += AuraEffectApplyFn(spell_leotheras_insidious_whisper_aura::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_leotheras_insidious_whisper_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
} }
}; };
class spell_leotheras_demon_link : public SpellScriptLoader class spell_leotheras_demon_link : public AuraScript
{ {
public: PrepareAuraScript(spell_leotheras_demon_link);
spell_leotheras_demon_link() : SpellScriptLoader("spell_leotheras_demon_link") { }
class spell_leotheras_demon_link_AuraScript : public AuraScript void OnPeriodic(AuraEffect const* aurEff)
{ {
PrepareAuraScript(spell_leotheras_demon_link_AuraScript); PreventDefaultAction();
if (Unit* victim = GetUnitOwner()->GetVictim())
void OnPeriodic(AuraEffect const* aurEff)
{ {
PreventDefaultAction(); GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true);
if (Unit* victim = GetUnitOwner()->GetVictim())
{
GetUnitOwner()->CastSpell(victim, GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell, true);
}
} }
}
void Register() override void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_leotheras_demon_link_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_leotheras_demon_link_AuraScript(); OnEffectPeriodic += AuraEffectPeriodicFn(spell_leotheras_demon_link::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
} }
}; };
class spell_leotheras_clear_consuming_madness : public SpellScriptLoader class spell_leotheras_clear_consuming_madness : public SpellScript
{ {
public: PrepareSpellScript(spell_leotheras_clear_consuming_madness);
spell_leotheras_clear_consuming_madness() : SpellScriptLoader("spell_leotheras_clear_consuming_madness") { }
class spell_leotheras_clear_consuming_madness_SpellScript : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PrepareSpellScript(spell_leotheras_clear_consuming_madness_SpellScript); PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
void HandleScriptEffect(SpellEffIndex effIndex)
{ {
PreventHitDefaultEffect(effIndex); Unit::Kill(GetCaster(), target);
if (Unit* target = GetHitUnit())
{
Unit::Kill(GetCaster(), target);
}
} }
}
void Register() override void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_leotheras_clear_consuming_madness_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_leotheras_clear_consuming_madness_SpellScript(); OnEffectHitTarget += SpellEffectFn(spell_leotheras_clear_consuming_madness::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
} }
}; };
@@ -480,9 +416,9 @@ void AddSC_boss_leotheras_the_blind()
{ {
RegisterSerpentShrineAI(boss_leotheras_the_blind); RegisterSerpentShrineAI(boss_leotheras_the_blind);
RegisterSerpentShrineAI(npc_inner_demon); RegisterSerpentShrineAI(npc_inner_demon);
new spell_leotheras_whirlwind(); RegisterSpellScript(spell_leotheras_whirlwind);
new spell_leotheras_chaos_blast(); RegisterSpellScript(spell_leotheras_chaos_blast);
new spell_leotheras_insidious_whisper(); RegisterSpellAndAuraScriptPair(spell_leotheras_insidious_whisper, spell_leotheras_insidious_whisper_aura);
new spell_leotheras_demon_link(); RegisterSpellScript(spell_leotheras_demon_link);
new spell_leotheras_clear_consuming_madness(); RegisterSpellScript(spell_leotheras_clear_consuming_madness);
} }
@@ -63,13 +63,7 @@ const Position positions[MAX_SUMMONS] =
struct boss_the_lurker_below : public BossAI struct boss_the_lurker_below : public BossAI
{ {
boss_the_lurker_below(Creature* creature) : BossAI(creature, DATA_THE_LURKER_BELOW) boss_the_lurker_below(Creature* creature) : BossAI(creature, DATA_THE_LURKER_BELOW) { }
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void Reset() override void Reset() override
{ {
@@ -226,49 +220,38 @@ public:
} }
}; };
class spell_lurker_below_spout : public SpellScriptLoader class spell_lurker_below_spout : public AuraScript
{ {
public: PrepareAuraScript(spell_lurker_below_spout);
spell_lurker_below_spout() : SpellScriptLoader("spell_lurker_below_spout") { }
class spell_lurker_below_spout_AuraScript : public AuraScript void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_lurker_below_spout_AuraScript); SetDuration(13000);
}
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
SetDuration(13000);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Creature* creature = GetUnitOwner()->ToCreature())
{
creature->resetAttackTimer();
creature->SetReactState(REACT_AGGRESSIVE);
if (Unit* target = creature->GetVictim())
creature->SetTarget(target->GetGUID());
}
}
void OnPeriodic(AuraEffect const* aurEff)
{
PreventDefaultAction();
GetUnitOwner()->SetFacingTo(Position::NormalizeOrientation(GetUnitOwner()->GetOrientation() + 0.1f));
GetUnitOwner()->CastSpell(GetUnitOwner(), aurEff->GetAmount(), true);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_lurker_below_spout_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_lurker_below_spout_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_lurker_below_spout_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_lurker_below_spout_AuraScript(); if (Creature* creature = GetUnitOwner()->ToCreature())
{
creature->resetAttackTimer();
creature->SetReactState(REACT_AGGRESSIVE);
if (Unit* target = creature->GetVictim())
creature->SetTarget(target->GetGUID());
}
}
void OnPeriodic(AuraEffect const* aurEff)
{
PreventDefaultAction();
GetUnitOwner()->SetFacingTo(Position::NormalizeOrientation(GetUnitOwner()->GetOrientation() + 0.1f));
GetUnitOwner()->CastSpell(GetUnitOwner(), aurEff->GetAmount(), true);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_lurker_below_spout::HandleEffectApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_lurker_below_spout::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_lurker_below_spout::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
} }
}; };
@@ -286,29 +269,18 @@ private:
Unit* _caster; Unit* _caster;
}; };
class spell_lurker_below_spout_cone : public SpellScriptLoader class spell_lurker_below_spout_cone : public SpellScript
{ {
public: PrepareSpellScript(spell_lurker_below_spout_cone);
spell_lurker_below_spout_cone() : SpellScriptLoader("spell_lurker_below_spout_cone") { }
class spell_lurker_below_spout_cone_SpellScript : public SpellScript void FilterTargets(std::list<WorldObject*>& targets)
{ {
PrepareSpellScript(spell_lurker_below_spout_cone_SpellScript); targets.remove_if(HasInLineCheck(GetCaster()));
}
void FilterTargets(std::list<WorldObject*>& targets) void Register() override
{
targets.remove_if(HasInLineCheck(GetCaster()));
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lurker_below_spout_cone_SpellScript::FilterTargets, EFFECT_ALL, TARGET_UNIT_CONE_ENEMY_24);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_lurker_below_spout_cone_SpellScript(); OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_lurker_below_spout_cone::FilterTargets, EFFECT_ALL, TARGET_UNIT_CONE_ENEMY_24);
} }
}; };
@@ -316,6 +288,6 @@ void AddSC_boss_the_lurker_below()
{ {
RegisterSerpentShrineAI(boss_the_lurker_below); RegisterSerpentShrineAI(boss_the_lurker_below);
new go_strange_pool(); new go_strange_pool();
new spell_lurker_below_spout(); RegisterSpellScript(spell_lurker_below_spout);
new spell_lurker_below_spout_cone(); RegisterSpellScript(spell_lurker_below_spout_cone);
} }
@@ -138,89 +138,67 @@ private:
bool _recentlySpoken; bool _recentlySpoken;
}; };
class spell_morogrim_tidewalker_watery_grave : public SpellScriptLoader class spell_morogrim_tidewalker_watery_grave : public SpellScript
{ {
public: PrepareSpellScript(spell_morogrim_tidewalker_watery_grave);
spell_morogrim_tidewalker_watery_grave() : SpellScriptLoader("spell_morogrim_tidewalker_watery_grave") { }
class spell_morogrim_tidewalker_watery_grave_SpellScript : public SpellScript bool Load() override
{ {
PrepareSpellScript(spell_morogrim_tidewalker_watery_grave_SpellScript); _targetNumber = 0;
return true;
bool Load() override
{
_targetNumber = 0;
return true;
}
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
if (_targetNumber < 4)
GetCaster()->CastSpell(target, wateryGraveIds[_targetNumber++], true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_watery_grave_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
private:
uint8 _targetNumber;
};
SpellScript* GetSpellScript() const override
{
return new spell_morogrim_tidewalker_watery_grave_SpellScript();
} }
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Unit* target = GetHitUnit())
if (_targetNumber < 4)
GetCaster()->CastSpell(target, wateryGraveIds[_targetNumber++], true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_watery_grave::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
private:
uint8 _targetNumber;
}; };
class spell_morogrim_tidewalker_water_globule_new_target : public SpellScriptLoader class spell_morogrim_tidewalker_water_globule_new_target : public SpellScript
{ {
public: PrepareSpellScript(spell_morogrim_tidewalker_water_globule_new_target);
spell_morogrim_tidewalker_water_globule_new_target() : SpellScriptLoader("spell_morogrim_tidewalker_water_globule_new_target") { }
class spell_morogrim_tidewalker_water_globule_new_target_SpellScript : public SpellScript void FilterTargets(std::list<WorldObject*>& unitList)
{ {
PrepareSpellScript(spell_morogrim_tidewalker_water_globule_new_target_SpellScript); Acore::Containers::RandomResize(unitList, 1);
}
void FilterTargets(std::list<WorldObject*>& unitList) void HandleDummy(SpellEffIndex effIndex)
{
Acore::Containers::RandomResize(unitList, 1);
}
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
// Xinef: if we have target we currently follow, return
if (Unit* target = GetCaster()->GetVictim())
if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f)
return;
// Xinef: acquire new target
// TODO: sniffs to see how this actually happens
if (Unit* target = GetHitUnit())
GetCaster()->AddThreat(target, 1000000.0f);
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_morogrim_tidewalker_water_globule_new_target_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_water_globule_new_target_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{ {
return new spell_morogrim_tidewalker_water_globule_new_target_SpellScript(); PreventHitDefaultEffect(effIndex);
// Xinef: if we have target we currently follow, return
if (Unit* target = GetCaster()->GetVictim())
if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f)
return;
// Xinef: acquire new target
// TODO: sniffs to see how this actually happens
if (Unit* target = GetHitUnit())
GetCaster()->AddThreat(target, 1000000.0f);
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_morogrim_tidewalker_water_globule_new_target::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
OnEffectHitTarget += SpellEffectFn(spell_morogrim_tidewalker_water_globule_new_target::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
} }
}; };
void AddSC_boss_morogrim_tidewalker() void AddSC_boss_morogrim_tidewalker()
{ {
RegisterSerpentShrineAI(boss_morogrim_tidewalker); RegisterSerpentShrineAI(boss_morogrim_tidewalker);
new spell_morogrim_tidewalker_watery_grave(); RegisterSpellScript(spell_morogrim_tidewalker_watery_grave);
new spell_morogrim_tidewalker_water_globule_new_target(); RegisterSpellScript(spell_morogrim_tidewalker_water_globule_new_target);
} }
@@ -208,185 +208,136 @@ public:
} }
}; };
class spell_serpentshrine_cavern_serpentshrine_parasite : public SpellScriptLoader class spell_serpentshrine_cavern_serpentshrine_parasite : public AuraScript
{ {
public: PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite);
spell_serpentshrine_cavern_serpentshrine_parasite() : SpellScriptLoader("spell_serpentshrine_cavern_serpentshrine_parasite") { }
class spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript : public AuraScript void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript) if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress())
GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void Register() override
{
if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress())
GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true);
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_serpentshrine_cavern_serpentshrine_parasite_AuraScript(); AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL);
} }
}; };
class spell_serpentshrine_cavern_serpentshrine_parasite_trigger : public SpellScriptLoader class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura : public AuraScript
{ {
public: PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura);
spell_serpentshrine_cavern_serpentshrine_parasite_trigger() : SpellScriptLoader("spell_serpentshrine_cavern_serpentshrine_parasite_trigger") { }
class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript : public AuraScript void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript) if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress())
GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true);
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (GetTarget()->GetInstanceScript() && GetTarget()->GetInstanceScript()->IsEncounterInProgress())
GetTarget()->CastSpell(GetTarget(), SPELL_SUMMON_SERPENTSHRINE_PARASITE, true);
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_serpentshrine_cavern_serpentshrine_parasite_trigger_AuraScript();
} }
class spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript : public SpellScript void Register() override
{ {
PrepareSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript); AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura::HandleEffectRemove, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAL);
void HandleApplyAura(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Creature* target = GetHitCreature())
target->DespawnOrUnsummon(1);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_serpentshrine_cavern_serpentshrine_parasite_trigger_SpellScript();
} }
}; };
class spell_serpentshrine_cavern_infection : public SpellScriptLoader class spell_serpentshrine_cavern_serpentshrine_parasite_trigger : public SpellScript
{ {
public: PrepareSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite_trigger);
spell_serpentshrine_cavern_infection() : SpellScriptLoader("spell_serpentshrine_cavern_infection") { }
class spell_serpentshrine_cavern_infection_AuraScript : public AuraScript void HandleApplyAura(SpellEffIndex effIndex)
{ {
PrepareAuraScript(spell_serpentshrine_cavern_infection_AuraScript) PreventHitDefaultEffect(effIndex);
if (Creature* target = GetHitCreature())
target->DespawnOrUnsummon(1);
}
void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) void Register() override
{
if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTarget()->GetInstanceScript())
{
CustomSpellValues values;
values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1);
values.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount() + 500);
values.AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount() + 500);
GetTarget()->CastCustomSpell(SPELL_RAMPART_INFECTION, values, GetTarget(), TRIGGERED_FULL_MASK, nullptr);
}
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_infection_AuraScript::HandleEffectRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_serpentshrine_cavern_infection_AuraScript(); OnEffectHitTarget += SpellEffectFn(spell_serpentshrine_cavern_serpentshrine_parasite_trigger::HandleApplyAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
} }
}; };
class spell_serpentshrine_cavern_coilfang_water : public SpellScriptLoader class spell_serpentshrine_cavern_infection : public AuraScript
{ {
public: PrepareAuraScript(spell_serpentshrine_cavern_infection);
spell_serpentshrine_cavern_coilfang_water() : SpellScriptLoader("spell_serpentshrine_cavern_coilfang_water") { }
class spell_serpentshrine_cavern_coilfang_water_AuraScript : public AuraScript void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_serpentshrine_cavern_coilfang_water_AuraScript) if (GetTargetApplication()->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTarget()->GetInstanceScript())
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript()) CustomSpellValues values;
if (instance->GetBossState(DATA_THE_LURKER_BELOW) != DONE) values.AddSpellMod(SPELLVALUE_MAX_TARGETS, 1);
if (instance->GetData(DATA_ALIVE_KEEPERS) == 0) values.AddSpellMod(SPELLVALUE_BASE_POINT0, aurEff->GetAmount() + 500);
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SCALDING_WATER, true); values.AddSpellMod(SPELLVALUE_BASE_POINT1, aurEff->GetAmount() + 500);
GetTarget()->CastCustomSpell(SPELL_RAMPART_INFECTION, values, GetTarget(), TRIGGERED_FULL_MASK, nullptr);
} }
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void Register() override
{
GetUnitOwner()->RemoveAurasDueToSpell(SPELL_SCALDING_WATER);
}
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
InstanceScript* instance = GetUnitOwner()->GetInstanceScript();
if (!instance || instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE)
return;
isPeriodic = true;
amplitude = 8 * IN_MILLISECONDS;
}
void HandlePeriodic(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
InstanceScript* instance = GetUnitOwner()->GetInstanceScript();
if (!instance || GetUnitOwner()->GetMapId() != 548)
{
SetDuration(0);
return;
}
if (instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE || instance->GetData(DATA_ALIVE_KEEPERS) == 0 || GetUnitOwner()->GetPositionZ() > -20.5f || !GetUnitOwner()->IsInWater())
return;
for (uint8 i = 0; i < 3; ++i)
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FRENZY_WATER, true);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_serpentshrine_cavern_coilfang_water_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_serpentshrine_cavern_coilfang_water_AuraScript(); AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_infection::HandleEffectRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_serpentshrine_cavern_coilfang_water : public AuraScript
{
PrepareAuraScript(spell_serpentshrine_cavern_coilfang_water);
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (InstanceScript* instance = GetUnitOwner()->GetInstanceScript())
if (instance->GetBossState(DATA_THE_LURKER_BELOW) != DONE)
if (instance->GetData(DATA_ALIVE_KEEPERS) == 0)
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SCALDING_WATER, true);
}
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->RemoveAurasDueToSpell(SPELL_SCALDING_WATER);
}
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
{
InstanceScript* instance = GetUnitOwner()->GetInstanceScript();
if (!instance || instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE)
return;
isPeriodic = true;
amplitude = 8 * IN_MILLISECONDS;
}
void HandlePeriodic(AuraEffect const* /*aurEff*/)
{
PreventDefaultAction();
InstanceScript* instance = GetUnitOwner()->GetInstanceScript();
if (!instance || GetUnitOwner()->GetMapId() != 548)
{
SetDuration(0);
return;
}
if (instance->GetBossState(DATA_THE_LURKER_BELOW) == DONE || instance->GetData(DATA_ALIVE_KEEPERS) == 0 || GetUnitOwner()->GetPositionZ() > -20.5f || !GetUnitOwner()->IsInWater())
return;
for (uint8 i = 0; i < 3; ++i)
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_FRENZY_WATER, true);
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_serpentshrine_cavern_coilfang_water::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_serpentshrine_cavern_coilfang_water::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_serpentshrine_cavern_coilfang_water::CalcPeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_serpentshrine_cavern_coilfang_water::HandlePeriodic, EFFECT_0, SPELL_AURA_DUMMY);
} }
}; };
void AddSC_instance_serpentshrine_cavern() void AddSC_instance_serpentshrine_cavern()
{ {
new instance_serpent_shrine(); new instance_serpent_shrine();
new spell_serpentshrine_cavern_serpentshrine_parasite(); RegisterSpellScript(spell_serpentshrine_cavern_serpentshrine_parasite);
new spell_serpentshrine_cavern_serpentshrine_parasite_trigger(); RegisterSpellAndAuraScriptPair(spell_serpentshrine_cavern_serpentshrine_parasite_trigger, spell_serpentshrine_cavern_serpentshrine_parasite_trigger_aura);
new spell_serpentshrine_cavern_infection(); RegisterSpellScript(spell_serpentshrine_cavern_infection);
new spell_serpentshrine_cavern_coilfang_water(); RegisterSpellScript(spell_serpentshrine_cavern_coilfang_water);
} }