Skip to content

Commit 04dff51

Browse files
Nyeriahclaude
andauthored
fix(Scripts/Karazhan): fix Moroes guests not respawning on evade (azerothcore#25851)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 46a649c commit 04dff51

1 file changed

Lines changed: 13 additions & 22 deletions

File tree

src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,25 @@ struct boss_moroes : public BossAI
7777
_activeGuests = 0;
7878
}
7979

80-
void InitializeAI() override
81-
{
82-
BossAI::InitializeAI();
83-
InitializeGuests();
84-
}
85-
86-
void JustReachedHome() override
87-
{
88-
BossAI::JustReachedHome();
89-
InitializeGuests();
90-
}
91-
9280
void InitializeGuests()
9381
{
9482
if (!me->IsAlive())
9583
return;
9684

9785
if (_activeGuests == 0)
9886
{
99-
_activeGuests |= 0x3F;
87+
_activeGuests = 0x3F;
10088
uint8 rand1 = RAND(0x01, 0x02, 0x04);
10189
uint8 rand2 = RAND(0x08, 0x10, 0x20);
10290
_activeGuests &= ~(rand1 | rand2);
10391
}
104-
for (uint8 i = 0; i < MAX_GUEST_COUNT; ++i)
92+
93+
uint8 positionIndex = 0;
94+
for (uint8 i = 0; i < MAX_GUEST_COUNT && positionIndex < ACTIVE_GUEST_COUNT; ++i)
10595
{
10696
if ((1 << i) & _activeGuests)
10797
{
108-
me->SummonCreature(GuestEntries[i], GuestsPosition[summons.size()], TEMPSUMMON_MANUAL_DESPAWN);
98+
me->SummonCreature(GuestEntries[i], GuestsPosition[positionIndex++], TEMPSUMMON_MANUAL_DESPAWN);
10999
}
110100
}
111101

@@ -130,6 +120,8 @@ struct boss_moroes : public BossAI
130120
_recentlySpoken = false;
131121
_vanished = false;
132122

123+
InitializeGuests();
124+
133125
ScheduleHealthCheckEvent(30, [&] {
134126
DoCastSelf(SPELL_FRENZY, true);
135127
});
@@ -203,6 +195,9 @@ struct boss_moroes : public BossAI
203195
}
204196
}
205197

198+
if (guestList.empty())
199+
return nullptr;
200+
206201
return Acore::Containers::SelectRandomContainerElement(guestList);
207202
}
208203

@@ -211,12 +206,12 @@ struct boss_moroes : public BossAI
211206
bool guestsInRoom = true;
212207
summons.DoForAllSummons([&guestsInRoom](WorldObject* summon)
213208
{
214-
if ((summon->ToCreature()->GetPositionX()) < -11028.f || (summon->ToCreature()->GetPositionY()) < -1955.f) //boundaries of the two doors
209+
Creature* creature = summon->ToCreature();
210+
if (creature->IsAlive() &&
211+
((creature->GetPositionX() < -11028.f) || (creature->GetPositionY() < -1955.f))) // boundaries of the two doors
215212
{
216213
guestsInRoom = false;
217-
return false;
218214
}
219-
return true;
220215
});
221216

222217
return guestsInRoom;
@@ -229,10 +224,6 @@ struct boss_moroes : public BossAI
229224
if (!CheckGuestsInRoom())
230225
{
231226
EnterEvadeMode();
232-
summons.DoForAllSummons([](WorldObject* summon)
233-
{
234-
summon->ToCreature()->DespawnOnEvade(5s);
235-
});
236227
return;
237228
}
238229

0 commit comments

Comments
 (0)