Example #1
0
    void BeginOutro()
    {
        debug_log("SD2: KALEC: Beginning Outro");

        if (!pInstance)
        {
            error_log(ERROR_INST_DATA);
            return;
        }

        Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR));
        if (Sathrovarr)
        {
            Sathrovarr->DealDamage(Sathrovarr, Sathrovarr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

            Sathrovarr->Relocate(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z);
            Sathrovarr->SendMonsterMove(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z, 0, 0, 0);
        }

        Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN)));
        if (Kalec)
        {
            Kalec->DeleteThreatList();
            Kalec->SetVisibility(VISIBILITY_OFF);
        }

        m_creature->GetMotionMaster()->MoveIdle();
        m_creature->setFaction(35);
    }
Example #2
0
    bool EffectDummy(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Object* pTarget, ObjectGuid /*originalCasterGuid*/) override
    {
        if (pCaster->GetTypeId() != TYPEID_PLAYER)
            return true;

        Creature* pCreatureTarget = pTarget->ToCreature();
        if (pCaster->HasAura(SPELL_DRAKE_HATCHLING_SUBDUED) || pCreatureTarget->HasAura(SPELL_SUBDUED))
            return true;

        Player* pPlayer = (Player*)pCaster;
        if (!pPlayer)
            return true;

        // check the quest
        if (pPlayer->GetQuestStatus(QUEST_DRAKE_HUNT) != QUEST_STATUS_INCOMPLETE && pPlayer->GetQuestStatus(QUEST_DRAKE_HUNT_DAILY) != QUEST_STATUS_INCOMPLETE)
            return true;

        // evade and set friendly and start following @TODO move to creature script
        pCreatureTarget->SetFactionTemporary(FACTION_FRIENDLY, TEMPFACTION_RESTORE_REACH_HOME | TEMPFACTION_RESTORE_RESPAWN);
        pCreatureTarget->DeleteThreatList();
        pCreatureTarget->CombatStop(true);
        pCreatureTarget->AI()->SendAIEvent(AI_EVENT_START_EVENT, pCaster, pCreatureTarget);

        // cast visual spells
        pCreatureTarget->CastSpell(pCreatureTarget, SPELL_DRAKE_VOMIT_PERIODIC, true);
        pCreatureTarget->CastSpell(pCreatureTarget, SPELL_SUBDUED, true);
        pCreatureTarget->CastSpell(pCaster, SPELL_DRAKE_HATCHLING_SUBDUED, true);
        return true;
    }
        void UpdateAI(const uint32 diff)
        {
            if (!Phase)
                return;

            if (me->getThreatManager().getThreatList().empty()) // Reset if event is begun and we don't have a threatlist
            {
                EnterEvadeMode();
                return;
            }

            Creature* Essence = NULL;
            if (EssenceGUID)
            {
                Essence = Unit::GetCreature(*me, EssenceGUID);
                if (!Essence)
                {
                    EnterEvadeMode();
                    return;
                }
            }

            if (Timer <= diff)
            {
                switch (Counter)
                {
                case 0:
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H);  // I R ANNNGRRRY!
                    DoStartNoMovement(me);
                    Timer = 3000;
                    break;
                case 1:
                    Timer = 2800;
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_SUBMERGE);  // Release the cube
                    DoCast(me, SPELL_SUBMERGE);
                    DoStartNoMovement(me);
                    break;
                case 2:
                    Timer = 5000;
                    if (Creature* Summon = DoSpawnCreature(23417+Phase, 0, 0, 0, 0, TEMPSUMMON_DEAD_DESPAWN, 0))
                    {
                        me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED);  // Ribs: open
                        Summon->AI()->AttackStart(SelectTarget(SELECT_TARGET_TOPAGGRO, 0));
                        EssenceGUID = Summon->GetGUID();
                        DoStartNoMovement(me);
                    } else EnterEvadeMode();
                    break;
                case 3:
                    Timer = 1000;
                    if (Phase == 3)
                    {
                        if (!Essence->isAlive())
                            DoCast(me, 7, true);
                        else return;
                    }
                    else
                    {
                        if (Essence->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
                        {
                            MergeThreatList(Essence);
                            Essence->RemoveAllAuras();
                            Essence->DeleteThreatList();
                            Essence->GetMotionMaster()->MoveFollow(me, 0.0f, 0.0f);
                        } else return;
                    }
                    break;
                case 4:
                    Timer = 1500;
                    if (Essence->IsWithinDistInMap(me, 10))
                    {
                        Essence->SetUInt32Value(UNIT_NPC_EMOTESTATE, 374); //rotate and disappear
                        Timer = 2000;
                        me->RemoveAurasDueToSpell(SPELL_SUBMERGE);
                    }
                    else
                    {
                        MergeThreatList(Essence);
                        Essence->RemoveAllAuras();
                        Essence->DeleteThreatList();
                        Essence->GetMotionMaster()->MoveFollow(me, 0, 0);
                        return;
                    }
                    break;
                case 5:
                    if (Phase == 1)
                    {
                        DoScriptText(SUFF_SAY_AFTER, Essence);
                    }
                    else
                    {
                        DoScriptText(DESI_SAY_AFTER, Essence);
                    }
                    Essence->DespawnOrUnsummon();
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
                    EssenceGUID = 0;
                    SoulCount = 0;
                    SoulDeathCount = 0;
                    Timer = 3000;
                    break;
                case 6:
                    if (SoulCount < NUMBER_ENSLAVED_SOUL)
                    {
                        if (SummonSoul())
                            ++SoulCount;
                        Timer = 500;
                        return;
                    }
                    break;
                case 7:
                    if (SoulDeathCount >= SoulCount)
                    {
                        Counter = 1;
                        ++Phase;
                        Timer = 5000;
                    }
                    return;
                default:
                    break;
                }
                ++Counter;
            } else Timer -= diff;
        }
    void DoIntro()
    {
        Creature *pMadrigosa = (Creature*)me->GetUnit(pInstance->GetData64(DATA_MADRIGOSA));
        if (!pMadrigosa)
            return;

        switch (IntroPhase)
        {
        case 0:
            DoScriptText(YELL_MADR_ICE_BARRIER, pMadrigosa);
            pMadrigosa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            for (uint8 i = 0; i < 8; ++i)
                pMadrigosa->SetSpeed(UnitMoveType(i), 2.5);

            pMadrigosa->GetMotionMaster()->MovePoint(1, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z);
            IntroPhaseTimer = 6500;
            ++IntroPhase;
            break;
        case 1:
            pInstance->SetData(DATA_BRUTALLUS_INTRO_EVENT, IN_PROGRESS);
            pMadrigosa->SetLevitate(false);
            pMadrigosa->SetWalk(true);
            pMadrigosa->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 2:
            pMadrigosa->SendHeartBeat();
            DoScriptText(YELL_MADR_INTRO, pMadrigosa);
            IntroPhaseTimer = 5000;
            ++IntroPhase;
            break;
        case 3:
            float x, y, z;
            pMadrigosa->GetMap()->CreatureRelocation((Creature*)pMadrigosa, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z, me->GetOrientation());
            me->SetInFront(pMadrigosa);
            pMadrigosa->SetInFront(me);
            DoScriptText(YELL_INTRO, me);
            IntroPhaseTimer = 6000;
            ++IntroPhase;
            break;
        case 4:
            pMadrigosa->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            DoStartMovement(pMadrigosa);
            pMadrigosa->GetMotionMaster()->MoveChase(me);
            me->Attack(pMadrigosa, true);
            pMadrigosa->Attack(me, true);
            IntroPhaseTimer = 7000;
            ++IntroPhase;
            break;
        case 5:
            pMadrigosa->CastSpell(me, SPELL_INTRO_FROST_BREATH, false);
            me->CastSpell(me, SPELL_INTRO_FROST_BREATH, true);
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 6:
            me->GetMotionMaster()->MoveIdle();
            pMadrigosa->SetLevitate(true);
            pMadrigosa->GetPosition(x, y, z);
            pMadrigosa->GetMotionMaster()->MovePoint(2, x, y, z+15);
            pMadrigosa->setHover(true);
            IntroPhaseTimer = 4500;
            ++IntroPhase;
        case 7:
            pMadrigosa->SetInFront(me);
            pMadrigosa->CastSpell(me, SPELL_INTRO_FROST_BLAST, false);
            me->CastSpell(me, SPELL_INTRO_FROST_BLAST, true);
            DoScriptText(YELL_MADR_ICE_BLOCK, pMadrigosa);
            IntroFrostBoltTimer = 500;
            IntroPhaseTimer = 10000;
            ++IntroPhase;
            break;
        case 8:
            DoScriptText(YELL_INTRO_BREAK_ICE, me);
            IntroPhaseTimer = 2000;
            ++IntroPhase;
            break;
        case 9:
            me->GetMotionMaster()->MoveIdle();
            me->AttackStop();
            pMadrigosa->setHover(false);
            pMadrigosa->SetLevitate(false);
            pMadrigosa->SetWalk(true);
            pMadrigosa->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
            pMadrigosa->SendHeartBeat();
            IntroPhaseTimer = 1000;
            ++IntroPhase;
            break;
        case 10:
            pMadrigosa->GetMotionMaster()->MoveIdle();
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 11:
            pMadrigosa->GetMap()->CreatureRelocation((Creature*)pMadrigosa, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z, me->GetOrientation());
            pMadrigosa->GetMotionMaster()->MoveIdle();
            IntroPhaseTimer = 2000;
            ++IntroPhase;
            break;
        case 12:
            me->GetMotionMaster()->MoveIdle();
            pMadrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE, false);
            DoScriptText(YELL_MADR_TRAP, pMadrigosa);
            IntroPhaseTimer = 1000;
            ++IntroPhase;
            break;
        case 13:
            me->GetPosition(x, y, z);
            me->GetMotionMaster()->MovePoint(1, x-6, y-15, z+10);
            me->SetInFront(pMadrigosa);
            IntroPhaseTimer = 8000;
            ++IntroPhase;
            break;
        case 14:
            me->RemoveAurasDueToSpell(44883);
            pMadrigosa->InterruptNonMeleeSpells(false);
            pMadrigosa->GetMotionMaster()->MoveIdle();
            DoScriptText(YELL_INTRO_CHARGE, me);
            me->SetInFront(pMadrigosa);
            me->GetPosition(x, y, z);
            me->GetMotionMaster()->MoveFall();
            IntroPhaseTimer = 3500;
            ++IntroPhase;
            break;
        case 15:
            for(uint8 i = 0; i < 8; ++i)
                me->SetSpeed(UnitMoveType(i), 10.0);
            me->GetMotionMaster()->MoveCharge(MADRI_FLY_X-5, MADRI_FLY_Y-15, MADRI_FLY_Z);
            AddSpellToCast((Unit*)NULL, SPELL_INTRO_CHARGE);
            IntroPhaseTimer = 1000;
            ++IntroPhase;
            break;
        case 16:
            DoScriptText(YELL_MADR_DEATH, pMadrigosa);
            pMadrigosa->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
            pMadrigosa->SetFlag(UNIT_DYNAMIC_FLAGS, (UNIT_DYNFLAG_DEAD | UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED));
            pMadrigosa->CombatStop();
            pMadrigosa->DeleteThreatList();
            pMadrigosa->setFaction(35);
            me->CombatStop();
            me->RemoveFlag(UNIT_FIELD_FLAGS, (UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_PVP_ATTACKABLE));
            IntroPhaseTimer = 4000;
            ++IntroPhase;
            break;
        case 17:
            if(pInstance)
                me->SetFacingToObject(GameObject::GetGameObject(*me, pInstance->GetData64(DATA_BRUTALLUS_TRIGGER)));
            for(uint8 i = 0; i < 8; ++i)
                me->SetSpeed(UnitMoveType(i), 2.0);
            IntroPhaseTimer = 6000;
            ++IntroPhase;
            break;
        case 18:
            DoScriptText(YELL_INTRO_KILL_MADRIGOSA, me);
            IntroPhaseTimer = 8000;
            ++IntroPhase;
            break;
        case 19:
            DoScriptText(YELL_INTRO_TAUNT, me);
            AddSpellToCast(me, SPELL_INTRO_BREAK_ICE);
            if(pInstance)
                pInstance->SetData(DATA_BRUTALLUS_INTRO_EVENT, DONE);
            else
                return;
            if(Unit *pTrigger = me->GetUnit(pInstance->GetData64(DATA_BRUTALLUS_TRIGGER)))
                pTrigger->CastSpell((Unit*)NULL, SPELL_INTRO_BREAK_ICE_KNOCKBACK, false);
            IntroPhaseTimer = 2000;
            ++IntroPhase;
            break;
        case 20:
            EnterEvadeMode();
            ++IntroPhase;
            break;
        }
    }
Example #5
0
/*
Tribute Event
*/
void instance_dire_maul::GordokTributeEvent(uint32 diff)
{
	if(1<2)return;
	Creature* pChoRush = instance->GetCreature(m_uiChoRushGUID);
	Creature* pMizzle = instance->GetCreature(m_uiMizzleGUID);
	Creature* pTrigger = instance->GetCreature(m_uiTributeTriggerGUID);

	Map* pMap;
	pMap = pChoRush->GetMap();

	Map::PlayerList const &PlayerList = pMap->GetPlayers();

	if ((GetData(TYPE_KING_GORDOK) == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isAlive() && !pChoRushHome)
	{
		pChoRush->SetFlag(UNIT_NPC_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PASSIVE);
		pChoRush->setFaction(35);
		pChoRush->DeleteThreatList();
		pChoRush->CombatStop();
		pChoRush->SetCanAttackPlayer(false);
		pChoRush->AI()->EnterEvadeMode();

		pChoRushHome = true;
		GossipStepGordok = 1;
		Text_Timer_Event = 1000;
	}
	else if ((TYPE_KING_GORDOK == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isDead())
	{
		for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
		{
			Player* pPlayer = itr->getSource();
			if (pPlayer->IsWithinDistInMap(pTrigger, 30.0f))
					pTrigger->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
		}
	}

	if(pChoRushHome)
	{
		if (Text_Timer_Event<diff)
		{
			switch (GossipStepGordok)
			{
				case 1:
				DoScriptText(ChoRush_SAY_1, pChoRush);
				pChoRush->HandleEmote(EMOTE_STATE_TALK);
				pChoRush->SummonCreature(NPC_MIZZLE_THE_CRAFTY, 817.666f, 478.371f, 37.3182f, 3.07057f, TEMPSUMMON_TIMED_DESPAWN, 9000000);
				Text_Timer_Event = 5000;
				break;

				case 2:
				pChoRush->HandleEmote(EMOTE_STATE_SIT);
				DoScriptText(Mizzle_SAY_1, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 5000;
				break;

				case 3:
				DoScriptText(Mizzle_SAY_2, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 8000;
				break;

				case 4:
				for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
				{
					Player* pPlayer = itr->getSource();
					if (pPlayer->IsWithinDistInMap(pMizzle, 50.0f))
							pMizzle->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
				}
				if (pMap->GetCreature(m_uiMoldarGUID)->isAlive() && pMap->GetCreature(m_uiMizzleGUID)->isAlive() && pMap->GetCreature(m_uiFengusGUID)->isAlive())
				{
					pMizzle->SummonObject(pMap, GO_GORDOK_TRIBUTE, 809.899719f, 482.306366f, 37.318359f, 0.212846f);
					pMizzle->HandleEmote(EMOTE_ONESHOT_APPLAUD);
				}
				pChoRushHome = false;
				break;
			}
		}
		else Text_Timer_Event -= diff;
	}
}
    void UpdateAI(const uint32 diff)
    {
        if (!Phase)
            return;

        // Reset if event is begun and we don't have a threatlist
        if (Phase && m_creature->getThreatManager().getThreatList().empty())
            EnterEvadeMode();

        if (Phase == 1)
        {
            if (AnimationTimer < diff)
            {
                // Release the cube
                m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374);
                AnimationTimer = 8300;
            }else AnimationTimer -= diff;

            if (SummonEssenceTimer < diff)
            {
                // Ribs: open
                m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373);
                Creature* EssenceSuffering = NULL;
                EssenceSuffering = m_creature->SummonCreature(23418, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000);

                if (EssenceSuffering)
                {
                    DoScriptText(SUFF_SAY_FREED, EssenceSuffering);

                    if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
                    {
                        EssenceSuffering->AddThreat(target);
                        EssenceSuffering->AI()->AttackStart(target);
                    }

                    SufferingGUID = EssenceSuffering->GetGUID();
                }

                EndingPhase = false;
                Phase = 2;
            }else SummonEssenceTimer -= diff;
        }

        if (Phase == 2)
        {
            if (SufferingGUID)
            {
                Creature* EssenceSuffering = NULL;
                EssenceSuffering = ((Creature*)Unit::GetUnit((*m_creature), SufferingGUID));

                if (!EssenceSuffering || (!EssenceSuffering->isAlive()))
                    EnterEvadeMode();

                if (!EndingPhase)
                {
                    if (EssenceSuffering)
                    {
                        if (EssenceSuffering->GetHealthPercent() < 10.0f)
                        {
                            DoScriptText(SUFF_SAY_RECAP, EssenceSuffering);
                            MergeThreatList(EssenceSuffering);
                            EssenceSuffering->RemoveAllAuras();
                            EssenceSuffering->DeleteThreatList();
                            EssenceSuffering->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f);
                            EssenceSuffering->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            DespawnEssenceTimer = 4000;
                            AnimationTimer = 2200;
                            EndingPhase = true;
                        }
                    }
                }

                if ((EndingPhase) && (EssenceSuffering) && (EssenceSuffering->isAlive()))
                {
                    if (AnimationTimer < diff)
                    {
                        // Return
                        EssenceSuffering->SetUInt32Value(UNIT_NPC_EMOTESTATE,374);
                        AnimationTimer = 10000;
                    }else AnimationTimer -= diff;

                    if (DespawnEssenceTimer < diff)
                    {
                        DoScriptText(SUFF_SAY_AFTER, EssenceSuffering);

                        EssenceSuffering->DeleteThreatList();
                        EssenceSuffering->SetDisplayId(11686);
                        EssenceSuffering->setFaction(35);
                        m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0);
                        SummonEssenceTimer = 20000;         //60000;
                        AnimationTimer = 18200;             //58100;
                        SoulDeathCount = 0;
                        SoulCount = 0;
                        SummonSoulTimer = 1000;
                        EndingPhase = false;
                        Phase = 3;
                        SufferingGUID = 0;
                    }else DespawnEssenceTimer -= diff;
                }
            }
        }

        if (Phase == 3)
        {
            if (SoulCount < 36)
            {
                if (SummonSoulTimer < diff)
                {
                    SummonSoul();
                    SummonSoulTimer = 500;
                }else SummonSoulTimer -= diff;
            }

            if (SoulDeathCount >= SoulCount)
            {
                if (AnimationTimer < diff)
                {
                    // Release the cube
                    m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374);
                    AnimationTimer = 10000;
                }else AnimationTimer -= diff;

                if (SummonEssenceTimer < diff)
                {
                    // Ribs: open
                    m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373);
                    Creature* EssenceDesire = NULL;
                    EssenceDesire = m_creature->SummonCreature(23419, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000);

                    if (EssenceDesire)
                    {
                        DoScriptText(DESI_SAY_FREED, EssenceDesire);

                        if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        {
                            EssenceDesire->AddThreat(target);
                            EssenceDesire->AI()->AttackStart(target);
                        }

                        DesireGUID = EssenceDesire->GetGUID();
                        SoulDeathCount = 0;
                    }

                    Phase = 4;
                }else SummonEssenceTimer -= diff;
            }
        }

        if (Phase == 4)
        {
            if (DesireGUID)
            {
                Creature* EssenceDesire = NULL;
                EssenceDesire = ((Creature*)Unit::GetUnit((*m_creature), DesireGUID));

                if (!EssenceDesire || !EssenceDesire->isAlive())
                    EnterEvadeMode();

                if (!EndingPhase && EssenceDesire)
                {
                    if (EssenceDesire->GetHealthPercent() < 10.0f)
                    {
                        MergeThreatList(EssenceDesire);
                        EssenceDesire->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f);
                        EssenceDesire->RemoveAllAuras();
                        EssenceDesire->DeleteThreatList();

                        DoScriptText(DESI_SAY_RECAP, EssenceDesire);

                        EssenceDesire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        DespawnEssenceTimer = 4000;
                        AnimationTimer = 2200;
                        EndingPhase = true;
                    }
                }

                if (EndingPhase && EssenceDesire)
                {
                    if (EssenceDesire->isAlive())
                    {
                        if (AnimationTimer < diff)
                        {
                            // Return
                            EssenceDesire->SetUInt32Value(UNIT_NPC_EMOTESTATE,374);
                            AnimationTimer = 10000;
                        }else AnimationTimer -= diff;

                        if (DespawnEssenceTimer < diff)
                        {
                            EssenceDesire->DeleteThreatList();
                            EssenceDesire->setFaction(35);

                            DoScriptText(DESI_SAY_AFTER, EssenceDesire);

                            EssenceDesire->SetDisplayId(11686);
                            m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0);
                            SummonEssenceTimer = 20000;
                            AnimationTimer = 18200;
                            SoulDeathCount = 0;
                            SoulCount = 0;
                            SummonSoulTimer = 1000;
                            EndingPhase = false;
                            Phase = 5;
                            DesireGUID = 0;
                        }else DespawnEssenceTimer -= diff;
                    }
                }
            }
        }

        if (Phase == 5)
        {
            if (SoulCount < 36)
            {
                if (SummonSoulTimer < diff)
                {
                    SummonSoul();
                    SummonSoulTimer = 500;
                }else SummonSoulTimer -= diff;
            }

            if (SoulDeathCount >= SoulCount)
            {
                if (AnimationTimer < diff)
                {
                    // Release the cube
                    m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374);
                    AnimationTimer = 10000;
                }else AnimationTimer -= diff;

                if (SummonEssenceTimer < diff)
                {
                    // Ribs: open
                    m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373);
                    Creature* EssenceAnger = NULL;
                    EssenceAnger = m_creature->SummonCreature(23420, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000);

                    if (EssenceAnger)
                    {
                        if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
                        {
                            EssenceAnger->AddThreat(target);
                            EssenceAnger->AI()->AttackStart(target);
                        }

                        AngerGUID = EssenceAnger->GetGUID();
                        DoScriptText(ANGER_SAY_FREED, EssenceAnger);
                        SoulDeathCount = 0;
                    }

                    Phase = 6;
                }else SummonEssenceTimer -= diff;
            }
        }

        if (Phase == 6)
        {
            if (AngerGUID)
            {
                Creature* EssenceAnger = NULL;
                EssenceAnger = ((Creature*)Unit::GetUnit((*m_creature), AngerGUID));

                if (!EssenceAnger)
                    EnterEvadeMode();

                if (m_creature->isAlive() && EssenceAnger)
                {
                    if (!EssenceAnger->isAlive())
                    {
                        AngerGUID = 0;
                        m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    }
                }
            }
        }
    }