refactor(Scripts/Karazhan): Update Moroes (#16682)

* init

* .
This commit is contained in:
Eddy Vega
2023-07-17 05:21:13 -06:00
committed by GitHub
parent dbc39a2817
commit 3a7274709b
@@ -41,7 +41,7 @@ enum Spells
SPELL_FRENZY = 37023, SPELL_FRENZY = 37023,
SPELL_DUAL_WIELD = 29651, SPELL_DUAL_WIELD = 29651,
SPELL_BERSERK = 26662, SPELL_BERSERK = 26662,
SPELL_VANISH_TELEPORT = 29431, SPELL_VANISH_TELEPORT = 29431
}; };
enum Misc enum Misc
@@ -52,9 +52,8 @@ enum Misc
EVENT_SPELL_GARROTE = 4, EVENT_SPELL_GARROTE = 4,
EVENT_SPELL_BLIND = 5, EVENT_SPELL_BLIND = 5,
EVENT_SPELL_GOUGE = 6, EVENT_SPELL_GOUGE = 6,
EVENT_CHECK_HEALTH = 7, EVENT_SPELL_ENRAGE = 7,
EVENT_SPELL_ENRAGE = 8, EVENT_KILL_TALK = 8,
EVENT_KILL_TALK = 9,
ACTIVE_GUEST_COUNT = 4, ACTIVE_GUEST_COUNT = 4,
MAX_GUEST_COUNT = 6 MAX_GUEST_COUNT = 6
@@ -65,17 +64,13 @@ const Position GuestsPosition[4] =
{-10987.38f, -1883.38f, 81.73f, 1.50f}, {-10987.38f, -1883.38f, 81.73f, 1.50f},
{-10989.60f, -1881.27f, 81.73f, 0.73f}, {-10989.60f, -1881.27f, 81.73f, 0.73f},
{-10978.81f, -1884.08f, 81.73f, 1.50f}, {-10978.81f, -1884.08f, 81.73f, 1.50f},
{-10976.38f, -1882.59f, 81.73f, 2.31f}, {-10976.38f, -1882.59f, 81.73f, 2.31f}
}; };
const uint32 GuestEntries[6] = const uint32 GuestEntries[6] =
{ {
17007, 17007, 19872, 19873,
19872, 19874, 19875, 19876
19873,
19874,
19875,
19876,
}; };
struct boss_moroes : public BossAI struct boss_moroes : public BossAI
@@ -109,11 +104,13 @@ struct boss_moroes : public BossAI
uint8 rand2 = RAND(0x08, 0x10, 0x20); uint8 rand2 = RAND(0x08, 0x10, 0x20);
_activeGuests &= ~(rand1 | rand2); _activeGuests &= ~(rand1 | rand2);
} }
for (uint8 i = 0; i < MAX_GUEST_COUNT; ++i) for (uint8 i = 0; i < MAX_GUEST_COUNT; ++i)
{
if ((1 << i) & _activeGuests) if ((1 << i) & _activeGuests)
{
me->SummonCreature(GuestEntries[i], GuestsPosition[summons.size()], TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(GuestEntries[i], GuestsPosition[summons.size()], TEMPSUMMON_MANUAL_DESPAWN);
}
}
_events2.Reset(); _events2.Reset();
_events2.ScheduleEvent(EVENT_GUEST_TALK, 10s); _events2.ScheduleEvent(EVENT_GUEST_TALK, 10s);
} }
@@ -128,26 +125,34 @@ struct boss_moroes : public BossAI
{ {
BossAI::JustEngagedWith(who); BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO); Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_SPELL_VANISH, 30s); events.ScheduleEvent(EVENT_SPELL_VANISH, 30s);
events.ScheduleEvent(EVENT_SPELL_BLIND, 20s); events.ScheduleEvent(EVENT_SPELL_BLIND, 20s);
events.ScheduleEvent(EVENT_SPELL_GOUGE, 13s); events.ScheduleEvent(EVENT_SPELL_GOUGE, 13s);
events.ScheduleEvent(EVENT_CHECK_HEALTH, 5s);
events.ScheduleEvent(EVENT_SPELL_ENRAGE, 10min); events.ScheduleEvent(EVENT_SPELL_ENRAGE, 10min);
_events2.Reset(); _events2.Reset();
me->CallForHelp(20.0f); me->CallForHelp(20.0f);
DoZoneInCombat(); DoZoneInCombat();
} }
void KilledUnit(Unit* /*victim*/) override void DamageTaken(Unit*, uint32& /*damage*/, DamageEffectType, SpellSchoolMask) override
{
if (HealthBelowPct(30))
{
DoCastSelf(SPELL_FRENZY, true);
}
}
void KilledUnit(Unit* victim) override
{ {
if (events.GetNextEventTime(EVENT_KILL_TALK) == 0) if (events.GetNextEventTime(EVENT_KILL_TALK) == 0)
{
if (victim->GetTypeId() == TYPEID_PLAYER)
{ {
Talk(SAY_KILL); Talk(SAY_KILL);
events.ScheduleEvent(EVENT_KILL_TALK, 5s); events.ScheduleEvent(EVENT_KILL_TALK, 5s);
} }
} }
}
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
@@ -160,9 +165,12 @@ struct boss_moroes : public BossAI
{ {
std::list<Creature*> guestList; std::list<Creature*> guestList;
for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i) for (SummonList::const_iterator i = summons.begin(); i != summons.end(); ++i)
{
if (Creature* summon = ObjectAccessor::GetCreature(*me, *i)) if (Creature* summon = ObjectAccessor::GetCreature(*me, *i))
{
guestList.push_back(summon); guestList.push_back(summon);
}
}
return Acore::Containers::SelectRandomContainerElement(guestList); return Acore::Containers::SelectRandomContainerElement(guestList);
} }
@@ -173,7 +181,9 @@ struct boss_moroes : public BossAI
{ {
case EVENT_GUEST_TALK: case EVENT_GUEST_TALK:
if (Creature* guest = GetRandomGuest()) if (Creature* guest = GetRandomGuest())
{
guest->AI()->Talk(SAY_GUEST); guest->AI()->Talk(SAY_GUEST);
}
_events2.Repeat(5s); _events2.Repeat(5s);
break; break;
case EVENT_GUEST_TALK2: case EVENT_GUEST_TALK2:
@@ -191,14 +201,6 @@ struct boss_moroes : public BossAI
switch (events.ExecuteEvent()) switch (events.ExecuteEvent())
{ {
case EVENT_CHECK_HEALTH:
if (me->HealthBelowPct(31))
{
DoCastSelf(SPELL_FRENZY, true);
break;
}
events.Repeat(1s);
break;
case EVENT_SPELL_ENRAGE: case EVENT_SPELL_ENRAGE:
DoCastSelf(SPELL_BERSERK, true); DoCastSelf(SPELL_BERSERK, true);
break; break;
@@ -227,9 +229,7 @@ struct boss_moroes : public BossAI
events.SetPhase(0); events.SetPhase(0);
break; break;
} }
if (events.GetPhaseMask() == 0) // Xinef: not in vanish
// Xinef: not in vanish
if (events.GetPhaseMask() == 0)
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
@@ -238,14 +238,9 @@ struct boss_moroes : public BossAI
uint8 _activeGuests; uint8 _activeGuests;
}; };
class spell_moroes_vanish : public SpellScriptLoader class spell_moroes_vanish : public SpellScript
{ {
public: PrepareSpellScript(spell_moroes_vanish);
spell_moroes_vanish() : SpellScriptLoader("spell_moroes_vanish") { }
class spell_moroes_vanish_SpellScript : public SpellScript
{
PrepareSpellScript(spell_moroes_vanish_SpellScript);
void HandleDummy(SpellEffIndex effIndex) void HandleDummy(SpellEffIndex effIndex)
{ {
@@ -261,18 +256,12 @@ public:
void Register() override void Register() override
{ {
OnEffectHitTarget += SpellEffectFn(spell_moroes_vanish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); OnEffectHitTarget += SpellEffectFn(spell_moroes_vanish::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_moroes_vanish_SpellScript();
} }
}; };
void AddSC_boss_moroes() void AddSC_boss_moroes()
{ {
RegisterKarazhanCreatureAI(boss_moroes); RegisterKarazhanCreatureAI(boss_moroes);
new spell_moroes_vanish(); RegisterSpellScript(spell_moroes_vanish);
} }