void UpdateAI(const uint32 diff)
    {
        if (pInstance->GetData(TYPE_EVENT_NPC) == NPC_LANATHEL)
        {
            UpdateTimer = pInstance->GetData(TYPE_EVENT_TIMER);
            if (UpdateTimer <= diff)
            {
            debug_log("EventMGR: creature %u received signal %u ",m_creature->GetEntry(),pInstance->GetData(TYPE_EVENT));
            switch (pInstance->GetData(TYPE_EVENT))
                {
                case 800:
                          DoScriptText(-1631301, m_creature);
                          UpdateTimer = 2000;
                          pInstance->SetData(TYPE_EVENT,810);
                          break;
                default:
                          break;
                }
             } else UpdateTimer -= diff;
             pInstance->SetData(TYPE_EVENT_TIMER, UpdateTimer);
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch(stage)
        {
            case 0: 

                    bsw->timedCast(SPELL_SWARMING_SHADOWS, diff);

                    if (bsw->timedQuery(SPELL_TWILIGHT_BLOODBOLT, diff)) bloodbolts = 1;

                    if (bsw->timedQuery(SPELL_DELRIOUS_SLASH, diff))
                        if (Unit* pTarget= m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1))
                            bsw->doCast(SPELL_DELRIOUS_SLASH, pTarget);

                    if (bsw->timedQuery(SPELL_PACT_OF_DARKFALLEN, diff))
                        doPactOfDarkfallen(true);

                    if (bsw->timedQuery(SPELL_VAMPIRIC_BITE,diff))
                        {
                           switch (urand(0,1)) {
                               case 0:
                                      DoScriptText(-1631322,m_creature);
                                      break;
                               case 1:
                                      DoScriptText(-1631323,m_creature);
                                      break;
                               }
                           bsw->doCast(SPELL_VAMPIRIC_BITE);
                        }

                    if (bsw->timedQuery(SPELL_BLOODBOLT_WHIRL,diff))
                        {
                            stage = 1;
                        };

                    doBloodMirror(true);

                    DoMeleeAttackIfReady();

                    break;
            case 1:             // Go in fly phase
                    m_creature->AttackStop();
                    SetCombatMovement(false);
                    StartMovement(1);
                    m_creature->SetUInt32Value(UNIT_FIELD_BYTES_0, 50331648);
                    m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 50331648);
                    m_creature->AddSplineFlag(SPLINEFLAG_FLYING);
                    doBloodMirror(false);
                    stage = 2;
                    break;
            case 2:
                    if (movementstarted) return;
                    DoScriptText(-1631327,m_creature);
                    stage = 3;
                    bsw->doCast(SPELL_BLOODBOLT_WHIRL);
                    return;
            case 3:
                    if (bsw->timedQuery(SPELL_TWILIGHT_BLOODBOLT, diff)) bloodbolts = 5;

                    if (bsw->timedQuery(SPELL_PACT_OF_DARKFALLEN, diff))
                        doPactOfDarkfallen(true);

                    bsw->timedCast(SPELL_SWARMING_SHADOWS, diff);

                    if (bsw->timedQuery(SPELL_BLOODBOLT_WHIRL,diff))
                        {
                            stage = 4;
                            DoScriptText(-1631325,m_creature);
                        };
                    break;
            case 4:             // Go in grownd phase
                    m_creature->AttackStop();
                    StartMovement(0);
                    stage = 5;
                    break;
            case 5:
                    if (movementstarted) return;
                    DoScriptText(-1631325,m_creature);
                    m_creature->SetUInt32Value(UNIT_FIELD_BYTES_0, 0);
                    m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                    m_creature->RemoveSplineFlag(SPLINEFLAG_FLYING);
                    stage = 0;
                    SetCombatMovement(true);
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    return;
            default:
                    break;
        }

        doPactOfDarkfallen(false);

        doMirrorDamage();

        if (bloodbolts > 0)
            {
                bsw->doCast(SPELL_TWILIGHT_BLOODBOLT);
                --bloodbolts;
            };

        if (bsw->timedQuery(SPELL_BERSERK, diff)){
                 bsw->doCast(SPELL_BERSERK);
                 DoScriptText(-1631332,m_creature);
                 };

    }
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            if (!me->HasAura(SPELL_SHROUD_OF_SORROW))
                DoCast(me, SPELL_SHROUD_OF_SORROW);

            if (m_uiPhase == 1)
            {

                if (darkfallened)
                    removePactOfDarkfallen();

                if (m_uiPactofDarkfallenTimer <= uiDiff)
                {
                    doPactOfDarkfallen();
                    m_uiPactofDarkfallenTimer = 30000;

                } else m_uiPactofDarkfallenTimer -= uiDiff;

                if (m_uiBloodMirror <= uiDiff)
                {
                    pMirrorTarget = SelectTarget(SELECT_TARGET_RANDOM);
                    Unit* pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
                    pTarget->CastSpell(pMirrorTarget, SPELL_BLOOD_MIRROR_1, true);
                    m_uiBloodMirror = 32000;
                } else m_uiBloodMirror -= uiDiff;

                if (m_uiSwarmingShadowsTimer < uiDiff)
                {
                    Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                    DoCast(pTarget, SPELL_SWARMING_SHADOWS);
                    m_uiSwarmingShadowsTimer = 30000;
                } else m_uiSwarmingShadowsTimer -= uiDiff;

                if (m_uiTwilightBloodboltTimer < uiDiff)
                {
                    Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                    DoCast(pTarget, SPELL_TWILIGHT_BLOODBOLT);
                    m_uiTwilightBloodboltTimer = 9000;
                } else m_uiTwilightBloodboltTimer -= uiDiff;

                if (m_uiVampBiteTimer < uiDiff)
                {
                    DoScriptText(RAND(SAY_VAMP_BITE_1, SAY_VAMP_BITE_2), me);
                    Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                    DoCast(pTarget, SPELL_VAMPIRIC_BITE);
                    m_uiVampBiteTimer = 45000 + rand()%20000;
                } else m_uiVampBiteTimer -= uiDiff;

                if (m_uiPhaseTimer < uiDiff)
                {
                    DoScriptText(SAY_AIR_PHASE, me);
                    DoCast(me, SPELL_INCITE_TERROR);
                    me->GetMotionMaster()->MovePoint(0, Phase2Position);
                    me->SetReactState(REACT_PASSIVE);
                    me->AttackStop();
                    m_uiPhase = 2;
                    m_uiPhaseTimer = 90000;
                    m_uiSetHoverTimer = 5000;
                    m_uiBloodboldSplashTimer = 10000;
                    m_uiLandingTimer = 26000;
                    m_uiFlyingFalseTimer = 30000;
                } else m_uiPhaseTimer -= uiDiff;
            }

            if (m_uiPhase == 2)
            {
                if (m_uiSetHoverTimer < uiDiff)
                {
                    me->GetMotionMaster()->MovePoint(0, FlyPosition);
                    me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
                    me->SetFlying(true);
                    m_uiSetHoverTimer = 90000;
                } else m_uiSetHoverTimer -= uiDiff;

                if (m_uiBloodboldSplashTimer < uiDiff)
                {
                    std::list<Unit*> pTargets;
                    SelectTargetList(pTargets, 5, SELECT_TARGET_RANDOM, 80, true);
                    for (std::list<Unit*>::const_iterator i = pTargets.begin(); i != pTargets.end(); ++i)
                        DoCast(*i, RAID_MODE(SPELL_TWILIGHT_BLOODBOLT,SPELL_TWILIGHT_BLOODBOLT));
                    m_uiBloodboldSplashTimer = 6000;
                } else m_uiBloodboldSplashTimer -= uiDiff;

                if (m_uiLandingTimer < uiDiff)
                {
                    me->GetMotionMaster()->MovePoint(0, Phase2Position);
                    me->SetUnitMovementFlags(MOVEMENTFLAG_JUMPING);
                    m_uiLandingTimer = 900000;
                    m_uiBloodboldSplashTimer = 900000;
                } else m_uiLandingTimer -= uiDiff;

                if (m_uiFlyingFalseTimer < uiDiff)
                {
                    me->SetFlying(false);
                    me->RemoveAllAuras();
                    me->SetReactState(REACT_AGGRESSIVE);
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    m_uiPhase = 1;
                    m_uiFlyingFalseTimer = 900000;
                } else m_uiFlyingFalseTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }