Rewritten Naxxramas boss state system using BossAI methods

This commit is contained in:
Yehonal
2017-12-06 01:36:21 +00:00
parent 2979fd6c1f
commit b9d7c85786
17 changed files with 227 additions and 293 deletions

View File

@@ -49,9 +49,9 @@ public:
return new boss_anubrekhanAI (pCreature);
}
struct boss_anubrekhanAI : public ScriptedAI
struct boss_anubrekhanAI : public BossAI
{
boss_anubrekhanAI(Creature *c) : ScriptedAI(c), summons(me)
boss_anubrekhanAI(Creature *c) : BossAI(c, BOSS_ANUB), summons(me)
{
pInstance = c->GetInstanceScript();
sayGreet = false;
@@ -71,15 +71,15 @@ public:
}
}
void Reset()
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
SummonCryptGuards();
if (pInstance)
{
pInstance->SetData(EVENT_ANUB, NOT_STARTED);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_ANUB_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
}
@@ -107,13 +107,13 @@ public:
void SummonedCreatureDespawn(Creature* cr) { summons.Despawn(cr); }
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
summons.DespawnAll();
if (pInstance)
{
pInstance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
pInstance->SetData(EVENT_ANUB, DONE);
}
}
@@ -132,13 +132,13 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->CallForHelp(30.0f); // catch helpers
Talk(SAY_AGGRO);
if (pInstance)
{
pInstance->SetData(EVENT_ANUB, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_ANUB_GATE)))
go->SetGoState(GO_STATE_READY);
}

View File

@@ -49,9 +49,9 @@ public:
return new boss_faerlinaAI (pCreature);
}
struct boss_faerlinaAI : public ScriptedAI
struct boss_faerlinaAI : public BossAI
{
boss_faerlinaAI(Creature *c) : ScriptedAI(c), summons(me)
boss_faerlinaAI(Creature *c) : BossAI(c, BOSS_FAERLINA), summons(me)
{
pInstance = me->GetInstanceScript();
sayGreet = false;
@@ -81,24 +81,21 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
SummonHelpers();
if (pInstance)
pInstance->SetData(EVENT_FAERLINA, NOT_STARTED);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_SPELL_POISON_BOLT, urand(12000,15000));
events.ScheduleEvent(EVENT_SPELL_RAIN_OF_FIRE, urand(6000,18000));
events.ScheduleEvent(EVENT_SPELL_FRENZY, urand(60000,80000), 1);
events.SetPhase(1);
if (pInstance)
pInstance->SetData(EVENT_FAERLINA, IN_PROGRESS);
}
void MoveInLineOfSight(Unit *who)
@@ -124,11 +121,10 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(EVENT_FAERLINA, DONE);
}
void UpdateAI(uint32 diff)

View File

@@ -121,9 +121,9 @@ public:
return new boss_four_horsemenAI (pCreature);
}
struct boss_four_horsemenAI : public ScriptedAI
struct boss_four_horsemenAI : public BossAI
{
boss_four_horsemenAI(Creature *c) : ScriptedAI(c)
boss_four_horsemenAI(Creature *c) : BossAI(c, BOSS_HORSEMAN)
{
pInstance = me->GetInstanceScript();
switch (me->GetEntry())
@@ -174,15 +174,13 @@ public:
void Reset()
{
BossAI::Reset();
me->SetPosition(me->GetHomePosition());
movementPhase = MOVE_PHASE_NONE;
currentWaypoint = 0;
me->SetReactState(REACT_AGGRESSIVE);
events.Reset();
if (pInstance)
pInstance->SetData(EVENT_HORSEMAN, NOT_STARTED);
// Schedule Events
events.RescheduleEvent(EVENT_SPELL_MARK_CAST, 24000);
events.RescheduleEvent(EVENT_BERSERK, 100*15000);
@@ -248,25 +246,24 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
if (pInstance)
{
pInstance->SetData(EVENT_HORSEMAN, DONE);
if (pInstance->GetData(EVENT_HORSEMAN) == DONE)
if (pInstance->GetBossState(BOSS_HORSEMAN) == DONE) {
if (!me->GetMap()->GetPlayers().isEmpty())
if (Player* player = me->GetMap()->GetPlayers().getFirst()->GetSource())
player->SummonGameObject(RAID_MODE(GO_HORSEMEN_CHEST_10, GO_HORSEMEN_CHEST_25), 2514.8f, -2944.9f, 245.55f, 5.51f, 0, 0, 0, 0, 0);
}
}
Talk(SAY_DEATH);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
if (pInstance)
pInstance->SetData(EVENT_HORSEMAN, IN_PROGRESS);
BossAI::EnterCombat(who);
if (movementPhase == MOVE_PHASE_NONE)
{
Talk(SAY_AGGRO);

View File

@@ -52,9 +52,9 @@ public:
return new boss_gluthAI (pCreature);
}
struct boss_gluthAI : public ScriptedAI
struct boss_gluthAI : public BossAI
{
boss_gluthAI(Creature *c) : ScriptedAI(c), summons(me)
boss_gluthAI(Creature *c) : BossAI(c, BOSS_GLUTH), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -66,14 +66,12 @@ public:
void Reset()
{
BossAI::Reset();
me->ApplySpellImmune(29306, IMMUNITY_ID, 29306, true);
events.Reset();
summons.DespawnAll();
gazeTarget = 0;
me->SetReactState(REACT_AGGRESSIVE);
if (pInstance)
pInstance->SetData(EVENT_GLUTH, NOT_STARTED);
}
void MoveInLineOfSight(Unit *who)
@@ -87,8 +85,9 @@ public:
ScriptedAI::MoveInLineOfSight(who);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
events.ScheduleEvent(EVENT_SPELL_MORTAL_WOUND, 10000);
events.ScheduleEvent(EVENT_SPELL_ENRAGE, 30000);
@@ -96,9 +95,6 @@ public:
events.ScheduleEvent(EVENT_SPELL_BERSERK, 8*60000);
events.ScheduleEvent(EVENT_SUMMON_ZOMBIE, 10000);
events.ScheduleEvent(EVENT_CAN_EAT_ZOMBIE, 1000);
if (pInstance)
pInstance->SetData(EVENT_GLUTH, IN_PROGRESS);
}
void JustSummoned(Creature *summon)
@@ -120,11 +116,10 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit*)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
summons.DespawnAll();
if (pInstance)
pInstance->SetData(EVENT_GLUTH, DONE);
}
bool SelectPlayerInRoom()

View File

@@ -135,9 +135,9 @@ public:
return new boss_gothikAI (pCreature);
}
struct boss_gothikAI : public ScriptedAI
struct boss_gothikAI : public BossAI
{
boss_gothikAI(Creature *c) : ScriptedAI(c), summons(me)
boss_gothikAI(Creature *c) : BossAI(c, BOSS_GOTHIK), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -162,6 +162,7 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_DISABLE_MOVE);
@@ -172,7 +173,6 @@ public:
if (pInstance)
{
pInstance->SetData(EVENT_GOTHIK, NOT_STARTED);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE)))
@@ -182,8 +182,9 @@ public:
}
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
Talk(SAY_SPEECH);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_DISABLE_MOVE);
@@ -194,7 +195,6 @@ public:
if (pInstance)
{
pInstance->SetData(EVENT_GOTHIK, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE)))
go->SetGoState(GO_STATE_READY);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE)))
@@ -225,14 +225,14 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
summons.DespawnAll();
if (pInstance)
{
pInstance->SetData(EVENT_GOTHIK, DONE);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_ENTER_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_GOTHIK_INNER_GATE)))

View File

@@ -45,9 +45,9 @@ public:
return new boss_grobbulusAI (pCreature);
}
struct boss_grobbulusAI : public ScriptedAI
struct boss_grobbulusAI : public BossAI
{
boss_grobbulusAI(Creature *c) : ScriptedAI(c), summons(me)
boss_grobbulusAI(Creature *c) : BossAI(c, BOSS_GROBBULUS), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -59,24 +59,20 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
dropSludgeTimer = 0;
if (pInstance)
pInstance->SetData(EVENT_GROBBULUS, NOT_STARTED);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
events.ScheduleEvent(EVENT_SPELL_POISON_CLOUD, 15000);
events.ScheduleEvent(EVENT_SPELL_MUTATING_INJECTION, 20000);
events.ScheduleEvent(EVENT_SPELL_SLIME_SPRAY, 10000);
events.ScheduleEvent(EVENT_SPELL_BERSERK, RAID_MODE(12*MINUTE*IN_MILLISECONDS, 9*MINUTE*IN_MILLISECONDS));
if (pInstance)
pInstance->SetData(EVENT_GROBBULUS, IN_PROGRESS);
}
void SpellHitTarget(Unit *target, const SpellInfo* spellInfo)
@@ -95,11 +91,10 @@ public:
void SummonedCreatureDespawn(Creature* summon){ summons.Despawn(summon); }
void JustDied(Unit*)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
summons.DespawnAll();
if (pInstance)
pInstance->SetData(EVENT_GROBBULUS, DONE);
}
void KilledUnit(Unit* who)

View File

@@ -48,9 +48,9 @@ public:
return new boss_heiganAI (pCreature);
}
struct boss_heiganAI : public ScriptedAI
struct boss_heiganAI : public BossAI
{
boss_heiganAI(Creature *c) : ScriptedAI(c)
boss_heiganAI(Creature *c) : BossAI(c, BOSS_HEIGAN)
{
pInstance = me->GetInstanceScript();
}
@@ -63,6 +63,7 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
currentPhase = 0;
currentSection = 3;
@@ -70,7 +71,6 @@ public:
if (pInstance)
{
pInstance->SetData(EVENT_HEIGAN, NOT_STARTED);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HEIGAN_ENTER_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
}
@@ -88,20 +88,19 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(EVENT_HEIGAN, DONE);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
Talk(SAY_AGGRO);
if (pInstance)
{
pInstance->SetData(EVENT_HEIGAN, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_HEIGAN_ENTER_GATE)))
go->SetGoState(GO_STATE_READY);
}

View File

@@ -115,9 +115,9 @@ public:
return new boss_kelthuzadAI (pCreature);
}
struct boss_kelthuzadAI : public ScriptedAI
struct boss_kelthuzadAI : public BossAI
{
boss_kelthuzadAI(Creature* c) : ScriptedAI(c), summons(me)
boss_kelthuzadAI(Creature* c) : BossAI(c, BOSS_KELTHUZAD), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -162,6 +162,7 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_DISABLE_MOVE);
@@ -169,7 +170,6 @@ public:
if (pInstance)
{
pInstance->SetData(EVENT_KELTHUZAD, NOT_STARTED);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_FLOOR)))
{
go->SetPhaseMask(1, true);
@@ -198,12 +198,11 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
summons.DespawnAll();
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(EVENT_KELTHUZAD, DONE);
}
void MoveInLineOfSight(Unit* who)
@@ -212,8 +211,9 @@ public:
AttackStart(who);
}
void EnterCombat(Unit* /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
Talk(SAY_SUMMON_MINIONS);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE);
me->RemoveAllAttackers();
@@ -229,7 +229,6 @@ public:
events.ScheduleEvent(EVENT_START_SECOND_PHASE, 228000);
if (pInstance)
{
pInstance->SetData(EVENT_KELTHUZAD, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_KELTHUZAD_FLOOR)))
{
events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15000);

View File

@@ -42,9 +42,9 @@ public:
return new boss_loathebAI (pCreature);
}
struct boss_loathebAI : public ScriptedAI
struct boss_loathebAI : public BossAI
{
boss_loathebAI(Creature *c) : ScriptedAI(c)
boss_loathebAI(Creature *c) : BossAI(c, BOSS_LOATHEB)
{
pInstance = me->GetInstanceScript();
}
@@ -54,10 +54,10 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
if (pInstance)
{
pInstance->SetData(EVENT_LOATHEB, NOT_STARTED);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_LOATHEB_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
}
@@ -77,11 +77,11 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
if (pInstance)
{
pInstance->SetData(EVENT_LOATHEB, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_LOATHEB_GATE)))
go->SetGoState(GO_STATE_READY);
}
@@ -93,12 +93,6 @@ public:
events.ScheduleEvent(EVENT_SPELL_BERSERK, 720000);
}
void JustDied(Unit* /*Killer*/)
{
if (pInstance)
pInstance->SetData(EVENT_LOATHEB, DONE);
}
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())

View File

@@ -53,9 +53,9 @@ public:
return new boss_maexxnaAI (pCreature);
}
struct boss_maexxnaAI : public ScriptedAI
struct boss_maexxnaAI : public BossAI
{
boss_maexxnaAI(Creature *c) : ScriptedAI(c), summons(me)
boss_maexxnaAI(Creature *c) : BossAI(c, BOSS_MAEXXNA), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -77,20 +77,21 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
if (pInstance)
{
pInstance->SetData(EVENT_MAEXXNA, NOT_STARTED);
if (pInstance->GetData(EVENT_FAERLINA) == DONE)
if (pInstance->GetData(BOSS_FAERLINA) == DONE)
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_MAEXXNA_GATE)))
go->SetGoState(GO_STATE_ACTIVE);
}
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
events.ScheduleEvent(EVENT_WEB_WRAP, 20000);
events.ScheduleEvent(EVENT_SPELL_WEB_SPRAY, 40000);
@@ -101,18 +102,11 @@ public:
if (pInstance)
{
pInstance->SetData(EVENT_MAEXXNA, IN_PROGRESS);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetData64(DATA_MAEXXNA_GATE)))
go->SetGoState(GO_STATE_READY);
}
}
void JustDied(Unit* /*Killer*/)
{
if (pInstance)
pInstance->SetData(EVENT_MAEXXNA, DONE);
}
void JustSummoned(Creature* cr)
{
if (cr->GetEntry() == NPC_MAEXXNA_SPIDERLING)

View File

@@ -66,9 +66,9 @@ public:
return new boss_nothAI (pCreature);
}
struct boss_nothAI : public ScriptedAI
struct boss_nothAI : public BossAI
{
boss_nothAI(Creature *c) : ScriptedAI(c), summons(me)
boss_nothAI(Creature *c) : BossAI(c, BOSS_NOTH), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -123,14 +123,12 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
me->SetControlled(false, UNIT_STATE_ROOT);
me->SetReactState(REACT_AGGRESSIVE);
events.SetPhase(0);
if (pInstance)
pInstance->SetData(EVENT_NOTH, NOT_STARTED);
}
void EnterEvadeMode()
@@ -139,12 +137,10 @@ public:
ScriptedAI::EnterEvadeMode();
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
Talk(SAY_AGGRO);
if (pInstance)
pInstance->SetData(EVENT_NOTH, IN_PROGRESS);
StartGroundPhase();
}
@@ -154,11 +150,10 @@ public:
summon->SetInCombatWithZone();
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(EVENT_NOTH, DONE);
}
void KilledUnit(Unit* who)

View File

@@ -47,9 +47,9 @@ public:
return new boss_patchwerkAI (pCreature);
}
struct boss_patchwerkAI : public ScriptedAI
struct boss_patchwerkAI : public BossAI
{
boss_patchwerkAI(Creature *c) : ScriptedAI(c)
boss_patchwerkAI(Creature *c) : BossAI(c, BOSS_PATCHWERK)
{
pInstance = me->GetInstanceScript();
}
@@ -59,9 +59,8 @@ public:
void Reset()
{
BossAI::Reset();
events.Reset();
if (pInstance)
pInstance->SetData(EVENT_PATCHWERK, NOT_STARTED);
}
void KilledUnit(Unit* who)
@@ -76,15 +75,15 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
if (pInstance)
pInstance->SetData(EVENT_PATCHWERK, DONE);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
Talk(SAY_AGGRO);
me->SetInCombatWithZone();
@@ -95,7 +94,6 @@ public:
if (pInstance)
{
pInstance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
pInstance->SetData(EVENT_PATCHWERK, IN_PROGRESS);
}
}

View File

@@ -60,9 +60,9 @@ public:
return new boss_razuviousAI (pCreature);
}
struct boss_razuviousAI : public ScriptedAI
struct boss_razuviousAI : public BossAI
{
boss_razuviousAI(Creature *c) : ScriptedAI(c), summons(me)
boss_razuviousAI(Creature *c) : BossAI(c, BOSS_RAZUVIOUS), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -86,11 +86,10 @@ public:
void Reset()
{
BossAI::Reset();
summons.DespawnAll();
events.Reset();
SpawnHelpers();
if (pInstance)
pInstance->SetData(EVENT_RAZUVIOUS, NOT_STARTED);
}
void KilledUnit(Unit* who)
@@ -115,18 +114,18 @@ public:
me->LowerPlayerDamageReq(damage);
}
void JustDied(Unit* /*killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
DoPlaySoundToSet(me, SOUND_DEATH);
me->MonsterYell("An honorable... death...", LANG_UNIVERSAL, 0);
me->CastSpell(me, SPELL_HOPELESS, true);
if (pInstance)
pInstance->SetData(EVENT_RAZUVIOUS, DONE);
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
switch (urand(0,2))
{
case 0:
@@ -147,8 +146,6 @@ public:
events.ScheduleEvent(EVENT_SPELL_DISRUPTING_SHOUT, 25000);
events.ScheduleEvent(EVENT_SPELL_JAGGED_KNIFE, 15000);
events.ScheduleEvent(EVENT_PLAY_COMMAND, 40000);
if (pInstance)
pInstance->SetData(EVENT_RAZUVIOUS, IN_PROGRESS);
summons.DoZoneInCombat();
}

View File

@@ -77,9 +77,9 @@ public:
return new boss_sapphironAI (pCreature);
}
struct boss_sapphironAI : public ScriptedAI
struct boss_sapphironAI : public BossAI
{
boss_sapphironAI(Creature* c) : ScriptedAI(c)
boss_sapphironAI(Creature* c) : BossAI(c, BOSS_SAPPHIRON)
{
pInstance = me->GetInstanceScript();
}
@@ -113,6 +113,7 @@ public:
void Reset()
{
BossAI::Reset();
if (me->IsVisible())
me->SetReactState(REACT_AGGRESSIVE);
@@ -121,9 +122,6 @@ public:
spawnTimer = 0;
currentTarget = 0;
blockList.clear();
if (pInstance)
pInstance->SetData(EVENT_SAPPHIRON, NOT_STARTED);
}
void EnterCombatSelfFunction()
@@ -147,8 +145,9 @@ public:
}
}
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
EnterCombatSelfFunction();
me->CastSpell(me, RAID_MODE(SPELL_FROST_AURA_10, SPELL_FROST_AURA_25), true);
@@ -159,16 +158,12 @@ public:
events.ScheduleEvent(EVENT_SPELL_BLIZZARD, 21000);
events.ScheduleEvent(EVENT_FLIGHT_START, 45000);
events.ScheduleEvent(EVENT_HUNDRED_CLUB, 5000);
if (pInstance)
pInstance->SetData(EVENT_SAPPHIRON, IN_PROGRESS);
}
void JustDied(Unit* /*who*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
me->CastSpell(me, SPELL_SAPPHIRON_DIES, true);
if (pInstance)
pInstance->SetData(EVENT_SAPPHIRON, DONE);
}
void DoAction(int32 param)

View File

@@ -94,9 +94,9 @@ public:
return new boss_thaddiusAI (pCreature);
}
struct boss_thaddiusAI : public ScriptedAI
struct boss_thaddiusAI : public BossAI
{
boss_thaddiusAI(Creature *c) : ScriptedAI(c), summons(me)
boss_thaddiusAI(Creature *c) : BossAI(c, BOSS_THADDIUS), summons(me)
{
pInstance = me->GetInstanceScript();
}
@@ -139,8 +139,9 @@ public:
}
}
void Reset()
void Reset()
{
BossAI::Reset();
events.Reset();
summons.DespawnAll();
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -149,9 +150,6 @@ public:
resetTimer = 1;
me->SetPosition(me->GetHomePosition());
if (pInstance)
pInstance->SetData(EVENT_THADDIUS, NOT_STARTED);
me->SummonCreature(NPC_STALAGG, 3450.45f, -2931.42f, 312.091f, 5.49779f);
me->SummonCreature(NPC_FEUGEN, 3508.14f, -2988.65f, 312.092f, 2.37365f);
if (Creature* cr = me->SummonCreature(NPC_TESLA_COIL, 3527.34f, -2951.56f, 318.75f, 0.0f))
@@ -182,12 +180,12 @@ public:
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
void JustDied(Unit* /*Killer*/)
void JustDied(Unit* killer)
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
if (pInstance)
{
pInstance->SetData(EVENT_THADDIUS, DONE);
pInstance->DoRemoveAurasDueToSpellOnPlayers(28059);
pInstance->DoRemoveAurasDueToSpellOnPlayers(28084);
}
@@ -195,14 +193,12 @@ public:
void JustSummoned(Creature* cr) { summons.Summon(cr); }
void EnterCombat(Unit * /*who*/)
void EnterCombat(Unit * who)
{
BossAI::EnterCombat(who);
me->SetInCombatWithZone();
summons.DoZoneInCombat(NPC_FEUGEN);
summons.DoZoneInCombat(NPC_STALAGG);
if (pInstance)
pInstance->SetData(EVENT_THADDIUS, IN_PROGRESS);
}
void UpdateAI(uint32 diff)

View File

@@ -49,7 +49,7 @@ public:
{
instance_naxxramas_InstanceMapScript(Map* pMap) : InstanceScript(pMap)
{
memset(&Encounters, 0, sizeof(Encounters));
SetBossNumber(MAX_ENCOUNTERS);
for (uint8 i = 0; i < 4; ++i)
HeiganEruption[i].clear();
@@ -101,7 +101,6 @@ public:
immortalAchievement = 1;
}
uint32 Encounters[MAX_ENCOUNTERS];
std::set<GameObject*> HeiganEruption[4];
// GOs
@@ -169,17 +168,17 @@ public:
}
}
bool IsEncounterInProgress() const
bool IsEncounterInProgress() const override
{
for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
{
if (Encounters[i] == IN_PROGRESS)
if (GetBossState(i) == IN_PROGRESS)
return true;
}
return false;
}
void OnCreatureCreate(Creature* creature)
void OnCreatureCreate(Creature* creature) override
{
switch(creature->GetEntry())
{
@@ -216,7 +215,7 @@ public:
}
}
void OnGameObjectCreate(GameObject* pGo)
void OnGameObjectCreate(GameObject* pGo) override
{
if (pGo->GetGOInfo()->displayId == 6785 || pGo->GetGOInfo()->displayId == 1287)
{
@@ -228,57 +227,57 @@ public:
{
case GO_PATCHWERK_GATE:
_patchwerkGateGUID = pGo->GetGUID();
if (Encounters[EVENT_PATCHWERK] == DONE)
if (GetBossState(BOSS_PATCHWERK) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_GLUTH_GATE:
_gluthGateGUID = pGo->GetGUID();
if (Encounters[EVENT_GLUTH] == DONE)
if (GetBossState(BOSS_GLUTH) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_NOTH_GATE:
_nothGateGUID = pGo->GetGUID();
if (Encounters[EVENT_NOTH] == DONE)
if (GetBossState(BOSS_NOTH) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_HEIGAN_ENTERANCE_GATE:
_heiganGateGUID = pGo->GetGUID();
if (Encounters[EVENT_HEIGAN] == DONE || Encounters[EVENT_NOTH] == DONE)
if (GetBossState(BOSS_HEIGAN) == DONE || GetBossState(BOSS_NOTH) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_HEIGAN_EXIT_GATE:
_heiganGateExitGUID = pGo->GetGUID();
if (Encounters[EVENT_HEIGAN] == DONE)
if (GetBossState(BOSS_HEIGAN) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_LOATHEB_GATE:
_loathebGateGUID = pGo->GetGUID();
if (Encounters[EVENT_LOATHEB] == DONE)
if (GetBossState(BOSS_LOATHEB) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_ANUB_GATE:
_anubGateGUID = pGo->GetGUID();
if (Encounters[EVENT_ANUB] == DONE)
if (GetBossState(BOSS_ANUB) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_ANUB_NEXT_GATE:
_anubNextGateGUID = pGo->GetGUID();
if (Encounters[EVENT_ANUB] == DONE)
if (GetBossState(BOSS_ANUB) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_FAERLINA_GATE:
_faerlinaGateGUID = pGo->GetGUID();
if (Encounters[EVENT_FAERLINA] == DONE)
if (GetBossState(BOSS_FAERLINA) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_MAEXXNA_GATE:
_maexxnaGateGUID = pGo->GetGUID();
if (Encounters[EVENT_FAERLINA] == DONE) // faerlina is correct
if (GetBossState(BOSS_FAERLINA) == DONE) // faerlina is correct
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_THADDIUS_GATE:
_thaddiusGateGUID = pGo->GetGUID();
if (Encounters[EVENT_GLUTH] == DONE) // gluth is correct
if (GetBossState(BOSS_GLUTH) == DONE) // gluth is correct
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_GOTHIK_ENTER_GATE:
@@ -289,12 +288,12 @@ public:
break;
case GO_GOTHIK_EXIT_GATE:
_gothikExitGateGUID = pGo->GetGUID();
if (Encounters[EVENT_GOTHIK] == DONE)
if (GetBossState(BOSS_GOTHIK) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_HORSEMAN_GATE:
_horsemanGateGUID = pGo->GetGUID();
if (Encounters[EVENT_GOTHIK] == DONE) // correct
if (GetBossState(BOSS_GOTHIK) == DONE) // correct
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_KELTHUZAD_FLOOR:
@@ -305,33 +304,33 @@ public:
break;
case GO_SAPPHIRON_GATE:
_sapphironGateGUID = pGo->GetGUID();
if (Encounters[EVENT_SAPPHIRON] == DONE)
if (GetBossState(BOSS_SAPPHIRON) == DONE)
pGo->SetGoState(GO_STATE_ACTIVE);
break;
case GO_DEATHKNIGHT_WING:
_loathebPortalGUID = pGo->GetGUID();
if (Encounters[EVENT_LOATHEB] == DONE)
if (GetBossState(BOSS_LOATHEB) == DONE)
pGo->SetPhaseMask(1, true);
break;
case GO_THADDIUS_PORTAL:
_thaddiusPortalGUID = pGo->GetGUID();
if (Encounters[EVENT_THADDIUS] == DONE)
if (GetBossState(BOSS_THADDIUS) == DONE)
pGo->SetPhaseMask(1, true);
break;
case GO_MAEXXNA_PORTAL:
_maexxnaPortalGUID = pGo->GetGUID();
if (Encounters[EVENT_MAEXXNA] == DONE)
if (GetBossState(BOSS_MAEXXNA) == DONE)
pGo->SetPhaseMask(1, true);
break;
case GO_HORSEMAN_PORTAL:
_horsemanPortalGUID = pGo->GetGUID();
if (Encounters[EVENT_HORSEMAN] == DONE)
if (GetBossState(BOSS_HORSEMAN) == DONE)
pGo->SetPhaseMask(1, true);
break;
}
}
void OnGameObjectRemove(GameObject* pGo)
void OnGameObjectRemove(GameObject* pGo) override
{
if (pGo->GetGOInfo()->displayId == 6785 || pGo->GetGOInfo()->displayId == 1287)
{
@@ -345,7 +344,7 @@ public:
cr->AI()->DoAction(ACTION_SAPPHIRON_BIRTH);
}
bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/)
bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override
{
switch(criteria_id)
{
@@ -389,7 +388,7 @@ public:
{
uint8 count = 0;
for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
if (Encounters[i] == NOT_STARTED)
if (GetBossState(i) == NOT_STARTED)
++count;
return !count && immortalAchievement;
@@ -398,57 +397,10 @@ public:
return false;
}
void SetData(uint32 id, uint32 data)
void SetData(uint32 id, uint32 data) override
{
// Bosses data
switch(id)
{
case EVENT_PATCHWERK:
case EVENT_GROBBULUS:
case EVENT_GLUTH:
case EVENT_NOTH:
case EVENT_ANUB:
case EVENT_MAEXXNA:
case EVENT_RAZUVIOUS:
case EVENT_GOTHIK:
// EVENT_HORSEMAN HANDLED BELOW
Encounters[id] = data;
break;
case EVENT_KELTHUZAD:
if (data == NOT_STARTED)
abominationsKilled = 0;
Encounters[id] = data;
break;
case EVENT_FAERLINA:
if (data == NOT_STARTED)
faerlinaAchievement = true;
Encounters[id] = data;
break;
case EVENT_THADDIUS:
if (data == NOT_STARTED)
thaddiusAchievement = true;
Encounters[id] = data;
break;
case EVENT_LOATHEB:
if (data == NOT_STARTED)
loathebAchievement = true;
Encounters[id] = data;
break;
case EVENT_HEIGAN:
if (data == NOT_STARTED)
heiganAchievement = true;
Encounters[id] = data;
break;
case DATA_HEIGAN_ERUPTION:
HeiganEruptSections(data);
return;
case EVENT_SAPPHIRON:
Encounters[id] = data;
if (data == DONE)
_speakTimer = 1;
else if (data == NOT_STARTED)
sapphironAchievement = true;
break;
case DATA_ABOMINATION_KILLED:
abominationsKilled++;
return;
@@ -471,17 +423,24 @@ public:
immortalAchievement = 0;
SaveToDB();
return;
case DATA_HEIGAN_ERUPTION:
HeiganEruptSections(data);
return;
}
}
bool SetBossState(uint32 bossId, EncounterState state) override
{
// Horseman handling
if (id == EVENT_HORSEMAN)
if (bossId == BOSS_HORSEMAN)
{
if (data == DONE)
if (state == DONE)
{
_horsemanTimer++;
_horsemanKilled++;
if (_horsemanKilled < 4)
return;
if (_horsemanKilled < 4) {
return false;
}
// All horsemans are killed
if (Creature* cr = instance->GetCreature(_blaumeuxGUID))
@@ -489,7 +448,7 @@ public:
}
// respawn
else if (data == NOT_STARTED && _horsemanKilled > 0)
else if (state == NOT_STARTED && _horsemanKilled > 0)
{
Creature* cr;
_horsemanKilled = 0;
@@ -518,7 +477,7 @@ public:
cr->Respawn();
}
}
else if (data == IN_PROGRESS)
else if (state == IN_PROGRESS)
{
Creature* cr;
if ((cr = instance->GetCreature(_blaumeuxGUID)))
@@ -531,66 +490,99 @@ public:
cr->SetInCombatWithZone();
}
if (data == NOT_STARTED)
if (state == NOT_STARTED)
_horsemanTimer = 0;
Encounters[id] = data;
}
if (!InstanceScript::SetBossState(bossId, state))
return false;
// Bosses data
switch(bossId)
{
case BOSS_KELTHUZAD:
if (state == NOT_STARTED)
abominationsKilled = 0;
break;
case BOSS_FAERLINA:
if (state == NOT_STARTED)
faerlinaAchievement = true;
break;
case BOSS_THADDIUS:
if (state == NOT_STARTED)
thaddiusAchievement = true;
break;
case BOSS_LOATHEB:
if (state == NOT_STARTED)
loathebAchievement = true;
break;
case BOSS_HEIGAN:
if (state == NOT_STARTED)
heiganAchievement = true;
break;
case BOSS_SAPPHIRON:
if (state == DONE)
_speakTimer = 1;
else if (state == NOT_STARTED)
sapphironAchievement = true;
break;
}
// Save instance and open gates
if (data == DONE)
if (state == DONE)
{
SaveToDB();
switch (id)
switch (bossId)
{
case EVENT_PATCHWERK:
case BOSS_PATCHWERK:
if (GameObject* go = instance->GetGameObject(_patchwerkGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_GLUTH:
case BOSS_GLUTH:
if (GameObject* go = instance->GetGameObject(_gluthGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_thaddiusGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_NOTH:
case BOSS_NOTH:
if (GameObject* go = instance->GetGameObject(_nothGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_heiganGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_HEIGAN:
case BOSS_HEIGAN:
if (GameObject* go = instance->GetGameObject(_heiganGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_heiganGateExitGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_LOATHEB:
case BOSS_LOATHEB:
if (GameObject* go = instance->GetGameObject(_loathebGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_loathebPortalGUID))
go->SetPhaseMask(1, true);
break;
case EVENT_ANUB:
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);
break;
case EVENT_FAERLINA:
case BOSS_FAERLINA:
if (GameObject* go = instance->GetGameObject(_faerlinaGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_maexxnaGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_MAEXXNA:
case BOSS_MAEXXNA:
if (GameObject* go = instance->GetGameObject(_maexxnaGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_maexxnaPortalGUID))
go->SetPhaseMask(1, true);
break;
case EVENT_GOTHIK:
case BOSS_GOTHIK:
if (GameObject* go = instance->GetGameObject(_gothikEnterGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
if (GameObject* go = instance->GetGameObject(_gothikExitGateGUID))
@@ -598,33 +590,25 @@ public:
if (GameObject* go = instance->GetGameObject(_horsemanGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_SAPPHIRON:
case BOSS_SAPPHIRON:
if (GameObject* go = instance->GetGameObject(_sapphironGateGUID))
go->SetGoState(GO_STATE_ACTIVE);
break;
case EVENT_THADDIUS:
case BOSS_THADDIUS:
if (GameObject* go = instance->GetGameObject(_thaddiusPortalGUID))
go->SetPhaseMask(1, true);
break;
case EVENT_HORSEMAN:
case BOSS_HORSEMAN:
if (GameObject* go = instance->GetGameObject(_horsemanPortalGUID))
go->SetPhaseMask(1, true);
break;
}
}
return true;
}
uint32 GetData(uint32 identifier) const
{
switch(identifier)
{
case EVENT_HORSEMAN:
return Encounters[identifier];
}
return 0;
}
void Update(uint32 diff)
void Update(uint32 diff) override
{
if (_speakTimer)
{
@@ -666,7 +650,7 @@ public:
_horsemanTimer += diff;
}
uint64 GetData64(uint32 id) const
uint64 GetData64(uint32 id) const override
{
switch (id)
{
@@ -703,21 +687,18 @@ public:
return 0;
}
std::string GetSaveData()
std::string GetSaveData() override
{
OUT_SAVE_INST_DATA;
std::ostringstream saveStream;
saveStream << "N X X " << Encounters[0] << ' ' << Encounters[1] << ' ' << Encounters[2] << ' ' << Encounters[3]
<< ' ' << Encounters[4] << ' ' << Encounters[5] << ' ' << Encounters[6] << ' ' << Encounters[7]
<< ' ' << Encounters[8] << ' ' << Encounters[9] << ' ' << Encounters[10] << ' ' << Encounters[11]
<< ' ' << Encounters[12] << ' ' << Encounters[13] << ' ' << Encounters[14] << ' ' << immortalAchievement;
saveStream << "N X X " << GetBossSaveData() << ' ' << immortalAchievement;
OUT_SAVE_INST_DATA_COMPLETE;
return saveStream.str();
}
void Load(const char* in)
void Load(const char* in) override
{
if (!in)
{
@@ -735,9 +716,12 @@ public:
{
for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
{
loadStream >> Encounters[i];
if (Encounters[i] == IN_PROGRESS)
Encounters[i] = NOT_STARTED;
uint32 tmpState;
loadStream >> tmpState;
if (tmpState == IN_PROGRESS)
tmpState = NOT_STARTED;
SetBossState(i, EncounterState(tmpState));
}
loadStream >> immortalAchievement;

View File

@@ -7,23 +7,23 @@
#include "ScriptPCH.h"
enum NXEncounter
enum Encouters
{
EVENT_PATCHWERK = 0,
EVENT_GROBBULUS = 1,
EVENT_GLUTH = 2,
EVENT_NOTH = 3,
EVENT_HEIGAN = 4,
EVENT_LOATHEB = 5,
EVENT_ANUB = 6,
EVENT_FAERLINA = 7,
EVENT_MAEXXNA = 8,
EVENT_THADDIUS = 9,
EVENT_RAZUVIOUS = 10,
EVENT_GOTHIK = 11,
EVENT_HORSEMAN = 12,
EVENT_SAPPHIRON = 13,
EVENT_KELTHUZAD = 14,
BOSS_PATCHWERK = 0,
BOSS_GROBBULUS = 1,
BOSS_GLUTH = 2,
BOSS_NOTH = 3,
BOSS_HEIGAN = 4,
BOSS_LOATHEB = 5,
BOSS_ANUB = 6,
BOSS_FAERLINA = 7,
BOSS_MAEXXNA = 8,
BOSS_THADDIUS = 9,
BOSS_RAZUVIOUS = 10,
BOSS_GOTHIK = 11,
BOSS_HORSEMAN = 12,
BOSS_SAPPHIRON = 13,
BOSS_KELTHUZAD = 14,
MAX_ENCOUNTERS,
};