fix(Scripts/ZulGurub): Jeklik (Bat Boss) - fix double-run scheduler (#17693)

* Don't double-run scheduler. Only run out of combat when needed.

* Comment clarification

* Rename variable

* Replace janky scheduling with `DespawnOnEvade()`
This commit is contained in:
KJack
2023-11-13 01:42:16 -05:00
committed by GitHub
parent 5a4ab0d102
commit 4fabaee597

View File

@@ -115,21 +115,10 @@ struct boss_jeklik : public BossAI
boss_jeklik(Creature* creature) : BossAI(creature, DATA_JEKLIK) { }
void InitializeAI() override
{
BossAI::InitializeAI();
}
void Reset() override
{
BossAI::Reset();
// allow the scheduler to interrupt casting
scheduler.ClearValidator();
// start invisible so we can setup the green channeling effect
me->SetVisible(false);
me->SetHomePosition(JeklikCaveHomePosition);
me->SetDisableGravity(false);
@@ -137,41 +126,13 @@ struct boss_jeklik : public BossAI
BossAI::SetCombatMovement(false);
batRidersCount = 0;
// once the path for her to come down to the ground starts, it appears to be near-impossible to stop it
// instead, simply wait the 3 seconds it takes the path to complete, then teleport her home
scheduler.Schedule(3s, [this](TaskContext)
{
float x, y, z, o;
JeklikCaveHomePosition.GetPosition(x, y, z, o);
me->NearTeleportTo(x, y, z, o);
});
scheduler.Schedule(4s, [this](TaskContext)
{
DoCastSelf(SPELL_GREEN_CHANNELING, true);
});
// restore visibility and unlock root
scheduler.Schedule(5s, [this](TaskContext)
{
me->SetVisible(true);
me->ClearUnitState(UNIT_STATE_ROOT);
});
DoCastSelf(SPELL_GREEN_CHANNELING, true);
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
scheduler.CancelAll();
Talk(SAY_AGGRO);
DoZoneInCombat();
@@ -190,8 +151,6 @@ struct boss_jeklik : public BossAI
SetCombatMovement(true);
me->SetReactState(REACT_AGGRESSIVE);
scheduler.CancelAll();
//
// Phase 1
//
@@ -292,27 +251,12 @@ struct boss_jeklik : public BossAI
void EnterEvadeMode(EvadeReason why) override
{
BossAI::EnterEvadeMode(why);
if (why != EvadeReason::EVADE_REASON_NO_PATH)
{
// make invisible to hide wonky-looking movement
me->SetVisible(false);
// cancel any pending moves and stop moving
me->GetMotionMaster()->Clear();
me->AddUnitState(UNIT_STATE_ROOT);
Reset();
me->DespawnOnEvade(5s);
}
}
void UpdateAI(uint32 diff) override
{
// ensures that the scheduler gets updated even out of combat
scheduler.Update(diff);
BossAI::UpdateAI(diff);
BossAI::EnterEvadeMode(why);
}
void JustDied(Unit* killer) override