refactor(Scripts/ShadowLabirynth): Rework Grandmaster Vorpil (#16053)

This commit is contained in:
Skjalf
2023-04-22 11:59:38 -03:00
committed by GitHub
parent ace0cee18c
commit fc7d2aedb0

View File

@@ -43,12 +43,6 @@ enum GrandmasterVorpil
NPC_VOID_PORTAL = 19224, NPC_VOID_PORTAL = 19224,
SPELL_VOID_PORTAL_VISUAL = 33569, SPELL_VOID_PORTAL_VISUAL = 33569,
EVENT_SPELL_SHADOWBOLT = 1,
EVENT_SPELL_DRAWSHADOWS = 2,
EVENT_SUMMON_TRAVELER = 3,
EVENT_SPELL_BANISH = 4,
EVENT_SPELL_RAIN_OF_FIRE = 5
}; };
float VorpilPosition[3] = {-253.548f, -263.646f, 17.0864f}; float VorpilPosition[3] = {-253.548f, -263.646f, 17.0864f};
@@ -67,23 +61,15 @@ struct boss_grandmaster_vorpil : public BossAI
{ {
boss_grandmaster_vorpil(Creature* creature) : BossAI(creature, DATA_GRANDMASTER_VORPIL) boss_grandmaster_vorpil(Creature* creature) : BossAI(creature, DATA_GRANDMASTER_VORPIL)
{ {
instance = creature->GetInstanceScript();
sayIntro = false; sayIntro = false;
} }
InstanceScript* instance;
bool sayIntro, sayHelp; bool sayIntro, sayHelp;
int count = 0;
void Reset() override void Reset() override
{ {
_Reset();
sayHelp = false; sayHelp = false;
events.Reset();
summons.DespawnAll();
if (instance)
{
instance->SetData(DATA_GRANDMASTER_VORPIL_EVENT, NOT_STARTED);
}
} }
void summonPortals() void summonPortals()
@@ -105,36 +91,30 @@ struct boss_grandmaster_vorpil : public BossAI
} }
} }
int counterVoidSpawns(int count) Milliseconds counterVoidSpawns(uint8 count)
{ {
int timer = 0; switch (count)
switch(count)
{ {
case 1: case 1:
case 2: case 2:
timer = 13300; return 13300ms;
break;
case 3: case 3:
timer = 12100; return 12100ms;
break;
case 4: case 4:
timer = 10900; return 10900ms;
break;
case 5: case 5:
case 6: case 6:
timer = 9700; return 9700ms;
break;
case 7: case 7:
case 8: case 8:
timer = 7200; return 7200ms;
break;
case 9: case 9:
timer = 6000; return 6000ms;
break;
default: default:
timer = 4800; return 4800ms;
} }
return timer;
return 1s;
} }
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
@@ -152,7 +132,7 @@ struct boss_grandmaster_vorpil : public BossAI
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() == TYPEID_PLAYER) if (victim->IsPlayer())
{ {
Talk(SAY_SLAY); Talk(SAY_SLAY);
} }
@@ -161,27 +141,50 @@ struct boss_grandmaster_vorpil : public BossAI
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
Talk(SAY_DEATH); Talk(SAY_DEATH);
summons.DespawnAll(); _JustDied();
if (instance)
{
instance->SetData(DATA_GRANDMASTER_VORPIL_EVENT, DONE);
}
} }
void JustEngagedWith(Unit* /*who*/) override void JustEngagedWith(Unit* /*who*/) override
{ {
Talk(SAY_AGGRO); Talk(SAY_AGGRO);
summonPortals(); summonPortals();
events.ScheduleEvent(EVENT_SPELL_SHADOWBOLT, urand(9700, 20000));
events.ScheduleEvent(EVENT_SPELL_DRAWSHADOWS, 36400); scheduler.Schedule(9700ms, 20s, [this](TaskContext context)
events.ScheduleEvent(EVENT_SUMMON_TRAVELER, 10900); {
DoCastAOE(SPELL_SHADOWBOLT_VOLLEY);
context.Repeat();
}).Schedule(36400ms, [this](TaskContext context)
{
DoCastSelf(SPELL_DRAW_SHADOWS, true);
me->GetMap()->DoForAllPlayers([&](Player* player)
{
if (player->IsAlive() && !player->HasAura(SPELL_BANISH))
{
player->TeleportTo(me->GetMapId(), VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT);
}
});
scheduler.Schedule(1s, [this](TaskContext /*context*/)
{
DoCastSelf(DUNGEON_MODE(SPELL_RAIN_OF_FIRE_N, SPELL_RAIN_OF_FIRE_H));
});
me->NearTeleportTo(VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f);
context.Repeat(36400ms, 44950ms);
}).Schedule(10900ms, [this](TaskContext context)
{
spawnVoidTraveler();
context.Repeat(counterVoidSpawns(context.GetRepeatCounter()));
});
if (IsHeroic()) if (IsHeroic())
{ {
events.ScheduleEvent(EVENT_SPELL_BANISH, urand(17000, 28000)); scheduler.Schedule(17s, 28s, [this](TaskContext context)
} {
if (instance) DoCastRandomTarget(SPELL_BANISH, 0, 30.0f, true);
{ context.Repeat();
instance->SetData(DATA_GRANDMASTER_VORPIL_EVENT, IN_PROGRESS); });
} }
} }
@@ -194,55 +197,6 @@ struct boss_grandmaster_vorpil : public BossAI
sayIntro = true; sayIntro = true;
} }
} }
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
switch (events.ExecuteEvent())
{
case EVENT_SPELL_SHADOWBOLT:
DoCastAOE(SPELL_SHADOWBOLT_VOLLEY);
events.RepeatEvent(urand(9700, 20000));
break;
case EVENT_SPELL_BANISH:
DoCastRandomTarget(SPELL_BANISH, 0, 30.0f, true);
events.RepeatEvent(urand(17000, 28000));
break;
case EVENT_SUMMON_TRAVELER:
spawnVoidTraveler();
count++;
events.RepeatEvent(counterVoidSpawns(count));
break;
case EVENT_SPELL_DRAWSHADOWS:
{
DoCastSelf(SPELL_DRAW_SHADOWS, true);
Map* map = me->GetMap();
Map::PlayerList const& PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (Player* player = i->GetSource())
{
if (player->IsAlive() && !player->HasAura(SPELL_BANISH))
{
player->TeleportTo(me->GetMapId(), VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0, TELE_TO_NOT_LEAVE_COMBAT);
}
}
}
me->NearTeleportTo(VorpilPosition[0], VorpilPosition[1], VorpilPosition[2], 0.0f);
events.ScheduleEvent(EVENT_SPELL_RAIN_OF_FIRE, 1000);
events.RepeatEvent(urand(36400, 44950));
break;
}
case EVENT_SPELL_RAIN_OF_FIRE:
DoCastSelf(DUNGEON_MODE(SPELL_RAIN_OF_FIRE_N, SPELL_RAIN_OF_FIRE_H));
events.DelayEvents(6000);
break;
}
DoMeleeAttackIfReady();
}
}; };
struct npc_voidtraveler : public ScriptedAI struct npc_voidtraveler : public ScriptedAI