refactor(Scripts/TheBotanica): Modernize Thorngrin the Tender's script (#15277)
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
--
|
||||||
|
UPDATE `creature_template` SET `ScriptName` = 'boss_thorngrin_the_tender' WHERE `entry` = 17978;
|
||||||
@@ -39,114 +39,84 @@ enum Spells
|
|||||||
SPELL_ENRAGE = 34670
|
SPELL_ENRAGE = 34670
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Events
|
struct boss_thorngrin_the_tender : public BossAI
|
||||||
{
|
{
|
||||||
EVENT_SACRIFICE = 1,
|
boss_thorngrin_the_tender(Creature* creature) : BossAI(creature, DATA_THORNGRIN_THE_TENDER)
|
||||||
EVENT_HELLFIRE = 2,
|
|
||||||
EVENT_ENRAGE = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
class boss_thorngrin_the_tender : public CreatureScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
boss_thorngrin_the_tender() : CreatureScript("thorngrin_the_tender") { }
|
|
||||||
|
|
||||||
struct boss_thorngrin_the_tenderAI : public BossAI
|
|
||||||
{
|
{
|
||||||
boss_thorngrin_the_tenderAI(Creature* creature) : BossAI(creature, DATA_THORNGRIN_THE_TENDER)
|
me->m_SightDistance = 100.0f;
|
||||||
|
_intro = false;
|
||||||
|
scheduler.SetValidator([this]
|
||||||
{
|
{
|
||||||
me->m_SightDistance = 100.0f;
|
return !me->HasUnitState(UNIT_STATE_CASTING);
|
||||||
_intro = false;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset() override
|
void Reset() override
|
||||||
{
|
{
|
||||||
_Reset();
|
_Reset();
|
||||||
ScheduleHealthCheckEvent(20, [&]() {
|
ScheduleHealthCheckEvent(20, [&]() {
|
||||||
Talk(SAY_20_PERCENT_HP);
|
Talk(SAY_20_PERCENT_HP);
|
||||||
});
|
});
|
||||||
ScheduleHealthCheckEvent(50, [&]() {
|
ScheduleHealthCheckEvent(50, [&]() {
|
||||||
Talk(SAY_50_PERCENT_HP);
|
Talk(SAY_50_PERCENT_HP);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveInLineOfSight(Unit* who) override
|
void MoveInLineOfSight(Unit* who) override
|
||||||
|
{
|
||||||
|
if (!_intro && who->IsPlayer())
|
||||||
{
|
{
|
||||||
if (!_intro && who->GetTypeId() == TYPEID_PLAYER)
|
_intro = true;
|
||||||
|
Talk(SAY_INTRO);
|
||||||
|
}
|
||||||
|
BossAI::MoveInLineOfSight(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JustEngagedWith(Unit* /*who*/) override
|
||||||
|
{
|
||||||
|
_JustEngagedWith();
|
||||||
|
Talk(SAY_AGGRO);
|
||||||
|
|
||||||
|
scheduler.Schedule(6s, [this](TaskContext context)
|
||||||
|
{
|
||||||
|
if (DoCastRandomTarget(SPELL_SACRIFICE, 1) == SPELL_CAST_OK)
|
||||||
{
|
{
|
||||||
_intro = true;
|
Talk(SAY_CAST_SACRIFICE);
|
||||||
Talk(SAY_INTRO);
|
|
||||||
}
|
}
|
||||||
BossAI::MoveInLineOfSight(who);
|
context.Repeat(30s);
|
||||||
}
|
}).Schedule(18s, [this](TaskContext context)
|
||||||
|
|
||||||
void JustEngagedWith(Unit* /*who*/) override
|
|
||||||
{
|
{
|
||||||
_JustEngagedWith();
|
if (roll_chance_i(50))
|
||||||
Talk(SAY_AGGRO);
|
Talk(SAY_CAST_HELLFIRE);
|
||||||
events.ScheduleEvent(EVENT_SACRIFICE, 6000);
|
DoCastAOE(SPELL_HELLFIRE);
|
||||||
events.ScheduleEvent(EVENT_HELLFIRE, 18000);
|
context.Repeat(22s);
|
||||||
events.ScheduleEvent(EVENT_ENRAGE, 15000);
|
}).Schedule(15s, [this](TaskContext context)
|
||||||
}
|
|
||||||
|
|
||||||
void KilledUnit(Unit* victim) override
|
|
||||||
{
|
{
|
||||||
if (victim->GetTypeId() == TYPEID_PLAYER)
|
Talk(EMOTE_ENRAGE);
|
||||||
Talk(SAY_KILL);
|
DoCastSelf(SPELL_ENRAGE);
|
||||||
}
|
context.Repeat(30s);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void JustDied(Unit* /*killer*/) override
|
void KilledUnit(Unit* victim) override
|
||||||
|
{
|
||||||
|
if (victim->IsPlayer())
|
||||||
{
|
{
|
||||||
_JustDied();
|
Talk(SAY_KILL);
|
||||||
Talk(SAY_DEATH);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateAI(uint32 diff) override
|
void JustDied(Unit* /*killer*/) override
|
||||||
{
|
{
|
||||||
if (!UpdateVictim())
|
_JustDied();
|
||||||
return;
|
Talk(SAY_DEATH);
|
||||||
|
}
|
||||||
events.Update(diff);
|
|
||||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (events.ExecuteEvent())
|
|
||||||
{
|
|
||||||
case EVENT_SACRIFICE:
|
|
||||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
|
|
||||||
{
|
|
||||||
Talk(SAY_CAST_SACRIFICE);
|
|
||||||
me->CastSpell(target, SPELL_SACRIFICE, false);
|
|
||||||
}
|
|
||||||
events.ScheduleEvent(EVENT_SACRIFICE, 30000);
|
|
||||||
break;
|
|
||||||
case EVENT_HELLFIRE:
|
|
||||||
if (roll_chance_i(50))
|
|
||||||
Talk(SAY_CAST_HELLFIRE);
|
|
||||||
me->CastSpell(me, SPELL_HELLFIRE, false);
|
|
||||||
events.ScheduleEvent(EVENT_HELLFIRE, 22000);
|
|
||||||
break;
|
|
||||||
case EVENT_ENRAGE:
|
|
||||||
Talk(EMOTE_ENRAGE);
|
|
||||||
me->CastSpell(me, SPELL_ENRAGE, false);
|
|
||||||
events.ScheduleEvent(EVENT_ENRAGE, 30000);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DoMeleeAttackIfReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _intro;
|
bool _intro;
|
||||||
};
|
|
||||||
|
|
||||||
CreatureAI* GetAI(Creature* creature) const override
|
|
||||||
{
|
|
||||||
return GetTheBotanicaAI<boss_thorngrin_the_tenderAI>(creature);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddSC_boss_thorngrin_the_tender()
|
void AddSC_boss_thorngrin_the_tender()
|
||||||
{
|
{
|
||||||
new boss_thorngrin_the_tender();
|
RegisterTheBotanicaCreatureAI(boss_thorngrin_the_tender);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user