feat(Core/AI): Implement ScheduleTimedEvent() helper (#17813)

This commit is contained in:
Andrew
2023-11-20 20:36:15 -03:00
committed by GitHub
parent 47752b1b5a
commit 59e9451c3c
3 changed files with 54 additions and 33 deletions

View File

@@ -44,37 +44,39 @@ enum Spells
struct boss_commander_sarannis : public BossAI
{
boss_commander_sarannis(Creature* creature) : BossAI(creature, DATA_COMMANDER_SARANNIS), _summoned(false) { }
void Reset() override
{
_Reset();
_summoned = false;
}
boss_commander_sarannis(Creature* creature) : BossAI(creature, DATA_COMMANDER_SARANNIS) { }
void JustEngagedWith(Unit* /*who*/) override
{
_JustEngagedWith();
Talk(SAY_AGGRO);
scheduler.Schedule(20s, [this](TaskContext context)
if (!IsHeroic())
{
if (roll_chance_i(50))
Talk(SAY_ARCANE_RESONANCE);
DoCastVictim(SPELL_ARCANE_RESONANCE);
context.Repeat(27s);
}).Schedule(10s, [this](TaskContext context)
{
if (roll_chance_i(50))
Talk(SAY_ARCANE_DEVASTATION);
DoCastVictim(SPELL_ARCANE_DEVASTATION);
context.Repeat(17s);
});
if (IsHeroic())
ScheduleHealthCheckEvent(55, [&] {
ScheduleReinforcements();
});
}
else
{
ScheduleReinforcements();
}
ScheduleTimedEvent(20s, [&] {
if (roll_chance_i(50))
{
Talk(SAY_ARCANE_RESONANCE);
}
DoCastVictim(SPELL_ARCANE_RESONANCE);
}, 27s);
ScheduleTimedEvent(10s, [&] {
if (roll_chance_i(50))
{
Talk(SAY_ARCANE_DEVASTATION);
}
DoCastVictim(SPELL_ARCANE_DEVASTATION);
}, 17s);
}
void KilledUnit(Unit* victim) override
@@ -91,15 +93,6 @@ struct boss_commander_sarannis : public BossAI
Talk(SAY_DEATH);
}
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override
{
if (!_summoned && me->HealthBelowPctDamaged(55, damage) && !IsHeroic())
{
_summoned = true;
ScheduleReinforcements();
}
}
void ScheduleReinforcements()
{
scheduler.Schedule(IsHeroic() ? 1min : 1s, [this](TaskContext context)
@@ -114,9 +107,6 @@ struct boss_commander_sarannis : public BossAI
}
});
}
private:
bool _summoned;
};
// 34799 - Arcane Devastation