Пример #1
0
        void UpdateAI(const uint32 diff)
        {
            if (Phase != INTRO)
                return;

            if (uiIntroTimer <= diff)
            {
                Creature* pArthas = Unit::GetCreature(*me, uiArthasGUID);
                if (!pArthas)
                    return;

                switch (uiIntroPhase)
                {
                    case 0:
                        DoScriptText(SAY_DIALOG_WITH_ARTHAS_1, me);
                        ++uiIntroPhase;
                        uiIntroTimer = 3500;
                        break;
                    case 1:
                        DoScriptText(SAY_DIALOG_OF_ARTHAS_1, pArthas);
                        ++uiIntroPhase;
                        uiIntroTimer = 3500;
                        break;
                    case 2:
                        DoScriptText(SAY_DIALOG_WITH_ARTHAS_2, me);
                        ++uiIntroPhase;
                        uiIntroTimer = 3500;
                        break;
                    case 3:
                        DoScriptText(SAY_DIALOG_OF_ARTHAS_2, pArthas);
                        ++uiIntroPhase;
                        uiIntroTimer = 3500;
                        break;
                    case 4:
                        DoScriptText(SAY_DIALOG_WITH_ARTHAS_3, me);
                        DoCast(me, SPELL_SVALA_TRANSFORMING1);
                        ++uiIntroPhase;
                        uiIntroTimer = 2800;
                        break;
                    case 5:
                        DoCast(me, SPELL_SVALA_TRANSFORMING2);
                        ++uiIntroPhase;
                        uiIntroTimer = 200;
                        break;
                    case 6:
                        if (me->SummonCreature(CREATURE_SVALA_SORROWGRAVE, SvalaPos, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60*IN_MILLISECONDS))
                        {
                            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
                            me->SetDisplayId(DATA_SVALA_DISPLAY_ID);
                            pArthas->DespawnOrUnsummon();
                            uiArthasGUID = 0;
                            Phase = FINISHED;
                        }
                        else
                            Reset();
                        break;
                }
            } else uiIntroTimer -= diff;
        }
            void Reset()
            {
                instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_ABILITATE_BALANCE_BAR);
                events.Reset();
                if (leftfoot)
                    leftfoot->DespawnOrUnsummon();
                if (rightfoot)
                    rightfoot->DespawnOrUnsummon();
                summons.DespawnAll();
                me->LowerPlayerDamageReq(me->GetMaxHealth());
                killtimer =0;

                if (instance)
                {
                    instance->SetData(DATA_RHYOLITH_EVENT, NOT_STARTED);
                }
            }
Пример #3
0
		void JustDied(Unit * /*victim*/)
		{
			DespawnCreatures(NPC_ANGERED_EARTH);
			me->MonsterYell("Boss Cho'gall not gonna be happy 'bout dis!", LANG_UNIVERSAL, NULL);

			if(chainsOfWoe != NULL)
				chainsOfWoe->DespawnOrUnsummon();

			chainsOfWoe = NULL;
		}
Пример #4
0
        void HandleDummy(SpellEffIndex /*effIndex*/)
        {
            Creature* lothalor = GetHitCreature();
            if (!lothalor || lothalor->GetEntry() != NPC_LOTHALOR)
                return;

            lothalor->AI()->Talk(SAY_LOTHALOR);
            lothalor->RemoveAura(SPELL_CONFUSED);
            lothalor->DespawnOrUnsummon(4000);
        }
Пример #5
0
void SummonList::DespawnAll()
{
    while (!storage_.empty())
    {
        Creature* summon = Unit::GetCreature(*me, storage_.front());
        storage_.pop_front();
        if (summon)
            summon->DespawnOrUnsummon();
    }
}
        uint32 NextStep(uint8 Step)
        {
            Creature* Spark = ObjectAccessor::GetCreature(*me, SparkGUID);
            if (!Spark)
            {
                me->DespawnOrUnsummon(1);
                return 5000;
            }

            switch (Step)
            {
                case 0:
                    Spark->GetMotionMaster()->MovePoint(0, -5080.70f, -11253.61f, 0.56f);
                    me->GetMotionMaster()->MovePoint(0, -5092.26f, -11252, 0.71f);
                    return 9000;
                case 1:
                    DespawnNagaFlag(true);
                    Spark->AI()->Talk(EMOTE_SPARK);
                    return 1000;
                case 2:
                    Talk(GEEZLE_SAY_1, Spark);
                    Spark->SetInFront(me);
                    me->SetInFront(Spark);
                    return 5000;
                case 3:
                    Spark->AI()->Talk(SPARK_SAY_2);
                    return 7000;
                case 4:
                    Spark->AI()->Talk(SPARK_SAY_3);
                    return 8000;
                case 5:
                    Talk(GEEZLE_SAY_4, Spark);
                    return 8000;
                case 6:
                    Spark->AI()->Talk(SPARK_SAY_5);
                    return 9000;
                case 7:
                    Spark->AI()->Talk(SPARK_SAY_6);
                    return 8000;
                case 8:
                    Talk(GEEZLE_SAY_7, Spark);
                    return 2000;
                case 9:
                    me->GetMotionMaster()->MoveTargetedHome();
                    Spark->GetMotionMaster()->MovePoint(0, SparkPos);
                    CompleteQuest();
                    return 9000;
                case 10:
                    Spark->DespawnOrUnsummon(1);
                    DespawnNagaFlag(false);
                    me->DespawnOrUnsummon(1);
                    return 5000;
                default: return 99999999;
            }
        }
Пример #7
0
        void MoveInLineOfSight(Unit* who)
        {
            if (!who || !drakeGUID)
                return;

            Creature* drake = Unit::GetCreature(*me, drakeGUID);
            if (!drake)
            {
                drakeGUID = 0;
                return;
            }

            if (!me->IsOnVehicle(drake) && !me->HasAura(SPELL_ICE_PRISON))
            {
                if (who->IsVehicle() && me->IsWithinDist(who, 25.0f, true) && who->ToCreature() && who->ToCreature()->GetEntry() == 29709)
                {
                    uint8 seat = who->GetVehicleKit()->GetNextEmptySeat(0, true);
                    if (seat <= 0)
                        return;

                    me->EnterVehicle(who, seat);
                    me->SendMovementFlagUpdate();
                    hasEmptySeats = false;
                }
            }

            if (who->ToCreature() && me->IsOnVehicle(drake))
            {
                if (who->ToCreature()->GetEntry() == NPC_QUEST_GIVER && me->IsWithinDist(who, 15.0f, false))
                {
                    Unit* rider = drake->GetVehicleKit()->GetPassenger(0);
                    if (!rider)
                        return;

                    rider->CastSpell(rider, SPELL_KILL_CREDIT_PRISONER, true);

                    me->ExitVehicle();
                    me->CastSpell(me, SPELL_SUMMON_LIBERATED, true);
                    me->DespawnOrUnsummon(500);

                    // drake is empty now, deliver credit for drake and despawn him
                    if (drake->GetVehicleKit()->HasEmptySeat(1) &&
                        drake->GetVehicleKit()->HasEmptySeat(2) &&
                        drake->GetVehicleKit()->HasEmptySeat(3))
                    {
                        // not working rider->CastSpell(rider, SPELL_KILL_CREDIT_DRAKE, true);
                        if (rider->ToPlayer())
                            rider->ToPlayer()->KilledMonsterCredit(29709, 0);

                        drake->DespawnOrUnsummon(0);
                    }
                }
            }
        }
Пример #8
0
 void DespawnDwarf()
 {
     if (lDwarfGUIDList.empty())
         return;
     for (GuidList::const_iterator itr = lDwarfGUIDList.begin(); itr != lDwarfGUIDList.end(); ++itr)
     {
         Creature* temp = ObjectAccessor::GetCreature(*me, instance ? (*itr) : ObjectGuid::Empty);
         if (temp && temp->IsAlive())
             temp->DespawnOrUnsummon();
     }
     lDwarfGUIDList.clear();
 }
Пример #9
0
 void DespawnDwarf()
 {
     if (lDwarfGUIDList.empty())
         return;
     for (std::list<uint64>::const_iterator itr = lDwarfGUIDList.begin(); itr != lDwarfGUIDList.end(); ++itr)
     {
         Creature* temp = Unit::GetCreature(*me, instance ? (*itr) : 0);
         if (temp && temp->isAlive())
             temp->DespawnOrUnsummon();
     }
     lDwarfGUIDList.clear();
 }
Пример #10
0
		void Reset()
		{
			me->GetMotionMaster()->MoveTargetedHome();
			castSkullCracker = false;

			if(chainsOfWoe != NULL)
				chainsOfWoe->DespawnOrUnsummon();

			chainsOfWoe = NULL;

			DespawnCreatures(NPC_ANGERED_EARTH);
		}
            void HandleScript(SpellEffIndex /*eff*/)
            {
                Creature* caster = GetCaster()->ToCreature();
                if (!caster)
                    return;

                caster->CastSpell(caster, SPELL_COSMETIC_BLOOD_EXPLOSION_GREEN_LARGE);

                for (uint8 i = 0; i < 10; ++i)
                    caster->CastSpell(caster, SPELL_RANDOM_CIRCUMFERENCE_POINT_POISON);

                caster->DespawnOrUnsummon(4000);
            }
Пример #12
0
void SummonList::DespawnAll()
{
    while (!empty())
    {
        Creature* summon = Unit::GetCreature(*me, *begin());
        if (!summon)
            erase(begin());
        else
        {
            erase(begin());
            summon->DespawnOrUnsummon();
        }
    }
}
Пример #13
0
 bool OnGossipHello(Player* player, GameObject* go) override
 {
     go->UseDoorOrButton();
     if (player->GetQuestStatus(QUEST_OUR_ONLY_HOPE) == QUEST_STATUS_INCOMPLETE)
     {
         Creature* gymerDummy = go->FindNearestCreature(NPC_GYMER_DUMMY, 20.0f);
         if (gymerDummy)
         {
             player->KilledMonsterCredit(gymerDummy->GetEntry(), gymerDummy->GetGUID());
             gymerDummy->CastSpell(gymerDummy, SPELL_GYMER_LOCK_EXPLOSION, true);
             gymerDummy->DespawnOrUnsummon(4 * IN_MILLISECONDS);
         }
     }
     return true;
 }
Пример #14
0
void SummonList::DespawnAll(uint32 msTimeToDespawn) {
    while (!empty()) {
        Creature* summon = Unit::GetCreature(*me, *begin());
        if (!summon)
            erase(begin());
        else {
            erase(begin());
            if (TempSummon* summ = summon->ToTempSummon()) {
                summon->DestroyForNearbyPlayers();
                summ->UnSummon(msTimeToDespawn);
            } else
                summon->DespawnOrUnsummon(msTimeToDespawn);
        }
    }
}
Пример #15
0
            void SummonChannelers()
            {
                for (uint8 i = 0; i < 5; ++i)
                {
                    Creature* channeler = ObjectAccessor::GetCreature(*me, channelers[i]);
					if (channeler && channeler->isDead())
					{
						channeler->DespawnOrUnsummon(1);
						channeler = NULL;
					}
                    if (!channeler)
                        channeler = me->SummonCreature(NPC_CHANNELER, ShadowmoonChannelers[i][0], ShadowmoonChannelers[i][1], ShadowmoonChannelers[i][2], ShadowmoonChannelers[i][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 300000);

					channelers[i] = channeler ? channeler->GetGUID() : 0;
                }
            }
Пример #16
0
 void DespawnMojo()
 {
     for (uint8 i = 0; i < 5; ++i)
     {
         if (MojoGUID[i])
         {
             Creature* pCreature = Unit::GetCreature((*me), MojoGUID[i]);
             if (pCreature && pCreature->isAlive())
             {
                 pCreature->SetVisible(false);
                 pCreature->DespawnOrUnsummon();
             }
         }
         MojoGUID[i] = 0;
     }
 }
Пример #17
0
 void DoDespawnMojo()
 {
     for (uint8 i = 0; i < 5; ++i)
     {
         if (_mojoGUID[i])
         {
             Creature* mojo = Unit::GetCreature((*me), _mojoGUID[i]);
             if (mojo && mojo->isAlive())
             {
                 mojo->SetVisible(false);
                 mojo->DespawnOrUnsummon();
             }
         }
         _mojoGUID[i] = 0;
     }
 }
Пример #18
0
void SummonList::DespawnEntry(uint32 entry)
{
    for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
    {
        Creature* summon = Unit::GetCreature(*me, *i);
        if (!summon)
            i = storage_.erase(i);
        else if (summon->GetEntry() == entry)
        {
            i = storage_.erase(i);
            summon->DespawnOrUnsummon();
        }
        else
            ++i;
    }
}
Пример #19
0
void SummonList::DespawnEntry(uint32 entry)
{
    for (iterator i = begin(); i != end();)
    {
        Creature* summon = Unit::GetCreature(*me, *i);
        if (!summon)
            erase(i++);
        else if (summon->GetEntry() == entry)
        {
            erase(i++);
            summon->DespawnOrUnsummon();
        }
        else
            ++i;
    }
}
        //Despawn all Inner Demon summoned
        void DespawnDemon()
        {
            for (uint8 i = 0; i < 5; ++i)
            {
                if (!InnderDemon[i].IsEmpty())
                {
                    //delete creature
                    Creature* creature = ObjectAccessor::GetCreature((*me), InnderDemon[i]);
                    if (creature && creature->IsAlive())
                        creature->DespawnOrUnsummon();

                    InnderDemon[i].Clear();
                }
            }

            InnerDemon_Count = 0;
        }
Пример #21
0
        void HandleScriptEffect(SpellEffIndex /*effIndex*/)
        {
            Unit* caster = GetCaster();
            Creature* target = GetHitCreature();
            if (!target || caster == target)
                return;

            target->CastSpell(target->GetPositionX()+irand(-10, 10), target->GetPositionY()+irand(-10, 10), target->GetPositionZ() , SPELL_RACER_DEATH_VISUAL, true);
            target->DespawnOrUnsummon(3000);
            target->CastSpell(target, SPELL_RACER_FLAMES, true);
            caster->CastSpell(caster, SPELL_RACER_KILL_COUNTER, true);

            if (Player* targetSummoner = target->GetCharmerOrOwnerPlayerOrPlayerItself())
            {
                //targetSummoner->RemoveCriteriaProgress(sAchievementCriteriaStore.LookupEntry(RACER_ACHI_CRITERIA)); !ZOMG, ADD ACCESSOR
                targetSummoner->RemoveAurasDueToSpell(SPELL_RACER_KILL_COUNTER);
            }
        }
Пример #22
0
        //Despawn all Inner Demon summoned
        void DespawnDemon()
        {
            for (uint8 i=0; i<5; ++i)
            {
                if (InnderDemon[i])
                {
                        //delete creature
                        Creature* pCreature = Unit::GetCreature((*me), InnderDemon[i]);
                        if (pCreature && pCreature->isAlive())
                        {
                            pCreature->DespawnOrUnsummon();
                        }
                        InnderDemon[i] = 0;
                }
            }

            InnerDemon_Count = 0;
        }
Пример #23
0
 bool OnGossipHello(Player *pPlayer, GameObject *pGO)
 {
     if (pPlayer->GetQuestStatus(QUEST_CORKI_GONE_MISSING_AGAIN) == QUEST_STATUS_INCOMPLETE)
     {
         Creature *pCorkiRun = pGO->FindNearestCreature(NPC_CORKI_RUN,1.0f);
         if (pCorkiRun)
         {
             pCorkiRun->GetMotionMaster()->MoveFleeing(pPlayer, 3500);
             DoScriptText(SAY_RUN, pCorkiRun);
             pCorkiRun->DespawnOrUnsummon();
             Quest const* qInfo = sObjectMgr->GetQuestTemplate(QUEST_CORKI_GONE_MISSING_AGAIN);
             if (qInfo)
             {
                 pPlayer->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0],0);
             }
         }
     }
     return true;
 }
Пример #24
0
        void MoveInLineOfSight(Unit* who)
        {
            if(!who || (!who->isAlive()))
                return;

            if(me->IsWithinDistInMap(who, 50.0f))
            {
                Creature* pCreature = me->FindNearestCreature(NPC_QUEST_CREDIT, 50);

                if(who->GetTypeId() == TYPEID_PLAYER && pCreature)
                {
                    Player* player = who->ToPlayer();
                    if(player->GetQuestStatus(QUEST_GETTING_THE_BLADESPIRE_TANKED) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(QUEST_BLADESPIRE_KEGGER) == QUEST_STATUS_INCOMPLETE)
                        player->KilledMonsterCredit(NPC_QUEST_CREDIT, 0);

                    pCreature->DespawnOrUnsummon();
                }
            }
        }
            void ResetBossEncounter(uint8 bossId)
            {
                if (bossId < DATA_CYANIGOSA || bossId > DATA_ZURAMAT)
                    return;

                Creature* boss = GetCreature(bossId);
                if (!boss)
                    return;

                switch (bossId)
                {
                    case DATA_CYANIGOSA:
                        boss->DespawnOrUnsummon();
                        break;
                    case DATA_EREKEM:
                        for (uint32 i = DATA_EREKEM_GUARD_1; i <= DATA_EREKEM_GUARD_2; ++i)
                        {
                            if (Creature* guard = instance->GetCreature(GetGuidData(i)))
                            {
                                if (guard->isDead())
                                    guard->Respawn();

                                if (GetBossState(bossId) == DONE)
                                    UpdateKilledBoss(guard);

                                guard->GetMotionMaster()->MoveTargetedHome();
                                guard->SetImmuneToAll(true);
                            }
                        }
                        /* fallthrough */
                    default:
                        if (boss->isDead())
                        {
                            // respawn and update to a placeholder npc to avoid be looted again
                            boss->Respawn();
                            UpdateKilledBoss(boss);
                        }

                        boss->GetMotionMaster()->MoveTargetedHome();
                        boss->SetImmuneToAll(true);
                        break;
                }
            }
Пример #26
0
        void Reset()
        {
            me->RemoveAllAuras();

            uiHolyFireTimer     = urand(9000, 12000);
            uiHolySmiteTimer    = urand(5000, 7000);
            uiRenewTimer        = urand(2000, 5000);

            uiResetTimer        = 7000;

            me->GetMotionMaster()->MovePoint(1, 746.71f, 661.02f, 411.69f);
            me->SetOrientation(4.714f);

            bHealth = false;
            bDone = false;

            if (Creature* pMemory = Unit::GetCreature(*me, MemoryGUID))
                if (pMemory->isAlive())
                    pMemory->DespawnOrUnsummon();
        }
Пример #27
0
        void RespawnDragons(bool combat)
        {
            if (pInstance)
            {
                Creature* cr = NULL;
                for (uint8 i = 0; i < 3; ++i)
                    if (dragons[i])
                        if (cr = ObjectAccessor::GetCreature(*me, dragons[i]))
                        {
                            if (combat && cr->IsInCombat())
                                continue;

                            cr->DespawnOrUnsummon();
                            cr->SetRespawnTime(10);
                        }

                dragons[0] = dragons[1] = dragons[2] = 0;
                dragonsCount = 0;
            }
        }
Пример #28
0
    bool OnGossipHello(Player* player, GameObject* go)
    {
        go->UseDoorOrButton();
        Creature* pPrisoner = go->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true);
        if (!pPrisoner)
        {
            pPrisoner = go->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true);
            if (!pPrisoner)
            {
                pPrisoner = go->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true);
                if (!pPrisoner)
                    pPrisoner = go->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true);
            }
        }
        if (!pPrisoner || !pPrisoner->IsAlive())
            return false;

        pPrisoner->DespawnOrUnsummon();
        player->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0);
        switch (pPrisoner->GetEntry())
        {
            case NPC_EBON_BLADE_PRISONER_HUMAN:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_H, true);
                break;
            case NPC_EBON_BLADE_PRISONER_NE:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_NE, true);
                break;
            case NPC_EBON_BLADE_PRISONER_TROLL:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_TROLL, true);
                break;
            case NPC_EBON_BLADE_PRISONER_ORC:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_ORC, true);
                break;
        }
        return true;
    }
Пример #29
0
        void UpdateAI(const uint32 diff)
        {
            if (Phase == IDLE)
                return;

            if (Phase == INTRO)
            {
                if (introTimer <= diff)
                {
                    Creature* arthas = Unit::GetCreature(*me, arthasGUID);
                    if (!arthas)
                        return;

                    switch (introPhase)
                    {
                        case 0:
                            Talk(SAY_SVALA_INTRO_0);
                            ++introPhase;
                            introTimer = 8100;
                            break;
                        case 1:
                            arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_1);
                            ++introPhase;
                            introTimer = 10000;
                            break;
                        case 2:
                            arthas->CastSpell(me, SPELL_TRANSFORMING_CHANNEL, false);
                            pos.Relocate(me);
                            pos.m_positionZ += 8.0f;
                            me->GetMotionMaster()->MoveTakeoff(0, pos);
                            // spectators flee event
                            if (instance)
                            {
                                std::list<Creature*> lspectatorList;
                                GetCreatureListWithEntryInGrid(lspectatorList, me, CREATURE_SPECTATOR, 100.0f);
                                for (std::list<Creature*>::iterator itr = lspectatorList.begin(); itr != lspectatorList.end(); ++itr)
                                {
                                    if ((*itr)->isAlive())
                                    {
                                        (*itr)->SetStandState(UNIT_STAND_STATE_STAND);
                                        (*itr)->SetWalk(false);
                                        (*itr)->GetMotionMaster()->MovePoint(1, spectatorWP[0][0], spectatorWP[0][1], spectatorWP[0][2]);
                                    }
                                }
                            }
                            ++introPhase;
                            introTimer = 4200;
                            break;
                        case 3:
                            me->CastSpell(me, SPELL_SVALA_TRANSFORMING1, false);
                            ++introPhase;
                            introTimer = 6200;
                            break;
                        case 4:
                            me->CastSpell(me, SPELL_SVALA_TRANSFORMING2, false);
                            arthas->InterruptNonMeleeSpells(true);
                            me->RemoveAllAuras();
                            me->UpdateEntry(CREATURE_SVALA_SORROWGRAVE);
                            me->SetFacingToObject(arthas);
                            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            ++introPhase;
                            introTimer = 3200;
                            break;
                        case 5:
                            Talk(SAY_SVALA_INTRO_1);
                            ++introPhase;
                            introTimer = 10000;
                            break;
                        case 6:
                            arthas->AI()->Talk(SAY_DIALOG_OF_ARTHAS_2);
                            ++introPhase;
                            introTimer = 7200;
                            break;
                        case 7:
                            Talk(SAY_SVALA_INTRO_2);
                            me->SetOrientation(1.58f);
                            me->SendMovementFlagUpdate();
                            arthas->SetVisible(false);
                            ++introPhase;
                            introTimer = 13800;
                            break;
                        case 8:
                            pos.Relocate(me);
                            pos.m_positionX = me->GetHomePosition().GetPositionX();
                            pos.m_positionY = me->GetHomePosition().GetPositionY();
                            pos.m_positionZ = 90.6065f;
                            me->GetMotionMaster()->MoveLand(0, pos);
                            me->SetDisableGravity(false, true);
                            me->SetHover(true);
                            ++introPhase;
                            introTimer = 3000;
                            break;
                        case 9:
                            if (GameObject* mirror = GetClosestGameObjectWithEntry(me, OBJECT_UTGARDE_MIRROR, 100.0f))
                                mirror->SetGoState(GO_STATE_ACTIVE);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            arthas->DespawnOrUnsummon();
                            arthasGUID = 0;
                            Phase = NORMAL;
                            break;
                    }
                }
                else
                    introTimer -= diff;

                return;
            }

            if (Phase == NORMAL)
            {
                //Return since we have no target
                if (!UpdateVictim())
                    return;

                if (sinsterStrikeTimer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_SINSTER_STRIKE);
                    sinsterStrikeTimer = urand(5 * IN_MILLISECONDS, 9 * IN_MILLISECONDS);
                }
                else
                    sinsterStrikeTimer -= diff;

                if (callFlamesTimer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
                    {
                        DoCast(target, SPELL_CALL_FLAMES);
                        callFlamesTimer = urand(10 * IN_MILLISECONDS, 20 * IN_MILLISECONDS);
                    }
                }
                    else callFlamesTimer -= diff;

                if (!sacrificed)
                {
                    if (HealthBelowPct(50))
                    {
                        if (Unit* sacrificeTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
                        {
                            if (instance)
                                instance->SetData64(DATA_SACRIFICED_PLAYER, sacrificeTarget->GetGUID());

                            Talk(SAY_SACRIFICE_PLAYER);

                            DoCast(sacrificeTarget, SPELL_RITUAL_PREPARATION);

                            SetCombatMovement(false);

                            Phase = SACRIFICING;
                            sacrePhase = 0;
                            sacrificeTimer = 1 * IN_MILLISECONDS;

                            DoCast(me, SPELL_RITUAL_OF_THE_SWORD);
                            sacrificed = true;
                        }
                    }
                }

                DoMeleeAttackIfReady();
            }
            else  //SACRIFICING
            {
                if (sacrificeTimer <= diff)
                {
                    switch (sacrePhase)
                    {
                        case 0:
                            // spawn ritual channelers
                            if (instance)
                            {
                                DoCast(me, SPELL_RITUAL_CHANNELER_1, true);
                                DoCast(me, SPELL_RITUAL_CHANNELER_2, true);
                                DoCast(me, SPELL_RITUAL_CHANNELER_3, true);
                            }
                            ++sacrePhase;
                            sacrificeTimer = 2 * IN_MILLISECONDS;
                            break;
                        case 1:
                            me->StopMoving();
                            me->GetMotionMaster()->MoveIdle();
                            me->InterruptNonMeleeSpells(true);
                            DoCast(me, SPELL_RITUAL_STRIKE_TRIGGER, true);
                            ++sacrePhase;
                            sacrificeTimer = 200;
                            break;
                        case 2:
                            DoCast(me, SPELL_RITUAL_DISARM);
                            ++sacrePhase;
                            break;
                        case 3:
                            break;
                    }
                }
                else sacrificeTimer -= diff;
            }
        }
        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;
        }