feat(Core/Scripting): Implement ScheduleEnrageTimer() helper (#21597)
This commit is contained in:
@@ -633,6 +633,7 @@ void BossAI::_Reset()
|
|||||||
me->ResetLootMode();
|
me->ResetLootMode();
|
||||||
events.Reset();
|
events.Reset();
|
||||||
scheduler.CancelAll();
|
scheduler.CancelAll();
|
||||||
|
me->m_Events.KillAllEvents(false);
|
||||||
summons.DespawnAll();
|
summons.DespawnAll();
|
||||||
ClearUniqueTimedEventsDone();
|
ClearUniqueTimedEventsDone();
|
||||||
_healthCheckEvents.clear();
|
_healthCheckEvents.clear();
|
||||||
@@ -787,6 +788,20 @@ void BossAI::ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, st
|
|||||||
_nextHealthCheck = _healthCheckEvents.front();
|
_nextHealthCheck = _healthCheckEvents.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BossAI::ScheduleEnrageTimer(uint32 spellId, Milliseconds timer, uint8 textId /*= 0*/)
|
||||||
|
{
|
||||||
|
me->m_Events.AddEventAtOffset([this, spellId, textId]
|
||||||
|
{
|
||||||
|
if (!me->IsAlive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (textId)
|
||||||
|
Talk(textId);
|
||||||
|
|
||||||
|
DoCastSelf(spellId, true);
|
||||||
|
}, timer);
|
||||||
|
}
|
||||||
|
|
||||||
// WorldBossAI - for non-instanced bosses
|
// WorldBossAI - for non-instanced bosses
|
||||||
|
|
||||||
WorldBossAI::WorldBossAI(Creature* creature) :
|
WorldBossAI::WorldBossAI(Creature* creature) :
|
||||||
|
|||||||
@@ -485,6 +485,12 @@ public:
|
|||||||
void ScheduleHealthCheckEvent(uint32 healthPct, std::function<void()> exec);
|
void ScheduleHealthCheckEvent(uint32 healthPct, std::function<void()> exec);
|
||||||
void ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, std::function<void()> exec);
|
void ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, std::function<void()> exec);
|
||||||
|
|
||||||
|
// @brief Casts the spell after the fixed time and says the text id if provided. Timer will run even if the creature is casting or out of combat.
|
||||||
|
// @param spellId The spell to cast.
|
||||||
|
// @param timer The time to wait before casting the spell.
|
||||||
|
// @param textId The text id to say.
|
||||||
|
void ScheduleEnrageTimer(uint32 spellId, Milliseconds timer, uint8 textId = 0);
|
||||||
|
|
||||||
// Hook used to execute events scheduled into EventMap without the need
|
// Hook used to execute events scheduled into EventMap without the need
|
||||||
// to override UpdateAI
|
// to override UpdateAI
|
||||||
// note: You must re-schedule the event within this method if the event
|
// note: You must re-schedule the event within this method if the event
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ struct boss_sacrolash : public BossAI
|
|||||||
_isSisterDead = false;
|
_isSisterDead = false;
|
||||||
BossAI::Reset();
|
BossAI::Reset();
|
||||||
me->SetLootMode(0);
|
me->SetLootMode(0);
|
||||||
me->m_Events.KillAllEvents(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoAction(int32 param) override
|
void DoAction(int32 param) override
|
||||||
@@ -124,10 +123,7 @@ struct boss_sacrolash : public BossAI
|
|||||||
if (alythess->IsAlive() && !alythess->IsInCombat())
|
if (alythess->IsAlive() && !alythess->IsInCombat())
|
||||||
alythess->AI()->AttackStart(who);
|
alythess->AI()->AttackStart(who);
|
||||||
|
|
||||||
me->m_Events.AddEventAtOffset([&] {
|
ScheduleEnrageTimer(SPELL_ENRAGE, 6min, YELL_BERSERK);
|
||||||
Talk(YELL_BERSERK);
|
|
||||||
DoCastSelf(SPELL_ENRAGE, true);
|
|
||||||
}, 6min);
|
|
||||||
|
|
||||||
ScheduleTimedEvent(10s, [&] {
|
ScheduleTimedEvent(10s, [&] {
|
||||||
DoCastSelf(SPELL_SHADOW_BLADES);
|
DoCastSelf(SPELL_SHADOW_BLADES);
|
||||||
@@ -195,7 +191,6 @@ struct boss_alythess : public BossAI
|
|||||||
_isSisterDead = false;
|
_isSisterDead = false;
|
||||||
BossAI::Reset();
|
BossAI::Reset();
|
||||||
me->SetLootMode(0);
|
me->SetLootMode(0);
|
||||||
me->m_Events.KillAllEvents(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoAction(int32 param) override
|
void DoAction(int32 param) override
|
||||||
@@ -236,10 +231,7 @@ struct boss_alythess : public BossAI
|
|||||||
if (sacrolash->IsAlive() && !sacrolash->IsInCombat())
|
if (sacrolash->IsAlive() && !sacrolash->IsInCombat())
|
||||||
sacrolash->AI()->AttackStart(who);
|
sacrolash->AI()->AttackStart(who);
|
||||||
|
|
||||||
me->m_Events.AddEventAtOffset([&] {
|
ScheduleEnrageTimer(SPELL_ENRAGE, 6min, YELL_BERSERK);
|
||||||
Talk(YELL_BERSERK);
|
|
||||||
DoCastSelf(SPELL_ENRAGE, true);
|
|
||||||
}, 6min);
|
|
||||||
|
|
||||||
ScheduleTimedEvent(1s, [&] {
|
ScheduleTimedEvent(1s, [&] {
|
||||||
DoCastVictim(SPELL_BLAZE);
|
DoCastVictim(SPELL_BLAZE);
|
||||||
|
|||||||
Reference in New Issue
Block a user