Beispiel #1
0
	void SetData(uint32 uiType, uint32 uiData)
	{
		switch(uiType)
		{
		case DATA_BALTHARUS_EVENT:
			m_auiEncounter[0] = uiData;
			if(uiData == DONE)
				m_uiBossCounter++;
			if(m_uiBossCounter == 3)
			{
				Creature *pCreature = instance->GetCreature(GetData64(DATA_HALION));
				pCreature->SetReactState(REACT_AGGRESSIVE);
				pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
				pCreature->SetVisibility(VISIBILITY_ON);
			}		
			break;
		case DATA_ZARITHRIAN_EVENT:
			m_auiEncounter[1] = uiData;
			if(uiData == DONE)
				m_uiBossCounter++;
			if(m_uiBossCounter == 3)
			{
				Creature *pCreature = instance->GetCreature(GetData64(DATA_HALION));
				pCreature->SetReactState(REACT_AGGRESSIVE);
				pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
				pCreature->SetVisibility(VISIBILITY_ON);
			}
			break;
		case DATA_RAGEFIRE_EVENT:
			m_auiEncounter[2] = uiData;
			if(uiData == DONE)
				m_uiBossCounter++;
			if(m_uiBossCounter == 3)
			{
				Creature *pCreature = instance->GetCreature(GetData64(DATA_HALION));
				pCreature->SetReactState(REACT_AGGRESSIVE);
				pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
				pCreature->SetVisibility(VISIBILITY_ON);
			}
			break;
		case DATA_HALION_EVENT:
			m_auiEncounter[3] = uiData;
			if(uiData == DONE)
			{
				switch(instance->GetDifficulty())
				{
				case RAID_DIFFICULTY_10MAN_NORMAL:
					DoCompleteAchievement(4817);
				case RAID_DIFFICULTY_10MAN_HEROIC:
					DoCompleteAchievement(4818);
				case RAID_DIFFICULTY_25MAN_NORMAL:
					DoCompleteAchievement(4815);
				case RAID_DIFFICULTY_25MAN_HEROIC:
					DoCompleteAchievement(4816);
				}
			}
		case DATA_XERESTRASZA_EVENT:
			m_uiXerestrasza = uiData;
		}
	}
	void Update(uint32 uiDiff)
	{
		if (m_uiLane1Timer < uiDiff)
		{
			if(Creature* pTrigger = instance->GetCreature(GetData64(DATA_LANE1)))
				if (Creature* pTemp = pTrigger->SummonCreature(NPC_POISEN, 3183.495779f, -3143.447998f, 294.062897f, 3.981270f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 9000))
					pTemp->MonsterMove(3165.249023f, -3166.019043f, 294.063446f, 9000);
			m_uiLane1Timer = 4000;
		}else m_uiLane1Timer -= uiDiff; 

		if (m_uiLane2Timer < uiDiff)
		{
			if(Creature* pTrigger = instance->GetCreature(GetData64(DATA_LANE2)))
				if (Creature* pTemp = pTrigger->SummonCreature(NPC_POISEN, 3174.359619f, -3137.360840f, 294.062897f, 4.044f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 9000))
					pTemp->MonsterMove(3155.766113f, -3158.337158f, 294.062897f, 9000);
			m_uiLane2Timer = 4000;
		}else m_uiLane2Timer -= uiDiff; 

		if (m_uiLane3Timer < uiDiff)
		{
			if(Creature* pTrigger = instance->GetCreature(GetData64(DATA_LANE3)))
				if (Creature* pTemp = pTrigger->SummonCreature(NPC_POISEN, 3192.833740f, -3151.343506f, 294.003479f, 4.044f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 9000))
					pTemp->MonsterMove(3173.857178f, -3173.015625f, 294.063354f, 9000);
			m_uiLane3Timer = 4000;
		}else m_uiLane3Timer -= uiDiff;
	}
 void ShiftPhase()
 {
     uiAscendantCouncilPhase++;
     if (uiAscendantCouncilPhase == 2)
     {
         ChangeState(GetData64(DATA_FELUDIUS),false,false);
         ChangeState(GetData64(DATA_IGNACIOUS),false,false);
         ChangeState(GetData64(DATA_ARION),true,false);
         ChangeState(GetData64(DATA_TERRASTRA),true,false);
     }
     else if (uiAscendantCouncilPhase == 3)
     {
     }
 }
 void OnPlayerEnter(Player* /*player*/)
 {
     if (!GetData64(DATA_HALION_CONTROLLER) && GetBossState(DATA_HALION) != DONE && GetBossState(DATA_GENERAL_ZARITHRIAN) == DONE)
     {
         instance->LoadGrid(HalionControllerSpawnPos.GetPositionX(), HalionControllerSpawnPos.GetPositionY());
         if (Creature* halionController = instance->SummonCreature(NPC_HALION_CONTROLLER, HalionControllerSpawnPos))
             halionController->AI()->DoAction(ACTION_INTRO_HALION);
     }
 }
Beispiel #5
0
		void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o) {
			if (Creature* npc = instance->GetCreature(GetData64(entry))) {
				if (npc->isAlive()) {
					npc->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
					npc->GetMotionMaster()->MovePoint(1, x, y, z);
					npc->SetHomePosition(x, y, z, o);
				}
			}
		}
 void initBlyCrewMember(uint32 entry, float x, float y, float z)
 {
     if (Creature* crew = GetCreature(GetData64(entry)))
     {
         crew->SetReactState(REACT_AGGRESSIVE);
         crew->SetWalk(true);
         crew->SetHomePosition(x, y, z, 0);
         crew->GetMotionMaster()->MovePoint(1, x, y, z);
         crew->SetFaction(FACTION_FREED);
     }
 }
            void OnPlayerEnter(Player* player)
            {
                if (instance->IsHeroic())
                {
                    player->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 1);
                    player->SendUpdateWorldState(UPDATE_STATE_UI_COUNT, GetData(TYPE_COUNTER));
                }
                else
                    player->SendUpdateWorldState(UPDATE_STATE_UI_SHOW, 0);

                // make sure Anub'arak isnt missing and floor is destroyed after a crash
                if (GetBossState(BOSS_LICH_KING) == DONE && TrialCounter && GetBossState(BOSS_ANUBARAK) != DONE)
                {
                    Creature* anubArak = Unit::GetCreature(*player, GetData64(NPC_ANUBARAK));
                    if (!anubArak)
                        anubArak = player->SummonCreature(NPC_ANUBARAK, AnubarakLoc[0].GetPositionX(), AnubarakLoc[0].GetPositionY(), AnubarakLoc[0].GetPositionZ(), 3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, DESPAWN_TIME);

                    if (GameObject* floor = GameObject::GetGameObject(*player, GetData64(GO_ARGENT_COLISEUM_FLOOR)))
                        floor->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
                }
            }
Beispiel #8
0
 void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
 {
     if (Creature* npc = instance->GetCreature(GetData64(entry)))
     {
         if (npc->isAlive())
         {
             npc->GetMotionMaster()->MovePoint(1, x, y, z, MOVE_PATHFINDING | MOVE_WALK_MODE);
             npc->SetCombatStartPosition(x, y, z);
             npc->SetHomePosition(x, y, z, npc->GetOrientation());
         }
     }
 }
 void MoveNPCIfAlive(uint32 entry, float x, float y, float z, float o)
 {
    if (Creature* npc = instance->GetCreature(GetData64(entry)))
    {
        if (npc->IsAlive())
        {
             npc->SetWalk(true);
             npc->GetMotionMaster()->MovePoint(1, x, y, z);
             npc->SetHomePosition(x, y, z, o);
        }
     }
 }
        void OnPlayerEnter(Player * plr)
        {
            if (!plr || !plr->IsInWorld())
                return;

            Position pos = { 5304.132324f, 2001.124634f, 709.341431f, 3.895033f };

            if (plr->HasAura(SPELL_QUELDELARS_ZWANG) && !GetData64(DATA_QUELDELAR_PLR))
            {
                SetData64(DATA_QUELDELAR_PLR, plr->GetGUID());

                if (!instance->GetCreature(QuelDelarGUID))
                    instance->SummonCreature(NPC_QUELDELAR_TRIGGER, pos);
            }

            if (WaveCnt)
                DoUpdateWorldState(WORLD_STATE_HOR, 1);
        }
 void OnCreatureCreate(Creature* creature, bool /*add*/)
 {
     switch (creature->GetEntry())
     {
     case NPC_EMPEROR: EmperorGUID = creature->GetGUID(); break;
     case NPC_PHALANX: PhalanxGUID = creature->GetGUID(); break;
     case NPC_DOOMREL: TombBossGUIDs[0] = creature->GetGUID(); break;
     case NPC_DOPEREL: TombBossGUIDs[1] = creature->GetGUID(); break;
     case NPC_HATEREL: TombBossGUIDs[2] = creature->GetGUID(); break;
     case NPC_VILEREL: TombBossGUIDs[3] = creature->GetGUID(); break;
     case NPC_SEETHREL: TombBossGUIDs[4] = creature->GetGUID(); break;
     case NPC_GLOOMREL: TombBossGUIDs[5] = creature->GetGUID(); break;
     case NPC_ANGERREL: TombBossGUIDs[6] = creature->GetGUID(); break;
     case NPC_MAGMUS:
         MagmusGUID = creature->GetGUID();
         if (!creature->isAlive())
             HandleGameObject(GetData64(DATA_THRONE_DOOR), true); // if Magmus is dead open door to last boss
         break;
     }
 }
    void Update(uint32 diff)
    {
        if(GetData(EVENT_TERONGOREFIEND) == IN_PROGRESS)
        {
            if(sodList.size())
            {
                for(std::map<uint64,uint32>::iterator itr = sodList.begin(); itr != sodList.end(); itr++)
                {
                    if(itr->second <= diff)
                    {
                        if(Unit *teron = instance->GetCreature(GetData64(DATA_TERONGOREFIEND)))
                            teron->CastSpell(teron, 40266, true);

                        sodList.erase(itr);
                    }
                    else
                        itr->second -= diff;
                }
            }
        }
    }
 void OnDestroy(InstanceMap* pMap)
 {
     if (Creature* weakSpot = instance->GetCreature(GetData64(NPC_WEAK_SPOT)))
         weakSpot->_ExitVehicle();
 }
Beispiel #14
0
    void OnCreatureCreate(Creature* pCreature, bool add/*, uint32 data, ScriptedInstance* m_pInstance, Map *m_pMap*/)
    {
        std::stringstream ss;
        ss << "pCreature->GetEntry()== " << pCreature->GetEntry();
        outstring_log(ss.str().c_str());

        outstring_log("OnCreatureCreate");
        switch (pCreature->GetEntry())
        {
            case NPC_LEVIATHAN:
                outstring_log("NPC_LEVIATHAN");
                m_uiLeviathanGUID = pCreature->GetGUID();
                break;
            case NPC_LEVIATHAN_TRIGGER:
                m_uiLeviathan_Trigger = pCreature->GetGUID();
                break;
            case NPC_IGNIS:
                m_uiIgnisGUID = pCreature->GetGUID();
                break;
            case NPC_RAZORSCALE:
                m_uiRazorscaleGUID = pCreature->GetGUID();
                if (/*data == FAIL && */instance)
                {
                    if (Creature *commander = instance->GetCreature(GetData64(TYPE_COMMANDER)))
                        commander->SetVisibility(VISIBILITY_ON);
                }
                break;
            case NPC_XT002:
                m_uiXT002GUID = pCreature->GetGUID();
                break;
            case NPC_STEELBREAKER:
                m_uiSteelbreaker = pCreature->GetGUID();
                break;
            case NPC_MOLGEIM:
                m_uiMolgeim = pCreature->GetGUID();
                break;
            case NPC_BRUNDIR:
                m_uiBrundir = pCreature->GetGUID();
                break;
            case NPC_KOLOGARN:
                m_uiKologarnGUID = pCreature->GetGUID();
                break;
            case NPC_KOLOGARN_LEFT_ARM:
                m_uiKologarnLeftGUID = pCreature->GetGUID();
                break;
            case NPC_KOLOGARN_RIGHT_ARM:
                m_uiKologarnRightGUID = pCreature->GetGUID();
                break;
            case NPC_AURIAYA:
                m_uiAuriayaGUID = pCreature->GetGUID();
                break;
            case NPC_MIMIRON:
                m_uiMimironGUID = pCreature->GetGUID();
                break;
            case NPC_HODIR:
                m_uiHodirGUID = pCreature->GetGUID();
                break;
            case NPC_THORIM:
                m_uiThorimGUID = pCreature->GetGUID();
                break;
            case NPC_FREYA:
                m_uiFreyaGUID = pCreature->GetGUID();
                break;
            case NPC_VEZAX:
                m_uiVezaxGUID = pCreature->GetGUID();
                break;
            case NPC_YOGGSARON:
                m_uiYoggSaronGUID = pCreature->GetGUID();
                break;
            case NPC_ALGALON:
                m_uiAlgalonGUID = pCreature->GetGUID();
                break;
            case NPC_COMMANDER:
                m_uiExpCommander = pCreature->GetGUID();
                break;
            case NPC_IRON_CONSTRUCT:
                {
                    pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
                    m_uiIronConstructGUIDs[m_auiConstrCount] = pCreature->GetGUID();
                    m_auiConstrCount++;
                    break;
                }
        }
    }
        void SetData(uint32 uiType, uint32 uiData)
        {
            switch(uiType)
            {
                case TYPE_JARAXXUS:
                    if (uiData == DONE) m_uiEvent = 2000;
                    break;
                case TYPE_CRUSADERS:
                    switch (uiData)
                    {
                        case IN_PROGRESS: m_uiResilienceWillFixItTimer = 0; break;
                        case SPECIAL: //Means the first blood
                            m_uiResilienceWillFixItTimer = 60*IN_MILLISECONDS;
                            uiData = IN_PROGRESS;
                            break;
                        case DONE:
                            DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DEFEAT_FACTION_CHAMPIONS);
                            if (m_uiResilienceWillFixItTimer > 0)
                                DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_CHAMPIONS_KILLED_IN_MINUTE);
                            if (GameObject* pChest = instance->GetGameObject(m_uiCrusadersCacheGUID))
                                if (pChest && !pChest->isSpawned())
                                    pChest->SetRespawnTime(7*DAY);
                            m_uiEvent = 3100;
                            break;
                    }
                    break;
                case TYPE_VALKIRIES:
                    switch (uiData)
                    {
                        case FAIL:
                            if (m_auiEncounter[TYPE_VALKIRIES] == NOT_STARTED) uiData = NOT_STARTED;
                            break;
                        case SPECIAL:
                            if (m_auiEncounter[TYPE_VALKIRIES] == SPECIAL) uiData = DONE;
                            break;
                        case DONE:
                            if (instance->GetPlayers().getFirst()->getSource()->GetTeam() == ALLIANCE)
                                m_uiEvent = 4020;
                            else
                                m_uiEvent = 4030;
                            break;
                    }
                    break;
                case TYPE_ANUBARAK:
                    switch (uiData)
                    {
                        case DONE:
                            m_uiEvent = 6000;
                            break;
                        case SPECIAL:
                            uint32 tributeChest = 0;
                            if (instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC)
                            {
                                if (m_uiTrialCounter >= 50)
                                    tributeChest = GO_TRIBUTE_CHEST_10H_99;
                                else
                                    if (m_uiTrialCounter >= 45)
                                        tributeChest = GO_TRIBUTE_CHEST_10H_50;
                                    else
                                        if (m_uiTrialCounter >= 25)
                                            tributeChest = GO_TRIBUTE_CHEST_10H_45;
                                        else
                                            tributeChest = GO_TRIBUTE_CHEST_10H_25;
                            }
                            else if (instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC)
                            {
                                if (m_uiTrialCounter >= 50)
                                    tributeChest = GO_TRIBUTE_CHEST_25H_99;
                                else
                                    if (m_uiTrialCounter >= 45)
                                        tributeChest = GO_TRIBUTE_CHEST_25H_50;
                                    else
                                        if (m_uiTrialCounter >= 25)
                                            tributeChest = GO_TRIBUTE_CHEST_25H_45;
                                        else
                                            tributeChest = GO_TRIBUTE_CHEST_25H_25;
                            }
                            if (tributeChest)
                                if (Creature* pTirion =  instance->GetCreature(m_uiTirionGUID))
                                    if (GameObject* pChest = pTirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, 90000000))
                                        pChest->SetRespawnTime(pChest->GetRespawnDelay());
                            break;
                    }
                    break;
                case TYPE_COUNTER:   m_uiTrialCounter = uiData; uiData = DONE; break;
                case TYPE_EVENT:     m_uiEvent = uiData; uiData = NOT_STARTED; break;
                case TYPE_EVENT_TIMER:      m_uiEventTimer = uiData; uiData = NOT_STARTED; break;
                case TYPE_NORTHREND_BEASTS:
                    m_uiNorthrendBeasts = uiData;
                    switch (uiData)
                    {
                        case GORMOK_DONE:
                            m_uiEvent = 200;
                            SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS);
                            SetData(TYPE_BEASTS, IN_PROGRESS);
                            break;
                        case SNAKES_IN_PROGRESS: m_uiNotOneButTwoJormungarsTimer = 0; break;
                        case SNAKES_SPECIAL: m_uiNotOneButTwoJormungarsTimer = 10*IN_MILLISECONDS; break;
                        case SNAKES_DONE:
                            if (m_uiNotOneButTwoJormungarsTimer > 0)
                                DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_WORMS_KILLED_IN_10_SECONDS);
                            m_uiEvent = 300;
                            SetData(TYPE_NORTHREND_BEASTS, IN_PROGRESS);
                            SetData(TYPE_BEASTS, IN_PROGRESS);
                            break;
                        case ICEHOWL_DONE:
                            m_uiEvent = 400;
                            SetData(TYPE_NORTHREND_BEASTS, DONE);
                            SetData(TYPE_BEASTS, DONE);
                            break;
                        case FAIL:
                            SetData(TYPE_BEASTS, FAIL);
                            break;
                    }
                    break;
                case DATA_HEALTH_TWIN_SHARED:     m_uiDataDamageTwin = uiData; uiData = NOT_STARTED; break;

                //Achievements
                case DATA_SNOBOLD_COUNT:
                    if (uiData == INCREASE)
                        ++m_uiSnoboldCount;
                    else if (uiData == DECREASE)
                        --m_uiSnoboldCount;
                    break;
                case DATA_MISTRESS_OF_PAIN_COUNT:
                    if (uiData == INCREASE)
                        ++m_uiMistressOfPainCount;
                    else if (uiData == DECREASE)
                        --m_uiMistressOfPainCount;
                    break;
                case DATA_TRIBUTE_TO_IMMORTALITY_ELEGIBLE:
                    m_bTributeToImmortalityElegible = false;
                    break;
            }
            if (IsEncounterInProgress())
            {
                CloseDoor(GetData64(GO_EAST_PORTCULLIS));
                CloseDoor(GetData64(GO_WEB_DOOR));
            } else {
                OpenDoor(GetData64(GO_EAST_PORTCULLIS));
                OpenDoor(GetData64(GO_WEB_DOOR));
            }

            if (uiType < MAX_ENCOUNTERS)
            {
                sLog->outBasic("[ToCr] m_auiEncounter[uiType %u] %u = uiData %u;", uiType, m_auiEncounter[uiType], uiData);
                if (uiData == FAIL)
                {
                    if (IsRaidWiped())
                    {
                        --m_uiTrialCounter;
                        m_bNeedSave = true;
                        m_uiEvent = (uiType == TYPE_BEASTS? 666 : 0);
                    }
                    uiData = NOT_STARTED;
                }
                m_auiEncounter[uiType] = uiData;

                if (uiData == DONE || m_bNeedSave == true)
                {
                    if (Unit* pAnnouncer = instance->GetCreature(GetData64(NPC_BARRENT)))
                        pAnnouncer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                    Save();
                }
            }
        }
        void SetData(uint32 type, uint32 data)
        {
            switch(type)
            {
            case BOSS_GRAND_CHAMPIONS:
                m_auiEncounter[0] = data;
                if (data == SPECIAL)
                {
                    for (std::list<uint64>::const_iterator itr = VehicleList.begin(); itr != VehicleList.end(); ++itr)
                        if (Creature* summon = instance->GetCreature(*itr))
                            summon->RemoveFromWorld();
                } else if (data == IN_PROGRESS)
                {
                    for (uint8 i=0; i<3; i++)
                        if (Creature* boss = instance->GetCreature(grandChampionGUID[i]))
                            AggroAllPlayers(boss);
                } else if (data == DONE)
                {
                    DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEVEMENT_CHAMPIONS);
                    if (Creature* announcer =  instance->GetCreature(uiAnnouncerGUID))
                    {
                        announcer->GetMotionMaster()->MovePoint(0, 742.742f, 630.207f, 411.172f);
                        announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        announcer->SummonGameObject(instance->IsHeroic()? GO_CHAMPIONS_LOOT_H : GO_CHAMPIONS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                    }
                }
                break;
            case BOSS_ARGENT_CHALLENGE_E:
                m_auiEncounter[1] = data;
                if (data == DONE)
                {
                    if (Creature* announcer = instance->GetCreature(uiAnnouncerGUID))
                    {
                        DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEVEMENT_EADRIC);
                        announcer->GetMotionMaster()->MovePoint(0, 742.742f, 630.207f, 411.172f);
                        announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        announcer->SummonGameObject(instance->IsHeroic()? GO_EADRIC_LOOT_H : GO_EADRIC_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                    }
                }
                break;
            case BOSS_ARGENT_CHALLENGE_P:
                m_auiEncounter[2] = data;
                if (data == DONE)
                {
                    if (Creature* announcer = instance->GetCreature(uiAnnouncerGUID))
                    {
                        DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEVEMENT_PALETRESS);
                        DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEVEMENT_MEMORIES);
                        announcer->GetMotionMaster()->MovePoint(0, 742.742f, 630.207f, 411.172f);
                        announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        announcer->SummonGameObject(instance->IsHeroic()? GO_PALETRESS_LOOT_H : GO_PALETRESS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                    }
                }
                break;
            case BOSS_BLACK_KNIGHT:
                m_auiEncounter[3] = data;
                if (data == DONE)
                    DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEVEMENT_BLACK_KNIGHT);
                break;
            case DATA_GRAND_CHAMPION_ENTRY:
                for (uint8 i=0; i<3; i++)
                {
                    if (grandChampionEntry[i] == 0)
                    {
                        grandChampionEntry[i] = data;
                        return;
                    }
                }
                break;
            case DATA_MEMORY_ENTRY:
                memoryEntry = data;
                break;
            case DATA_I_VE_HAD_WORSE:
                achievementHadWorse = (bool)data;
                break;
            }

            if (type != DATA_I_VE_HAD_WORSE)
            {
                if (data == DONE || data == FAIL)
                    HandleGameObject(GetData64(DATA_PORTCULLIS), true);
                else if (data == IN_PROGRESS)
                    HandleGameObject(GetData64(DATA_PORTCULLIS), false);

                if (data == DONE)
                    SaveToDB();
            }
        }
    void MovementInform(Creature* creature, uint32 uiType, uint32 uiPointId)
    {
        if (uiType != POINT_MOTION_TYPE)
            return;

        switch (uiPointId)
        {
        case 0:
            switch (creature->GetEntry())
            {
            case NPC_RIFTWALKER:
                if (Creature* riftTarget = GetCreature(riftTargets[0]))
                {
                    creature->CastSpell(riftTarget, SPELL_OPEN_PORTAL_KJ, false);
                    riftTarget->GetMotionMaster()->MovePoint(0, aOutroLocations[9].m_fX, aOutroLocations[9].m_fY, aOutroLocations[9].m_fZ + 13.0f);
                }
                break;
            case NPC_SOLDIER:
                if (creature->GetGUID() == soldiersGuid[0] || creature->GetGUID() == soldiersGuid[10])
                    creature->SetStandState(UNIT_STAND_STATE_KNEEL);

                if (Creature* portal = GetCreature(portalGuid))
                    creature->SetFacingTo(creature->GetAngle(aOutroLocations[5].m_fX, aOutroLocations[5].m_fY));

                break;
            }
            break;
        case 1:
            switch (creature->GetEntry())
            {
            case NPC_RIFTWALKER:
                if (Creature* riftTarget = GetCreature(riftTargets[1]))
                {
                    creature->CastSpell(riftTarget, SPELL_OPEN_PORTAL_KJ, false);
                    riftTarget->GetMotionMaster()->MovePoint(0, aOutroLocations[10].m_fX, aOutroLocations[10].m_fY, aOutroLocations[10].m_fZ + 13.0f);
                }
                break;
            case NPC_CORE_ENTROPIUS:
                if (Creature* pVelen = GetCreature(prophetGuid))
                    pVelen->InterruptNonMeleeSpells(false);
                break;
            case CREATURE_PROPHET:
                creature->ForcedDespawn(1000);

                // Note: portal should despawn only after all the soldiers have reached this point and "teleported" outside
                if (Creature* pPortal = GetCreature(portalGuid))
                    pPortal->ForcedDespawn(30000);

                for (uint8 i = 0; i < 2; i++)
                {
                    if (Creature* rift = GetCreature(riftGuid[i]))
                        rift->ForcedDespawn(1000);
                }

                if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    controller->ForcedDespawn(300000);
                break;
            }
            break;
        case 2:
            if (creature->GetEntry() == NPC_SOLDIER)
                creature->ForcedDespawn(1000);
            break;
        case 10:
            if (creature->GetEntry() == NPC_SOLDIER)
                 creature->SetFacingTo(SoldierMiddle[0].m_fO);
            break;
        case 11:
            if (creature->GetEntry() == NPC_SOLDIER)
                creature->SetFacingTo(SoldierMiddle[1].m_fO);
            break;
        }
    }
            bool SetBossState(uint32 type, EncounterState state)
            {
                if (!InstanceScript::SetBossState(type, state))
                    return false;

                switch (type)
                {
                    case BOSS_BEASTS:
                        break;
                    case BOSS_JARAXXUS:
                        // Cleanup Icehowl
                        if (Creature* icehowl = instance->GetCreature(IcehowlGUID))
                            icehowl->DespawnOrUnsummon();
                        if (state == DONE)
                            EventStage = 2000;
                        break;
                    case BOSS_CRUSADERS:
                        // Cleanup Jaraxxus
                        if (Creature* jaraxxus = instance->GetCreature(JaraxxusGUID))
                            jaraxxus->DespawnOrUnsummon();
                        if (Creature* fizzlebang = instance->GetCreature(FizzlebangGUID))
                            fizzlebang->DespawnOrUnsummon();
                        switch (state)
                        {
                            case IN_PROGRESS:
                                ResilienceWillFixItTimer = 0;
                                break;
                            case SPECIAL: //Means the first blood
                                ResilienceWillFixItTimer = 60*IN_MILLISECONDS;
                                state = IN_PROGRESS;
                                break;
                            case DONE:
                                DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_DEFEAT_FACTION_CHAMPIONS);
                                if (ResilienceWillFixItTimer > 0)
                                    DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_CHAMPIONS_KILLED_IN_MINUTE);
                                DoRespawnGameObject(CrusadersCacheGUID, 7*DAY);
                                if (GameObject* cache = instance->GetGameObject(CrusadersCacheGUID))
                                    cache->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
                                EventStage = 3100;
                                break;
                            default:
                                break;
                        }
                        break;
                    case BOSS_VALKIRIES:
                        // Cleanup chest
                        if (GameObject* cache = instance->GetGameObject(CrusadersCacheGUID))
                            cache->Delete();
                        switch (state)
                        {
                            case FAIL:
                                if (GetBossState(BOSS_VALKIRIES) == NOT_STARTED)
                                    state = NOT_STARTED;
                                break;
                            case SPECIAL:
                                if (GetBossState(BOSS_VALKIRIES) == SPECIAL)
                                    state = DONE;
                                break;
                            case DONE:
                                if (instance->GetPlayers().getFirst()->getSource()->GetTeam() == ALLIANCE)
                                    EventStage = 4020;
                                else
                                    EventStage = 4030;
                                break;
                            default:
                                break;
                        }
                        break;
                    case BOSS_LICH_KING:
                        break;
                    case BOSS_ANUBARAK:
                        switch (state)
                        {
                            case DONE:
                            {
                                EventStage = 6000;
                                uint32 tributeChest = 0;
                                if (instance->GetSpawnMode() == RAID_DIFFICULTY_10MAN_HEROIC)
                                {
                                    if (TrialCounter >= 50)
                                        tributeChest = GO_TRIBUTE_CHEST_10H_99;
                                    else
                                    {
                                        if (TrialCounter >= 45)
                                            tributeChest = GO_TRIBUTE_CHEST_10H_50;
                                        else
                                        {
                                            if (TrialCounter >= 25)
                                                tributeChest = GO_TRIBUTE_CHEST_10H_45;
                                            else
                                                tributeChest = GO_TRIBUTE_CHEST_10H_25;
                                        }
                                    }
                                }
                                else if (instance->GetSpawnMode() == RAID_DIFFICULTY_25MAN_HEROIC)
                                {
                                    if (TrialCounter >= 50)
                                        tributeChest = GO_TRIBUTE_CHEST_25H_99;
                                    else
                                    {
                                        if (TrialCounter >= 45)
                                            tributeChest = GO_TRIBUTE_CHEST_25H_50;
                                        else
                                        {
                                            if (TrialCounter >= 25)
                                                tributeChest = GO_TRIBUTE_CHEST_25H_45;
                                            else
                                                tributeChest = GO_TRIBUTE_CHEST_25H_25;
                                        }
                                    }
                                }

                                if (tributeChest)
                                    if (Creature* tirion =  instance->GetCreature(TirionGUID))
                                        if (GameObject* chest = tirion->SummonGameObject(tributeChest, 805.62f, 134.87f, 142.16f, 3.27f, 0, 0, 0, 0, WEEK))
                                            chest->SetRespawnTime(chest->GetRespawnDelay());
                                break;
                            }
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }

                if (IsEncounterInProgress())
                {
                    CloseDoor(GetData64(GO_EAST_PORTCULLIS));
                    CloseDoor(GetData64(GO_WEB_DOOR));
                }
                else
                {
                    OpenDoor(GetData64(GO_EAST_PORTCULLIS));
                    OpenDoor(GetData64(GO_WEB_DOOR));
                }

                if (type < MAX_ENCOUNTERS)
                {
                    TC_LOG_INFO(LOG_FILTER_TSCR, "[ToCr] BossState(type %u) %u = state %u;", type, GetBossState(type), state);
                    if (state == FAIL)
                    {
                        if (instance->IsHeroic())
                        {
                            --TrialCounter;
                            // decrease attempt counter at wipe
                            Map::PlayerList const &PlayerList = instance->GetPlayers();
                            for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                                if (Player* player = itr->getSource())
                                    player->SendUpdateWorldState(UPDATE_STATE_UI_COUNT, TrialCounter);

                            // if theres no more attemps allowed
                            if (!TrialCounter)
                            {
                                if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT)))
                                    announcer->ToCreature()->DespawnOrUnsummon();

                                if (Creature* anubArak = instance->GetCreature(GetData64(NPC_ANUBARAK)))
                                    anubArak->DespawnOrUnsummon();
                            }
                        }
                        NeedSave = true;
                        EventStage = (type == BOSS_BEASTS ? 666 : 0);
                        state = NOT_STARTED;
                    }

                    if (state == DONE || NeedSave)
                    {
                        if (Unit* announcer = instance->GetCreature(GetData64(NPC_BARRENT)))
                            announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        Save();
                    }
                }
                return true;
            }
    void SetData(uint32 idx, uint32 data)
    {
        if (idx == SCARAB_DEATH)
        {
            scarabsDeaths.push_back(time(NULL));
            if (scarabsDeaths.size() >= 40)
            {
                for (int i=0; i<(int)scarabsDeaths.size(); ++i)
                {
                    time_t scarab1 = scarabsDeaths[i];
                    uint32 count = 0;

                    for (int j=0; j<(int)scarabsDeaths.size(); ++j)
                    {
                        if (i == j)
                            continue;

                        time_t scarab2 = scarabsDeaths[j];

                        if ((scarab2 > scarab1 ? scarab2 - scarab1 : scarab1 - scarab2) <= 30)
                            ++count;

                        if (count >= 40)
                        {
                            if (instance->GetSpawnMode() == 0 || instance->GetSpawnMode() == 2)
                                DoCompleteAchievement(3800);
                            if (instance->GetSpawnMode() == 1 || instance->GetSpawnMode() == 3)
                                DoCompleteAchievement(3816);

                            break;
                        }
                    }

                    if (count >= 40)
                        break;
                }
            }

            return;
        }

        if (idx == UPDATE_DEATHS_COUNT)
        {
            ++deathsCount;
            return;
        }

        if (idx == TIME_ACIDMAW_DEAD || idx == TIME_DREADSCALE_DEAD)
        {
            if (idx == TIME_ACIDMAW_DEAD)
                acidmawDead = time(NULL);
            if (idx == TIME_DREADSCALE_DEAD)
                dreadscaleDead = time(NULL);

            if (acidmawDead && dreadscaleDead)
            {
                time_t interval = acidmawDead >= dreadscaleDead ? acidmawDead - dreadscaleDead : dreadscaleDead - acidmawDead;
                if (interval <= 10)
                {
                    //Not One, But Two Jormungars
                    uint32 achi = 0;
                    if (instance->GetSpawnMode() == 0 || instance->GetSpawnMode() == 2) //10 man normal/hero
                        achi = 3936;
                    else if (instance->GetSpawnMode() == 1 || instance->GetSpawnMode() == 3) //25 man normal/hero
                        achi = 3937;

                    if (achi)
                        DoCompleteAchievement(achi);
                }
            }
        }

        if (idx != RESET_TO_FIGHT)
            return;
        else
        {
            //prevent for '--attempts' for multiple function calls (ie in case of wipe during champions fight, when function is called 6-10 times)
            if (GetBossState(data) != FAIL)
            {
                if (attempts)
                    --attempts;
            }

            if (data == DATA_ANUBARAK)
            {
                scarabsDeaths.clear();
                return;
            }
        }

        for (int i=BOSS_GORMOK; i<=BOSS_DARK_TWIN; ++i)
        {
            if (Creature* boss = instance->GetCreature(GetData64(i)))
                boss->DespawnOrUnsummon();
        }

        if (Creature* gadajacy = instance->GetCreature(GetData64(GADAJACY)))
        {
            if (!gadajacy->isAlive())
                gadajacy->Respawn(true);

            gadajacy->SetVisible(true);
        }

        if (data == DATA_TWIN_VALKYR)
        {
            SetBossState(DATA_ANUBARAK, NOT_STARTED);
            SetBossState(DATA_TWIN_VALKYR, FAIL);
        }

        if (data == DATA_FACTION_CHAMPIONS)
        {
            SetBossState(DATA_ANUBARAK, NOT_STARTED);
            SetBossState(DATA_TWIN_VALKYR, NOT_STARTED);
            SetBossState(DATA_FACTION_CHAMPIONS, FAIL);
        }

        if (data == DATA_LORD_JARAXXUS)
        {
            SetBossState(DATA_ANUBARAK, NOT_STARTED);
            SetBossState(DATA_TWIN_VALKYR, NOT_STARTED);
            SetBossState(DATA_FACTION_CHAMPIONS, NOT_STARTED);
            SetBossState(DATA_LORD_JARAXXUS, FAIL);
        }

        if (data == DATA_BEASTS)
        {
            uiSnoboldGuid_1 = 0;
            uiSnoboldGuid_2 = 0;
            uiSnoboldGuid_3 = 0;
            uiSnoboldGuid_4 = 0;

            acidmawDead = 0;
            dreadscaleDead = 0;

            SetBossState(DATA_ANUBARAK, NOT_STARTED);
            SetBossState(DATA_TWIN_VALKYR, NOT_STARTED);
            SetBossState(DATA_FACTION_CHAMPIONS, NOT_STARTED);
            SetBossState(DATA_LORD_JARAXXUS, NOT_STARTED);
            SetBossState(DATA_BEASTS, FAIL);
        }
    }
    void Update(uint32 diff)
    {
        // KilJaeden Outro
        if (m_Outrotimer <= diff)
        {
            switch (GetData(DATA_OUTRO_KJ))
            {
                case POINT_KILJAEDEN_DIE:
                    // While Kil'Jaeden die
                    if (Creature* Anveena = GetCreature(GetData64(DATA_ANVEENA)))
                        Anveena->ForcedDespawn(); //this should already be done but let's do it again in case phase was gm rushed

                    m_Outrotimer = 15000;
                    SetData(DATA_OUTRO_KJ, POINT_TELEPORT_KALECGOS);
                    break;
                case POINT_TELEPORT_KALECGOS:
                    if (Creature* pKalec = GetCreature(GetData64(DATA_KALECGOS_KJ)))
                    {
                        pKalec->SetVisible(true);
                        pKalec->CastSpell(pKalec, SPELL_KALEC_TELEPORT, true);
                        pKalec->SendMovementFlagUpdate();
                    }

                    if (Creature* pKJ = GetCreature(GetData64(DATA_KILJAEDEN)))
                        pKJ->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); //allow loot

                    m_Outrotimer = 2000;
                    SetData(DATA_OUTRO_KJ, SAY_KALECGOS_GOODBYE);
                    break;
                case SAY_KALECGOS_GOODBYE:
                    if (Creature* pKalec = GetCreature(GetData64(DATA_KALECGOS_KJ)))
                        DoScriptText(-1580090, pKalec);

                    m_Outrotimer = 15000;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_SHATTERED);
                    break;
                case POINT_SUMMON_SHATTERED:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        if (Creature* portal = controller->SummonCreature(NPC_BOSS_PORTAL, aOutroLocations[0].m_fX, aOutroLocations[0].m_fY, aOutroLocations[0].m_fZ, aOutroLocations[0].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            portalGuid = portal->GetGUID();

                        for (uint8 i = 1; i < 3; i++)
                        {
                            if (TempSummon * riftWalker = controller->SummonCreature(NPC_RIFTWALKER, aOutroLocations[i].m_fX, aOutroLocations[i].m_fY, aOutroLocations[i].m_fZ, aOutroLocations[i].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            {
                                riftGuid[i - 1] = riftWalker->GetGUID();

                                if (i == 1)
                                    riftWalker->GetMotionMaster()->MovePoint(0, aOutroLocations[7].m_fX, aOutroLocations[7].m_fY, aOutroLocations[7].m_fZ);
                                else
                                    riftWalker->GetMotionMaster()->MovePoint(1, aOutroLocations[8].m_fX, aOutroLocations[8].m_fY, aOutroLocations[8].m_fZ);

                                if (Creature * riftTarget = controller->SummonCreature(WORLD_TRIGGER, aOutroLocations[8 + i].m_fX, aOutroLocations[8 + i].m_fY, aOutroLocations[8 + i].m_fZ, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
                                {
                                    riftTargets[i - 1] = riftTarget->GetGUID();
                                    riftTarget->SetSpeed(MOVE_RUN, 0.5f);
                                }
                            }
                        }
                    }

                    m_Outrotimer = 15000;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_PORTAL);
                    break;
                case POINT_SUMMON_PORTAL:
                    if (Creature* portal = GetCreature(portalGuid))
                    {
                        portal->SetDisplayId(DISPLAYID_PORTAL_OPENING);
                        for (uint8 i = 0; i < 2; i++)
                        {
                            if (Creature* riftTarget = GetCreature(riftTargets[i]))
                                riftTarget->ForcedDespawn(1000);
                        }
                    }

                    m_Outrotimer = 500;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_PORTAL_ENDOPENANIM);
                    break;
                case POINT_SUMMON_PORTAL_ENDOPENANIM:
                    if (Creature* portal = GetCreature(portalGuid))
                        portal->SetStandState(UNIT_STAND_STATE_SIT); //this smoothly stop the explosion effect and just let the smokes continues

                    m_Outrotimer = 3500;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_SOLDIERS_RIGHT);
                    break;
                case POINT_SUMMON_SOLDIERS_RIGHT:
                    for (uint8 i = 0; i < 2; i++)
                    {
                        if (Creature* rift = GetCreature(riftGuid[i]))
                        {
                            rift->RemoveAurasDueToSpell(SPELL_OPEN_PORTAL_KJ);
                            rift->InterruptNonMeleeSpells(false);
                        }
                    }
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        for (uint8 i = 0; i < 10; i++)
                        {
                            if (TempSummon *soldier = controller->SummonCreature(NPC_SOLDIER, SoldierLocations[i].m_fX, SoldierLocations[i].m_fY, SoldierLocations[i].m_fZ, SoldierLocations[i].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            {
                                soldiersGuid[i] = soldier->GetGUID();
                                soldier->GetMotionMaster()->MovePoint(0, SoldierMiddle[0].m_fX, SoldierMiddle[0].m_fY, SoldierMiddle[0].m_fZ, false);

                                if (i == 0)
                                    soldier->GetMotionMaster()->MovePoint(0, SoldierMiddle[0].m_fX, SoldierMiddle[0].m_fY, SoldierMiddle[0].m_fZ, false);
                                else
                                {
                                    float sx, sy;
                                    float angle = m_currentAngleFirst * (2.0f * M_PI) / 360.0f;
                                    float rayon = 5.0f;
                                    sx = SoldierMiddle[0].m_fX + cos(angle) * rayon;
                                    sy = SoldierMiddle[0].m_fY + sin(angle) * rayon;
                                    soldier->GetMotionMaster()->MovePoint(0, sx, sy, SoldierMiddle[0].m_fZ, false);
                                    m_currentAngleFirst = m_currentAngleFirst + 36;
                                }
                            }
                        }
                    }

                    m_Outrotimer = 8000;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_SOLDIERS_LEFT);
                    break;
                case POINT_SUMMON_SOLDIERS_LEFT:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        for (uint8 i = 10; i < 20; i++)
                        {
                            if (Creature *soldier = controller->SummonCreature(NPC_SOLDIER, SoldierLocations[i].m_fX, SoldierLocations[i].m_fY, SoldierLocations[i].m_fZ, SoldierLocations[i].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            {
                                soldiersGuid[i] = soldier->GetGUID();

                                if (i == 10)
                                    soldier->GetMotionMaster()->MovePoint(0, SoldierMiddle[1].m_fX, SoldierMiddle[1].m_fY, SoldierMiddle[1].m_fZ, false);
                                else
                                {
                                    float sx, sy;
                                    float angle = m_currentAngleFirst * (2 * M_PI) / 360;
                                    float rayon = 5.0f;
                                    sx = SoldierMiddle[1].m_fX + cos(angle) * rayon;
                                    sy = SoldierMiddle[1].m_fY + sin(angle) * rayon;
                                    soldier->GetMotionMaster()->MovePoint(0, sx, sy, SoldierMiddle[1].m_fZ, false);
                                    m_currentAngleFirst = m_currentAngleFirst + 36;
                                }
                            }
                        }
                    }

                    m_Outrotimer = 10000;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_PROPHET);
                    break;
                case POINT_SUMMON_PROPHET:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        if (TempSummon* prophet = controller->SummonCreature(CREATURE_PROPHET, aOutroLocations[3].m_fX, aOutroLocations[3].m_fY, aOutroLocations[3].m_fZ, aOutroLocations[3].m_fO, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            prophetGuid = prophet->GetGUID();

                        if (TempSummon* core = controller->SummonCreature(NPC_CORE_ENTROPIUS, controller->GetPositionX(), controller->GetPositionY(), 85.0f, 0, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            entropiusCoreGuid = core->GetGUID();
                    }

                    m_Outrotimer = 2000;
                    SetData(DATA_OUTRO_KJ, POINT_SUMMON_LIADRIN);
                    break;
                case POINT_SUMMON_LIADRIN:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                        if (Creature* liadrin = controller->SummonCreature(CREATURE_LIADRIN, aOutroLocations[4].m_fX, aOutroLocations[4].m_fY, aOutroLocations[4].m_fZ, aOutroLocations[4].m_fO, TEMPSUMMON_TIMED_DESPAWN, 4 * MINUTE * IN_MILLISECONDS))
                            liadrinGuid = liadrin->GetGUID();
                    
                    m_Outrotimer = 4000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_1);
                    break;
                case SAY_OUTRO_1:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580099, prophet);

                    m_Outrotimer = 25000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_2);
                    break;
                case SAY_OUTRO_2:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580100, prophet);

                    m_Outrotimer = 14000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_3);
                    break;
                case SAY_OUTRO_3:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580111, prophet);

                    m_Outrotimer = 10000;
                    SetData(DATA_OUTRO_KJ, POINT_CALL_ENTROPIUS);
                    break;
                case POINT_CALL_ENTROPIUS:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        if (Creature* pEntropius = GetCreature(entropiusCoreGuid))
                        {
                            if (Creature* pVelen = GetCreature(prophetGuid))
                                pVelen->CastSpell(pEntropius, SPELL_CALL_ENTROPIUS, false);

                            pEntropius->SetWalk(false);
                            pEntropius->GetMotionMaster()->MovePoint(1, controller->GetPositionX(), controller->GetPositionY(), 40.0f);
                        }
                    }

                    m_Outrotimer = 10000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_4);
                    break;
                case SAY_OUTRO_4:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580101, prophet);

                    m_Outrotimer = 22000;
                    SetData(DATA_OUTRO_KJ, POINT_MOVE_LIADRIN);
                    break;
                case POINT_MOVE_LIADRIN:
                    if (Creature* pLiadrin = GetCreature(liadrinGuid))
                        pLiadrin->GetMotionMaster()->MovePoint(0, aOutroLocations[6].m_fX, aOutroLocations[6].m_fY, aOutroLocations[6].m_fZ);
                    
                    m_Outrotimer = 6000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_5);
                    break;
                case SAY_OUTRO_5:
                    if (Creature* pLiadrin = GetCreature(liadrinGuid))
                        DoScriptText(-1580107, pLiadrin);

                    m_Outrotimer = 10000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_6);
                    break;
                case SAY_OUTRO_6:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580102, prophet);

                    m_Outrotimer = 15000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_7);
                    break;
                case SAY_OUTRO_7:
                    if (Creature* pLiadrin = GetCreature(liadrinGuid))
                        DoScriptText(-1580108, pLiadrin);

                    m_Outrotimer = 2500;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_8);
                    break;
                case SAY_OUTRO_8:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580103, prophet);

                    m_Outrotimer = 4000;
                    SetData(DATA_OUTRO_KJ, POINT_BLAZE);
                    break;
                case POINT_BLAZE:
                    if (Creature* pEntropius = GetCreature(entropiusCoreGuid))
                    {
                        pEntropius->CastSpell(pEntropius, SPELL_BLAZE_TO_LIGHT, true);
                        pEntropius->RemoveAurasDueToSpell(SPELL_ENTROPIUS_BODY);
                    }

                    m_Outrotimer = 10000;
                    SetData(DATA_OUTRO_KJ, POINT_IGNITE);
                    break;
                case POINT_IGNITE:
                    if (Creature *controller = GetCreature(GetData64(DATA_KILJAEDEN_CONTROLLER)))
                    {
                        // When the purified Muru reaches the ground the sunwell ignites and Muru despawns
                        controller->AI()->DoCast(controller, SPELL_SUNWELL_IGNITION);

                        if (Creature* pLiadrin = GetCreature(liadrinGuid))
                            pLiadrin->SetStandState(UNIT_STAND_STATE_KNEEL);

                        if (Creature* pEntropius = GetCreature(entropiusCoreGuid))
                            pEntropius->ForcedDespawn();
                    }

                    m_Outrotimer = 500;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_9);
                    break;
                case SAY_OUTRO_9:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580104, prophet);

                    m_Outrotimer = 15000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_10);
                    break;
                case SAY_OUTRO_10:
                    if (Creature* pLiadrin = GetCreature(liadrinGuid))
                        DoScriptText(-1580109, pLiadrin);

                    m_Outrotimer = 20000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_11);
                    break;
                case SAY_OUTRO_11:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580105, prophet);

                    m_Outrotimer = 6000;
                    SetData(DATA_OUTRO_KJ, SAY_OUTRO_12);
                    break;
                case SAY_OUTRO_12:
                    if (Creature* prophet = GetCreature(prophetGuid))
                        DoScriptText(-1580106, prophet);

                    m_Outrotimer = 2000;
                    SetData(DATA_OUTRO_KJ, POINT_EVENT_SOLDIER_EXIT);
                    break;
                case POINT_EVENT_SOLDIER_EXIT:
                    for (uint8 i = 0; i < 20; i++)
                    {
                        if (Creature* soldier = GetCreature(soldiersGuid[i]))
                        {
                            soldier->SetWalk(false);
                            soldier->SetSpeed(MOVE_RUN, 1.0f);
                            soldier->GetMotionMaster()->MovePoint(2, SoldierLocations[i].m_fX, SoldierLocations[i].m_fY, SoldierLocations[i].m_fZ, false);
                        }
                    }

                    m_Outrotimer = 8000;
                    SetData(DATA_OUTRO_KJ, POINT_EVENT_VELEN_EXIT);
                    break;
                case POINT_EVENT_VELEN_EXIT:
                    if (Creature* pVelen = GetCreature(prophetGuid))
                        pVelen->GetMotionMaster()->MovePoint(1, aOutroLocations[3].m_fX, aOutroLocations[3].m_fY, aOutroLocations[3].m_fZ);

                    if (Creature* pKalec = GetCreature(GetData64(DATA_KALECGOS_KJ)))
                    {
                        pKalec->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        pKalec->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }

                    m_Outrotimer = 0;
                    SetData(DATA_OUTRO_KJ, OUTRO_DONE);
                    break;
            }
        }
        else
            m_Outrotimer -= diff;
    }
void instance_naxxramas::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_ANUB_REKHAN:
            m_auiEncounter[0] = uiData;
            DoUseDoorOrButton(m_uiAnubDoorGUID);
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiAnubGateGUID);
            break;
		case DATA_HEIGAN_ERUPT:
            HeiganErupt(uiData);
			break;
		case TYPE_ENR_FAERLINA:
			if(Creature* Faerlina = instance->GetCreature(GetData64(NPC_FAERLINA)))
			{
				Faerlina->RemoveAurasDueToSpell(54100);
				Faerlina->RemoveAurasDueToSpell(28798);
				Faerlina->CastSpell(Faerlina,28732,false);
				break;
			}
        case TYPE_FAERLINA:
            if (uiData == SPECIAL)                          // Used to inform about failed special achievement
            {
                return;
            }
            DoUseDoorOrButton(m_uiFaerWebGUID);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiFaerDoorGUID);
                DoUseDoorOrButton(m_uiMaexOuterGUID);
            }
            if (uiData == FAIL)
            {
                for (std::list<uint64>::const_iterator itr = m_lFaerlinaAddGUIDs.begin(); itr != m_lFaerlinaAddGUIDs.end(); ++itr)
                {
                    Creature* pAdd = instance->GetCreature(*itr);
                    if (pAdd && !pAdd->isAlive())
                        pAdd->Respawn();
                }
            }
            m_auiEncounter[1] = uiData;
            break;
        case TYPE_MAEXXNA:
            m_auiEncounter[2] = uiData;
            DoUseDoorOrButton(m_uiMaexInnerGUID, uiData);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiAracEyeRampGUID);
                DoRespawnGameObject(m_uiAracPortalGUID, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_NOTH:
            m_auiEncounter[3] = uiData;
            DoUseDoorOrButton(m_uiNothEntryDoorGUID);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiNothExitDoorGUID);
                DoUseDoorOrButton(m_uiHeigEntryDoorGUID);
            }
            break;
        case TYPE_HEIGAN:
            m_auiEncounter[4] = uiData;
            DoUseDoorOrButton(m_uiHeigEntryDoorGUID);
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiHeigExitDoorGUID);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[5] = uiData;
            DoUseDoorOrButton(m_uiLoathebDoorGUID);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiPlagEyeRampGUID);
                DoRespawnGameObject(m_uiPlagPortalGUID, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_RAZUVIOUS:
            m_auiEncounter[6] = uiData;
            break;
        case TYPE_GOTHIK:
            switch(uiData)
            {
                case IN_PROGRESS:
                    DoUseDoorOrButton(m_uiGothikEntryDoorGUID);
                    DoUseDoorOrButton(m_uiGothCombatGateGUID);
                    break;
                case SPECIAL:
                    DoUseDoorOrButton(m_uiGothCombatGateGUID);
                    break;
                case FAIL:
                    if (m_auiEncounter[7] == IN_PROGRESS)
                        DoUseDoorOrButton(m_uiGothCombatGateGUID);

                    DoUseDoorOrButton(m_uiGothikEntryDoorGUID);
                    break;
                case DONE:
                    DoUseDoorOrButton(m_uiGothikEntryDoorGUID);
                    DoUseDoorOrButton(m_uiGothikExitDoorGUID);
                    DoUseDoorOrButton(m_uiHorsemenDoorGUID);
                    break;
            }
            m_auiEncounter[7] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            m_auiEncounter[8] = uiData;
            DoUseDoorOrButton(m_uiHorsemenDoorGUID);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiMiliEyeRampGUID);
                DoRespawnGameObject(m_uiMiliPortalGUID, 30*MINUTE);
                DoRespawnGameObject(m_uiHorsemenChestGUID, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_PATCHWERK:
            m_auiEncounter[9] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiPathExitDoorGUID);
            break;
        case TYPE_GROBBULUS:
            m_auiEncounter[10] = uiData;
            break;
        case TYPE_GLUTH:
            m_auiEncounter[11] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiGlutExitDoorGUID);
                DoUseDoorOrButton(m_uiThadDoorGUID);
            }
            break;
        case TYPE_THADDIUS:
            m_auiEncounter[12] = uiData;
            DoUseDoorOrButton(m_uiThadDoorGUID, uiData);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiConsEyeRampGUID);
                DoRespawnGameObject(m_uiConsPortalGUID, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[13] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiKelthuzadDoorGUID);
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[14] = uiData;
            DoUseDoorOrButton(m_uiKelthuzadExitDoorGUID);
            break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
            << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
            << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8] << " "
            << m_auiEncounter[9] << " " << m_auiEncounter[10] << " " << m_auiEncounter[11] << " "
            << m_auiEncounter[12] << " " << m_auiEncounter[13] << " " << m_auiEncounter[14];

        strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Beispiel #22
0
    void SetData(uint32 type, uint32 data)
    {
        Player *player = GetPlayerInMap();

        if (!player)
        {
            debug_log("TSCR: Instance Stratholme: SetData (Type: %u Data %u) cannot find any player.", type, data);
            return;
        }

        switch(type)
        {
        case TYPE_BARON_RUN:
            switch(data)
            {
            case IN_PROGRESS:
                if (Encounter[0] == IN_PROGRESS || Encounter[0] == FAIL)
                    break;
                BaronRun_Timer = 2700000;
                debug_log("TSCR: Instance Stratholme: Baron run in progress.");
                break;
            case FAIL:
                //may add code to remove aura from players, but in theory the time should be up already and removed.
                break;
            case DONE:
                BaronRun_Timer = 0;
                break;
            }
            Encounter[0] = data;
            break;
        case TYPE_BARONESS:
            Encounter[1] = data;
            if (data == SPECIAL)
                UpdateGoState(ziggurat1GUID,0,false);
            if (data == DONE)
                StartSlaugtherSquare();
            break;
        case TYPE_NERUB:
            Encounter[2] = data;
            if (data == SPECIAL)
                UpdateGoState(ziggurat2GUID,0,false);
            if (data == DONE)
                StartSlaugtherSquare();
            break;
        case TYPE_PALLID:
            Encounter[3] = data;
            if (data == SPECIAL)
                UpdateGoState(ziggurat3GUID,0,false);
            if (data == DONE)
                StartSlaugtherSquare();
            break;
        case TYPE_RAMSTEIN:
            if (data == IN_PROGRESS)
            {
                if (Encounter[4] != IN_PROGRESS)
                    UpdateGoState(portGauntletGUID,1,false);

                uint32 count = abomnationGUID.size();
                for(std::set<uint64>::iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i)
                {
                    if (Unit* abom = Unit::GetUnit(*player, *i))
                    {
                        if (!abom->isAlive())
                            --count;
                    }
                }

                if (!count)
                {
                    //a bit itchy, it should close the door after 10 secs, but it doesn't. skipping it for now.
                    //UpdateGoState(ziggurat4GUID,0,true);
                    player->SummonCreature(C_RAMSTEIN,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
                    debug_log("TSCR: Instance Stratholme: Ramstein spawned.");
                } else debug_log("TSCR: Instance Stratholme: %u Abomnation left to kill.",count);
            }
            if (data == SPECIAL)
            {
                SlaugtherSquare_Timer = 300000;
                HandleGameObject(portGauntletGUID, true);
                debug_log("TSCR: Instance Stratholme: Slaugther event will continue in 5 minutes.");
            }
            if (data == DONE)
            {
                SlaugtherSquare_Timer = 10000;
                debug_log("TSCR: Instance Stratholme: Skeletons died, slaughter event will continue");
            }
            if (data == FAIL)
            {
                HandleGameObject(portGauntletGUID, true);
                data = SPECIAL;
            }
            Encounter[4] = data;
            break;
        case TYPE_BARON:
            if (data == IN_PROGRESS)
            {
                if (GetData(TYPE_BARON_RUN) == IN_PROGRESS)
                {
                    if (Unit *t = Unit::GetUnit(*player, ysidaTriggerGUID))
                        t->SummonCreature(C_YSIDA,t->GetPositionX(),t->GetPositionY(),t->GetPositionZ(),t->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,1800000);

                    if (Group *pGroup = player->GetGroup())
                    {
                        for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
                        {
                            Player* pGroupie = itr->getSource();
                            if (!pGroupie)
                                continue;

                            if (pGroupie->HasAura(SPELL_BARON_ULTIMATUM,0))
                                pGroupie->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);
                            
                            if (pGroupie->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
                            {
                                pGroupie->CastedCreatureOrGO(C_YSIDA, ysidaGUID,0);
                                pGroupie->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
                            }
                        }
                    } else if (player->HasAura(SPELL_BARON_ULTIMATUM,0))
                        player->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);

                    if (Unit *temp = Unit::GetUnit(*player,GetData64(DATA_BARON)))
                    {
                        player->CastedCreatureOrGO(C_YSIDA, ysidaGUID,0);
                        player->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
                    }
                    SetData(TYPE_BARON_RUN,DONE);
                }
            }

            if (data == DONE)
            {
                HandleGameObject(portGauntletGUID, true);
            }
            if (Encounter[5] != DONE)
                Encounter[5] = data;
            break;
        case TYPE_SH_AELMAR:
            IsSilverHandDead[0] = (data) ? true : false;
            break;
        case TYPE_SH_CATHELA:
            IsSilverHandDead[1] = (data) ? true : false;
            break;
        case TYPE_SH_GREGOR:
            IsSilverHandDead[2] = (data) ? true : false;
            break;
        case TYPE_SH_NEMAS:
            IsSilverHandDead[3] = (data) ? true : false;
            break;
        case TYPE_SH_VICAR:
            IsSilverHandDead[4] = (data) ? true : false;
            break;
        case TYPE_GAUNTLET_MOB:
            if (data != 1)
                break;
            if (GetData(TYPE_NERUB) != DONE && std::none_of(acolyte2GUID.begin(),acolyte2GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;}))
            {
                Creature *c = GetCreature(CrystalsGUID[1]);
                if(c && c->isAlive())
                    c->Kill(c,false);
                SetData(TYPE_NERUB,DONE);
            }
            if (GetData(TYPE_BARONESS) != DONE && std::none_of(acolyte1GUID.begin(),acolyte1GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;}))
            {
                Creature *c = GetCreature(CrystalsGUID[0]);
                if(c && c->isAlive())
                    c->Kill(c,false);
                SetData(TYPE_BARONESS,DONE);
            }
            if (GetData(TYPE_PALLID) != DONE && std::none_of(acolyte3GUID.begin(),acolyte3GUID.end(),[this](uint64 guid)-> bool {Creature *c = GetCreature(guid) ; return c ? c->isAlive():false;}))
            {
                Creature *c = GetCreature(CrystalsGUID[2]);
                if(c && c->isAlive())
                    c->Kill(c,false);
                SetData(TYPE_PALLID,DONE);
            }
        }
    }
        void OnPlayerEnter(Player* plr)
        {
            instance->LoadGrid(LeaderIntroPos.GetPositionX(), LeaderIntroPos.GetPositionY());
            if (Creature* c = instance->GetCreature(GetData64(DATA_LEADER_FIRST_GUID)))
	    	c->AI()->SetData(DATA_START_INTRO, 0);
        }
            void SetData(uint32 type, uint32 data)
            {
                switch (type)
                {
                    case DATA_MEATHOOK_EVENT:
                        _encounterState[0] = data;
                        break;
                    case DATA_SALRAMM_EVENT:
                        if(data == DONE)
                        {
                            DoUpdateWorldState(WORLDSTATE_WAVE_COUNT, 0);
                            if(ArthasNeedsTeleport())
                                if(Creature* arthas = instance->GetCreature(_arthasGUID))
                                    arthas->AI()->SetData(1, 0);
                        }
                        _encounterState[1] = data;
                        break;
                    case DATA_EPOCH_EVENT:
                        _encounterState[2] = data;
                        break;
                    case DATA_MAL_GANIS_EVENT:
                        _encounterState[3] = data;

                        switch (_encounterState[3])
                        {
                            case NOT_STARTED:
                                HandleGameObject(_malGanisGate2GUID, true);
                                break;
                            case IN_PROGRESS:
                                HandleGameObject(_malGanisGate2GUID, false);
                                break;
                            case DONE:
                                HandleGameObject(_exitGateGUID, true);
                                if (GameObject* go = instance->GetGameObject(_malGanisChestGUID))
								{
                                    go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
									go->SetPhaseMask(1, true);
								}
                                instance->SummonCreature(NPC_CHROMIE_3, ChromieExitSummonPos);
                                Map::PlayerList const &players = instance->GetPlayers();
                                for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                                    itr->getSource()->KilledMonsterCredit(31006, 0);
                                break;
                        }
                        break;
                    case DATA_INFINITE_EVENT:
                        _encounterState[4] = data;
                        switch(data)
                        {
                            case DONE:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0);
                                //DoCompleteAchievement(ACHIEVEMENT_CULLING_TIME);
                                break;
                            case FAIL:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0);
                                if(Creature* infinite = instance->GetCreature(_infiniteGUID))
                                    infinite->AI()->DoAction(0);
                                break;
                            case IN_PROGRESS:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 1);
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN, 25);
								timerVisible = true;
                                instance->SummonCreature(NPC_INFINITE, InfiniteSummonPos);
                                break;
                        }
                        break;
                    case DATA_ARTHAS_EVENT:
                        if(data == FAIL)
                        {
                            if(Creature* deadArthas = instance->GetCreature(_arthasGUID))
                            {
                                deadArthas->DespawnOrUnsummon(10000);
                                int index;
                                if(_artasStepUi >= 83) // Before last run
                                    index = 2;
                                else if(_artasStepUi >= 60) // Before the council
                                    index = 1;
                                else // entrance of city
                                    index = 0;

                                if(Creature* newArthas = instance->SummonCreature(NPC_ARTHAS, ArthasSpawnPositions[index]))
                                    newArthas->AI()->SetData(0, (uint32)pow(2.0f, index));
                            }
                        }
                        break;
                    case DATA_CRATE_COUNT:
                        _crateCount = data;
						DoUpdateWorldState(WORLDSTATE_CRATES_REVEALED, _crateCount);
                        if (_crateCount == 5)
                        {
                            if (Creature* bunny = instance->GetCreature(_genericBunnyGUID))
                                bunny->CastSpell(bunny, SPELL_CRATES_CREDIT, true);

							// Summon Chromie and global whisper
                            if (Creature* chromie = instance->SummonCreature(NPC_CHROMIE_2, ChromieSummonPos))
                                if (!instance->GetPlayers().isEmpty())
                                    if (Player* player = instance->GetPlayers().getFirst()->getSource())
                                        sCreatureTextMgr->SendChat(chromie, SAY_CRATES_COMPLETED, player->GetGUID(), CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);

							DoUpdateWorldState(WORLDSTATE_SHOW_CRATES, 0);

							if(Creature* crier = instance->GetCreature(_lordaeronCrierGUID))
								crier->YellToZone(-1595053, LANG_UNIVERSAL, 0);
						}
                        break;
                    case DATA_TRANSFORM_CITIZENS:
                        switch(data)
                        {
                            case SPECIAL: // Respawn Zombies
                                while(!_zombiesList.empty())
                                {
                                    Creature* summon = instance->GetCreature(*_zombiesList.begin());
                                    if(!summon)
                                        _zombiesList.erase(_zombiesList.begin());
                                    else
                                    {
                                        _zombiesList.erase(_zombiesList.begin());
                                        if(TempSummon* summ = summon->ToTempSummon())
                                        {
                                            summon->DestroyForNearbyPlayers();
                                            summ->UnSummon();
                                        }
                                        else
                                            summon->DisappearAndDie();
                                    }
                                }
                            case IN_PROGRESS: // Transform Citizens
                                for(std::list<uint64>::iterator itr = _citizensList.begin(); itr != _citizensList.end(); ++itr)
                                    if(Creature* citizen = instance->GetCreature((*itr)))
                                    {
                                        if(Creature* arthas = instance->GetCreature(GetData64(DATA_ARTHAS)))
                                            if(Creature* risenZombie = arthas->SummonCreature(NPC_ZOMBIE, citizen->GetPositionX(), citizen->GetPositionY(), citizen->GetPositionZ(), citizen->GetOrientation())) //, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000))
											{
                                                _zombiesList.push_back(risenZombie->GetGUID());
												risenZombie->SetRespawnTime(60);
												risenZombie->GetMotionMaster()->MoveRandom(10.0f);
											}
                                        citizen->SetPhaseMask(2, true);
                                    }
                                break;
                        }
                        break;
                    case DATA_ZOMBIEFEST:
                        if(!instance->IsHeroic() || GetData(DATA_ZOMBIEFEST) == DONE)
                            break;

                        switch(data)
                        {
                            case DONE:
                                //DoCompleteAchievement(ACHIEVEMENT_ZOMBIEFEST);
                                _zombieFest = data;
                                break;
                            case IN_PROGRESS:
                                _zombieFest = data;
                                break;
                            case FAIL:
                                _killedZombieCount = 0;
                                _zombieTimer = 60000;
                                _zombieFest = data;
                               DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_CREATURE, ACHIEVEMENT_ZOMBIEFEST);
                                break;
                            case SPECIAL:
                                _killedZombieCount++;
								DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, 27737, 1);
                                if(_killedZombieCount == 1)
								{
                                    SetData(DATA_ZOMBIEFEST, IN_PROGRESS);
									DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_CREATURE, ACHIEVEMENT_ZOMBIEFEST);
								}
                                else if(_killedZombieCount >= 100 && GetData(DATA_ZOMBIEFEST) == IN_PROGRESS)
                                    SetData(DATA_ZOMBIEFEST, DONE);
                                //else
                                //{
                                    //if(_killedZombieCount%10 == 0);
                                //}
                                break;
                        }
                        break;
                    case DATA_ARTHAS_STEP:
                        _artasStepUi = data;
                        return;
                    case DATA_SKIP:
                        _skipUi = data;
                }

                if (data == DONE)
                    SaveToDB();
            }
Beispiel #25
0
        void SetData(uint32 type, uint32 data)
        {
            switch (type)
            {
                case DATA_MOVEMENT_DONE:
                    movementDone = data;
                    if (movementDone == 3)
                    {
                        if (Creature* announcer = instance->GetCreature(announcerGUID))
                            announcer->AI()->SetData(DATA_IN_POSITION, 0);
                    }
                    break;
                case BOSS_GRAND_CHAMPIONS:
                    m_auiEncounter[0] = data;
                    if (data == IN_PROGRESS)
                    {
                        for (std::list<uint64>::const_iterator itr = vehicleList.begin(); itr != vehicleList.end(); ++itr)
                            if (Creature* summon = instance->GetCreature(*itr))
                                summon->RemoveFromWorld();
                    }
                    else if (data == DONE)
                    {
                        ++grandChampionsDeaths;
                        if (grandChampionsDeaths >= 3)
                        {
                            for (uint8 i = 0; i < 3; ++i)
                                if (Creature* GrandChampion = instance->GetCreature(GetData64(DATA_GRAND_CHAMPION_1 + i)))
                                    GrandChampion->AI()->SetData(11, 0);

                            if (Creature* announcer = instance->GetCreature(announcerGUID))
                            {
                                m_auiEncounter[0] = data;
                                announcer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
                                announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                                announcer->SummonGameObject(instance->IsHeroic() ? GO_CHAMPIONS_LOOT_H : GO_CHAMPIONS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                                BindPlayersToInstance(announcer);
                            }
                        }
                    }
                    break;
                case DATA_ARGENT_SOLDIER_DEFEATED:
                    argentSoldierDeaths = data;
                    if (argentSoldierDeaths == 9)
                    {
                        if (Creature* boss = instance->GetCreature(argentChampionGUID))
                        {
                            boss->GetMotionMaster()->MovePoint(0, 746.88f, 618.74f, 411.06f);
                            boss->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE);
                            boss->SetReactState(REACT_AGGRESSIVE);
                            boss->setFaction(16);
                        }
                    }
                    break;
                case BOSS_ARGENT_CHALLENGE_E:
                    m_auiEncounter[1] = data;
                    if (data == IN_PROGRESS)
                    {
                        for (std::list<uint64>::const_iterator itr = vehicleList.begin(); itr != vehicleList.end(); ++itr)
                            if (Creature* summon = instance->GetCreature(*itr))
                                summon->RemoveFromWorld();
                    }
                    else if (data == DONE)
                    {
                        if (Creature* announcer = instance->GetCreature(announcerGUID))
                        {
                            announcer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
                            announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                            announcer->SummonGameObject(instance->IsHeroic() ? GO_EADRIC_LOOT_H : GO_EADRIC_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                            BindPlayersToInstance(announcer);
                        }
                    }
                    break;
                case BOSS_ARGENT_CHALLENGE_P:
                    m_auiEncounter[2] = data;
                    if (data == IN_PROGRESS)
                    {
                        for (std::list<uint64>::const_iterator itr = vehicleList.begin(); itr != vehicleList.end(); ++itr)
                            if (Creature* summon = instance->GetCreature(*itr))
                                summon->RemoveFromWorld();
                    }
                    else if (data == DONE)
                    {
                        if (Creature* announcer = instance->GetCreature(announcerGUID))
                        {
                            announcer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
                            announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                            announcer->SummonGameObject(instance->IsHeroic() ? GO_PALETRESS_LOOT_H : GO_PALETRESS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, 0, 0, 0, 0, 90000000);
                            BindPlayersToInstance(announcer);
                        }
                    }
                    break;
                case BOSS_BLACK_KNIGHT:
                    m_auiEncounter[3] = data;
                    break;
            }

            if (data == DONE)
                SaveToDB();
        }
    void SetData(uint32 uiType, uint32 uiData)
    {
        switch(uiType)
        {
        case TYPE_STAGE:    m_auiEncounter[0] = uiData; break;
        case TYPE_BEASTS:   m_auiEncounter[1] = uiData; break;
        case TYPE_JARAXXUS: m_auiEncounter[2] = uiData; break;
        case TYPE_CRUSADERS:if (uiData == FAIL && (m_auiEncounter[3] == FAIL || m_auiEncounter[3] == NOT_STARTED))
                            m_auiEncounter[3] = NOT_STARTED;
                            else
                                m_auiEncounter[3] = uiData;
                            if (uiData == DONE) 
                            {
                               if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiCrusadersCache))
                                   if (pChest && !pChest->isSpawned())
                                         pChest->SetRespawnTime(7*DAY);
                            };
                            break;
        case TYPE_CRUSADERS_COUNT:  if (uiData == 0) --m_auiCrusadersCount;
                                         else m_auiCrusadersCount = uiData;
                                    break;
        case TYPE_VALKIRIES: if (m_auiEncounter[4] == SPECIAL && uiData == SPECIAL) uiData = DONE;
                             m_auiEncounter[4] = uiData; break;
        case TYPE_LICH_KING: m_auiEncounter[5] = uiData; break;
        case TYPE_ANUBARAK:  m_auiEncounter[6] = uiData; 
                            if (uiData == DONE) {
                            if (Difficulty == RAID_DIFFICULTY_10MAN_HEROIC)
                            {
                                if ( m_auiEncounter[7] >= 25) m_uiTributeChest1 = GO_TRIBUTE_CHEST_10H_25;
                                if ( m_auiEncounter[7] >= 45) m_uiTributeChest2 = GO_TRIBUTE_CHEST_10H_45;
                                if ( m_auiEncounter[7] >= 49) m_uiTributeChest3 = GO_TRIBUTE_CHEST_10H_50;
                                m_uiTributeChest4 = GO_TRIBUTE_CHEST_10H_99;
                            }
                            if (Difficulty == RAID_DIFFICULTY_25MAN_HEROIC){
                                if ( m_auiEncounter[7] >= 25) m_uiTributeChest1 = GO_TRIBUTE_CHEST_25H_25;
                                if ( m_auiEncounter[7] >= 45) m_uiTributeChest2 = GO_TRIBUTE_CHEST_25H_45;
                                if ( m_auiEncounter[7] >= 49) m_uiTributeChest3 = GO_TRIBUTE_CHEST_25H_50;
                                m_uiTributeChest4 = GO_TRIBUTE_CHEST_25H_99;
                            }
                            // Attention! It is (may be) not off-like, but  spawning all Tribute Chests is real
                            // reward for clearing TOC instance
                            if (m_uiTributeChest1)
                              if (GameObject* pChest1 = GetSingleGameObjectFromStorage(m_uiTributeChest1))
                                if (pChest1 && !pChest1->isSpawned()) pChest1->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest2)
                              if (GameObject* pChest2 = GetSingleGameObjectFromStorage(m_uiTributeChest2))
                                if (pChest2 && !pChest2->isSpawned()) pChest2->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest3)
                              if (GameObject* pChest3 = GetSingleGameObjectFromStorage(m_uiTributeChest3))
                                if (pChest3 && !pChest3->isSpawned()) pChest3->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest4)
                              if (GameObject* pChest4 = GetSingleGameObjectFromStorage(m_uiTributeChest4))
                                if (pChest4 && !pChest4->isSpawned()) pChest4->SetRespawnTime(7*DAY);
                            };
        break;
        case TYPE_COUNTER:   m_auiEncounter[7] = uiData; uiData = DONE; break;
        case TYPE_EVENT:     m_auiEncounter[8] = uiData; uiData = NOT_STARTED; break;
        case TYPE_EVENT_TIMER:      m_auiEventTimer = uiData; uiData = NOT_STARTED; break;
        case TYPE_NORTHREND_BEASTS: m_auiNorthrendBeasts = uiData; break;
        case DATA_HEALTH_FJOLA:     m_uiDataDamageFjola = uiData; uiData = NOT_STARTED; break;
        case DATA_HEALTH_EYDIS:     m_uiDataDamageEydis = uiData; uiData = NOT_STARTED; break;
        case DATA_CASTING_VALKYRS:  m_uiValkyrsCasting = uiData; uiData = NOT_STARTED; break;
        }

        if (IsEncounterInProgress()) 
        {
            DoCloseDoor(GetData64(GO_WEST_PORTCULLIS));
            DoCloseDoor(GetData64(GO_NORTH_PORTCULLIS));
//            DoCloseDoor(GetData64(GO_SOUTH_PORTCULLIS));
        }
        else
        {
            DoOpenDoor(GetData64(GO_WEST_PORTCULLIS));
            DoOpenDoor(GetData64(GO_NORTH_PORTCULLIS));
//            DoOpenDoor(GetData64(GO_SOUTH_PORTCULLIS));
        };

        if (uiData == FAIL && uiType != TYPE_STAGE
                           && uiType != TYPE_EVENT
                           && uiType != TYPE_COUNTER
                           && uiType != TYPE_EVENT_TIMER)
        { if (IsRaidWiped()) { --m_auiEncounter[7];
                               needsave = true;
                             }
                               uiData = NOT_STARTED;
        }

        if ((uiData == DONE && uiType != TYPE_STAGE
                           && uiType != TYPE_EVENT
                           && uiType != TYPE_EVENT_TIMER)
                           || needsave == true)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;

            for(uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
                saveStream << m_auiEncounter[i] << " ";

            m_strInstData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        needsave = false;
        }
    }
Beispiel #27
0
        // Wipe has been detected. Perform cleanup and reset.
        void DoWipe()
        {
            if (GetData(DATA_WAVES_STATE) == IN_PROGRESS)    // are the waves already done ?
            {
                HandleGameObject(uiFrontDoor, true);
                HandleGameObject(uiFrostwornDoor, false);
                // Reset - set down to the last uiEncounter that was fulfilled
                if (GetData(DATA_FALRIC_EVENT) != DONE)
                {
                    SetData(DATA_WAVES_STATE, FAIL);
                    uiWaveCount = 0;
                    events.Reset();
                    DoUpdateWorldState(WORLD_STATE_HOR, 1);
                    DoUpdateWorldState(WORLD_STATE_HOR_WAVE_COUNT, uiWaveCount);
                    if (GetData(DATA_INTRO_EVENT) == DONE)
                    {
                        if (Creature* pMarwyn = instance->GetCreature(uiMarwyn))
                            pMarwyn->SetVisible(true);
                        if (Creature* pFalric = instance->GetCreature(uiFalric))
                            pFalric->SetVisible(true);
                    }
                }
                else if (GetData(DATA_MARWYN_EVENT) != DONE)
                {
                    SetData(DATA_WAVES_STATE, FAIL);
                    uiWaveCount = 5;
                    events.Reset();
                    DoUpdateWorldState(WORLD_STATE_HOR, 1);
                    DoUpdateWorldState(WORLD_STATE_HOR_WAVE_COUNT, uiWaveCount);
                    if (GetData(DATA_INTRO_EVENT) == DONE)
                    {
                        if (Creature* pMarwyn = instance->GetCreature(uiMarwyn))
                            pMarwyn->SetVisible(true);
                    }
                }
            }
            else
            {
                // Falric and Marwyn have been finished by the group
                if (GetData(DATA_LICHKING_EVENT) == NOT_STARTED)
                {
                    // Lichking-Event was not started yet, i.e. the group has wiped on the Frostworn General
                    HandleGameObject(uiFrontDoor, true);

                    if (GetData(DATA_MARWYN_EVENT) == DONE)
                        HandleGameObject(uiFrostwornDoor, true);
                }
                else
                {
                    // Group has wiped on escape
                    SetData(DATA_LICHKING_EVENT, NOT_STARTED);
                    SetData(DATA_WIPE, 1);
                    Creature* pSylvanasOrJaina = instance->GetCreature(GetData64(DATA_ESCAPE_LEADER));
                    if (pSylvanasOrJaina && pSylvanasOrJaina->GetAI())
                    {
                        pSylvanasOrJaina->Respawn(true);
                        pSylvanasOrJaina->GetAI()->Reset();
                    }
                    Creature* pLichKing = instance->GetCreature(GetData64(DATA_LICHKING));
                    if (pLichKing && pLichKing->GetAI())
                    {
                        pLichKing->Respawn(true);
                        pLichKing->GetAI()->Reset();
                    }
                    // TODO: maybe something is missing here
                }
            }
        }