Exemplo n.º 1
0
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (events.GetEvent())
            {
                case EVENT_BALL_LIGHTNING:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                        me->CastSpell(target, me->GetMap()->IsHeroic() ? SPELL_BALL_LIGHTNING_H : SPELL_BALL_LIGHTNING_N, false);
                    
                    events.RepeatEvent(10000 + rand()%1000);
                    break;
                case EVENT_STATIC_OVERLOAD:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                        me->CastSpell(target, me->GetMap()->IsHeroic() ? SPELL_STATIC_OVERLOAD_H : SPELL_STATIC_OVERLOAD_N, false);

                    events.RepeatEvent(5000 + rand()%1000);
                    break;
                case EVENT_CHECK_HEALTH:
                    if (HealthBelowPct(HealthCheck))
                        me->CastSpell(me, SPELL_DISPERSE, false);

                    events.RepeatEvent(1000);
                    return;
                case EVENT_CALL_SPARKS:
                {
                    EntryCheckPredicate pred(NPC_SPARK_OF_IONAR);
                    summons.DoAction(ACTION_CALLBACK, pred);
                    events.PopEvent();
                    events.ScheduleEvent(EVENT_RESTORE, 2000, 0, 2);
                    return;
                }
                case EVENT_RESTORE:
                    EntryCheckPredicate pred(NPC_SPARK_OF_IONAR);
                    summons.DoAction(ACTION_SPARK_DESPAWN, pred);
                    events.PopEvent();

                    me->SetVisible(true);
                    me->SetControlled(false, UNIT_STATE_STUNNED);
                    ScheduleEvents(true);
                    return;
            }

            DoMeleeAttackIfReady();
        }
Exemplo n.º 2
0
 void ChangePhase()
 {
     if (!phase || phase == PHASE_CHASE)
     {
         phase = PHASE_STRIKE;
         summons.DoAction(EVENT_VOLCANO, 0);
         events.ScheduleEvent(EVENT_HATEFUL_STRIKE, 5000, GCD_CAST, PHASE_STRIKE);
         me->SetSpeed(MOVE_RUN, 1.2f);
         me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
         me->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, false);
     }
     else
     {
         phase = PHASE_CHASE;
         events.ScheduleEvent(EVENT_VOLCANO, 5000, GCD_CAST, PHASE_CHASE);
         events.ScheduleEvent(EVENT_SWITCH_TARGET, 10000, 0, PHASE_CHASE);
         me->SetSpeed(MOVE_RUN, 0.9f);
         me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
         me->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
     }
     DoResetThreat();
     DoZoneInCombat();
     events.SetPhase(phase);
     events.ScheduleEvent(EVENT_SWITCH_PHASE, 60000, GCD_CAST);
 }
 void EnterEvadeMode()
 {
     BossAI::EnterEvadeMode();
     summonsGenerator.DoAction(ACTION_DESPAWN_ALL);
     events2.ScheduleEvent(EVENT_SHADE_RESET_ENCOUNTER, 20000);
     me->SetVisible(false);
     ChannelersAction(ACTION_KILL_CHANNELERS);                   
 }
 void DoAction(int32 param)
 {
     if (param == ACTION_DESPAWN_ADDS)
     {
         summons.DoAction(ACTION_DESPAWN_ADDS);
         summons.DespawnAll();
     }
 }
Exemplo n.º 5
0
		void UpdateAI(uint32 diff)
		{
			if (!UpdateVictim())
				return;

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

			switch (events.GetEvent())
			{
				case EVENT_SUMMON_FERAL_DEFENDER:
					me->MonsterTextEmote("Auriaya begins to activate Feral Defender.", 0, true);
					me->CastSpell(me, SPELL_ACTIVATE_FERAL_DEFENDER, true);
					events.PopEvent();
					me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
					events.ScheduleEvent(EVENT_REMOVE_IMMUNE, 3000);
					break;
				case EVENT_REMOVE_IMMUNE:
					events.PopEvent();
					me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false);
					break;
				case EVENT_TERRIFYING_SCREECH:
					me->MonsterTextEmote("Auriaya begins to cast Terrifying Screech.", 0, true);
					me->CastSpell(me, SPELL_TERRIFYING_SCREECH, false);
					events.RepeatEvent(35000);
					break;
				case EVENT_SONIC_SCREECH:
					me->CastSpell(me, SPELL_SONIC_SCREECH, false);
					events.RepeatEvent(50000);
					break;
				case EVENT_GUARDIAN_SWARM:
					me->CastSpell(me->GetVictim(), SPELL_GUARDIAN_SWARM, false);
					events.RepeatEvent(40000);
					break;
				case EVENT_SENTINEL_BLAST:
					me->CastSpell(me, SPELL_SENTINEL_BLAST, false);
					events.RepeatEvent(35000);
					events.DelayEvents(5000, 0);
					break;
				case EVENT_RESPAWN_FERAL_DEFENDER:
				{
					EntryCheckPredicate pred(NPC_FERAL_DEFENDER);
					summons.DoAction(ACTION_FERAL_RESPAWN, pred);
					events.PopEvent();
					break;
				}
				case EVENT_ENRAGE:
					me->MonsterTextEmote("You waste my time!", 0);
					me->PlayDirectSound(SOUND_BERSERK);
					me->CastSpell(me, SPELL_ENRAGE, true);
					events.PopEvent();
					break;
			}

			DoMeleeAttackIfReady();
		}
Exemplo n.º 6
0
        void Reset()
        {
            for (uint8 i = 0; i < 4; ++i)
            {
                bool good;
                do
                {
                    good = true;
                    RandomUnfreeze[i] = urand(0,3);

                    for (uint8 j = 0; j < i; ++j)
                        if (RandomUnfreeze[i] == RandomUnfreeze[j])
                        {
                            good = false;
                            break;
                        }
                }
                while (!good);
            }

            events.Reset();
            summons.DoAction(ACTION_DESPAWN_ADDS);
            summons.DespawnAll();
            OrbGUID = 0;
            Counter = 0;
            me->CastSpell(me, SPELL_FREEZE, true);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
            me->SetControlled(false, UNIT_STATE_STUNNED);

            if (m_pInstance)
            {
                m_pInstance->SetData(DATA_GORTOK_PALEHOOF, NOT_STARTED);

                // Reset statue
                if (GameObject *statisGenerator = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(STATIS_GENERATOR)))
                {
                    statisGenerator->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
                    statisGenerator->SetGoState(GO_STATE_READY);
                }

                // Reset mini bosses
                for(uint8 i = 0; i < 4; ++i)
                {
                    if(Creature *Animal = ObjectAccessor::GetCreature(*me, m_pInstance->GetData64(DATA_NPC_FRENZIED_WORGEN+i)))
                    {
                        Animal->SetPosition(Animal->GetHomePosition());
                        Animal->StopMovingOnCurrentPos();
                        if(Animal->isDead())
                            Animal->Respawn(true);

                        Animal->CastSpell(Animal, SPELL_FREEZE, true);
                    }
                }
            }
        }
Exemplo n.º 7
0
		void JustDied(Unit *victim)
		{
			if (m_pInstance)
				m_pInstance->SetData(TYPE_AURIAYA, DONE);

			EntryCheckPredicate pred(NPC_FERAL_DEFENDER);
			summons.DoAction(ACTION_DESPAWN_ADDS, pred);
			summons.DespawnAll();
			me->MonsterTextEmote("Auriaya screams in agony.", 0);
			me->PlayDirectSound(SOUND_DEATH);
		}
 void JustDied(Unit* killer)
 {
     BossAI::JustDied(killer);
     summonsGenerator.DoAction(ACTION_DESPAWN_ALL);
     summonsChanneler.DespawnAll();
     me->CastSpell(me, SPELL_SHADE_OF_AKAMA_TRIGGER, true);
     if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE)))
     {
         akama->SetHomePosition(*akama);
         akama->AI()->DoAction(ACTION_SHADE_DIED);
     }
 }
 void DoAction(int32 param)
 {
     if (param == ACTION_START_ENCOUNTER)
     {
         summonsGenerator.DoAction(ACTION_START_ENCOUNTER);
         ChannelersAction(ACTION_START_ENCOUNTER);
         events.ScheduleEvent(EVENT_SHADE_CHECK_DISTANCE, 1000);
     }
     else if (param == ACTION_AKAMA_DIED)
     {
         EnterEvadeMode();
     }
 }
Exemplo n.º 10
0
 void EnterCombat(Unit* /*pWho*/)
 {
     DoScriptText(SAY_AGGRO, me);
     me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
     me->SetInCombatWithZone();
     if (m_pInstance)
         m_pInstance->SetData(TYPE_ANUBARAK, IN_PROGRESS);
     //Despawn Scarab Swarms neutral
     Summons.DoAction(NPC_SCARAB, ACTION_SCARAB_SUBMERGE);
     //Spawn Burrow
     for (int i=0; i < 4; i++)
         me->SummonCreature(NPC_BURROW, AnubarakLoc[i+2]);
     //Spawn Frost Spheres
     for (int i=0; i < 6; i++)
         if (Unit *pSummoned = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i]))
             m_aSphereGUID[i] = pSummoned->GetGUID();
 }
Exemplo n.º 11
0
        void UpdateAI(uint32 diff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            events.Update(diff);

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (events.GetEvent())
            {
                case EVENT_HEAT:
                    me->CastSpell(me, me->GetMap()->IsHeroic() ? SPELL_HEAT_H : SPELL_HEAT_N, true);
                    events.RepeatEvent(8000);
                    break;
                case EVENT_CHECK_HEALTH:
                    if (HealthBelowPct(HealthCheck))
                        GoToAnvil();

                    events.RepeatEvent(1000);
                    return;
                case EVENT_SHATTER:
                {
                    events.RepeatEvent(10000);
                    summons.DoAction(ACTION_SHATTER);
                    break;
                }
                case EVENT_MOVE_TO_ANVIL:
                    GetNextPos();
                    me->GetMotionMaster()->MovePoint(PointID, x, y, z);
                    events.PopEvent();
                    return;
                case EVENT_POSITION:
                    if (me->GetDistance(1331.9f, -106, 56) > 95)
                        EnterEvadeMode();
                    else
                        events.RepeatEvent(4000);
                
                    return;
            }
            
            DoMeleeAttackIfReady();
        }
Exemplo n.º 12
0
		void Reset()
		{
			_feralDied = false;
			_nineLives = false;

			events.Reset();
			EntryCheckPredicate pred(NPC_FERAL_DEFENDER);
			summons.DoAction(ACTION_DESPAWN_ADDS, pred);
			summons.DespawnAll();

			if (m_pInstance)
				m_pInstance->SetData(TYPE_AURIAYA, NOT_STARTED);

			for (uint8 i = 0; i < RAID_MODE(2,4); ++i)
				me->SummonCreature(NPC_SANCTUM_SENTRY, me->GetPositionX()+urand(4,12), me->GetPositionY()+urand(4,12), me->GetPositionZ());
				
			me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false);
		}
Exemplo n.º 13
0
 void EnterCombat(Unit* /*who*/)
 {
     Talk(SAY_AGGRO);
     me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
     me->SetInCombatWithZone();
     if (instance)
         instance->SetData(TYPE_ANUBARAK, IN_PROGRESS);
     //Despawn Scarab Swarms neutral
     EntryCheckPredicate pred(NPC_SCARAB);
     Summons.DoAction(ACTION_SCARAB_SUBMERGE, pred);
     //Spawn Burrow
     for (int i=0; i < 4; i++)
         me->SummonCreature(NPC_BURROW, AnubarakLoc[i+2]);
     //Spawn Frost Spheres
     for (int i=0; i < 6; i++)
         if (Unit* summoned = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i]))
             m_aSphereGUID[i] = summoned->GetGUID();
 }
Exemplo n.º 14
0
        void UpdateAI(uint32 diff)
        {
            // Call speach
            if (timer)
            {
                timer += diff;
                if (timer >= 4000)
                {
                    Talk(SAY_TENEBRON_RESPOND);
                    me->SetCanFly(true);
                    me->SetSpeed(MOVE_FLIGHT, 3.0f);
                    me->GetMotionMaster()->MovePath(me->GetEntry()*10, false);
                    timer = 0;
                }
            }

            if (!UpdateVictim())
                return;

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

            switch (events.GetEvent())
            {
                case EVENT_MINIBOSS_SHADOW_BREATH:
                    if (!urand(0,10))
                        Talk(SAY_TENEBRON_BREATH);
                    me->CastSpell(me->GetVictim(), SPELL_SHADOW_BREATH, false);
                    events.RepeatEvent(17500);
                    break;
                case EVENT_MINIBOSS_SHADOW_FISSURE:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                        me->CastSpell(target, SPELL_SHADOW_FISSURE, false);
                    events.RepeatEvent(22500);
                    break;
                case EVENT_MINIBOSS_OPEN_PORTAL:
                    Talk(WHISPER_OPEN_PORTAL);
                    Talk(SAY_TENEBRON_SPECIAL);
                    
                    if (!isSartharion)
                    {
                        if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[BOSS_TENEBRON_EVENT].GetPositionX(), portalPos[BOSS_TENEBRON_EVENT].GetPositionY(), portalPos[BOSS_TENEBRON_EVENT].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0))
                            portalGUID = Portal->GetGUID();
                    }
                    else if (pInstance)
                        pInstance->SetData(DATA_ADD_PORTAL, 0);

                        
                    events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2000);
                    events.RepeatEvent(60000);
                    break;
                case EVENT_MINIBOSS_SPAWN_HELPERS:
                {
                    Talk(WHISPER_HATCH_EGGS);
                    Creature* cr = NULL;
                    for (uint8 i = 0; i < 6; ++i)
                    {
                        if (cr = me->SummonCreature(NPC_TWILIGHT_EGG, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                        {
                            summons.Summon(cr);
                            cr->SetPhaseMask(16, true);
                        }
                        if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, EggsPos[isSartharion ? i+6 : i].GetPositionX(), EggsPos[isSartharion ? i+6 : i].GetPositionY(), EggsPos[isSartharion ? i+6 : i].GetPositionZ(), EggsPos[isSartharion ? i+6 : i].GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                        {
                            summons.Summon(cr);
                            cr->SetPhaseMask(16, true);
                        }
                    }

                    events.ScheduleEvent(EVENT_MINIBOSS_HATCH_EGGS, 25000);
                    events.PopEvent();
                    break;
                }
                case EVENT_MINIBOSS_HATCH_EGGS:
                {
                    Creature* cr = NULL;
                    summons.RemoveNotExisting();
                    summons.DespawnEntry(NPC_TWILIGHT_WHELP);
                    for (SummonList::iterator i = summons.begin(); i != summons.end(); ++i)
                    {
                        if (cr = ObjectAccessor::GetCreature(*me, *i))
                        {
                            if (!cr->IsAlive())
                                continue;

                            if (cr->GetEntry() == NPC_TWILIGHT_EGG)
                                if (cr = me->SummonCreature(NPC_TWILIGHT_WHELP, cr->GetPositionX(), cr->GetPositionY(), cr->GetPositionZ(), cr->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
                                    summons2.Summon(cr);
                        }
                    }

                    if (!isSartharion)
                    {
                        // Remove phase shift
                        if (InstanceScript* instance = me->GetInstanceScript())
                            instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_SHIFT);

                        RemoveTwilightPortal();
                    }
                    else if (pInstance)
                        pInstance->SetData(DATA_CLEAR_PORTAL, 0);

                    EntryCheckPredicate pred(NPC_TWILIGHT_EGG);
                    summons.DoAction(ACTION_SWITCH_PHASE, pred);
                    events.PopEvent();
                    break;
                }
            }

            DoMeleeAttackIfReady();
        }
Exemplo n.º 15
0
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (m_uiStage)
            {
                case 0:
                    if (m_uiFreezeSlashTimer <= uiDiff)
                    {
                        DoCastVictim(SPELL_FREEZE_SLASH);
                        m_uiFreezeSlashTimer = 15*IN_MILLISECONDS;
                    } else m_uiFreezeSlashTimer -= uiDiff;

                    if (m_uiPenetratingColdTimer <= uiDiff)
                    {
                        me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5));
                        m_uiPenetratingColdTimer = 20*IN_MILLISECONDS;
                    } else m_uiPenetratingColdTimer -= uiDiff;

                    if (m_uiSummonNerubianTimer <= uiDiff && (IsHeroic() || !m_bReachedPhase3))
                    {
                        me->CastCustomSpell(SPELL_SUMMON_BURROWER, SPELLVALUE_MAX_TARGETS, RAID_MODE(1, 2, 2, 4));
                        m_uiSummonNerubianTimer = 45*IN_MILLISECONDS;
                    } else m_uiSummonNerubianTimer -= uiDiff;

                    if (IsHeroic() && m_uiNerubianShadowStrikeTimer <= uiDiff)
                    {
                        EntryCheckPredicate pred(NPC_BURROWER);
                        Summons.DoAction(ACTION_SHADOW_STRIKE, pred);
                        m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
                    } else m_uiNerubianShadowStrikeTimer -= uiDiff;

                    if (m_uiSubmergeTimer <= uiDiff && !m_bReachedPhase3 && !me->HasAura(SPELL_BERSERK))
                    {
                        m_uiStage = 1;
                        m_uiSubmergeTimer = 60*IN_MILLISECONDS;
                    } else m_uiSubmergeTimer -= uiDiff;
                    break;
                case 1:
                    DoCast(me, SPELL_SUBMERGE_ANUBARAK);
                    DoCast(me, SPELL_CLEAR_ALL_DEBUFFS);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
                    DoScriptText(SAY_BURROWER, me);
                    m_uiScarabSummoned = 0;
                    m_uiSummonScarabTimer = 4*IN_MILLISECONDS;
                    m_uiStage = 2;
                    break;
                case 2:
                    if (m_uiPursuingSpikeTimer <= uiDiff)
                    {
                        DoCast(SPELL_SPIKE_CALL);
                        // Just to make sure it won't happen again in this phase
                        m_uiPursuingSpikeTimer = 90*IN_MILLISECONDS;
                    } else m_uiPursuingSpikeTimer -= uiDiff;

                    if (m_uiSummonScarabTimer <= uiDiff)
                    {
                        /* WORKAROUND
                         * - The correct implementation is more likely the comment below but it needs spell knowledge
                         */
                        std::list<uint64>::iterator i = m_vBurrowGUID.begin();
                        uint32 at = urand(0, m_vBurrowGUID.size()-1);
                        for (uint32 k = 0; k < at; k++)
                            ++i;
                        if (Creature* pBurrow = Unit::GetCreature(*me, *i))
                            pBurrow->CastSpell(pBurrow, 66340, false);
                        m_uiScarabSummoned++;
                        m_uiSummonScarabTimer = 4*IN_MILLISECONDS;
                        if (m_uiScarabSummoned == 4) m_uiSummonScarabTimer = RAID_MODE(4, 20)*IN_MILLISECONDS;

                        /*It seems that this spell have something more that needs to be taken into account
                        //Need more sniff info
                        DoCast(SPELL_SUMMON_BEATLES);
                        // Just to make sure it won't happen again in this phase
                        m_uiSummonScarabTimer = 90*IN_MILLISECONDS;*/
                    } else m_uiSummonScarabTimer -= uiDiff;

                    if (m_uiSubmergeTimer <= uiDiff)
                    {
                        m_uiStage = 3;
                        m_uiSubmergeTimer = 80*IN_MILLISECONDS;
                    } else m_uiSubmergeTimer -= uiDiff;
                    break;
                case 3:
                    m_uiStage = 0;
                    DoCast(SPELL_SPIKE_TELE);
                    Summons.DespawnEntry(NPC_SPIKE);
                    me->RemoveAurasDueToSpell(SPELL_SUBMERGE_ANUBARAK);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
                    DoCast(me, SPELL_EMERGE_ANUBARAK);
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    m_uiSummonNerubianTimer = 10*IN_MILLISECONDS;
                    m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
                    m_uiSummonScarabTimer = 2*IN_MILLISECONDS;
                    break;
            }

            if (!IsHeroic())
            {
                if (m_uiSummonFrostSphereTimer <= uiDiff)
                {
                    uint8 startAt = urand(0, 5);
                    uint8 i = startAt;
                    do
                    {
                        if (Unit* pSphere = Unit::GetCreature(*me, m_aSphereGUID[i]))
                        {
                            if (!pSphere->HasAura(SPELL_FROST_SPHERE))
                            {
                                if (Creature* summon = me->SummonCreature(NPC_FROST_SPHERE, SphereSpawn[i]))
                                    m_aSphereGUID[i] = summon->GetGUID();
                                break;
                            }
                        }
                        i = (i+1)%6;
                    } while (i != startAt);
                    m_uiSummonFrostSphereTimer = urand(20, 30)*IN_MILLISECONDS;
                } else m_uiSummonFrostSphereTimer -= uiDiff;
            }

            if (HealthBelowPct(30) && m_uiStage == 0 && !m_bReachedPhase3)
            {
                m_bReachedPhase3 = true;
                DoCastAOE(SPELL_LEECHING_SWARM);
                DoScriptText(EMOTE_LEECHING_SWARM, me);
                DoScriptText(SAY_LEECHING_SWARM, me);
            }

            if (m_uiBerserkTimer <= uiDiff && !me->HasAura(SPELL_BERSERK))
            {
                DoCast(me, SPELL_BERSERK);
            } else m_uiBerserkTimer -= uiDiff;

            DoMeleeAttackIfReady();
        }
            void UpdateAI(uint32 diff)
            {
                events2.Update(diff);
                switch (events2.ExecuteEvent())
                {
                    case EVENT_SHADE_GATHER_NPCS:
                    {
                        std::list<Creature*> ChannelerList;
                        me->GetCreaturesWithEntryInRange(ChannelerList, 100.0f, NPC_ASHTONGUE_CHANNELER);
                        for (std::list<Creature*>::const_iterator itr = ChannelerList.begin(); itr != ChannelerList.end(); ++itr)
                            summonsChanneler.Summon(*itr);

                        std::list<Creature*> SpawnerList;
                        me->GetCreaturesWithEntryInRange(SpawnerList, 100.0f, NPC_CREATURE_GENERATOR_AKAMA);
                        for (std::list<Creature*>::const_iterator itr = SpawnerList.begin(); itr != SpawnerList.end(); ++itr)
                            summonsGenerator.Summon(*itr);

                        summonsChanneler.Respawn();
                        summonsGenerator.Respawn();
                        ChannelersAction(ACTION_CHANNELERS_START_CHANNEL);
                        
                        if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE)))
                            akama->Respawn(true);
                        break;
                    }
                    case EVENT_SHADE_RESET_ENCOUNTER:
                        me->SetVisible(true);
                        summonsGenerator.Respawn();
                        summonsChanneler.Respawn();
                        ChannelersAction(ACTION_CHANNELERS_START_CHANNEL);

                        if (Creature* akama = ObjectAccessor::GetCreature(*me, instance->GetData64(NPC_AKAMA_SHADE)))
                            akama->Respawn(true);
                        break;
                }

                if (!UpdateVictim())
                    return;

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

                switch (events.ExecuteEvent())
                {
                    case EVENT_SHADE_CHECK_DISTANCE:
                        if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
                        {
                            int32 slow = me->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED);
                            if (slow > -100)
                            {
                                me->SetWalk(true);
                                me->GetMotionMaster()->MovePoint(POINT_START, 510.0f, 400.7993f, 112.7837f);
                            }
                        }
                        else
                        {
                            int32 slow = me->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED);
                            if (slow < -100)
                                me->GetMotionMaster()->Clear();
                            else if (slow == 0)
                            {
                                summonsGenerator.DoAction(ACTION_NO_SORCERERS);
                                me->SetWalk(false);
                            }
                        }

                        if (me->IsWithinMeleeRange(me->GetVictim()))
                        {
                            me->SetReactState(REACT_AGGRESSIVE);
                            DoResetThreat();
                            me->GetVictim()->InterruptNonMeleeSpells(false);
                            me->AddThreat(me->GetVictim(), 1000000.0f);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC|UNIT_FLAG_NOT_SELECTABLE);
                            summonsGenerator.DoAction(ACTION_STOP_SPAWNING);
                            break;
                        }
                        events.ScheduleEvent(EVENT_SHADE_CHECK_DISTANCE, 1000);
                        break;
                }

                DoMeleeAttackIfReady();
                EnterEvadeIfOutOfCombatArea();
            }