refactor(Scripts/BlackTemple): Modernize Najentus boss script (#17871)

* refactor(Scripts/BlackTemple): Modernize Najentus boss script

* fix build

* Update ScriptedCreature.h
This commit is contained in:
Andrew
2023-11-26 19:47:15 -03:00
committed by GitHub
parent 5659ac48f3
commit daec8345e0
3 changed files with 59 additions and 63 deletions

View File

@@ -43,23 +43,63 @@ enum Spells
enum Events
{
EVENT_SPELL_BERSERK = 1,
EVENT_YELL = 2,
EVENT_SPELL_NEEDLE = 3,
EVENT_SPELL_SPINE = 4,
EVENT_SPELL_SHIELD = 5,
EVENT_KILL_SPEAK = 6
EVENT_TALK_CHECK = 2
};
struct boss_najentus : public BossAI
{
boss_najentus(Creature* creature) : BossAI(creature, DATA_HIGH_WARLORD_NAJENTUS) { }
boss_najentus(Creature* creature) : BossAI(creature, DATA_HIGH_WARLORD_NAJENTUS), _canTalk(true) { }
void JustEngagedWith(Unit* who) override
{
_canTalk = true;
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
ScheduleUniqueTimedEvent(8min, [&]
{
Talk(SAY_ENRAGE);
DoCastSelf(SPELL_BERSERK, true);
}, EVENT_SPELL_BERSERK);
ScheduleTimedEvent(25s, 100s, [&]
{
Talk(SAY_SPECIAL);
}, 25s, 100s);
ScheduleTimedEvent(10s, [&]
{
me->CastCustomSpell(SPELL_NEEDLE_SPINE, SPELLVALUE_MAX_TARGETS, 3, me, false);
}, 15s, 15s);
ScheduleTimedEvent(21s, [&]
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
{
DoCast(target, SPELL_IMPALING_SPINE);
target->CastSpell(target, SPELL_SUMMON_IMPALING_SPINE, true);
Talk(SAY_NEEDLE);
}
}, 20s, 20s);
ScheduleTimedEvent(1min, [&]
{
DoCastSelf(SPELL_TIDAL_SHIELD);
scheduler.DelayAll(10s);
}, 1min, 1min);
}
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER && events.GetNextEventTime(EVENT_KILL_SPEAK) == 0)
if (victim->GetTypeId() == TYPEID_PLAYER && _canTalk)
{
Talk(SAY_SLAY);
events.ScheduleEvent(EVENT_KILL_SPEAK, 5000);
_canTalk = false;
ScheduleUniqueTimedEvent(5s, [&]
{
_canTalk = true;
}, EVENT_TALK_CHECK);
}
}
@@ -69,58 +109,8 @@ struct boss_najentus : public BossAI
Talk(SAY_DEATH);
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_SPELL_BERSERK, 480000);
events.ScheduleEvent(EVENT_YELL, urand(25000, 100000));
events.RescheduleEvent(EVENT_SPELL_NEEDLE, 10000);
events.RescheduleEvent(EVENT_SPELL_SPINE, 20001);
events.RescheduleEvent(EVENT_SPELL_SHIELD, 60000);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (events.ExecuteEvent())
{
case EVENT_SPELL_SHIELD:
me->CastSpell(me, SPELL_TIDAL_SHIELD, false);
events.DelayEvents(10000);
events.ScheduleEvent(EVENT_SPELL_SHIELD, 60000);
break;
case EVENT_SPELL_BERSERK:
Talk(SAY_ENRAGE);
me->CastSpell(me, SPELL_BERSERK, true);
break;
case EVENT_SPELL_NEEDLE:
me->CastCustomSpell(SPELL_NEEDLE_SPINE, SPELLVALUE_MAX_TARGETS, 3, me, false);
events.ScheduleEvent(EVENT_SPELL_NEEDLE, 15000);
break;
case EVENT_SPELL_SPINE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
{
me->CastSpell(target, SPELL_IMPALING_SPINE, false);
target->CastSpell(target, SPELL_SUMMON_IMPALING_SPINE, true);
Talk(SAY_NEEDLE);
}
events.ScheduleEvent(EVENT_SPELL_SPINE, 20000);
return;
case EVENT_YELL:
Talk(SAY_SPECIAL);
events.ScheduleEvent(EVENT_YELL, urand(25000, 100000));
break;
}
DoMeleeAttackIfReady();
}
private:
bool _canTalk;
};
class spell_najentus_needle_spine : public SpellScript