feat(Core/AI): Move TaskScheduler to BossAI class (#14757)

This commit is contained in:
Skjalf
2023-01-26 13:46:30 -03:00
committed by GitHub
parent 916d4f50da
commit aeed96f3b7
4 changed files with 30 additions and 28 deletions

View File

@@ -20,7 +20,6 @@
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "ruins_of_ahnqiraj.h"
#include "TaskScheduler.h"
enum Spells
{
@@ -88,7 +87,7 @@ struct boss_ayamiss : public BossAI
_phase = PHASE_AIR;
_enraged = false;
SetCombatMovement(false);
_scheduler.CancelAll();
scheduler.CancelAll();
me->SetReactState(REACT_AGGRESSIVE);
}
@@ -129,7 +128,7 @@ struct boss_ayamiss : public BossAI
}, 1s);
_scheduler.Schedule(5s, 8s, [this](TaskContext context) {
scheduler.Schedule(5s, 8s, [this](TaskContext context) {
DoCastVictim(SPELL_LASH);
context.Repeat(8s, 15s);
}).Schedule(16s, [this](TaskContext context)
@@ -140,9 +139,9 @@ struct boss_ayamiss : public BossAI
}
}
void ScheduleTasks()
void ScheduleTasks() override
{
_scheduler.Schedule(20s, 30s, [this](TaskContext context)
scheduler.Schedule(20s, 30s, [this](TaskContext context)
{
DoCastSelf(SPELL_STINGER_SPRAY);
context.Repeat(15s, 20s);
@@ -222,7 +221,7 @@ struct boss_ayamiss : public BossAI
me->SetDisableGravity(false);
me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false);
DoResetThreatList();
_scheduler.CancelGroup(PHASE_AIR);
scheduler.CancelGroup(PHASE_AIR);
}
if (!_enraged && me->HealthBelowPctDamaged(20, damage))
@@ -238,14 +237,13 @@ struct boss_ayamiss : public BossAI
if (!UpdateVictim())
return;
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&BossAI::DoMeleeAttackIfReady, this));
}
private:
GuidList _swarmers;
uint8 _phase;
bool _enraged;
TaskScheduler _scheduler;
Position homePos;
};

View File

@@ -26,7 +26,6 @@ EndScriptData */
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "TaskScheduler.h"
#include "temple_of_ahnqiraj.h"
enum Spells
@@ -172,7 +171,7 @@ struct boss_eye_of_cthun : public BossAI
if (pPortal)
pPortal->SetReactState(REACT_PASSIVE);
_scheduler.CancelAll();
scheduler.CancelAll();
BossAI::Reset();
}
@@ -187,7 +186,7 @@ struct boss_eye_of_cthun : public BossAI
void EnterCombat(Unit* who) override
{
ScheduleTasks(true);
ScheduleTask(true);
BossAI::EnterCombat(who);
_beamTarget = who->GetGUID();
}
@@ -228,9 +227,9 @@ struct boss_eye_of_cthun : public BossAI
}
}
void ScheduleTasks(bool onEngage = false)
void ScheduleTask(bool onEngage = false)
{
_scheduler.
scheduler.
Schedule(3s, [this, onEngage](TaskContext task)
{
if (task.GetRepeatCounter() < 3 && onEngage)
@@ -244,7 +243,7 @@ struct boss_eye_of_cthun : public BossAI
}
else
{
_scheduler.Schedule(5s, [this](TaskContext task)
scheduler.Schedule(5s, [this](TaskContext task)
{
DoCastRandomTarget(SPELL_GREEN_BEAM);
@@ -276,7 +275,7 @@ struct boss_eye_of_cthun : public BossAI
})
.Schedule(46s, [this](TaskContext /*task*/)
{
_scheduler.CancelGroup(GROUP_BEAM_PHASE);
scheduler.CancelGroup(GROUP_BEAM_PHASE);
me->StopMoving();
me->SetReactState(REACT_PASSIVE);
@@ -286,7 +285,7 @@ struct boss_eye_of_cthun : public BossAI
//Freeze animation
DoCast(me, SPELL_FREEZE_ANIM, true);
_scheduler.Schedule(1s, [this](TaskContext /*task*/)
scheduler.Schedule(1s, [this](TaskContext /*task*/)
{
//Select random target for dark beam to start on
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
@@ -304,7 +303,7 @@ struct boss_eye_of_cthun : public BossAI
me->SetOrientation(DarkGlareAngle);
}
_scheduler.Schedule(3s, [this](TaskContext tasker)
scheduler.Schedule(3s, [this](TaskContext tasker)
{
me->SetTarget(ObjectGuid::Empty);
me->StopMoving();
@@ -319,7 +318,7 @@ struct boss_eye_of_cthun : public BossAI
if (tasker.GetRepeatCounter() >= 35)
{
_scheduler.CancelAll();
scheduler.CancelAll();
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveAurasDueToSpell(SPELL_RED_COLORATION);
me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM);
@@ -339,7 +338,7 @@ struct boss_eye_of_cthun : public BossAI
if (!UpdateVictim())
return;
_scheduler.Update(diff);
scheduler.Update(diff);
}
void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override
@@ -365,7 +364,7 @@ struct boss_eye_of_cthun : public BossAI
me->InterruptNonMeleeSpells(true);
me->RemoveAllAuras();
_scheduler.CancelAll();
scheduler.CancelAll();
me->m_Events.AddEventAtOffset([this]()
{
@@ -384,7 +383,6 @@ private:
uint32 _eyeTentacleCounter;
ObjectGuid _beamTarget;
TaskScheduler _scheduler;
};
struct boss_cthun : public BossAI
@@ -406,7 +404,7 @@ struct boss_cthun : public BossAI
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
BossAI::Reset();
_scheduler.CancelAll();
scheduler.CancelAll();
}
void EnterCombat(Unit* /*who*/) override
@@ -439,9 +437,9 @@ struct boss_cthun : public BossAI
}
}
void ScheduleTasks()
void ScheduleTasks() override
{
_scheduler.Schedule(13800ms, [this](TaskContext context)
scheduler.Schedule(13800ms, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, NotInStomachSelector()))
{
@@ -530,7 +528,7 @@ struct boss_cthun : public BossAI
me->SetTarget();
_scheduler.Update(diff);
scheduler.Update(diff);
}
void JustDied(Unit* killer) override
@@ -560,7 +558,7 @@ struct boss_cthun : public BossAI
if (_fleshTentaclesKilled > 1)
{
_scheduler.CancelAll();
scheduler.CancelAll();
_fleshTentaclesKilled = 0;
@@ -569,7 +567,7 @@ struct boss_cthun : public BossAI
DoCast(me, SPELL_PURPLE_COLORATION, true);
me->RemoveAurasDueToSpell(SPELL_CARAPACE_CTHUN);
_scheduler.Schedule(45s, [this](TaskContext /*context*/)
scheduler.Schedule(45s, [this](TaskContext /*context*/)
{
ScheduleTasks();
//Remove purple coloration
@@ -591,7 +589,6 @@ struct boss_cthun : public BossAI
//Body Phase
uint8 _fleshTentaclesKilled;
TaskScheduler _scheduler;
};
struct npc_eye_tentacle : public ScriptedAI