refactor(Scripts/TheEye): Update Astromancer's spellscripts to new re… (#18058)

refactor(Scripts/TheEye): Update Astromancer's spellscripts to new register method
This commit is contained in:
Andrew
2024-01-01 10:00:33 -03:00
committed by GitHub
parent e3fd42f3d4
commit c4a7ef2eb0

View File

@@ -59,19 +59,12 @@ enum Misc
struct boss_high_astromancer_solarian : public BossAI struct boss_high_astromancer_solarian : public BossAI
{ {
boss_high_astromancer_solarian(Creature* creature) : BossAI(creature, DATA_ASTROMANCER) boss_high_astromancer_solarian(Creature* creature) : BossAI(creature, DATA_ASTROMANCER) { }
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void Reset() override void Reset() override
{ {
BossAI::Reset(); BossAI::Reset();
me->SetModelVisible(true); me->SetModelVisible(true);
_visible = true;
ScheduleHealthCheckEvent(20, [&]{ ScheduleHealthCheckEvent(20, [&]{
scheduler.CancelAll(); scheduler.CancelAll();
@@ -131,7 +124,6 @@ struct boss_high_astromancer_solarian : public BossAI
context.Repeat(33900ms, 48100ms); context.Repeat(33900ms, 48100ms);
}).Schedule(52100ms, [this](TaskContext context) }).Schedule(52100ms, [this](TaskContext context)
{ {
_visible = false;
me->SetReactState(REACT_PASSIVE); me->SetReactState(REACT_PASSIVE);
me->SetModelVisible(false); me->SetModelVisible(false);
scheduler.DelayAll(21s); scheduler.DelayAll(21s);
@@ -158,7 +150,6 @@ struct boss_high_astromancer_solarian : public BossAI
}); });
}).Schedule(20s, [this](TaskContext) }).Schedule(20s, [this](TaskContext)
{ {
_visible = true;
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
Talk(SAY_SUMMON2); Talk(SAY_SUMMON2);
summons.DoForAllSummons([&](WorldObject* summon) summons.DoForAllSummons([&](WorldObject* summon)
@@ -204,7 +195,7 @@ struct boss_high_astromancer_solarian : public BossAI
scheduler.Update(diff); scheduler.Update(diff);
if (_visible) if (me->GetReactState() == REACT_AGGRESSIVE)
{ {
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
@@ -223,76 +214,52 @@ struct boss_high_astromancer_solarian : public BossAI
{ {
return me->GetDistance2d(432.59f, -371.93f) > 105.0f; return me->GetDistance2d(432.59f, -371.93f) > 105.0f;
} }
private:
bool _visible;
}; };
class spell_astromancer_wrath_of_the_astromancer : public SpellScriptLoader class spell_astromancer_wrath_of_the_astromancer : public AuraScript
{ {
public: PrepareAuraScript(spell_astromancer_wrath_of_the_astromancer);
spell_astromancer_wrath_of_the_astromancer() : SpellScriptLoader("spell_astromancer_wrath_of_the_astromancer") { }
class spell_astromancer_wrath_of_the_astromancer_AuraScript : public AuraScript void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_astromancer_wrath_of_the_astromancer_AuraScript); if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
return;
void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) Unit* target = GetUnitOwner();
{ target->CastSpell(target, GetSpellInfo()->Effects[EFFECT_1].CalcValue(), false);
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) }
return;
Unit* target = GetUnitOwner(); void Register() override
target->CastSpell(target, GetSpellInfo()->Effects[EFFECT_1].CalcValue(), false);
}
void Register() override
{
AfterEffectRemove += AuraEffectRemoveFn(spell_astromancer_wrath_of_the_astromancer_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_astromancer_wrath_of_the_astromancer_AuraScript(); AfterEffectRemove += AuraEffectRemoveFn(spell_astromancer_wrath_of_the_astromancer::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
} }
}; };
class spell_astromancer_solarian_transform : public SpellScriptLoader class spell_astromancer_solarian_transform : public AuraScript
{ {
public: PrepareAuraScript(spell_astromancer_solarian_transform);
spell_astromancer_solarian_transform() : SpellScriptLoader("spell_astromancer_solarian_transform") { }
class spell_astromancer_solarian_transform_AuraScript : public AuraScript void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
PrepareAuraScript(spell_astromancer_solarian_transform_AuraScript); GetUnitOwner()->HandleStatModifier(UnitMods(UNIT_MOD_ARMOR), TOTAL_PCT, 400.0f, true);
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->HandleStatModifier(UnitMods(UNIT_MOD_ARMOR), TOTAL_PCT, 400.0f, true);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->HandleStatModifier(UnitMods(UNIT_MOD_ARMOR), TOTAL_PCT, 400.0f, false);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_astromancer_solarian_transform_AuraScript::OnApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_astromancer_solarian_transform_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{ {
return new spell_astromancer_solarian_transform_AuraScript(); GetUnitOwner()->HandleStatModifier(UnitMods(UNIT_MOD_ARMOR), TOTAL_PCT, 400.0f, false);
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_astromancer_solarian_transform::OnApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
OnEffectRemove += AuraEffectRemoveFn(spell_astromancer_solarian_transform::OnRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
} }
}; };
void AddSC_boss_high_astromancer_solarian() void AddSC_boss_high_astromancer_solarian()
{ {
RegisterTheEyeAI(boss_high_astromancer_solarian); RegisterTheEyeAI(boss_high_astromancer_solarian);
new spell_astromancer_wrath_of_the_astromancer(); RegisterSpellScript(spell_astromancer_wrath_of_the_astromancer);
new spell_astromancer_solarian_transform(); RegisterSpellScript(spell_astromancer_solarian_transform);
} }