refactor(Scripts/Outland): Update Doomwalker to new register model (#17987)

This commit is contained in:
Andrew
2023-12-11 08:02:03 -03:00
committed by GitHub
parent e5c6d49587
commit 23c407ceb7

View File

@@ -38,115 +38,100 @@ enum Spells
SPELL_AURA_DEATH = 37131
};
class boss_doomwalker : public CreatureScript
struct boss_doomwalker : public ScriptedAI
{
public:
boss_doomwalker() : CreatureScript("boss_doomwalker") { }
boss_doomwalker(Creature* creature) : ScriptedAI(creature) { }
struct boss_doomwalkerAI : public ScriptedAI
void Reset() override
{
boss_doomwalkerAI(Creature* creature) : ScriptedAI(creature) {}
void Reset() override
{
_inEnrage = false;
scheduler.CancelAll();
}
void KilledUnit(Unit* victim) override
{
victim->CastSpell(victim, SPELL_MARK_DEATH, 0);
if (urand(0, 4))
return;
if (victim->GetTypeId() == TYPEID_PLAYER)
{
Talk(SAY_SLAY);
}
}
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_DEATH);
}
void JustEngagedWith(Unit* /*who*/) override
{
Talk(SAY_AGGRO);
scheduler.Schedule(1ms, [this](TaskContext context)
{
if (!HealthAbovePct(20))
{
DoCastSelf(SPELL_ENRAGE);
context.Repeat(6s);
_inEnrage = true;
}
}).Schedule(5s, 13s, [this](TaskContext context)
{
DoCastVictim(SPELL_SUNDER_ARMOR);
context.Repeat(10s, 25s);
}).Schedule(10s, 30s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
{
DoCast(target, SPELL_CHAIN_LIGHTNING);
}
context.Repeat(7s, 27s);
}).Schedule(25s, 35s, [this](TaskContext context)
{
if (urand(0, 1))
{
return;
}
Talk(SAY_EARTHQUAKE);
if (_inEnrage) // avoid enrage + earthquake
{
me->RemoveAurasDueToSpell(SPELL_ENRAGE);
}
DoCastAOE(SPELL_EARTHQUAKE);
context.Repeat(30s, 55s);
}).Schedule(30s, 45s, [this](TaskContext context)
{
Talk(SAY_OVERRUN);
DoCastVictim(SPELL_OVERRUN);
context.Repeat(25s, 40s);
});
}
void MoveInLineOfSight(Unit* who) override
{
if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who))
{
if (who->HasAura(SPELL_MARK_DEATH) && !who->HasAura(27827)) // Spirit of Redemption
{
who->CastSpell(who, SPELL_AURA_DEATH, 1);
}
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoMeleeAttackIfReady();
}
private:
bool _inEnrage;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new boss_doomwalkerAI (creature);
_inEnrage = false;
scheduler.CancelAll();
}
void KilledUnit(Unit* victim) override
{
victim->CastSpell(victim, SPELL_MARK_DEATH, 0);
if (roll_chance_i(25) && victim->IsPlayer())
{
Talk(SAY_SLAY);
}
}
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_DEATH);
}
void JustEngagedWith(Unit* /*who*/) override
{
Talk(SAY_AGGRO);
scheduler.Schedule(1ms, [this](TaskContext context)
{
if (!HealthAbovePct(20))
{
DoCastSelf(SPELL_ENRAGE);
context.Repeat(6s);
_inEnrage = true;
}
}).Schedule(5s, 13s, [this](TaskContext context)
{
DoCastVictim(SPELL_SUNDER_ARMOR);
context.Repeat(10s, 25s);
}).Schedule(10s, 30s, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_CHAIN_LIGHTNING, 1);
context.Repeat(7s, 27s);
}).Schedule(25s, 35s, [this](TaskContext context)
{
if (urand(0, 1))
{
return;
}
Talk(SAY_EARTHQUAKE);
if (_inEnrage) // avoid enrage + earthquake
{
me->RemoveAurasDueToSpell(SPELL_ENRAGE);
}
DoCastAOE(SPELL_EARTHQUAKE);
context.Repeat(30s, 55s);
}).Schedule(30s, 45s, [this](TaskContext context)
{
Talk(SAY_OVERRUN);
DoCastVictim(SPELL_OVERRUN);
context.Repeat(25s, 40s);
});
}
void MoveInLineOfSight(Unit* who) override
{
if (who && who->GetTypeId() == TYPEID_PLAYER && me->IsValidAttackTarget(who))
{
if (who->HasAura(SPELL_MARK_DEATH) && !who->HasAura(27827)) // Spirit of Redemption
{
who->CastSpell(who, SPELL_AURA_DEATH, 1);
}
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoMeleeAttackIfReady();
}
private:
bool _inEnrage;
};
void AddSC_boss_doomwalker()
{
new boss_doomwalker();
RegisterCreatureAI(boss_doomwalker);
}