Skip to content

Commit

Permalink
refactor(Scripts/Naxxramas): Modernize Anubrekhan script (#20596)
Browse files Browse the repository at this point in the history
* refactor(Scripts/Naxxramas): Modernize Anubrekhan script

* Update boss_anubrekhan.cpp
  • Loading branch information
Nyeriah authored Nov 16, 2024
1 parent d5a33f1 commit 86d06d8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 116 deletions.
132 changes: 31 additions & 101 deletions src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ enum Spells
SPELL_BERSERK = 26662
};

enum Events
{
EVENT_IMPALE = 1,
EVENT_LOCUST_SWARM = 2,
EVENT_BERSERK = 3,
EVENT_SPAWN_GUARD = 4
};

enum Misc
{
NPC_CORPSE_SCARAB = 16698,
Expand All @@ -72,17 +64,11 @@ class boss_anubrekhan : public CreatureScript

struct boss_anubrekhanAI : public BossAI
{
explicit boss_anubrekhanAI(Creature* c) : BossAI(c, BOSS_ANUB), summons(me)
boss_anubrekhanAI(Creature* c) : BossAI(c, BOSS_ANUB)
{
pInstance = c->GetInstanceScript();
sayGreet = false;
}

InstanceScript* pInstance;
EventMap events;
SummonList summons;
bool sayGreet;

void SummonCryptGuards()
{
if (Is25ManRaid())
Expand All @@ -95,16 +81,8 @@ class boss_anubrekhan : public CreatureScript
void Reset() override
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
SummonCryptGuards();
if (pInstance)
{
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_ANUB_GATE)))
{
go->SetGoState(GO_STATE_ACTIVE);
}
}
me->m_Events.KillAllEvents(false);
}

void JustSummoned(Creature* cr) override
Expand All @@ -113,9 +91,7 @@ class boss_anubrekhan : public CreatureScript
{
cr->SetInCombatWithZone();
if (cr->GetEntry() == NPC_CRYPT_GUARD)
{
cr->AI()->Talk(EMOTE_SPAWN, me);
}
}
summons.Summon(cr);
}
Expand All @@ -129,19 +105,10 @@ class boss_anubrekhan : public CreatureScript
}
}

void SummonedCreatureDespawn(Creature* cr) override
{
summons.Despawn(cr);
}

void JustDied(Unit* killer) override
{
BossAI::JustDied(killer);
summons.DespawnAll();
if (pInstance)
{
pInstance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}
instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
}

void KilledUnit(Unit* victim) override
Expand All @@ -151,35 +118,44 @@ class boss_anubrekhan : public CreatureScript

Talk(SAY_SLAY);
victim->CastSpell(victim, SPELL_SUMMON_CORPSE_SCRABS_5, true, nullptr, nullptr, me->GetGUID());
if (pInstance)
{
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
instance->SetData(DATA_IMMORTAL_FAIL, 0);
}

void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
me->CallForHelp(30.0f);
Talk(SAY_AGGRO);
if (pInstance)
{
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_ANUB_GATE)))
{
go->SetGoState(GO_STATE_READY);
}
}
events.ScheduleEvent(EVENT_IMPALE, 15s);
events.ScheduleEvent(EVENT_LOCUST_SWARM, 70s, 120s);
events.ScheduleEvent(EVENT_BERSERK, 10min);

if (!summons.HasEntry(NPC_CRYPT_GUARD))
{
SummonCryptGuards();
}
if (!Is25ManRaid())
{
events.ScheduleEvent(EVENT_SPAWN_GUARD, 15s, 20s);
me->m_Events.AddEventAtOffset([&]
{
me->SummonCreature(NPC_CRYPT_GUARD, 3331.217f, -3476.607f, 287.074f, 3.269f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
}, Milliseconds(urand(15000, 20000)));
}

ScheduleTimedEvent(15s, [&] {
DoCastRandomTarget(RAID_MODE(SPELL_IMPALE_10, SPELL_IMPALE_25));
}, 20s);

ScheduleTimedEvent(70s, 2min, [&] {
Talk(EMOTE_LOCUST);
DoCastSelf(RAID_MODE(SPELL_LOCUST_SWARM_10, SPELL_LOCUST_SWARM_25));

me->m_Events.AddEventAtOffset([&]
{
me->SummonCreature(NPC_CRYPT_GUARD, 3331.217f, -3476.607f, 287.074f, 3.269f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
}, 3s);

}, 90s);

me->m_Events.AddEventAtOffset([&]
{
DoCastSelf(SPELL_BERSERK, true);
}, 10min);
}

void MoveInLineOfSight(Unit* who) override
Expand All @@ -192,54 +168,8 @@ class boss_anubrekhan : public CreatureScript
ScriptedAI::MoveInLineOfSight(who);
}

void UpdateAI(uint32 diff) override
{
if (!me->IsInCombat() && sayGreet)
{
for (SummonList::iterator itr = summons.begin(); itr != summons.end(); ++itr)
{
if (pInstance)
{
if (Creature* cr = pInstance->instance->GetCreature(*itr))
{
if (cr->IsInCombat())
DoZoneInCombat();
}
}
}
}

if (!UpdateVictim())
return;

events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;

switch (events.ExecuteEvent())
{
case EVENT_IMPALE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
me->CastSpell(target, RAID_MODE(SPELL_IMPALE_10, SPELL_IMPALE_25), false);
}
events.Repeat(20s);
break;
case EVENT_LOCUST_SWARM:
Talk(EMOTE_LOCUST);
me->CastSpell(me, RAID_MODE(SPELL_LOCUST_SWARM_10, SPELL_LOCUST_SWARM_25), false);
events.ScheduleEvent(EVENT_SPAWN_GUARD, 3s);
events.Repeat(90s);
break;
case EVENT_SPAWN_GUARD:
me->SummonCreature(NPC_CRYPT_GUARD, 3331.217f, -3476.607f, 287.074f, 3.269f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
break;
case EVENT_BERSERK:
me->CastSpell(me, SPELL_BERSERK, true);
break;
}
DoMeleeAttackIfReady();
}
private:
bool sayGreet;
};
};

Expand Down
21 changes: 7 additions & 14 deletions src/server/scripts/Northrend/Naxxramas/instance_naxxramas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ inline uint8 GetEruptionSection(float x, float y)
return 3;
}

DoorData const doorData[] =
{
{ GO_ANUB_GATE, BOSS_ANUB, DOOR_TYPE_ROOM },
{ 0, 0, DOOR_TYPE_ROOM },
};

ObjectData const creatureData[] =
{
{ NPC_RAZUVIOUS, DATA_RAZUVIOUS },
Expand Down Expand Up @@ -79,6 +85,7 @@ class instance_naxxramas : public InstanceMapScript
{
SetHeaders(DataHeader);
SetBossNumber(MAX_ENCOUNTERS);
LoadDoorData(doorData);
LoadObjectData(creatureData, gameObjectData);
for (auto& i : HeiganEruption)
i.clear();
Expand Down Expand Up @@ -115,7 +122,6 @@ class instance_naxxramas : public InstanceMapScript
ObjectGuid _heiganGateGUID;
ObjectGuid _heiganGateExitGUID;
ObjectGuid _loathebGateGUID;
ObjectGuid _anubGateGUID;
ObjectGuid _anubNextGateGUID;
ObjectGuid _faerlinaWebGUID;
ObjectGuid _faerlinaGateGUID;
Expand Down Expand Up @@ -328,13 +334,6 @@ class instance_naxxramas : public InstanceMapScript
pGo->SetGoState(GO_STATE_ACTIVE);
}
break;
case GO_ANUB_GATE:
_anubGateGUID = pGo->GetGUID();
if (GetBossState(BOSS_ANUB) == DONE)
{
pGo->SetGoState(GO_STATE_ACTIVE);
}
break;
case GO_ANUB_NEXT_GATE:
_anubNextGateGUID = pGo->GetGUID();
if (GetBossState(BOSS_ANUB) == DONE)
Expand Down Expand Up @@ -880,10 +879,6 @@ class instance_naxxramas : public InstanceMapScript
events.ScheduleEvent(EVENT_KELTHUZAD_WING_TAUNT, 6s);
break;
case BOSS_ANUB:
if (GameObject* go = instance->GetGameObject(_anubGateGUID))
{
go->SetGoState(GO_STATE_ACTIVE);
}
if (GameObject* go = instance->GetGameObject(_anubNextGateGUID))
{
go->SetGoState(GO_STATE_ACTIVE);
Expand Down Expand Up @@ -1074,8 +1069,6 @@ class instance_naxxramas : public InstanceMapScript
return _heiganGateGUID;
case DATA_LOATHEB_GATE:
return _loathebGateGUID;
case DATA_ANUB_GATE:
return _anubGateGUID;
case DATA_FAERLINA_WEB:
return _faerlinaWebGUID;
case DATA_MAEXXNA_GATE:
Expand Down
1 change: 0 additions & 1 deletion src/server/scripts/Northrend/Naxxramas/naxxramas.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ enum NXData
DATA_HEIGAN_ERUPTION = 101,
DATA_HEIGAN_ENTER_GATE = 102,
DATA_LOATHEB_GATE = 103,
DATA_ANUB_GATE = 104,
DATA_FAERLINA_WEB = 105,
DATA_MAEXXNA_GATE = 106,
DATA_THADDIUS_BOSS = 107,
Expand Down

0 comments on commit 86d06d8

Please sign in to comment.