refactor(Scripts/Karazhan): Update Attumen and Midnight (#16681)
* init * .
This commit is contained in:
@@ -45,7 +45,6 @@ enum Spells
|
||||
SPELL_INTANGIBLE_PRESENCE = 29833,
|
||||
SPELL_SPAWN_SMOKE = 10389,
|
||||
SPELL_CHARGE = 29847,
|
||||
|
||||
// Midnight
|
||||
SPELL_KNOCKDOWN = 29711,
|
||||
SPELL_SUMMON_ATTUMEN = 29714,
|
||||
@@ -62,17 +61,12 @@ enum Phases
|
||||
|
||||
enum Actions
|
||||
{
|
||||
ACTION_SET_MIDNIGHT_PHASE,
|
||||
ACTION_SET_MIDNIGHT_PHASE
|
||||
};
|
||||
|
||||
class boss_attumen : public CreatureScript
|
||||
struct boss_attumen : public BossAI
|
||||
{
|
||||
public:
|
||||
boss_attumen() : CreatureScript("boss_attumen") { }
|
||||
|
||||
struct boss_attumenAI : public BossAI
|
||||
{
|
||||
boss_attumenAI(Creature* creature) : BossAI(creature, DATA_ATTUMEN)
|
||||
boss_attumen(Creature* creature) : BossAI(creature, DATA_ATTUMEN)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
@@ -98,32 +92,29 @@ public:
|
||||
{
|
||||
midnight->AI()->EnterEvadeMode(why);
|
||||
}
|
||||
|
||||
me->DespawnOrUnsummon();
|
||||
}
|
||||
|
||||
void ScheduleTasks() override
|
||||
{
|
||||
scheduler.Schedule(Seconds(15), Seconds(25), [this](TaskContext task)
|
||||
scheduler.Schedule(15s, 25s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_SHADOWCLEAVE);
|
||||
task.Repeat(Seconds(15), Seconds(25));
|
||||
task.Repeat(15s, 25s);
|
||||
});
|
||||
|
||||
scheduler.Schedule(Seconds(25), Seconds(45), [this](TaskContext task)
|
||||
scheduler.Schedule(25s, 45s, [this](TaskContext task)
|
||||
{
|
||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
|
||||
{
|
||||
DoCast(target, SPELL_INTANGIBLE_PRESENCE);
|
||||
}
|
||||
|
||||
task.Repeat(Seconds(25), Seconds(45));
|
||||
task.Repeat(25s, 45s);
|
||||
});
|
||||
|
||||
scheduler.Schedule(Seconds(30), Seconds(60), [this](TaskContext task)
|
||||
scheduler.Schedule(30s, 1min, [this](TaskContext task)
|
||||
{
|
||||
Talk(SAY_RANDOM);
|
||||
task.Repeat(Seconds(30), Seconds(60));
|
||||
task.Repeat(30s, 1min);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,7 +125,6 @@ public:
|
||||
{
|
||||
damage = me->GetHealth() - 1;
|
||||
}
|
||||
|
||||
if (_phase == PHASE_ATTUMEN_ENGAGES && me->HealthBelowPctDamaged(25, damage))
|
||||
{
|
||||
_phase = PHASE_NONE;
|
||||
@@ -146,10 +136,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* /*victim*/) override
|
||||
void KilledUnit(Unit* victim) override
|
||||
{
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Talk(SAY_KILL);
|
||||
}
|
||||
}
|
||||
|
||||
void JustSummoned(Creature* summon) override
|
||||
{
|
||||
@@ -165,11 +158,9 @@ public:
|
||||
{
|
||||
summon->SetHealth(me->GetHealth());
|
||||
}
|
||||
|
||||
summon->AI()->DoZoneInCombat();
|
||||
}
|
||||
}
|
||||
|
||||
BossAI::JustSummoned(summon);
|
||||
}
|
||||
|
||||
@@ -179,39 +170,34 @@ public:
|
||||
{
|
||||
_phase = PHASE_ATTUMEN_ENGAGES;
|
||||
}
|
||||
|
||||
if (summoner->GetEntry() == NPC_ATTUMEN_THE_HUNTSMAN)
|
||||
{
|
||||
_phase = PHASE_MOUNTED;
|
||||
DoCastSelf(SPELL_SPAWN_SMOKE);
|
||||
|
||||
scheduler.Schedule(Seconds(10), Seconds(25), [this](TaskContext task)
|
||||
scheduler.Schedule(10s, 25s, [this](TaskContext task)
|
||||
{
|
||||
Unit* target = nullptr;
|
||||
std::vector<Unit*> target_list;
|
||||
|
||||
for (auto* ref : me->GetThreatMgr().GetUnsortedThreatList())
|
||||
{
|
||||
target = ref->GetVictim();
|
||||
if (target && !target->IsWithinDist(me, 8.00f, false) && target->IsWithinDist(me, 25.0f, false))
|
||||
{
|
||||
target_list.push_back(target);
|
||||
|
||||
}
|
||||
target = nullptr;
|
||||
}
|
||||
|
||||
if (!target_list.empty())
|
||||
{
|
||||
target = Acore::Containers::SelectRandomContainerElement(target_list);
|
||||
}
|
||||
|
||||
DoCast(target, SPELL_CHARGE);
|
||||
task.Repeat(Seconds(10), Seconds(25));
|
||||
task.Repeat(10s, 25s);
|
||||
});
|
||||
|
||||
scheduler.Schedule(Seconds(25), Seconds(35), [this](TaskContext task)
|
||||
scheduler.Schedule(25s, 35s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_KNOCKDOWN);
|
||||
task.Repeat(Seconds(25), Seconds(35));
|
||||
task.Repeat(25s, 35s);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -223,7 +209,6 @@ public:
|
||||
{
|
||||
midnight->KillSelf();
|
||||
}
|
||||
|
||||
_JustDied();
|
||||
}
|
||||
|
||||
@@ -236,14 +221,11 @@ public:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CanMeleeHit())
|
||||
{
|
||||
BossAI::EnterEvadeMode(EvadeReason::EVADE_REASON_BOUNDARY);
|
||||
}
|
||||
|
||||
scheduler.Update(diff,
|
||||
std::bind(&BossAI::DoMeleeAttackIfReady, this));
|
||||
scheduler.Update(diff, std::bind(&BossAI::DoMeleeAttackIfReady, this));
|
||||
}
|
||||
|
||||
void SpellHit(Unit* /*caster*/, SpellInfo const* spellInfo) override
|
||||
@@ -259,21 +241,18 @@ public:
|
||||
{
|
||||
_phase = PHASE_NONE;
|
||||
scheduler.CancelAll();
|
||||
|
||||
midnight->AI()->DoAction(ACTION_SET_MIDNIGHT_PHASE);
|
||||
midnight->AttackStop();
|
||||
midnight->RemoveAllAttackers();
|
||||
midnight->SetReactState(REACT_PASSIVE);
|
||||
midnight->GetMotionMaster()->MoveFollow(me, 2.0f, 0.0f);
|
||||
midnight->AI()->Talk(EMOTE_MOUNT_UP);
|
||||
|
||||
me->AttackStop();
|
||||
me->RemoveAllAttackers();
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
me->GetMotionMaster()->MoveFollow(midnight, 2.0f, 0.0f);
|
||||
Talk(SAY_MOUNT);
|
||||
|
||||
scheduler.Schedule(Seconds(1), [this](TaskContext task)
|
||||
scheduler.Schedule(1s, [this](TaskContext task)
|
||||
{
|
||||
if (Creature* midnight = instance->GetCreature(DATA_MIDNIGHT))
|
||||
{
|
||||
@@ -299,20 +278,9 @@ public:
|
||||
uint8 _phase;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
struct boss_midnight : public BossAI
|
||||
{
|
||||
return GetKarazhanAI<boss_attumenAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class boss_midnight : public CreatureScript
|
||||
{
|
||||
public:
|
||||
boss_midnight() : CreatureScript("boss_midnight") { }
|
||||
|
||||
struct boss_midnightAI : public BossAI
|
||||
{
|
||||
boss_midnightAI(Creature* creature) : BossAI(creature, DATA_ATTUMEN), _phase(PHASE_NONE) { }
|
||||
boss_midnight(Creature* creature) : BossAI(creature, DATA_ATTUMEN), _phase(PHASE_NONE) { }
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
@@ -354,7 +322,6 @@ public:
|
||||
summon->AI()->AttackStart(me->GetVictim());
|
||||
summon->AI()->Talk(SAY_APPEAR);
|
||||
}
|
||||
|
||||
BossAI::JustSummoned(summon);
|
||||
}
|
||||
|
||||
@@ -369,11 +336,10 @@ public:
|
||||
void JustEngagedWith(Unit* who) override
|
||||
{
|
||||
BossAI::JustEngagedWith(who);
|
||||
|
||||
scheduler.Schedule(Seconds(15), Seconds(25), [this](TaskContext task)
|
||||
scheduler.Schedule(15s, 25s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_KNOCKDOWN);
|
||||
task.Repeat(Seconds(15), Seconds(25));
|
||||
task.Repeat(15s, 25s);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -402,66 +368,50 @@ public:
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanMeleeHit())
|
||||
{
|
||||
BossAI::EnterEvadeMode(EvadeReason::EVADE_REASON_BOUNDARY);
|
||||
}
|
||||
}
|
||||
|
||||
scheduler.Update(diff,
|
||||
std::bind(&BossAI::DoMeleeAttackIfReady, this));
|
||||
scheduler.Update(diff, std::bind(&BossAI::DoMeleeAttackIfReady, this));
|
||||
}
|
||||
|
||||
private:
|
||||
uint8 _phase;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
class spell_midnight_fixate : public AuraScript
|
||||
{
|
||||
return GetKarazhanAI<boss_midnightAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_midnight_fixate : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_midnight_fixate() : SpellScriptLoader("spell_midnight_fixate") { }
|
||||
|
||||
class spell_midnight_fixate_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_midnight_fixate_AuraScript);
|
||||
PrepareAuraScript(spell_midnight_fixate)
|
||||
|
||||
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
caster->TauntApply(target);
|
||||
}
|
||||
}
|
||||
|
||||
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* target = GetTarget();
|
||||
if (Unit* caster = GetCaster())
|
||||
{
|
||||
caster->TauntFadeOut(target);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectApply += AuraEffectApplyFn(spell_midnight_fixate_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_midnight_fixate_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript* GetAuraScript() const override
|
||||
{
|
||||
return new spell_midnight_fixate_AuraScript();
|
||||
OnEffectApply += AuraEffectApplyFn(spell_midnight_fixate::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
OnEffectRemove += AuraEffectRemoveFn(spell_midnight_fixate::HandleEffectRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_boss_attumen()
|
||||
{
|
||||
new boss_midnight();
|
||||
new boss_attumen();
|
||||
new spell_midnight_fixate();
|
||||
RegisterKarazhanCreatureAI(boss_midnight);
|
||||
RegisterKarazhanCreatureAI(boss_attumen);
|
||||
RegisterSpellScript(spell_midnight_fixate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user