fix(Scripts/Blackmorass): Clean unnecessary repetitions (#15299)

This commit is contained in:
Skjalf
2023-03-07 09:19:48 -03:00
committed by GitHub
parent 86a2e94746
commit 527f462826
2 changed files with 23 additions and 52 deletions
@@ -56,7 +56,6 @@ public:
_currentRift = 0; _currentRift = 0;
_shieldPercent = 100; _shieldPercent = 100;
_encounterNPCs.clear(); _encounterNPCs.clear();
_timerToNextBoss = 0;
} }
void CleanupInstance() void CleanupInstance()
@@ -114,6 +113,8 @@ public:
case DATA_CHRONO_LORD_DEJA: case DATA_CHRONO_LORD_DEJA:
case DATA_TEMPORUS: case DATA_TEMPORUS:
{ {
_scheduler.RescheduleGroup(CONTEXT_GROUP_RIFTS, 2min + 30s);
for (ObjectGuid const& guid : _encounterNPCs) for (ObjectGuid const& guid : _encounterNPCs)
{ {
if (Creature* creature = instance->GetCreature(guid)) if (Creature* creature = instance->GetCreature(guid))
@@ -132,17 +133,6 @@ public:
} }
} }
} }
if (!_timerToNextBoss || _timerToNextBoss > 30 * IN_MILLISECONDS)
{
ScheduleNextPortal(30s);
}
else
{
ScheduleNextPortal(Milliseconds(_timerToNextBoss));
}
_timerToNextBoss = (instance->IsHeroic() ? 300 : 150) * IN_MILLISECONDS;
break; break;
} }
default: default:
@@ -190,23 +180,21 @@ public:
} }
// Here we check if we have available rift spots. // Here we check if we have available rift spots.
// If there are spots available, spawn a rift instantly. if (_currentRift < 18)
{
if (!_availableRiftPositions.empty()) if (!_availableRiftPositions.empty())
{ {
context.Repeat((_currentRift >= 13 ? 2min : 90s)); context.Repeat((_currentRift >= 13 ? 2min : 90s));
} }
else else
{ {
context.Repeat(3s); context.Repeat(4s);
}
} }
} }
else
{
context.Repeat(3s);
} }
context.SetGroup(CONTEXT_GROUP_RIFTS); context.SetGroup(CONTEXT_GROUP_RIFTS);
}
}); });
} }
@@ -242,21 +230,19 @@ public:
switch (creature->GetEntry()) switch (creature->GetEntry())
{ {
case NPC_TIME_RIFT: case NPC_TIME_RIFT:
_availableRiftPositions.push_back(creature->GetHomePosition()); if (_currentRift < 18)
if (GetBossState(DATA_AEONUS) != DONE)
{ {
// Here we check if we have available rift spots. if (!_availableRiftPositions.empty() && _availableRiftPositions.size() < 3)
// If there are spots available, spawn a rift instantly.
if (!_availableRiftPositions.empty())
{
ScheduleNextPortal(4s);
}
else
{ {
ScheduleNextPortal((_currentRift >= 13 ? 2min : 90s)); ScheduleNextPortal((_currentRift >= 13 ? 2min : 90s));
} }
else
{
ScheduleNextPortal(4s);
} }
}
_availableRiftPositions.push_back(creature->GetHomePosition());
[[fallthrough]]; [[fallthrough]];
case NPC_CHRONO_LORD_DEJA: case NPC_CHRONO_LORD_DEJA:
case NPC_INFINITE_CHRONO_LORD: case NPC_INFINITE_CHRONO_LORD:
@@ -291,8 +277,6 @@ public:
ScheduleNextPortal(3s); ScheduleNextPortal(3s);
_timerToNextBoss = (instance->IsHeroic() ? 300 : 150) * IN_MILLISECONDS;
for (ObjectGuid const& guid : _encounterNPCs) for (ObjectGuid const& guid : _encounterNPCs)
{ {
if (guid.GetEntry() == NPC_DP_BEAM_STALKER) if (guid.GetEntry() == NPC_DP_BEAM_STALKER)
@@ -463,24 +447,11 @@ public:
void Update(uint32 diff) override void Update(uint32 diff) override
{ {
if (_timerToNextBoss) _scheduler.Update(diff);
{
if (_timerToNextBoss <= diff)
{
_timerToNextBoss = 0;
}
else
{
_timerToNextBoss -= diff;
}
}
_scheduler.Update();
} }
protected: protected:
std::list<Position> _availableRiftPositions; std::list<Position> _availableRiftPositions;
uint32 _timerToNextBoss;
GuidSet _encounterNPCs; GuidSet _encounterNPCs;
uint8 _currentRift; uint8 _currentRift;
int8 _shieldPercent; int8 _shieldPercent;
@@ -269,7 +269,7 @@ struct npc_time_rift : public NullCreatureAI
void JustSummoned(Creature* creature) override void JustSummoned(Creature* creature) override
{ {
if (creature->GetEntry() != NPC_AEONUS) if (creature->GetEntry() != NPC_AEONUS && _riftKeeperGUID.IsEmpty())
{ {
_riftKeeperGUID = creature->GetGUID(); _riftKeeperGUID = creature->GetGUID();
} }