diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index dc300de981..93c6bcab74 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -77,18 +77,6 @@ struct boss_moroes : public BossAI _activeGuests = 0; } - void InitializeAI() override - { - BossAI::InitializeAI(); - InitializeGuests(); - } - - void JustReachedHome() override - { - BossAI::JustReachedHome(); - InitializeGuests(); - } - void InitializeGuests() { if (!me->IsAlive()) @@ -96,16 +84,18 @@ struct boss_moroes : public BossAI if (_activeGuests == 0) { - _activeGuests |= 0x3F; + _activeGuests = 0x3F; uint8 rand1 = RAND(0x01, 0x02, 0x04); uint8 rand2 = RAND(0x08, 0x10, 0x20); _activeGuests &= ~(rand1 | rand2); } - for (uint8 i = 0; i < MAX_GUEST_COUNT; ++i) + + uint8 positionIndex = 0; + for (uint8 i = 0; i < MAX_GUEST_COUNT && positionIndex < ACTIVE_GUEST_COUNT; ++i) { if ((1 << i) & _activeGuests) { - me->SummonCreature(GuestEntries[i], GuestsPosition[summons.size()], TEMPSUMMON_MANUAL_DESPAWN); + me->SummonCreature(GuestEntries[i], GuestsPosition[positionIndex++], TEMPSUMMON_MANUAL_DESPAWN); } } @@ -130,6 +120,8 @@ struct boss_moroes : public BossAI _recentlySpoken = false; _vanished = false; + InitializeGuests(); + ScheduleHealthCheckEvent(30, [&] { DoCastSelf(SPELL_FRENZY, true); }); @@ -203,6 +195,9 @@ struct boss_moroes : public BossAI } } + if (guestList.empty()) + return nullptr; + return Acore::Containers::SelectRandomContainerElement(guestList); } @@ -211,12 +206,12 @@ struct boss_moroes : public BossAI bool guestsInRoom = true; summons.DoForAllSummons([&guestsInRoom](WorldObject* summon) { - if ((summon->ToCreature()->GetPositionX()) < -11028.f || (summon->ToCreature()->GetPositionY()) < -1955.f) //boundaries of the two doors + Creature* creature = summon->ToCreature(); + if (creature->IsAlive() && + ((creature->GetPositionX() < -11028.f) || (creature->GetPositionY() < -1955.f))) // boundaries of the two doors { guestsInRoom = false; - return false; } - return true; }); return guestsInRoom; @@ -229,10 +224,6 @@ struct boss_moroes : public BossAI if (!CheckGuestsInRoom()) { EnterEvadeMode(); - summons.DoForAllSummons([](WorldObject* summon) - { - summon->ToCreature()->DespawnOnEvade(5s); - }); return; }