refactor(Scripts/Mechanar): Modernize Serpethrea script (#15493)

* refactor(Scripts/Mechanar): Modernize Serpethrea script

* validators
This commit is contained in:
Skjalf
2023-03-19 20:49:56 -03:00
committed by GitHub
parent 8f3a215b68
commit 39236220bf
3 changed files with 110 additions and 153 deletions
@@ -36,7 +36,13 @@ enum Spells
struct boss_gatewatcher_gyrokill : public BossAI struct boss_gatewatcher_gyrokill : public BossAI
{ {
boss_gatewatcher_gyrokill(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_GYROKILL) { } boss_gatewatcher_gyrokill(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_GYROKILL)
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
@@ -37,7 +37,13 @@ enum Spells
struct boss_gatewatcher_iron_hand : public BossAI struct boss_gatewatcher_iron_hand : public BossAI
{ {
boss_gatewatcher_iron_hand(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_IRON_HAND) { } boss_gatewatcher_iron_hand(Creature* creature) : BossAI(creature, DATA_GATEWATCHER_IRON_HAND)
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustEngagedWith(Unit* /*who*/) override void JustEngagedWith(Unit* /*who*/) override
{ {
@@ -36,31 +36,40 @@ enum Spells
SPELL_DRAGONS_BREATH = 35250, SPELL_DRAGONS_BREATH = 35250,
}; };
enum Events struct boss_nethermancer_sepethrea : public BossAI
{ {
EVENT_FROST_ATTACK = 1, boss_nethermancer_sepethrea(Creature* creature) : BossAI(creature, DATA_NETHERMANCER_SEPRETHREA)
EVENT_ARCANE_BLAST = 2,
EVENT_DRAGONS_BREATH = 3,
};
class boss_nethermancer_sepethrea : public CreatureScript
{ {
public: scheduler.SetValidator([this]
boss_nethermancer_sepethrea(): CreatureScript("boss_nethermancer_sepethrea") { }
struct boss_nethermancer_sepethreaAI : public BossAI
{ {
boss_nethermancer_sepethreaAI(Creature* creature) : BossAI(creature, DATA_NETHERMANCER_SEPRETHREA) { } return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustEngagedWith(Unit* /*who*/) override void JustEngagedWith(Unit* /*who*/) override
{ {
_JustEngagedWith(); _JustEngagedWith();
events.ScheduleEvent(EVENT_FROST_ATTACK, 6000);
events.ScheduleEvent(EVENT_ARCANE_BLAST, 14000); scheduler.Schedule(6s, [this](TaskContext context)
events.ScheduleEvent(EVENT_DRAGONS_BREATH, 18000); {
DoCastVictim(SPELL_FROST_ATTACK);
context.Repeat(8s);
}).Schedule(14s, [this](TaskContext context)
{
DoCastVictim(SPELL_ARCANE_BLAST);
context.Repeat(12s);
}).Schedule(18s, [this](TaskContext context)
{
DoCastVictim(SPELL_DRAGONS_BREATH);
context.Repeat(16s);
if (roll_chance_i(50))
{
Talk(SAY_DRAGONS_BREATH);
}
});
Talk(SAY_AGGRO); Talk(SAY_AGGRO);
me->CastSpell(me, SPELL_SUMMON_RAGIN_FLAMES, true); DoCastSelf(SPELL_SUMMON_RAGIN_FLAMES, true);
} }
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
@@ -76,59 +85,16 @@ public:
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() == TYPEID_PLAYER) if (victim->IsPlayer())
{
Talk(SAY_SLAY); Talk(SAY_SLAY);
} }
}
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
events.Reset(); _JustDied();
if (instance)
{
instance->SetBossState(DATA_NETHERMANCER_SEPRETHREA, DONE);
instance->SaveToDB();
}
Talk(SAY_DEATH); Talk(SAY_DEATH);
for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
Unit::Kill(summon, summon);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (events.ExecuteEvent())
{
case EVENT_FROST_ATTACK:
me->CastSpell(me->GetVictim(), SPELL_FROST_ATTACK, false);
events.ScheduleEvent(EVENT_FROST_ATTACK, 8000);
break;
case EVENT_ARCANE_BLAST:
me->CastSpell(me->GetVictim(), SPELL_ARCANE_BLAST, false);
events.ScheduleEvent(EVENT_ARCANE_BLAST, 12000);
break;
case EVENT_DRAGONS_BREATH:
me->CastSpell(me->GetVictim(), SPELL_DRAGONS_BREATH, true);
events.ScheduleEvent(EVENT_DRAGONS_BREATH, 16000);
if (roll_chance_i(50))
Talk(SAY_DRAGONS_BREATH);
break;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetMechanarAI<boss_nethermancer_sepethreaAI>(creature);
} }
}; };
@@ -142,14 +108,9 @@ enum raginFlames
EVENT_SPELL_INFERNO = 2 EVENT_SPELL_INFERNO = 2
}; };
class npc_ragin_flames : public CreatureScript struct npc_ragin_flames : public ScriptedAI
{ {
public: npc_ragin_flames(Creature* creature) : ScriptedAI(creature) { }
npc_ragin_flames() : CreatureScript("npc_ragin_flames") { }
struct npc_ragin_flamesAI : public ScriptedAI
{
npc_ragin_flamesAI(Creature* creature) : ScriptedAI(creature) { }
EventMap events; EventMap events;
@@ -190,20 +151,10 @@ public:
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
}; };
CreatureAI* GetAI(Creature* creature) const override
{
return GetMechanarAI<npc_ragin_flamesAI>(creature);
}
};
class spell_ragin_flames_inferno : public SpellScriptLoader class spell_ragin_flames_inferno : public AuraScript
{ {
public: PrepareAuraScript(spell_ragin_flames_inferno);
spell_ragin_flames_inferno() : SpellScriptLoader("spell_ragin_flames_inferno") { }
class spell_ragin_flames_inferno_AuraScript : public AuraScript
{
PrepareAuraScript(spell_ragin_flames_inferno_AuraScript);
void HandlePeriodic(AuraEffect const* aurEff) void HandlePeriodic(AuraEffect const* aurEff)
{ {
@@ -212,19 +163,13 @@ public:
void Register() override void Register() override
{ {
OnEffectPeriodic += AuraEffectPeriodicFn(spell_ragin_flames_inferno_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL); OnEffectPeriodic += AuraEffectPeriodicFn(spell_ragin_flames_inferno::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_ragin_flames_inferno_AuraScript();
} }
}; };
void AddSC_boss_nethermancer_sepethrea() void AddSC_boss_nethermancer_sepethrea()
{ {
new boss_nethermancer_sepethrea(); RegisterMechanarCreatureAI(boss_nethermancer_sepethrea);
new npc_ragin_flames(); RegisterMechanarCreatureAI(npc_ragin_flames);
new spell_ragin_flames_inferno(); RegisterSpellScript(spell_ragin_flames_inferno);
} }