void JustDied(Unit* pKiller)
        {
            RespawnDragons(true);
            summons.DespawnEntry(NPC_FLAME_TSUNAMI);
            Talk(SAY_SARTHARION_DEATH);

            if (pInstance)
                pInstance->SetData(BOSS_SARTHARION_EVENT, DONE);
        }
Esempio n. 2
0
 void EnterPhase(uint32 NextPhase)
 {
     switch(NextPhase)
     {
     case 0:
         break;
     case 1:
     case 2:
     case 3:
     case 4:
         DoTeleportTo(CENTER_X, CENTER_Y, CENTER_Z, 100);
         DoResetThreat();
         me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, 0);
         me->RemoveAurasDueToSpell(Transform[Phase].unaura);
         DoCast(me, Transform[Phase].spell);
         me->MonsterYell(Transform[Phase].text, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(me, Transform[Phase].sound);
         if (Phase > 0)
         {
             if (Unit *Temp = Unit::GetUnit(*me, SpiritGUID[Phase - 1]))
                 Temp->SetUInt32Value(UNIT_FIELD_BYTES_1,UNIT_STAND_STATE_DEAD);
         }
         if (Unit *Temp = Unit::GetUnit(*me, SpiritGUID[NextPhase - 1]))
             Temp->CastSpell(me, SPELL_SIPHON_SOUL, false); // should m cast on temp
         if (NextPhase == 2)
         {
             me->GetMotionMaster()->Clear();
             DoCast(me, SPELL_ENERGY_STORM, true); // enemy aura
             for (uint8 i = 0; i < 4; ++i)
             {
                 Creature* Vortex = DoSpawnCreature(CREATURE_FEATHER_VORTEX, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                 if (Vortex)
                 {
                     Vortex->CastSpell(Vortex, SPELL_CYCLONE_PASSIVE, true);
                     Vortex->CastSpell(Vortex, SPELL_CYCLONE_VISUAL, true);
                     Vortex->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                     Vortex->SetSpeed(MOVE_RUN, 1.0f);
                     Vortex->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
                     DoZoneInCombat(Vortex);
                 }
             }
         }
         else
             me->AI()->AttackStart(me->getVictim());
         if (NextPhase == 3)
         {
             me->RemoveAurasDueToSpell(SPELL_ENERGY_STORM);
             Summons.DespawnEntry(CREATURE_FEATHER_VORTEX);
             me->GetMotionMaster()->MoveChase(me->getVictim());
         }
         break;
     default:
         break;
     }
     Phase = NextPhase;
 }
Esempio n. 3
0
            void JustDied(Unit* /*killer*/)
            {
                if (instance)
                    instance->SetData(DATA_ZULJINEVENT, DONE);

                Talk(YELL_DEATH);
                Summons.DespawnEntry(CREATURE_COLUMN_OF_FIRE);

                if (Unit* Temp = Unit::GetUnit(*me, SpiritGUID[3]))
                    Temp->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_DEAD);
            }
Esempio n. 4
0
            void JustDied(Unit* /*Killer*/)
            {
                if (pInstance)
                    pInstance->SetData(DATA_ZULJINEVENT, DONE);

                me->MonsterYell(YELL_DEATH, LANG_UNIVERSAL, NULL);
                DoPlaySoundToSet(me, SOUND_DEATH);
                Summons.DespawnEntry(CREATURE_COLUMN_OF_FIRE);

                if (Unit *Temp = Unit::GetUnit(*me, SpiritGUID[3]))
                    Temp->SetUInt32Value(UNIT_FIELD_BYTES_1,UNIT_STAND_STATE_DEAD);
            }
        void DoAction(int32 action)
        {
            if (action == ACTION_REPENTANCE_DONE)
            {
                lSummons.DespawnEntry(NPC_SOUL_FRAGMENT);

                for (SummonList::const_iterator itr = lSummons.begin(); itr != lSummons.end(); ++itr)
					if (Creature* pSummon = ObjectAccessor::GetCreature(*me, (*itr)))
                        if (pSummon->GetEntry() == NPC_REPENTANCE_MIRROR && pSummon->IsAIEnabled)
                            pSummon->AI()->DoAction(ACTION_REPENTANCE_DONE);
                    
                events.ScheduleEvent(EVENT_REPENTANCE, 1500, 0, PHASE_REPENTANCE);
            }
        }
        inline void ResetWeapon()
        {
            events.Reset();
            Summons.DespawnEntry(NPC_TWILIGHT_ARCHER);

            me->RemoveAura(SPELL_FLAMING_SHIELD);
            me->RemoveAura(SPELL_PERSONAL_PHALANX);

            me->RemoveAura(SPELL_DUAL_BLADES_BUFF);
            me->RemoveAura(SPELL_TRASH_BUFF);

            me->RemoveAura(SPELL_LAVA_PATCH);
            me->RemoveAura(SPELL_ENCUMBERED);

        }
Esempio n. 7
0
        void EnterCombat(Unit* /*who*/) override
        {
            Talk(SAY_AGGRO);

            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);

            Phase = FLYING;

            m_uiMovementTimer = 1000;
            m_uiSummonTimer = 10000;
            me->SetInCombatWithZone();
            instance->SetBossState(DATA_SKADI_THE_RUTHLESS, IN_PROGRESS);
            instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
            me->GetMotionMaster()->MoveJump(Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 5.0f, 10.0f);
            me->SetWalk(false);
            m_uiMountTimer = 1000;
            Summons.DespawnEntry(NPC_GRAUF);
        }
Esempio n. 8
0
        inline void ResetWeapon()
        {
            events.Reset();
            Summons.DespawnEntry(NPC_TWILIGHT_ARCHER);

            me->ModifyAuraState(AURA_STATE_UNKNOWN22, false);
            me->InterruptNonMeleeSpells(false, SPELL_PARALAX_TARGET);

            me->RemoveAura(SPELL_SHIELD_VISUAL);
            me->RemoveAura(SPELL_FLAMING_SHIELD);
            me->RemoveAura(SPELL_PERSONAL_PHALANX);

            me->RemoveAura(SPELL_DUAL_BLADES_BUFF);
            me->RemoveAura(SPELL_TRASH_BUFF);
            me->RemoveAura(SPELL_BURNING_FLAMES);

            me->RemoveAura(SPELL_ENCUMBERED);
        }
Esempio n. 9
0
        void EnterCombat(Unit* /*who*/)
        {
            DoScriptText(SAY_AGGRO, me);

            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);

            Phase = FLYING;

            m_uiMovementTimer = 1000;
            m_uiSummonTimer = 10000;
            me->SetInCombatWithZone();
            if (m_instance)
            {
                m_instance->SetData(DATA_SKADI_THE_RUTHLESS_EVENT, IN_PROGRESS);
                m_instance->DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_EVENT, ACHIEV_TIMED_START_EVENT);
                me->GetMotionMaster()->MoveJump(Location[0].GetPositionX(), Location[0].GetPositionY(), Location[0].GetPositionZ(), 5.0f, 10.0f);
                me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
                m_uiMountTimer = 1000;
                Summons.DespawnEntry(CREATURE_GRAUF);
            }
        }
Esempio n. 10
0
        void updateai(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (me->HasUnitState(UNIT_STATE_CASTING))
                if (!me->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
                    return;

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                case EVENT_MODULATION:
                    DoCast(me, SPELL_MODULATION);
                    events.ScheduleEvent(EVENT_MODULATION, urand(18000, 22000));
                    break;
                case EVENT_FLY:
                    me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                    me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
                    events.Reset();
                    SetCombatMovement(false);
                    me->SetCanFly(true);
                    me->GetMotionMaster()->MovePoint(1, flyPos);
                    break;
                case EVENT_GROUND:
                    me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                    me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
                    me->CastStop();
                    summons.DespawnEntry(NPC_ROARING_FLAME_TARGET);
                    me->RemoveAurasDueToSpell(SPELL_SONAR_FIREBALL_T);
                    events.Reset();
                    me->GetMotionMaster()->MovePoint(2, groundPos);
                    break;
                case EVENT_NEXT_SPELL:
                    //За одну фазу будет скастовано 7 скиллов
                    if (nextspell > 7)
                        break;
                    switch (nextspell)
                    {
                    case 0:
                    case 2:
                    case 5:
                    case 7:
                        for (uint8 i = 0; i < 3; i++)
                            me->SummonCreature(NPC_SONAR_PULSE,
                                me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0.0f);
                        break;
                    case 1:
                    case 3:
                    case 6:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true))
                        {
                            me->SummonCreature(NPC_TRACKING_FLAMES,
                                target->GetPositionX(), target->GetPositionY(),
                                target->GetPositionZ(), me->GetOrientation(),
                                TEMPSUMMON_TIMED_DESPAWN, 8000);
                        }
                        break;
                    case 4:
                        Talk(SAY_FLAME);
                        DoCast(SPELL_SEARING_FLAME_1);
                        DoCast(SPELL_SEARING_FLAME);
                        break;
                    }
                    nextspell++;
                    events.ScheduleEvent(EVENT_NEXT_SPELL, 10000);
                    break;
                case EVENT_SONAR_FIREBALL:
                    me->CastSpell(me, SPELL_SONAR_FIREBALL, true);
                    events.ScheduleEvent(EVENT_SONAR_FIREBALL, 10000);
                    break;
                case EVENT_SONAR_BOMB:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                        me->CastSpell(target, SPELL_SONAR_BOMB, true);
                    events.ScheduleEvent(EVENT_SONAR_BOMB, 2000);
                    break;
                case EVENT_ROARING_FLAME:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                    {
                        atramedesTarget = target;
                        me->SummonCreature(NPC_ROARING_FLAME_TARGET,
                            target->GetPositionX() + urand(5,9),
                            target->GetPositionY() + urand(5,9),
                            target->GetPositionZ());
                    }
                    break;
                }
            }
            DoMeleeAttackIfReady();
        }
        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();
        }
Esempio n. 12
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();
        }
Esempio n. 13
0
		void UpdateAI(uint32 diff)
		{
			if( !UpdateVictim() )
				return;

			events.Update(diff);

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

			if( !bPhase3 && HealthBelowPct(30) && !me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && !me->HasAura(SPELL_SUBMERGE) && !me->HasAura(SPELL_EMERGE) )
			{
				bPhase3 = true;
				events.CancelEvent(EVENT_SUBMERGE);
				events.CancelEvent(EVENT_EMERGE);
				events.CancelEvent(EVENT_EMERGE_2);
				if( !IsHeroic() )
					events.CancelEvent(EVENT_SUMMON_NERUBIAN);
				me->CastSpell((Unit*)NULL, SPELL_LEECHING_SWARM, false);
				Talk(EMOTE_LEECHING_SWARM);
				Talk(SAY_LEECHING_SWARM);
				return;
			}

			switch( events.GetEvent() )
			{
				case 0:
					break;
				case EVENT_ENRAGE:
					{
						me->CastSpell(me, SPELL_BERSERK, true);
						events.PopEvent();
					}
					break;
				case EVENT_RESPAWN_SPHERE:
					{
						uint8 StartAt = urand(0,5);
						uint8 i = StartAt;
						do
						{
							if( Creature* c = ObjectAccessor::GetCreature(*me, SphereGUID[i]) )
								if( !c->HasAura(SPELL_FROST_SPHERE) )
								{
									if( Creature* c = me->SummonCreature(NPC_FROST_SPHERE, AnubLocs[i+5]) )
										SphereGUID[i] = c->GetGUID();
									break;
								}
							i = (i+1)%6;
						}
						while( i != StartAt );
						events.RepeatEvent(4000);
					}
					break;
				case EVENT_SPELL_FREEZING_SLASH:
					{
						if( me->GetVictim() )
							me->CastSpell(me->GetVictim(), SPELL_FREEZING_SLASH, false);
						events.RepeatEvent(urand(15000,20000));
					}
					break;
				case EVENT_SPELL_PENETRATING_COLD:
					{
						me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2,5,2,5));
						events.RepeatEvent(18000);
					}
					break;
				case EVENT_SUMMON_NERUBIAN:
					{
						me->CastCustomSpell(SPELL_SUMMON_BURROWER, SPELLVALUE_MAX_TARGETS, RAID_MODE(1,2,2,4));
						events.RepeatEvent(45000);
					}
					break;
				case EVENT_SUBMERGE:
					{
						me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
						bool berserk = me->HasAura(SPELL_BERSERK);
						me->RemoveAllAuras();
						if (berserk)
							me->CastSpell(me, SPELL_BERSERK, true);
						Talk(EMOTE_SUBMERGE);
						Talk(EMOTE_BURROWER);
						me->CastSpell(me, SPELL_SUBMERGE, false);
						events.CancelEvent(EVENT_SUMMON_NERUBIAN);
						events.CancelEvent(EVENT_SPELL_FREEZING_SLASH);
						events.CancelEvent(EVENT_SPELL_PENETRATING_COLD);
						events.RescheduleEvent(EVENT_EMERGE, EMERGE_INTERVAL);
						events.RescheduleEvent(EVENT_SPELL_SUMMON_SPIKE, 2500);
						events.RescheduleEvent(EVENT_SUMMON_SCARAB, 3000);
						events.PopEvent();
					}
					break;
				case EVENT_SUMMON_SCARAB:
					{
						uint8 i = urand(0,3);
						if( Creature* c = ObjectAccessor::GetCreature(*me, BurrowGUID[i]) )
							me->CastSpell(c, SPELL_SUMMON_SCARAB, true);
						events.RepeatEvent(4000);
					}
					break;
				case EVENT_EMERGE:
					{
						me->CastSpell(me, SPELL_SPIKE_TELE, true);
						summons.DespawnEntry(NPC_SPIKE);
						events.CancelEvent(EVENT_SUMMON_SCARAB);
						events.RescheduleEvent(EVENT_EMERGE_2, 2000);
						events.PopEvent();
					}
					break;
				case EVENT_EMERGE_2:
					{
						Talk(SAY_EMERGE);
						me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
						me->setAttackTimer(BASE_ATTACK, 3000);
						me->RemoveAura(SPELL_SUBMERGE);
						me->CastSpell(me, SPELL_EMERGE, false);
						events.RescheduleEvent(EVENT_SUMMON_NERUBIAN, urand(5000,8000));
						events.RescheduleEvent(EVENT_SPELL_FREEZING_SLASH, urand(7000,15000));
						events.RescheduleEvent(EVENT_SPELL_PENETRATING_COLD, urand(15000,20000));
						events.RescheduleEvent(EVENT_SUBMERGE, SUBMERGE_INTERVAL);
						events.PopEvent();
					}
					break;
				case EVENT_SPELL_SUMMON_SPIKE:
					me->CastSpell(me, SPELL_SUMMON_SPIKE, true);
					events.PopEvent();
					break;
			}

			DoMeleeAttackIfReady();
		}
Esempio n. 14
0
        void UpdateAI(uint32 diff)
        {
            events.Update(diff);

            switch (events.ExecuteEvent())
            {
                case EVENT_SPAWN:
                    {
                        if (Creature* Dalfors = DoSummon(NPC_CRUSADER_LORD_DALFORS, DalforsPos[0]))
                        {
                            guidDalfors = Dalfors->GetGUID();
                            Dalfors->GetMotionMaster()->MovePoint(0, DalforsPos[1]);
                        }
                        if (Creature* Priest1 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest1Pos[0]))
                        {
                            guidPriest[0] = Priest1->GetGUID();
                            Priest1->GetMotionMaster()->MovePoint(0, Priest1Pos[1]);
                        }
                        if (Creature* Priest2 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest2Pos[0]))
                        {
                            guidPriest[1] = Priest2->GetGUID();
                            Priest2->GetMotionMaster()->MovePoint(0, Priest2Pos[1]);
                        }
                        if (Creature* Priest3 = DoSummon(NPC_ARGENT_BATTLE_PRIEST, Priest3Pos[0]))
                        {
                            guidPriest[2] = Priest3->GetGUID();
                            Priest3->GetMotionMaster()->MovePoint(0, Priest3Pos[1]);
                        }
                        if (Creature* Mason1 = DoSummon(NPC_ARGENT_MASON, Mason1Pos[0]))
                        {
                            guidMason[0] = Mason1->GetGUID();
                            Mason1->GetMotionMaster()->MovePoint(0, Mason1Pos[1]);
                        }
                        if (Creature* Mason2 = DoSummon(NPC_ARGENT_MASON, Mason2Pos[0]))
                        {
                            guidMason[1] = Mason2->GetGUID();
                            Mason2->GetMotionMaster()->MovePoint(0, Mason2Pos[1]);
                        }
                        if (Creature* Mason3 = DoSummon(NPC_ARGENT_MASON, Mason3Pos[0]))
                        {
                            guidMason[2] = Mason3->GetGUID();
                            Mason3->GetMotionMaster()->MovePoint(0, Mason3Pos[1]);
                        }
                        events.ScheduleEvent(EVENT_INTRO_1, 15000);
                    }
                    break;
                case EVENT_INTRO_1:
                    {
                        if (Creature* Dalfors = me->GetCreature(*me, guidDalfors))
                            Dalfors->AI()->Talk(DALFORS_SAY_PRE_1);
                        events.ScheduleEvent(EVENT_INTRO_2, 5000);
                    }
                    break;
                case EVENT_INTRO_2:
                    {
                        if (Creature* Dalfors = me->GetCreature(*me, guidDalfors))
                        {
                            Dalfors->SetFacingTo(6.215f);
                            Dalfors->AI()->Talk(DALFORS_SAY_PRE_2);
                        }
                    events.ScheduleEvent(EVENT_INTRO_3, 5000);
                    }
                    break;
                case EVENT_INTRO_3:
                    {
                        if (Creature* Dalfors = me->GetCreature(*me, guidDalfors))
                        {
                            Dalfors->GetMotionMaster()->MovePoint(0, DalforsPos[2]);
                            Dalfors->SetHomePosition(DalforsPos[2]);
                        }
                        if (Creature* Priest1 = me->GetCreature(*me, guidPriest[0]))
                        {
                            Priest1->SetFacingTo(5.7421f);
                            Priest1->SetHomePosition(Priest1Pos[1]);
                        }
                        if (Creature* Priest2 = me->GetCreature(*me, guidPriest[1]))
                        {
                            Priest2->SetFacingTo(5.7421f);
                            Priest2->SetHomePosition(Priest2Pos[1]);
                        }
                        if (Creature* Priest3 = me->GetCreature(*me, guidPriest[2]))
                        {
                            Priest3->SetFacingTo(5.7421f);
                            Priest3->SetHomePosition(Priest3Pos[1]);
                        }
                        if (Creature* Mason1 = me->GetCreature(*me, guidMason[0]))
                        {
                            Mason1->GetMotionMaster()->MovePoint(0, Mason1Pos[2]);
                            Mason1->SetHomePosition(Mason1Pos[2]);
                        }
                        if (Creature* Mason2 = me->GetCreature(*me, guidMason[1]))
                        {
                            Mason2->GetMotionMaster()->MovePoint(0, Mason2Pos[2]);
                            Mason2->SetHomePosition(Mason2Pos[2]);
                        }
                        if (Creature* Mason3 = me->GetCreature(*me, guidMason[2]))
                        {
                            Mason3->GetMotionMaster()->MovePoint(0, Mason3Pos[2]);
                            Mason3->SetHomePosition(Mason3Pos[2]);
                        }
                        events.ScheduleEvent(EVENT_START_FIGHT, 5000);
                        events.ScheduleEvent(EVENT_MASON_ACTION, 15000);
                    }
                    break;
                case EVENT_MASON_ACTION:
                    {
                        if (Creature* Mason1 = me->GetCreature(*me, guidMason[0]))
                        {
                            Mason1->SetFacingTo(2.8972f);
                            Mason1->AI()->SetData(1, 1); // triggers SAI actions on npc
                        }
                        if (Creature* Mason2 = me->GetCreature(*me, guidMason[1]))
                        {
                            Mason2->SetFacingTo(3.1241f);
                            Mason2->AI()->SetData(1, 1); // triggers SAI actions on npc
                        }
                        if (Creature* Mason3 = me->GetCreature(*me, guidMason[2]))
                        {
                            Mason3->SetFacingTo(3.6651f);
                            Mason3->AI()->SetData(1, 1); // triggers SAI actions on npc
                        }
                    }
                    break;
                case EVENT_START_FIGHT:
                    {
                        if (Creature* LK = GetClosestCreatureWithEntry(me, NPC_LK, 100))
                            LK->AI()->Talk(LK_TALK_1);
                        if (Creature* Dalfors = me->GetCreature(*me, guidDalfors))
                            Dalfors->AI()->Talk(DALFORS_SAY_START);
                        events.ScheduleEvent(EVENT_WAVE_SPAWN, 1000);
                    }
                    break;
                case EVENT_WAVE_SPAWN:
                    {
                        if (PhaseCount == 3)
                        {
                            if (Creature* LK = GetClosestCreatureWithEntry(me, NPC_LK, 100))
                                LK->AI()->Talk(LK_TALK_2);
                        }
                        else if (PhaseCount == 6)
                        {
                            if (Creature* LK = GetClosestCreatureWithEntry(me, NPC_LK, 100))
                                LK->AI()->Talk(LK_TALK_3);
                        }
                        if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE, Mason3Pos[0]))
                            {
                                tempsum->SetHomePosition(DalforsPos[2]);
                                tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                            }
                        if (urand(0, 1) == 0)
                        {
                            if (Creature* tempsum = DoSummon(NPC_HIDEOUS_PLAGEBRINGER, Mason1Pos[0]))
                            {
                                tempsum->SetHomePosition(DalforsPos[2]);
                                tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                            }
                            if (Creature* tempsum = DoSummon(NPC_HIDEOUS_PLAGEBRINGER, Mason2Pos[0]))
                            {
                                tempsum->SetHomePosition(DalforsPos[2]);
                                tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                            }
                        }
                        else
                        {
                            if (Creature* tempsum = DoSummon(NPC_REANIMATED_CAPTAIN, Mason1Pos[0]))
                            {
                                tempsum->SetHomePosition(DalforsPos[2]);
                                tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                            }
                            if (Creature* tempsum = DoSummon(NPC_REANIMATED_CAPTAIN, Mason2Pos[0]))
                            {
                                tempsum->SetHomePosition(DalforsPos[2]);
                                tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                            }
                        }

                        PhaseCount++;

                        if (PhaseCount < 8)
                            events.ScheduleEvent(EVENT_WAVE_SPAWN, urand(10000, 20000));
                        else
                            events.ScheduleEvent(EVENT_HALOF, urand(10000, 20000));
                    }
                    break;
                case EVENT_HALOF:
                    {
                        if (Creature* LK = GetClosestCreatureWithEntry(me, NPC_LK, 100))
                            LK->AI()->Talk(LK_TALK_4);
                        if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE, Mason1Pos[0]))
                        {
                            tempsum->SetHomePosition(DalforsPos[2]);
                            tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                        }
                        if (Creature* tempsum = DoSummon(NPC_SCOURGE_DRUDGE, Mason2Pos[0]))
                        {
                            tempsum->SetHomePosition(DalforsPos[2]);
                            tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                        }
                        if (Creature* tempsum = DoSummon(NPC_HALOF_THE_DEATHBRINGER, DalforsPos[0]))
                        {
                            HalofSpawned = true;
                            guidHalof = tempsum->GetGUID();
                            tempsum->SetHomePosition(DalforsPos[2]);
                            tempsum->AI()->AttackStart(GetClosestCreatureWithEntry(me, NPC_BLESSED_BANNER, 100));
                        }
                    }
                    break;
                case EVENT_ENDED:
                    {
                        Summons.DespawnAll();
                        me->DespawnOrUnsummon();
                    }
                    break;
            }

            if (PhaseCount == 8)
                if (Creature* Halof = me->GetCreature(*me, guidHalof))
                    if (Halof->isDead())
                    {
                        DoCast(me, SPELL_CRUSADERS_SPIRE_VICTORY, true);
                        Summons.DespawnEntry(NPC_HIDEOUS_PLAGEBRINGER);
                        Summons.DespawnEntry(NPC_REANIMATED_CAPTAIN);
                        Summons.DespawnEntry(NPC_SCOURGE_DRUDGE);
                        Summons.DespawnEntry(NPC_HALOF_THE_DEATHBRINGER);
                        if (Creature* Dalfors = me->GetCreature(*me, guidDalfors))
                            Dalfors->AI()->Talk(DALFORS_YELL_FINISHED);
                        events.ScheduleEvent(EVENT_ENDED, 10000);
                    }
        }
Esempio n. 15
0
            void UpdateAI(uint32 const diff)
            {
                if (!intro)
                {
                    me->SummonCreature(NPC_SLIPPERY_FLOOR, SummonPositions[0]); // floor ambient
                    me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
                    me->SetReactState(REACT_AGGRESSIVE);
                    intro = true;
                }

                if (!UpdateVictim())
                    return;

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SWITCH_PHASE:
                            if (events.GetPhaseMask() & PHASE_MASK_ONE)
                            {
                                // Emote: Ahune retreats. His defenses diminish.
                                //                                 me->MonsterTextEmote(EMOTE_SUBMERGE, 0, true); //Hack Fix by jacob


                                events.SetPhase(PHASE_TWO);
                                events.ScheduleEvent(EVENT_SWITCH_PHASE, 30000);

                                DoCast(me, SPELL_MAKE_BONFIRE);

                                me->AttackStop();
                                me->SetReactState(REACT_PASSIVE);
                                me->setFaction(35);
                                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED);
                                me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE);

                                me->SummonCreature(NPC_FROZEN_CORE, SummonPositions[0], TEMPSUMMON_CORPSE_DESPAWN);
                            }
                            else
                            {
                                events.SetPhase(PHASE_ONE);
                                events.ScheduleEvent(EVENT_SWITCH_PHASE, 90000);
                                events.ScheduleEvent(EVENT_COLD_SLAP, 500, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_HAILSTONE, 1000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, 8000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, 9000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_ICE_SPEAR, 9500, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_EARTHEN_RING_ATTACK, 10000, 0, PHASE_ONE);

                                me->SetReactState(REACT_AGGRESSIVE);
                                me->setFaction(14);
                                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
                                me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);

                                DoCastVictim(SPELL_RESURFACE);

                                summons.DespawnEntry(NPC_FROZEN_CORE);
                            }
                            break;
                        case EVENT_COLD_SLAP:
                            if (Unit* target = SelectTarget(SELECT_TARGET_NEAREST, 0, 8.0f, true))
                            {
                                DoCast(target, SPELL_COLD_SLAP);
                                Position targetPos;
                                target->GetNearPosition(targetPos, float(rand_norm()) * 5.0f + 35.0f, me->GetAngle(target));
                                target->GetMotionMaster()->MoveJump(targetPos.GetPositionX(), targetPos.GetPositionY(), targetPos.GetPositionZ(), target->GetExactDist2d(targetPos.GetPositionX(), targetPos.GetPositionY()), 10.0f);
                            }
                            events.ScheduleEvent(EVENT_COLD_SLAP, 500, 0, PHASE_ONE);
                            break;
                        case EVENT_ICE_SPEAR: 
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120.0f, true))
                            {
                                target->CastSpell(target, SPELL_ICESPEAR_SUMMON_BUNNY);
                                target->CastSpell(target, SPELL_ICESPEAR_SUMMON_GO);
                                events.ScheduleEvent(EVENT_ICE_SPEAR_KNOCKBACK, 2000);
                            }
                            events.ScheduleEvent(EVENT_ICE_SPEAR, 7000, 0, PHASE_ONE);
                            break;
                        case EVENT_ICE_SPEAR_KNOCKBACK:
                            if (GameObject* go = me->FindNearestGameObject(GO_ICE_SPEAR, 120.0f))
                            {
                                go->UseDoorOrButton();
                                Map::PlayerList const& playerList = me->GetMap()->GetPlayers();
                                if (!playerList.isEmpty())
                                    for (Map::PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
                                        if (i->getSource() && go->GetDistance(i->getSource()) <= 2.0f)
                                            i->getSource()->CastSpell(i->getSource(), SPELL_ICESPEAR_KNOCKBACK);
                                go->Delete();
                            }
                            break;
                        case EVENT_SUMMON_HAILSTONE:
                            me->SummonCreature(NPC_AHUNITE_HAILSTONE, SummonPositions[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            break;
                        case EVENT_SUMMON_COLDWEAVE: 
                            me->SummonCreature(NPC_AHUNITE_COLDWEAVE, SummonPositions[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            me->SummonCreature(NPC_AHUNITE_COLDWEAVE, SummonPositions[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, 5000, 0, PHASE_ONE);
                            break;
                        case EVENT_SUMMON_FROSTWIND: 
                            me->SummonCreature(NPC_AHUNITE_FROSTWIND, SummonPositions[urand(2,3)], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, 7000, 0, PHASE_ONE);
                            break;
                        case EVENT_EARTHEN_RING_ATTACK:
                            if (Creature* totem = me->FindNearestCreature(NPC_EARTHEN_RING_TOTEM, 200.0f))
                            {
                                totem->CastSpell(me, SPELL_BEAM_ATTACK, false);
                                totem->CastSpell(me, SPELL_BEAM_ATTACK_BEAM, false);
                            }
                            events.ScheduleEvent(EVENT_EARTHEN_RING_ATTACK, 10000, 0, PHASE_ONE);
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
Esempio n. 16
0
            void UpdateAI(uint32 diff)
            {
                if (!intro)
                {
                    me->SummonCreature(NPC_SLIPPERY_FLOOR, SummonPositions[0]); // floor ambient
                    me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
                    me->SetReactState(REACT_AGGRESSIVE);
                    intro = true;
                }

                if (!UpdateVictim())
                    return;

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SWITCH_PHASE:
                            if (events.GetPhaseMask() & PHASE_ONE)
                            {
                                // Emote: Ahune retreats. His defenses diminish.
                                me->TextEmote(EMOTE_SUBMERGE, 0, true);


                                events.SetPhase(PHASE_TWO);
                                events.ScheduleEvent(EVENT_SWITCH_PHASE, 40000);
                                events.ScheduleEvent(EVENT_GHOST_VISUAL, 10000);
                                events.ScheduleEvent(EVENT_GHOST_VISUAL, 20000);
                                events.ScheduleEvent(EVENT_GHOST_VISUAL, 30000);

                                me->CastSpell(me, SPELL_MAKE_BONFIRE);

                                // Handle Submerge. This is essentially a copy of how Ragnaros submerges... :) minus the threatwipe
                                me->AttackStop();
                                me->SetReactState(REACT_PASSIVE);
                                me->setFaction(35);
                                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                me->RemoveAurasDueToSpell(SPELL_AHUNES_SHIELD);
                                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED);
                                me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE);

                                // spawn core
                                me->SummonCreature(NPC_FROZEN_CORE, SummonPositions[0], TEMPSUMMON_CORPSE_DESPAWN);
                            }
                            else
                            {
                                events.SetPhase(PHASE_ONE);
                                events.ScheduleEvent(EVENT_SWITCH_PHASE, 95000);
                                events.ScheduleEvent(EVENT_COLD_SLAP, 500, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_HAILSTONE, 1000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, 8000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, 9000, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_ICE_SPEAR, 9500, 0, PHASE_ONE);
                                events.ScheduleEvent(EVENT_EARTHEN_RING_ATTACK, 10000, 0, PHASE_ONE);

                                me->SetReactState(REACT_AGGRESSIVE);
                                me->RestoreFaction();
                                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
                                me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
                                me->AddAura(SPELL_AHUNES_SHIELD, me);

                                me->CastSpell(me, SPELL_RESURFACE, true);

                                // despawn core
                                summons.DespawnEntry(NPC_FROZEN_CORE);
                            }
                            break;
                        case EVENT_COLD_SLAP:
                            if (Unit* target = SelectTarget(SELECT_TARGET_NEAREST, 0, 8.0f, true))
                            {
                                DoCast(target, SPELL_COLD_SLAP);
                                Position targetPos = target->GetNearPosition(float(rand_norm()) * 5.0f + 35.0f, me->GetAngle(target));
                                //target->GetNearPosition(targetPos, float(rand_norm()) * 5.0f + 35.0f, me->GetAngle(target));
                                target->GetMotionMaster()->MoveJump(targetPos.GetPositionX(), targetPos.GetPositionY(), targetPos.GetPositionZ(), target->GetExactDist2d(targetPos.GetPositionX(), targetPos.GetPositionY()), 10.0f);
                            }
                            events.ScheduleEvent(EVENT_COLD_SLAP, 500, 0, PHASE_ONE);
                            break;
                        case EVENT_ICE_SPEAR: // FIXME: should make use of all the proper spells...
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 120.0f, true))
                            {
                                target->CastSpell(target, SPELL_ICESPEAR_SUMMON_BUNNY);
                                target->CastSpell(target, SPELL_ICESPEAR_SUMMON_GO);
                                events.ScheduleEvent(EVENT_ICE_SPEAR_KNOCKBACK, 2000);
                            }
                            events.ScheduleEvent(EVENT_ICE_SPEAR, 7000, 0, PHASE_ONE);
                            break;
                        case EVENT_ICE_SPEAR_KNOCKBACK:
                            if (GameObject* go = me->FindNearestGameObject(GO_ICE_SPEAR, 200.0f))
                            {
                                go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
                                go->UseDoorOrButton();
                                Map::PlayerList const& playerList = me->GetMap()->GetPlayers();
                                if (!playerList.isEmpty())
                                    for (Map::PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i)
                                        if (i->GetSource() && go->GetDistance(i->GetSource()) <= 2.0f)
                                            i->GetSource()->CastSpell(i->GetSource(), SPELL_ICESPEAR_KNOCKBACK);
                                go->Delete();
                            }
                            break;
                        case EVENT_SUMMON_HAILSTONE:
                            me->SummonCreature(NPC_AHUNITE_HAILSTONE, SummonPositions[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            break;
                        case EVENT_SUMMON_COLDWEAVE: // they always come in pairs of two
                            me->SummonCreature(NPC_AHUNITE_COLDWEAVE, SummonPositions[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            me->SummonCreature(NPC_AHUNITE_COLDWEAVE, SummonPositions[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            events.ScheduleEvent(EVENT_SUMMON_COLDWEAVE, 5000, 0, PHASE_ONE);
                            break;
                        case EVENT_SUMMON_FROSTWIND: // not in first phase 1
                            me->SummonCreature(NPC_AHUNITE_FROSTWIND, SummonPositions[urand(2,3)], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);
                            events.ScheduleEvent(EVENT_SUMMON_FROSTWIND, 7000, 0, PHASE_ONE);
                            break;
                        case EVENT_EARTHEN_RING_ATTACK:
                            if (Creature* totem = me->FindNearestCreature(NPC_EARTHEN_RING_TOTEM, 200.0f))
                            {
                                totem->CastSpell(me, SPELL_BEAM_ATTACK, false);
                                totem->CastSpell(me, SPELL_BEAM_ATTACK_BEAM, false);
                            }
                            events.ScheduleEvent(EVENT_EARTHEN_RING_ATTACK, 10000, 0, PHASE_ONE);
                            break;
                        case EVENT_GHOST_VISUAL:
                            if (Creature* ghost = me->SummonCreature(NPC_AHUNE_GHOST, SummonPositions[0], TEMPSUMMON_TIMED_DESPAWN, 3000))
                                ghost->CastSpell(ghost, SPELL_GHOST_VISUAL);
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }