void JustDied(Unit* /*pKiller*/) override
    {
        DoScriptText(SAY_DEATH, m_creature);

        if (m_pInstance)
            m_pInstance->SetData(TYPE_ANUBARAK, DONE);
    }
 void JustReachedHome() override
 {
     if (m_pInstance)
     {
         if (m_pInstance->GetData(TYPE_FACTION_CHAMPIONS) != FAIL)
             m_pInstance->SetData(TYPE_FACTION_CHAMPIONS, FAIL);
     }
 }
    void Aggro(Unit* /*pWho*/) override
    {
        DoScriptText(SAY_AGGRO, m_creature);
        DoCastSpellIfCan(m_creature, SPELL_SURGE_OF_LIGHT);

        if (m_pInstance && m_pInstance->GetData(TYPE_TWIN_VALKYR) != IN_PROGRESS)
            m_pInstance->SetData(TYPE_TWIN_VALKYR, IN_PROGRESS);
    }
    void JustDied(Unit* /*pKiller*/) override
    {
        DoScriptText(SAY_DEATH, m_creature);

        if (m_pInstance && m_pInstance->GetData(TYPE_TWIN_VALKYR) != DONE)
            m_pInstance->SetData(TYPE_TWIN_VALKYR, DONE);

        DoCastSpellIfCan(m_creature, SPELL_CLEAR_VALKYR_ESSENCE, CAST_TRIGGERED);
        DoCastSpellIfCan(m_creature, SPELL_CLEAR_VALKYR_TOUCH, CAST_TRIGGERED);
    }
 void Aggro(Unit* pWho) override
 {
     if (m_pInstance)
     {
         if (m_pInstance->GetData(TYPE_FACTION_CHAMPIONS) != IN_PROGRESS)
         {
             m_pInstance->SetData(TYPE_FACTION_CHAMPIONS, IN_PROGRESS);
             m_pInstance->DoSetCrusadersInCombat(pWho);
         }
     }
 }
    void EnterEvadeMode() override
    {
        if (m_pInstance && m_pInstance->GetData(TYPE_TWIN_VALKYR) != FAIL)
            m_pInstance->SetData(TYPE_TWIN_VALKYR, FAIL);

        DoCastSpellIfCan(m_creature, SPELL_CLEAR_VALKYR_ESSENCE, CAST_TRIGGERED);
        DoCastSpellIfCan(m_creature, SPELL_CLEAR_VALKYR_TOUCH, CAST_TRIGGERED);

        // cleanup handled by creature linking
        m_creature->ForcedDespawn();
    }
    void EnterEvadeMode() override
    {
        if (m_pInstance)
            m_pInstance->SetData(TYPE_NORTHREND_BEASTS, FAIL);

        for (uint8 i = 0; i < 4; ++i)
        {
            if (Creature* pBoss = m_creature->GetMap()->GetCreature(m_aSummonedBossGuid[i]))
                pBoss->ForcedDespawn();
        }

        m_creature->ForcedDespawn();
    }
    void SummonedCreatureJustDied(Creature* pSummoned) override
    {
        if (!m_pInstance)
            return;

        switch (pSummoned->GetEntry())
        {
            case NPC_GORMOK:
                if (m_uiPhase == PHASE_GORMOK)
                    DoSummonNextBeast(NPC_DREADSCALE);
                break;

            case NPC_DREADSCALE:
            case NPC_ACIDMAW:
                if (m_bFirstWormDied && m_uiPhase == PHASE_WORMS)
                {
                    DoSummonNextBeast(NPC_ICEHOWL);

                    // cast achiev spell if timer is still running
                    if (m_uiWormAchievTimer)
                    {
                        m_creature->CastSpell(m_creature, SPELL_JORMUNGAR_ACHIEV_CREDIT, TRIGGERED_OLD_TRIGGERED);
                        m_uiWormAchievTimer = 0;
                    }
                }
                else
                {
                    m_bFirstWormDied = true;

                    // jormungar brother enrages
                    if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(pSummoned->GetEntry() == NPC_ACIDMAW ? NPC_DREADSCALE : NPC_ACIDMAW))
                    {
                        pWorm->CastSpell(pWorm, SPELL_JORMUNGAR_ENRAGE, TRIGGERED_OLD_TRIGGERED);
                        DoScriptText(EMOTE_JORMUNGAR_ENRAGE, pWorm);
                        m_uiWormAchievTimer = 10000;
                    }
                }
                break;

            case NPC_ICEHOWL:
                m_pInstance->SetData(TYPE_NORTHREND_BEASTS, DONE);
                m_creature->ForcedDespawn();
                break;
        }
    }
    void Aggro(Unit* /*pWho*/) override
    {
        DoScriptText(SAY_AGGRO, m_creature);

        // Summon the spheres on random points
        for (uint8 i = 0; i < MAX_FROSTSPHERES; ++i)
        {
            if (Creature* pTemp = m_creature->SummonCreature(NPC_FROSTSPHERE, aFrostSphereSpawnPositions[i][0], aFrostSphereSpawnPositions[i][1], aFrostSphereSpawnPositions[i][2], 0, TEMPSUMMON_DEAD_DESPAWN, 0))
                m_vSpheresGuidVector[i] = pTemp->GetObjectGuid();
        }

        // It's not clear if these should be spawned by DB or summoned
        for (uint8 i = 0; i < MAX_BURROWS; ++i)
            m_creature->SummonCreature(NPC_BURROW, aBurrowSpawnPositions[i][0], aBurrowSpawnPositions[i][1], aBurrowSpawnPositions[i][2], aBurrowSpawnPositions[i][3], TEMPSUMMON_DEAD_DESPAWN, 0);

        if (m_pInstance)
            m_pInstance->SetData(TYPE_ANUBARAK, IN_PROGRESS);
    }
 void Aggro(Unit* /*pWho*/) override
 {
     if (m_pInstance)
         m_pInstance->SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS);
 }
 void JustReachedHome() override
 {
     if (m_pInstance)
         m_pInstance->SetData(TYPE_ANUBARAK, FAIL);
 }