// Boss has an interesting speech before killed, so we need to fake death (without stand state) and allow him to finish his theatre
    void DamageTaken(Unit* /*pKiller*/, uint32& uiDamage, DamageEffectType /*damagetype*/) override
    {
        if (uiDamage < m_creature->GetHealth())
            return;

        // Make sure it won't die by accident
        if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
        {
            uiDamage = 0;
            return;
        }

        uiDamage = 0;
        RemoveGravityLapse();
        StartNextDialogueText(SAY_DEATH);
        m_creature->HandleEmote(EMOTE_STATE_TALK);

        m_creature->InterruptNonMeleeSpells(true);
        m_creature->SetHealth(1);
        m_creature->StopMoving();
        m_creature->ClearComboPointHolders();
        m_creature->RemoveAllAurasOnDeath();
        m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false);
        m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false);
        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
        m_creature->ClearAllReactives();
        m_creature->GetMotionMaster()->Clear();
        m_creature->GetMotionMaster()->MoveIdle();
    }
Esempio n. 2
0
    void JustDied(Unit *killer)
    {
		RemoveGravityLapse();
        DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL);
        DoPlaySoundToSet(m_creature,SOUND_DEATH);
		if(pInstance)
			pInstance->SetData(DATA_KAELTHAS_EVENT, DONE);
    }
Esempio n. 3
0
	void EnterEvadeMode()
	{
		RemoveGravityLapse();
		m_creature->InterruptNonMeleeSpells(true);
		m_creature->RemoveAllAuras();
		m_creature->DeleteThreatList();
		m_creature->CombatStop();
		m_creature->LoadCreaturesAddon();

		if( m_creature->isAlive() )
			m_creature->GetMotionMaster()->MoveTargetedHome();

		m_creature->SetLootRecipient(NULL);

		InCombat = false;
		Reset();
	}
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch(Phase)
        {
            case 0:
            {
                // *Heroic mode only:
                if (!m_bIsRegularMode)
                {
                    if (PyroblastTimer < diff)
                    {
                        m_creature->InterruptSpell(CURRENT_CHANNELED_SPELL);
                        m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
                        DoCastSpellIfCan(m_creature, SPELL_SHOCK_BARRIER, CAST_TRIGGERED);
                        DoCastSpellIfCan(m_creature->getVictim(), SPELL_PYROBLAST);
                        PyroblastTimer = 60000;
						FireballTimer += 6000;
						FlameStrikeTimer += 6000;
                    }else PyroblastTimer -= diff;
                }

                if (FireballTimer < diff)
                {
                    DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FIREBALL_NORMAL : SPELL_FIREBALL_HEROIC);
                    FireballTimer = urand(2000, 6000);
                }else FireballTimer -= diff;

                if (PhoenixTimer < diff)
                {

                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1))
                    {
                        uint32 random = urand(1, 2);
                        float x = KaelLocations[random][0];
                        float y = KaelLocations[random][1];

                        if (Creature* Phoenix = m_creature->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000))
                        {
                            Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
                            SetThreatList(Phoenix);
                            Phoenix->AI()->AttackStart(pTarget);
                            DoScriptText(SAY_PHOENIX, m_creature);
                        }
                    }

                    PhoenixTimer = 60000;
                }else PhoenixTimer -= diff;

                if (FlameStrikeTimer < diff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        if (m_creature->IsNonMeleeSpellCasted(false))
                            m_creature->InterruptNonMeleeSpells(false);

                        DoCastSpellIfCan(pTarget, SPELL_FLAME_STRIKE);
                        DoScriptText(SAY_FLAMESTRIKE, m_creature);
                    }
                    FlameStrikeTimer = urand(15000, 25000);
                }else FlameStrikeTimer -= diff;

                // Below 50%
                if (m_creature->GetHealth() * 2 < m_creature->GetMaxHealth())
                {
                    m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                    m_creature->StopMoving();
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();
                    GravityLapseTimer = 0;
                    GravityLapsePhase = 0;
                    Phase = 1;
                }

                DoMeleeAttackIfReady();
            }
            break;

            case 1:
            {
                if (GravityLapseTimer < diff)
                {
                    switch(GravityLapsePhase)
                    {
                        case 0:
                            if (FirstGravityLapse)          // Different yells at 50%, and at every following Gravity Lapse
                            {
                                DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                FirstGravityLapse = false;

                                if (m_pInstance)
                                {
                                    if (GameObject* pKaelLeft = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(DATA_KAEL_STATUE_LEFT)))
                                        pKaelLeft->SetGoState(GO_STATE_ACTIVE);

                                    if (GameObject* pKaelRight = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(DATA_KAEL_STATUE_RIGHT)))
                                        pKaelRight->SetGoState(GO_STATE_ACTIVE);
                                }
                            }
                            else
                            {
                                DoScriptText(SAY_RECAST_GRAVITY, m_creature);
                            }

                            DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_INITIAL);
                            GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell
                            GravityLapsePhase = 1;
                            break;

                        case 1:
                            TeleportPlayersToSelf();
                            GravityLapseTimer = 1000;
                            GravityLapsePhase = 2;
                            break;

                        case 2:
                            CastGravityLapseKnockUp();
                            GravityLapseTimer = 1000;
                            GravityLapsePhase = 3;
                            break;

                        case 3:
                            CastGravityLapseFly();
                            GravityLapseTimer = 30000;
                            GravityLapsePhase = 4;


                            for(uint8 i = 0; i < 3; ++i)
                            {
                                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                                {
                                    if (Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000))
                                        Orb->AI()->AttackStart(pTarget);
                                }
                            }

                            DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL);
                            break;

                        case 4:
                            m_creature->InterruptNonMeleeSpells(false);
                            DoScriptText(SAY_TIRED, m_creature);
                            DoCastSpellIfCan(m_creature, SPELL_POWER_FEEDBACK);
                            RemoveGravityLapse();
                            GravityLapseTimer = 10000;
                            GravityLapsePhase = 0;
                            break;
                    }
                }else GravityLapseTimer -= diff;
            }
            break;
        }
    }
 void DamageTaken(Unit* done_by, uint32 &damage)
 {
     if (damage > m_creature->GetHealth())
         RemoveGravityLapse();                           // Remove Gravity Lapse so that players fall to ground if they kill him when in air.
 }
Esempio n. 6
0
        void UpdateAI(uint32 diff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            switch (Phase)
            {
                case 0:
                {
                    // *Heroic mode only:
                    if (IsHeroic())
                    {
                        if (PyroblastTimer <= diff)
                        {
                            me->InterruptSpell(CURRENT_CHANNELED_SPELL);
                            me->InterruptSpell(CURRENT_GENERIC_SPELL);
                            DoCast(me, SPELL_SHOCK_BARRIER, true);
                            DoCast(me->getVictim(), SPELL_PYROBLAST);
                            PyroblastTimer = 60000;
                        } else PyroblastTimer -= diff;
                    }

                    if (FireballTimer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_FIREBALL_NORMAL);
                        FireballTimer = urand(2000, 6000);
                    } else FireballTimer -= diff;

                    if (PhoenixTimer <= diff)
                    {
                        Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);

                        uint8 random = urand(1, 2);
                        float x = KaelLocations[random][0];
                        float y = KaelLocations[random][1];

                        Creature* Phoenix = me->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
                        if (Phoenix)
                        {
                            Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
                            SetThreatList(Phoenix);
                            Phoenix->AI()->AttackStart(target);
                        }

                        Talk(SAY_PHOENIX);

                        PhoenixTimer = 60000;
                    } else PhoenixTimer -= diff;

                    if (FlameStrikeTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        {
                            me->InterruptSpell(CURRENT_CHANNELED_SPELL);
                            me->InterruptSpell(CURRENT_GENERIC_SPELL);
                            DoCast(target, SPELL_FLAMESTRIKE3, true);
                            Talk(SAY_FLAMESTRIKE);
                        }
                        FlameStrikeTimer = urand(15000, 25000);
                    } else FlameStrikeTimer -= diff;

                    // Below 50%
                    if (HealthBelowPct(50))
                    {
                        me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                        me->StopMoving();
                        me->GetMotionMaster()->Clear();
                        me->GetMotionMaster()->MoveIdle();
                        GravityLapseTimer = 0;
                        GravityLapsePhase = 0;
                        Phase = 1;
                    }

                    DoMeleeAttackIfReady();
                }
                break;

                case 1:
                {
                    if (GravityLapseTimer <= diff)
                    {
                        switch (GravityLapsePhase)
                        {
                            case 0:
                                if (FirstGravityLapse)          // Different yells at 50%, and at every following Gravity Lapse
                                {
                                    Talk(SAY_GRAVITY_LAPSE);
                                    FirstGravityLapse = false;

                                    if (instance)
                                        instance->SetData(DATA_KAELTHAS_STATUES, 1);
                                }
                                else
                                    Talk(SAY_RECAST_GRAVITY);

                                DoCast(me, SPELL_GRAVITY_LAPSE_INITIAL);
                                GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell
                                GravityLapsePhase = 1;
                                break;

                            case 1:
                                TeleportPlayersToSelf();
                                GravityLapseTimer = 1000;
                                GravityLapsePhase = 2;
                                break;

                            case 2:
                                CastGravityLapseKnockUp();
                                GravityLapseTimer = 1000;
                                GravityLapsePhase = 3;
                                break;

                            case 3:
                                CastGravityLapseFly();
                                GravityLapseTimer = 30000;
                                GravityLapsePhase = 4;

                                for (uint8 i = 0; i < 3; ++i)
                                {
                                    Unit* target = NULL;
                                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);

                                    Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                                    if (Orb && target)
                                    {
                                        Orb->SetSpeed(MOVE_RUN, 0.5f);
                                        Orb->AddThreat(target, 1000000.0f);
                                        Orb->AI()->AttackStart(target);
                                    }
                                }

                                DoCast(me, SPELL_GRAVITY_LAPSE_CHANNEL);
                                break;

                            case 4:
                                me->InterruptNonMeleeSpells(false);
                                Talk(SAY_TIRED);
                                DoCast(me, SPELL_POWER_FEEDBACK);
                                RemoveGravityLapse();
                                GravityLapseTimer = 10000;
                                GravityLapsePhase = 0;
                                break;
                        }
                    } else GravityLapseTimer -= diff;
                }
                break;
            }
        }
    void UpdateAI(const uint32 uiDiff)
    {
        DialogueUpdate(uiDiff);

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

        // Don't use spells during the epilogue
        if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
            return;

        if (m_bIsFirstPhase)
        {
            // *Heroic mode only:
            if (!m_bIsRegularMode)
            {
                if (m_uiShockBarrierTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SHOCK_BARRIER) == CAST_OK)
                    {
                        m_uiPyroblastTimer = 1000;
                        m_uiShockBarrierTimer = 60000;
                    }
                }
                else
                    m_uiShockBarrierTimer -= uiDiff;

                if (m_uiPyroblastTimer)
                {
                    if (m_uiPyroblastTimer <= uiDiff)
                    {
                        if (DoCastSpellIfCan(m_creature, SPELL_PYROBLAST) == CAST_OK)
                            m_uiPyroblastTimer = 0;
                    }
                    else
                        m_uiPyroblastTimer -= uiDiff;
                }
            }

            if (m_uiFireballTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_FIREBALL : SPELL_FIREBALL_H) == CAST_OK)
                        m_uiFireballTimer = urand(2000, 4000);
                }
            }
            else
                m_uiFireballTimer -= uiDiff;

            if (m_uiPhoenixTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_PHOENIX) == CAST_OK)
                {
                    DoScriptText(SAY_PHOENIX, m_creature);
                    m_uiPhoenixTimer = 45000;
                }
            }
            else
                m_uiPhoenixTimer -= uiDiff;

            if (m_uiFlameStrikeTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_FLAME_STRIKE) == CAST_OK)
                    {
                        DoScriptText(SAY_FLAMESTRIKE, m_creature);
                        m_uiFlameStrikeTimer = urand(15000, 25000);
                    }
                }
            }
            else
                m_uiFlameStrikeTimer -= uiDiff;

            // Below 50%
            if (m_creature->GetHealthPercent() < 50.0f)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_TELEPORT_CENTER, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    SetCombatMovement(false);
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();

                    m_bIsFirstPhase = false;
                }
            }

            DoMeleeAttackIfReady();
        }
        else
        {
            if (m_uiGravityLapseTimer < uiDiff)
            {
                switch (m_uiGravityLapseStage)
                {
                    case 0:
                        // Cast Gravity Lapse on Players
                        if (DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE) == CAST_OK)
                        {
                            if (m_bFirstGravityLapse)
                            {
                                DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                m_bFirstGravityLapse = false;
                            }
                            else
                                DoScriptText(SAY_RECAST_GRAVITY, m_creature);

                            m_uiGravityLapseTimer = 2000;
                            m_uiGravityIndex = 0;
                            ++m_uiGravityLapseStage;
                        }
                        break;
                    case 1:
                        // Summon spheres and apply the Gravity Lapse visual - upon visual expire, the gravity lapse is removed
                        if (DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_VISUAL) == CAST_OK)
                        {
                            for (uint8 i = 0; i < MAX_ARCANE_SPHERES; ++i)
                                DoCastSpellIfCan(m_creature, SPELL_ARCANE_SPHERE_SUMMON, CAST_TRIGGERED);

                            m_uiGravityLapseTimer = 30000;
                            ++m_uiGravityLapseStage;
                        }
                        break;
                    case 2:
                        // Cast Power Feedback and stay stunned for 10 secs - also break the statues if they are not broken
                        if (DoCastSpellIfCan(m_creature, SPELL_POWER_FEEDBACK) == CAST_OK)
                        {
                            DoScriptText(SAY_TIRED, m_creature);
                            RemoveGravityLapse();
                            m_uiGravityLapseTimer = 10000;
                            m_uiGravityLapseStage = 0;
                        }
                        break;
                }
            }
            else
                m_uiGravityLapseTimer -= uiDiff;
        }
    }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch (m_uiPhase)
        {
            case 0:
            {
                // *Heroic mode only:
                if (!m_bIsRegularMode)
                {
                    if (m_uiPyroblastTimer < uiDiff)
                    {
                        m_creature->InterruptSpell(CURRENT_CHANNELED_SPELL);
                        m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
                        DoCastSpellIfCan(m_creature, SPELL_SHOCK_BARRIER, CAST_TRIGGERED);
                        DoCastSpellIfCan(m_creature->getVictim(), SPELL_PYROBLAST);
                        m_uiPyroblastTimer = 60000;
                    }
                    else
                        m_uiPyroblastTimer -= uiDiff;
                }

                if (m_uiFireballTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FIREBALL : SPELL_FIREBALL_H) == CAST_OK)
                        m_uiFireballTimer = urand(2000, 6000);
                }
                else
                    m_uiFireballTimer -= uiDiff;

                if (m_uiPhoenixTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_PHOENIX) == CAST_OK)
                    {
                        DoScriptText(SAY_PHOENIX, m_creature);
                        m_uiPhoenixTimer = 60000;
                    }
                }
                else
                    m_uiPhoenixTimer -= uiDiff;

                if (m_uiFlameStrikeTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        DoCastSpellIfCan(pTarget, SPELL_FLAME_STRIKE, CAST_INTERRUPT_PREVIOUS);
                        DoScriptText(SAY_FLAMESTRIKE, m_creature);
                    }
                    m_uiFlameStrikeTimer = urand(15000, 25000);
                }
                else
                    m_uiFlameStrikeTimer -= uiDiff;

                // Below 50%
                if (m_creature->GetHealthPercent() < 50.0f)
                {
                    m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                    m_creature->StopMoving();
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();
                    m_uiGravityLapseTimer = 0;
                    m_uiGravityLapsePhase = 0;
                    m_uiPhase = 1;

                    return;
                }

                DoMeleeAttackIfReady();

                break;
            }
            case 1:
            {
                if (m_uiGravityLapseTimer < uiDiff)
                {
                    switch (m_uiGravityLapsePhase)
                    {
                        case 0:
                            if (m_bFirstGravityLapse)       // Different yells at 50%, and at every following Gravity Lapse
                            {
                                DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                m_bFirstGravityLapse = false;

                                if (m_pInstance)
                                {
                                    if (GameObject* pKaelLeft = m_pInstance->GetSingleGameObjectFromStorage(GO_KAEL_STATUE_LEFT))
                                        pKaelLeft->SetGoState(GO_STATE_ACTIVE);

                                    if (GameObject* pKaelRight =  m_pInstance->GetSingleGameObjectFromStorage(GO_KAEL_STATUE_RIGHT))
                                        pKaelRight->SetGoState(GO_STATE_ACTIVE);
                                }
                            }
                            else
                            {
                                DoScriptText(SAY_RECAST_GRAVITY, m_creature);
                            }

                            DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_INITIAL);
                            m_uiGravityLapseTimer = 2000 + uiDiff;// Don't interrupt the visual spell
                            m_uiGravityLapsePhase = 1;
                            break;

                        case 1:
                            TeleportPlayersToSelf();
                            m_uiGravityLapseTimer = 1000;
                            m_uiGravityLapsePhase = 2;
                            break;

                        case 2:
                            CastGravityLapseKnockUp();
                            m_uiGravityLapseTimer = 1000;
                            m_uiGravityLapsePhase = 3;
                            break;

                        case 3:
                            CastGravityLapseFly();
                            m_uiGravityLapseTimer = 30000;
                            m_uiGravityLapsePhase = 4;

                            for(uint8 i = 0; i < 3; ++i)
                            {
                                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                                {
                                    if (Creature* Orb = DoSpawnCreature(NPC_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000))
                                        Orb->AI()->AttackStart(pTarget);
                                }
                            }

                            DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL);
                            break;

                        case 4:
                            m_creature->InterruptNonMeleeSpells(false);
                            DoScriptText(SAY_TIRED, m_creature);
                            DoCastSpellIfCan(m_creature, SPELL_POWER_FEEDBACK);
                            RemoveGravityLapse();
                            m_uiGravityLapseTimer = 10000;
                            m_uiGravityLapsePhase = 0;
                            break;
                    }
                }
                else
                    m_uiGravityLapseTimer -= uiDiff;

                break;
            }
        }
    }
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!UpdateVictim())
            return;

        switch(Phase)
        {
            case 0:
            {
                // *Heroic mode only:
                if (Heroic)
                {
                    if (PyroblastTimer < diff)
                    {
                        DoCast(m_creature, SPELL_SHOCK_BARRIER, true);
                        DoCast(m_creature->getVictim(), SPELL_PYROBLAST);
                        PyroblastTimer = 60000;
                    }else PyroblastTimer -= diff;
                }

                if (FireballTimer < diff)
                {
                    DoCast(m_creature->getVictim(), Heroic ? SPELL_FIREBALL_HEROIC : SPELL_FIREBALL_NORMAL);
                    FireballTimer = 2000 + rand()%4000;
                }else FireballTimer -= diff;

                if (PhoenixTimer < diff)
                {

                    Unit* target = NULL;
                    target = SelectUnit(SELECT_TARGET_RANDOM,1);

                    uint32 random = rand()%2 + 1;
                    float x = KaelLocations[random][0];
                    float y = KaelLocations[random][1];

                    Creature* Phoenix = m_creature->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
                    if (Phoenix)
                    {
                        Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
                        SetThreatList(Phoenix);
                        Phoenix->AI()->AttackStart(target);
                    }

                    DoScriptText(SAY_PHOENIX, m_creature);

                    PhoenixTimer = 60000;
                }else PhoenixTimer -= diff;

                if (FlameStrikeTimer < diff)
                {
                    if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        DoCast(target, SPELL_FLAMESTRIKE3, true);
                        DoScriptText(SAY_FLAMESTRIKE, m_creature);
                    }
                    FlameStrikeTimer = 15000 + rand()%10000;
                }else FlameStrikeTimer -= diff;

                // Below 50%
                if (m_creature->GetMaxHealth() * 0.5 > m_creature->GetHealth())
                {
                    m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                    m_creature->StopMoving();
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();
                    GravityLapseTimer = 0;
                    GravityLapsePhase = 0;
                    Phase = 1;
                }

                DoMeleeAttackIfReady();
            }
            break;

            case 1:
            {
                if (GravityLapseTimer < diff)
                {
                    switch(GravityLapsePhase)
                    {
                        case 0:
                            if (FirstGravityLapse)          // Different yells at 50%, and at every following Gravity Lapse
                            {
                                DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                FirstGravityLapse = false;

                                if (pInstance)
                                {
                                    GameObject* KaelLeft = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_LEFT));
                                    if (KaelLeft) KaelLeft->SetGoState(GO_STATE_ACTIVE);
                                    GameObject* KaelRight = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_RIGHT));
                                    if (KaelRight) KaelRight->SetGoState(GO_STATE_ACTIVE);
                                }
                            }else
                            {
                                DoScriptText(SAY_RECAST_GRAVITY, m_creature);
                            }

                            DoCast(m_creature, SPELL_GRAVITY_LAPSE_INITIAL);
                            GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell
                            GravityLapsePhase = 1;
                            break;

                        case 1:
                            TeleportPlayersToSelf();
                            GravityLapseTimer = 1000;
                            GravityLapsePhase = 2;
                            break;

                        case 2:
                            CastGravityLapseKnockUp();
                            GravityLapseTimer = 1000;
                            GravityLapsePhase = 3;
                            break;

                        case 3:
                            CastGravityLapseFly();
                            GravityLapseTimer = 30000;
                            GravityLapsePhase = 4;


                            for(uint8 i = 0; i < 3; ++i)
                            {
                                Unit* target = NULL;
                                target = SelectUnit(SELECT_TARGET_RANDOM,0);

                                Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                                if (Orb && target)
                                {
                                    //SetThreatList(Orb);
                                    Orb->AddThreat(target, 1.0f);
                                    Orb->AI()->AttackStart(target);
                                }

                            }

                            DoCast(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL);
                            break;

                        case 4:
                            m_creature->InterruptNonMeleeSpells(false);
                            DoScriptText(SAY_TIRED, m_creature);
                            DoCast(m_creature, SPELL_POWER_FEEDBACK);
                            RemoveGravityLapse();
                            GravityLapseTimer = 10000;
                            GravityLapsePhase = 0;
                            break;
                    }
                }else GravityLapseTimer -= diff;
            }
            break;
        }
    }
 void DamageTaken(Unit* /*done_by*/, uint32 &damage) override
 {
     if (damage > me->GetHealth())
         RemoveGravityLapse(); // Remove Gravity Lapse so that players fall to ground if they kill him when in air.
 }