refactor(Scripts/RuinsOfAhnQiraj): Clean up script files (#17723)

This commit is contained in:
Andrew
2023-11-15 20:41:56 -03:00
committed by GitHub
parent 8d1fa77727
commit db851b483e
3 changed files with 29 additions and 67 deletions

View File

@@ -56,17 +56,16 @@ enum Misc
ACTION_SWARMER_SWARM = 1,
};
enum TaskGroups
{
GROUP_AIR = 1
};
enum Emotes
{
EMOTE_FRENZY = 0
};
enum Phases
{
PHASE_AIR = 0,
PHASE_GROUND = 1
};
enum Points
{
POINT_AIR = 0,
@@ -84,11 +83,23 @@ struct boss_ayamiss : public BossAI
void Reset() override
{
BossAI::Reset();
_phase = PHASE_AIR;
_enraged = false;
SetCombatMovement(false);
scheduler.CancelAll();
me->SetReactState(REACT_AGGRESSIVE);
ScheduleHealthCheckEvent(70, [&] {
me->ClearUnitState(UNIT_STATE_ROOT);
me->SetReactState(REACT_PASSIVE);
me->SetCanFly(false);
me->SetDisableGravity(false);
me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false);
DoResetThreatList();
scheduler.CancelGroup(GROUP_AIR);
});
ScheduleHealthCheckEvent(20, [&] {
DoCastSelf(SPELL_FRENZY);
Talk(EMOTE_FRENZY);
});
}
void JustSummoned(Creature* who) override
@@ -145,9 +156,8 @@ struct boss_ayamiss : public BossAI
{
DoCastSelf(SPELL_STINGER_SPRAY);
context.Repeat(15s, 20s);
}).Schedule(5s, [this](TaskContext context) {
}).Schedule(5s, GROUP_AIR, [this](TaskContext context) {
DoCastVictim(SPELL_POISON_STINGER);
context.SetGroup(PHASE_AIR);
context.Repeat(2s, 3s);
}).Schedule(5s, [this](TaskContext context) {
DoCastAOE(SPELL_SUMMON_HIVEZARA_SWARMER, true);
@@ -210,40 +220,8 @@ struct boss_ayamiss : public BossAI
ScheduleTasks();
}
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType, SpellSchoolMask) override
{
if (_phase == PHASE_AIR && me->HealthBelowPctDamaged(70, damage))
{
_phase = PHASE_GROUND;
me->ClearUnitState(UNIT_STATE_ROOT);
me->SetReactState(REACT_PASSIVE);
me->SetCanFly(false);
me->SetDisableGravity(false);
me->GetMotionMaster()->MovePath(me->GetEntry() * 10, false);
DoResetThreatList();
scheduler.CancelGroup(PHASE_AIR);
}
if (!_enraged && me->HealthBelowPctDamaged(20, damage))
{
DoCastSelf(SPELL_FRENZY);
Talk(EMOTE_FRENZY);
_enraged = true;
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff,
std::bind(&BossAI::DoMeleeAttackIfReady, this));
}
private:
GuidList _swarmers;
uint8 _phase;
bool _enraged;
Position homePos;
};

View File

@@ -44,11 +44,6 @@ struct boss_kurinnaxx : public BossAI
void InitializeAI() override
{
me->m_CombatDistance = 50.0f;
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustEngagedWith(Unit* who) override

View File

@@ -19,7 +19,6 @@
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "ruins_of_ahnqiraj.h"
#include "TaskScheduler.h"
enum Spells
{
@@ -37,20 +36,18 @@ enum Spells
struct npc_hivezara_stinger : public ScriptedAI
{
npc_hivezara_stinger(Creature* creature) : ScriptedAI(creature)
{
}
npc_hivezara_stinger(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
}
void JustEngagedWith(Unit* who) override
{
DoCast(who ,who->HasAura(SPELL_HIVEZARA_CATALYST) ? SPELL_STINGER_CHARGE_BUFFED : SPELL_STINGER_CHARGE_NORMAL, true);
_scheduler.Schedule(5s, [this](TaskContext context)
scheduler.Schedule(5s, [this](TaskContext context)
{
Unit* target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* u)
{
@@ -80,29 +77,24 @@ struct npc_hivezara_stinger : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
};
struct npc_obsidian_destroyer : public ScriptedAI
{
npc_obsidian_destroyer(Creature* creature) : ScriptedAI(creature)
{
}
npc_obsidian_destroyer(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_scheduler.CancelAll();
scheduler.CancelAll();
me->SetPower(POWER_MANA, 0);
}
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.Schedule(6s, [this](TaskContext context)
scheduler.Schedule(6s, [this](TaskContext context)
{
std::list<Unit*> targets;
SelectTargetList(targets, 6, SelectTargetMethod::Random, 1, [&](Unit* target)
@@ -136,12 +128,9 @@ struct npc_obsidian_destroyer : public ScriptedAI
return;
}
_scheduler.Update(diff,
scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
};
class spell_drain_mana : public SpellScript