void instance_trial_of_the_crusader::Initialize()
{
    for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
        m_auiEncounter[i] = NOT_STARTED;

    for (uint8 i = 0; i < MAX_SPECIAL_ACHIEV_CRITS - 1; ++i)
        m_bAchievCriteria[i] = false;

    SetSpecialAchievementCriteria(TYPE_SKILL, true);
    SetSpecialAchievementCriteria(TYPE_MAD_SKILL, true);
    SetSpecialAchievementCriteria(TYPE_INSANITY, true);
    SetSpecialAchievementCriteria(TYPE_IMMORTALITY, true);

    m_auiEncounter[TYPE_STAGE] = 0;
    m_auiEncounter[TYPE_COUNTER] = 50;
    m_auiEncounter[TYPE_DEATHS] = 0;
    m_auiEncounter[TYPE_EVENT] = 0;

    m_auiNorthrendBeasts = NOT_STARTED;
    m_auiEventTimer = 1000;
    m_auiCrusadersCount = 6;
    m_auiCrusadersDead = 0;
    m_auiCrusadersAchievFail = 0;
    m_auiCrusadersAchievTimer = 60000;
    needsave = false;
}
void instance_ulduar::OnCreatureDeath(Creature * pCreature)
{
    if (GetData(TYPE_IGNIS) == IN_PROGRESS && pCreature->GetEntry() == NPC_IRON_CONSTRUCT)
    {
        if (m_bOneIsDeath)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_SHATTERED, true);
        }
        else
        {
            m_bOneIsDeath = true;
            m_uiShatterTimer = 5 * IN_MILLISECONDS;
        }
    }
    if (GetData(TYPE_AURIAYA) == IN_PROGRESS && pCreature->GetEntry() == NPC_SANCTUM_SENTRY)
    {
        SetSpecialAchievementCriteria(TYPE_ACHIEV_CRAZY_CAT_LADY, false);
    }
    if (GetData(TYPE_THORIM) == IN_PROGRESS // Thorim
            || pCreature->GetEntry() == NPC_JORMUNGAR_BEHEMOTH // Preadds
            || pCreature->GetEntry() == NPC_CAPTAIN_ALY
            || pCreature->GetEntry() == NPC_CAPTAIN_HORDE
            || pCreature->GetEntry() == NPC_MERCENARY_ALY
            || pCreature->GetEntry() == NPC_MERCENARY_HORDE)
    {
        m_lThorimMobsGuids.push_back(pCreature->GetObjectGuid());
    }
}
void instance_pit_of_saron::OnCreatureDeath(Creature* pCreature)
{
    switch (pCreature->GetEntry())
    {
        case NPC_YMIRJAR_DEATHBRINGER:
        case NPC_YMIRJAR_WRATHBRINGER:
        case NPC_YMIRJAR_FLAMEBEARER:
        case NPC_FALLEN_WARRIOR:
        case NPC_COLDWRAITH:
            // Check for tunnel event end - these mobs are not summoned
            if (pCreature->IsTemporarySummon())
            {
                m_lAmbushNpcsGuidList.remove(pCreature->GetObjectGuid());

                // If empty start tunnel event
                if (m_lAmbushNpcsGuidList.empty())
                {
                    Creature* pTyrannus = GetSingleCreatureFromStorage(NPC_TYRANNUS_INTRO);
                    if (!pTyrannus)
                        return;

                    DoScriptText(SAY_GAUNTLET, pTyrannus);
                    pTyrannus->SetWalk(false);
                    pTyrannus->GetMotionMaster()->MovePoint(0, afTyrannusMovePos[0][0], afTyrannusMovePos[0][1], afTyrannusMovePos[0][2]);
                    pTyrannus->ForcedDespawn(20000);

                    m_uiIciclesTimer = urand(3000, 5000);
                    SetSpecialAchievementCriteria(TYPE_ACHIEV_DONT_LOOK_UP, true);
                }
            }
            break;
    }
}
void instance_naxxramas::OnPlayerDeath(Player* pPlayer)
{
    if (IsEncounterInProgress())
        SetData(TYPE_UNDYING_FAILED, DONE);

    if (GetData(TYPE_HEIGAN) == IN_PROGRESS)
        SetSpecialAchievementCriteria(TYPE_ACHIEV_SAFETY_DANCE, false);
}
void instance_ulduar::DoProcessShatteredEvent()
{
    // If timer is already running set achiev criteria to true, else start the timer
    if (m_uiShatterAchievTimer)
        SetSpecialAchievementCriteria(TYPE_ACHIEV_SHATTERED, true);
    else
        m_uiShatterAchievTimer = 5000;
}
void instance_ulduar::OnCreatureDeath(Creature* pCreature)
{
    switch(pCreature->GetEntry())
    {
        case NPC_SANCTUM_SENTRY:
            if (GetData(TYPE_AURIAYA) == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CAT_LADY, false);
            break;
    }
}
void instance_pinnacle::OnCreatureDeath(Creature* pCreature)
{
    switch (pCreature->GetEntry())
    {
        case NPC_FURBOLG:
        case NPC_WORGEN:
        case NPC_JORMUNGAR:
        case NPC_RHINO:
            m_uiGortokOrbTimer = 3000;
            break;
        case NPC_SCOURGE_HULK:
            if (pCreature->HasAura(SPELL_AURA_RITUAL_STRIKE))
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_INCREDIBLE_HULK, true);
            }
            break;
        default:
            break;
    }
}
Exemple #8
0
void instance_pinnacle::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_SVALA:
            if (uiData == IN_PROGRESS || uiData == FAIL)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_INCREDIBLE_HULK, false);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GORTOK:
            if (uiData == IN_PROGRESS)
            {
                if (Creature* pOrb = instance->GetCreature(m_gortokEventTriggerGuid))
                {
                    pOrb->SetLevitate(true);
                    pOrb->CastSpell(pOrb, SPELL_ORB_VISUAL, true);
                    pOrb->GetMotionMaster()->MovePoint(0, aOrbPositions[0][0], aOrbPositions[0][1], aOrbPositions[0][2]);

                    m_uiGortokOrbTimer = 2000;
                }
            }
            if (uiData == FAIL)
            {
                if (Creature* pOrb = instance->GetCreature(m_gortokEventTriggerGuid))
                {
                    if (!pOrb->isAlive())
                        pOrb->Respawn();
                    else
                        pOrb->RemoveAllAuras();

                    // For some reasone the Orb doesn't evade automatically
                    pOrb->GetMotionMaster()->MoveTargetedHome();
                }

                for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                {
                    // Reset each miniboss
                    if (Creature* pTemp = GetSingleCreatureFromStorage(aGortokMiniBosses[i]))
                    {
                        if (!pTemp->isAlive())
                            pTemp->Respawn();

                        pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                }

                m_uiGortokOrbPhase = 0;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_SKADI:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_SKADI);

            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_YMIRON:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_YMIRON);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KINGS_BANE, true);
            if (uiData == SPECIAL)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KINGS_BANE, false);
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            error_log("SD2: Instance Pinnacle: SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            return;
    }

    // Saving also SPECIAL for this instance
    if (uiData == DONE || uiData == SPECIAL)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ulduar::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_LEVIATHAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_SHIELD_WALL);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_XT002_GATE);
                DoUseDoorOrButton(GO_LIGHTNING_FIELD);
            }
            break;
        case TYPE_IGNIS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_RAZORSCALE:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_XT002:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_XT002_GATE);
            break;
        case TYPE_ASSEMBLY:
            // Don't set the same encounter data twice
            if (uiData == m_auiEncounter[uiType])
                return;
            m_auiEncounter[uiType] = uiData;
            // don't continue for encounter = special
            if (uiData == SPECIAL)
                return;
            DoUseDoorOrButton(GO_IRON_ENTRANCE_DOOR);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_ARCHIVUM_DOOR);
            else if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_BRUNDIR, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_MOLGEIM, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_STEELBREAKER, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_STUNNED, true);
            }
            break;
        case TYPE_KOLOGARN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_SHATTERED_DOOR);
            if (uiData == DONE)
            {
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_LIVING_STONE_10 : GO_CACHE_OF_LIVING_STONE_25, 30*MINUTE);
                if (GameObject* pBridge = GetSingleGameObjectFromStorage(GO_KOLOGARN_BRIDGE))
                    pBridge->SetGoState(GO_STATE_READY);
            }
            break;
        case TYPE_AURIAYA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CAT_LADY, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_NINE_LIVES, false);
            }
            break;
        // Keepers
        case TYPE_MIMIRON:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MIMIRON_DOOR_1);
            DoUseDoorOrButton(GO_MIMIRON_DOOR_2);
            DoUseDoorOrButton(GO_MIMIRON_DOOR_3);
            if (uiData == DONE)
            {
                if (GetData(TYPE_MIMIRON_HARD) != DONE)
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_INOV_10 : GO_CACHE_OF_INOV_25, 30*MINUTE);
                SpawnFriendlyKeeper(NPC_MIMIRON_IMAGE);
            }
            break;
        case TYPE_HODIR:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_HODIR_ENTER);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_HODIR_ICE_WALL);
                DoUseDoorOrButton(GO_HODIR_EXIT);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_WINTER_10 : GO_CACHE_OF_WINTER_25, 30*MINUTE);
                SpawnFriendlyKeeper(NPC_HODIR_IMAGE);
            }
            break;
        case TYPE_THORIM:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_LIGHTNING_FIELD);
            if (uiData == IN_PROGRESS)
                DoUseDoorOrButton(GO_DARK_IRON_PORTCULIS);
            if (uiData == DONE)
            {
                if (GetData(TYPE_THORIM_HARD) != DONE)
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10 : GO_CACHE_OF_STORMS_25, 30*MINUTE);
                SpawnFriendlyKeeper(NPC_THORIM_IMAGE);
            }
            break;
        case TYPE_FREYA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                SpawnFriendlyKeeper(NPC_FREYA_IMAGE);
            break;
        // Prison
        case TYPE_VEZAX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(GO_VEZAX_GATE);
            break;
        case TYPE_YOGGSARON:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_YOGG_GATE);
            break;

        // Celestial Planetarium
        case TYPE_ALGALON:
            m_auiEncounter[uiType] = uiData;
            //TODO: need to find the proper way to use these
            DoUseDoorOrButton(GO_CELESTIAL_DOOR);
            DoUseDoorOrButton(GO_UNIVERSE_FLOOR_CELESTIAL);
            if (uiData == DONE)
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_GIFT_OF_OBSERVER_10 : GO_GIFT_OF_OBSERVER_25, 30*MINUTE);
            break;

        // Hard modes
        case TYPE_LEVIATHAN_HARD:
            m_auiHardBoss[0] = uiData;                      // TODO: add extra loot
            break;
        case TYPE_XT002_HARD:
            m_auiHardBoss[1] = uiData;                      // TODO: add extra loot
            break;
        case TYPE_HODIR_HARD:
            m_auiHardBoss[2] = uiData;
            if (uiData == DONE)
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_RARE_WINTER_10 : GO_CACHE_OF_RARE_WINTER_25, 30*MINUTE);
            break;
        case TYPE_THORIM_HARD:
            m_auiHardBoss[3] = uiData;
            if (uiData == DONE)
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10_H : GO_CACHE_OF_STORMS_25_H, 30*MINUTE);
            break;
        case TYPE_MIMIRON_HARD:
            m_auiHardBoss[4] = uiData;
            if (uiData == DONE)
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_INOV_10_H : GO_CACHE_OF_INOV_25_H, 30*MINUTE);
            break;
        case TYPE_VEZAX_HARD:
            m_auiHardBoss[5] = uiData;                      // TODO: add extra loot
            break;
        case TYPE_YOGGSARON_HARD:
            m_auiHardBoss[6] = uiData;                      // TODO: add extra loot
            break;

        // Ulduar keepers
        case TYPE_KEEPER_HODIR:
            m_auiUlduarKeepers[0] = uiData;
            break;
        case TYPE_KEEPER_THORIM:
            m_auiUlduarKeepers[1] = uiData;
            break;
        case TYPE_KEEPER_FREYA:
            m_auiUlduarKeepers[2] = uiData;
            break;
        case TYPE_KEEPER_MIMIRON:
            m_auiUlduarKeepers[3] = uiData;
            break;
    }

    DoOpenMadnessDoorIfCan();

    if (uiData == DONE || uiData == FAIL)
    {
        OUT_SAVE_INST_DATA;

        // Save all encounters, hard bosses, keepers and teleporters
        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_auiHardBoss[0] << " "
            << m_auiHardBoss[1] << " " << m_auiHardBoss[2] << " " << m_auiHardBoss[2] << " "
            << m_auiHardBoss[4] << " " << m_auiHardBoss[5] << " " << m_auiHardBoss[6] << " "
            << m_auiUlduarKeepers[0] << " " << m_auiUlduarKeepers[1] << " " << m_auiUlduarKeepers[2] << " " << m_auiUlduarKeepers[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_trial_of_the_crusader::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
    case TYPE_STAGE:
        m_auiEncounter[TYPE_STAGE] = uiData;
        break;
    case TYPE_BEASTS:
        m_auiEncounter[TYPE_BEASTS] = uiData;
        if (uiData == IN_PROGRESS)
            SetSpecialAchievementCriteria(TYPE_UPPER_BACK_PAIN, false);
        break;
    case TYPE_JARAXXUS:
        m_auiEncounter[TYPE_JARAXXUS] = uiData;
        if (uiData == IN_PROGRESS)
            SetSpecialAchievementCriteria(TYPE_THREE_SIXTY_PAIN_SPIKE, false);
        break;
    case TYPE_CRUSADERS:
        if (uiData == FAIL && (m_auiEncounter[TYPE_CRUSADERS] == FAIL || m_auiEncounter[TYPE_CRUSADERS] == NOT_STARTED))
            m_auiEncounter[TYPE_CRUSADERS] = NOT_STARTED;
        else
            m_auiEncounter[TYPE_CRUSADERS] = uiData;
        if (uiData == DONE)
        {
            if (Creature* pTirion = GetSingleCreatureFromStorage(NPC_TIRION))
                DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_ACHIEV_FACTION_CHAMPIONS_DEFEAT);

            uint32 uiCacheEntry = GO_CRUSADERS_CACHE_10;

            switch (instance->GetDifficulty())
            {
            case RAID_DIFFICULTY_10MAN_HEROIC:
                uiCacheEntry = GO_CRUSADERS_CACHE_10_H;
                break;
            case RAID_DIFFICULTY_25MAN_NORMAL:
                uiCacheEntry = GO_CRUSADERS_CACHE_25;
                break;
            case RAID_DIFFICULTY_25MAN_HEROIC:
                uiCacheEntry = GO_CRUSADERS_CACHE_25_H;
                break;
            }
            if (GameObject* pChest = GetSingleGameObjectFromStorage(uiCacheEntry))
                if (!pChest->isSpawned())
                    pChest->SetRespawnTime(7*DAY);
        };
        break;
    case TYPE_CRUSADERS_COUNT:
        if (uiData == 0)
            --m_auiCrusadersCount;
        else
            m_auiCrusadersCount = uiData;
        break;
    case TYPE_CRUSADERS_DEAD:
        m_auiCrusadersDead = uiData;
        break;
    case TYPE_CRUSADERS_ACHIEV_TIMER:
        if(m_auiCrusadersAchievFail)
            break;
        if (m_auiCrusadersAchievTimer <= uiData)
            m_auiCrusadersAchievFail = 1;
        else
            m_auiCrusadersAchievTimer -= uiData;
        break;
    case TYPE_CRUSADERS_ACHIEV_FAIL:
        m_auiCrusadersAchievFail = uiData;
        break;
    case TYPE_VALKIRIES:
        /*if (m_auiEncounter[4] == SPECIAL && uiData == SPECIAL)
            uiData = DONE;*/
        m_auiEncounter[TYPE_VALKIRIES] = uiData;
        break;
    case TYPE_LICH_KING:
        m_auiEncounter[TYPE_LICH_KING] = uiData;
        break;
    case TYPE_ANUBARAK:
        m_auiEncounter[TYPE_ANUBARAK] = uiData;

        if (uiData == IN_PROGRESS)
        {
            DoCloseDoor(GO_WEB_DOOR);
        }
        else
            DoOpenDoor(GO_WEB_DOOR);

        if (uiData == DONE)
        {
            if (Difficulty == RAID_DIFFICULTY_10MAN_HEROIC)
            {
                if (m_auiEncounter[TYPE_COUNTER] >= 25)
                    m_uiTributeChest1 = GO_TRIBUTE_CHEST_10H_25;
                if (m_auiEncounter[TYPE_COUNTER] >= 45)
                    m_uiTributeChest2 = GO_TRIBUTE_CHEST_10H_45;
                if (m_auiEncounter[TYPE_COUNTER] > 49)
                    m_uiTributeChest3 = GO_TRIBUTE_CHEST_10H_50;

                m_uiTributeChest4 = GO_TRIBUTE_CHEST_10H_99;
            }
            if (Difficulty == RAID_DIFFICULTY_25MAN_HEROIC)
            {
                if (m_auiEncounter[TYPE_COUNTER] >= 25)
                    m_uiTributeChest1 = GO_TRIBUTE_CHEST_25H_25;
                if (m_auiEncounter[TYPE_COUNTER] >= 45)
                    m_uiTributeChest2 = GO_TRIBUTE_CHEST_25H_45;
                if (m_auiEncounter[TYPE_COUNTER] > 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[TYPE_COUNTER] = uiData;
        if (uiData < 25)
            SetSpecialAchievementCriteria(TYPE_SKILL, false);
        if (uiData < 45)
            SetSpecialAchievementCriteria(TYPE_MAD_SKILL, false);
        if (uiData < 50)
        {
            SetSpecialAchievementCriteria(TYPE_INSANITY, false);
            SetSpecialAchievementCriteria(TYPE_IMMORTALITY, false);
        }

        //uiData = DONE;
        break;
    case TYPE_DEATHS:
        m_auiEncounter[TYPE_DEATHS] += uiData;
        if (GetData(TYPE_DEATHS))
            SetSpecialAchievementCriteria(TYPE_IMMORTALITY, false);
        break;
    case TYPE_EVENT:
        m_auiEncounter[TYPE_EVENT] = 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;
    }

    if (IsEncounterInProgress()) 
    {
        DoCloseDoor(GO_WEST_PORTCULLIS);
        DoCloseDoor(GO_NORTH_PORTCULLIS);
        DoCloseDoor(GO_SOUTH_PORTCULLIS);

        if (Creature* pBarrent = GetSingleCreatureFromStorage(NPC_BARRENT)) 
            pBarrent->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
    }
    else
    {
        DoOpenDoor(GO_WEST_PORTCULLIS);
        DoCloseDoor(GO_NORTH_PORTCULLIS);
        DoCloseDoor(GO_SOUTH_PORTCULLIS);

        if (Creature* pBarrent = GetSingleCreatureFromStorage(NPC_BARRENT)) 
            pBarrent->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
    };

    if (uiData == FAIL && uiType != TYPE_STAGE && uiType != TYPE_EVENT && uiType != TYPE_COUNTER && uiType != TYPE_EVENT_TIMER)
    {
        if (IsRaidWiped())
        {
            //--m_auiEncounter[TYPE_COUNTER];
            SetData(TYPE_COUNTER, GetData(TYPE_COUNTER) - 1);
            needsave = true;
            UpdateWorldState();
        }
        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;
    }
}
void instance_pit_of_saron::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_GARFROST:
            if (uiData == DONE && m_auiEncounter[TYPE_KRICK] == DONE)
                DoUseDoorOrButton(GO_ICEWALL);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_DOESNT_GO_ELEVEN, true);
            else if (uiData == DONE)
                StartNextDialogueText(NPC_GARFROST);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_KRICK:
            if (uiData == DONE && m_auiEncounter[TYPE_GARFROST] == DONE)
                DoUseDoorOrButton(GO_ICEWALL);
            if (uiData == SPECIAL)
            {
                // Used just to start the epilogue
                StartNextDialogueText(SAY_JAINA_KRICK_1);
                return;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_TYRANNUS:
            if (uiData == DONE)
                StartNextDialogueText(NPC_SINDRAGOSA);
            else if (uiData == SPECIAL)
            {
                // Used just to start the intro
                StartNextDialogueText(NPC_TYRANNUS);
                return;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_AMBUSH:
            if (uiData == DONE)
            {
                // Complete tunnel achievement
                if (Creature* pTyrannus = GetSingleCreatureFromStorage(NPC_TYRANNUS))
                    pTyrannus->CastSpell(pTyrannus, SPELL_ACHIEVEMENT_CHECK, TRIGGERED_OLD_TRIGGERED);

                m_uiIciclesTimer = 0;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            return;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ulduar::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
            // Siege of Ulduar
        case TYPE_LEVIATHAN:
            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_SHIELD_WALL);
            if (uiData == IN_PROGRESS)
            {
                // make sure that the Lightning door is closed when engaged in combat
                if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_LIGHTNING_DOOR))
                {
                    if (pDoor->GetGoState() != GO_STATE_READY)
                        DoUseDoorOrButton(GO_LIGHTNING_DOOR);
                }

                SetSpecialAchievementCriteria(TYPE_ACHIEV_SHUTOUT, true);
            }
            else if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_XT002_GATE);
                DoUseDoorOrButton(GO_LIGHTNING_DOOR);
            }
            else if (uiData == FAIL)
                DoCallLeviathanHelp();
            break;
        case TYPE_IGNIS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_IGNIS_ID);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SHATTERED, false);
            }
            break;
        case TYPE_RAZORSCALE:
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_QUICK_SHAVE, true);
            else if (uiData == FAIL)
            {
                // reset the commander
                if (Creature* pCommander = GetSingleCreatureFromStorage(NPC_EXPEDITION_COMMANDER))
                    pCommander->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);

                // reset all creatures
                for (GuidList::const_iterator itr = m_lDefendersGuids.begin(); itr != m_lDefendersGuids.end(); ++itr)
                {
                    if (Creature* pDefender = instance->GetCreature(*itr))
                    {
                        if (!pDefender->isAlive())
                            pDefender->Respawn();
                        else
                            pDefender->GetMotionMaster()->MoveTargetedHome();
                    }
                }
                for (GuidList::const_iterator itr = m_lEngineersGuids.begin(); itr != m_lEngineersGuids.end(); ++itr)
                {
                    if (Creature* pEngineer = instance->GetCreature(*itr))
                    {
                        if (!pEngineer->isAlive())
                            pEngineer->Respawn();
                        else
                            pEngineer->GetMotionMaster()->MoveTargetedHome();
                    }
                }
                for (GuidList::const_iterator itr = m_lTrappersGuids.begin(); itr != m_lTrappersGuids.end(); ++itr)
                {
                    if (Creature* pTrapper = instance->GetCreature(*itr))
                    {
                        if (!pTrapper->isAlive())
                            pTrapper->Respawn();
                        else
                            pTrapper->GetMotionMaster()->MoveTargetedHome();
                    }
                }
                for (GuidList::const_iterator itr = m_lHarpoonDummyGuids.begin(); itr != m_lHarpoonDummyGuids.end(); ++itr)
                {
                    if (Creature* pHarpoon = instance->GetCreature(*itr))
                        pHarpoon->InterruptNonMeleeSpells(false);
                }

                // reset Harpoons: respawn the broken ones and despawn the repaired ones
                for (GuidVector::const_iterator itr = m_vBrokenHarpoonsGuids.begin(); itr != m_vBrokenHarpoonsGuids.end(); ++itr)
                {
                    if (GameObject* pHarpoon = instance->GetGameObject(*itr))
                    {
                        if (!pHarpoon->isSpawned())
                            pHarpoon->Respawn();
                    }
                }
                for (GuidList::const_iterator itr = m_lRepairedHarpoonsGuids.begin(); itr != m_lRepairedHarpoonsGuids.end(); ++itr)
                {
                    if (GameObject* pHarpoon = instance->GetGameObject(*itr))
                    {
                        if (pHarpoon->isSpawned())
                            pHarpoon->SetLootState(GO_JUST_DEACTIVATED);
                    }
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_XT002:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_XT002_GATE);
            if (uiData == IN_PROGRESS)
            {
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_XT002_ID);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_NERF_ENG, true);
            }
            break;

            // Antechamber of Ulduar
        case TYPE_ASSEMBLY:
            // Don't set the same encounter data twice
            if (uiData == m_auiEncounter[uiType])
                return;
            m_auiEncounter[uiType] = uiData;
            // don't continue for encounter = special
            if (uiData == SPECIAL)
                return;
            DoUseDoorOrButton(GO_IRON_ENTRANCE_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARCHIVUM_DOOR);

                if (Player* pPlayer = GetPlayerInMap())
                {
                    pPlayer->SummonCreature(NPC_BRANN_ARCHIVUM, afBrannArchivumSpawnPos[0], afBrannArchivumSpawnPos[1], afBrannArchivumSpawnPos[2], afBrannArchivumSpawnPos[3], TEMPSUMMON_DEAD_DESPAWN, 0, true);
                    pPlayer->SummonCreature(instance->IsRegularDifficulty() ? NPC_PROSPECTOR_DOREN : NPC_PROSPECTOR_DOREN_H, afProspectorSpawnPos[0], afProspectorSpawnPos[1], afProspectorSpawnPos[2], afProspectorSpawnPos[3], TEMPSUMMON_DEAD_DESPAWN, 0, true);
                }
            }
            else if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_BRUNDIR, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_MOLGEIM, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_STEELBREAKER, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_STUNNED, true);
            }
            break;
        case TYPE_KOLOGARN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_LIVING_STONE_10 : GO_CACHE_OF_LIVING_STONE_25, 30 * MINUTE);
                DoUseDoorOrButton(GO_KOLOGARN_BRIDGE);
            }
            else if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_RUBBLE, false);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_DISARMED, false);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_LOOKS_KILL, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_OPEN_ARMS, true);
            }
            break;
        case TYPE_AURIAYA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CAT_LADY, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_NINE_LIVES, false);
            }
            break;

            // Keepers of Ulduar
        case TYPE_MIMIRON:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MIMIRON_DOOR_1);
            DoUseDoorOrButton(GO_MIMIRON_DOOR_2);
            DoUseDoorOrButton(GO_MIMIRON_DOOR_3);
            if (uiData == DONE)
            {
                if (GetData(TYPE_MIMIRON_HARD) != DONE)
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_INOV_10 : GO_CACHE_OF_INOV_25, 30 * MINUTE);

                SpawnFriendlyKeeper(NPC_KEEPER_MIMIRON);
                DoOpenMadnessDoorIfCan();
            }
            break;
        case TYPE_HODIR:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_HODIR_ENTER);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_HODIR_ICE_WALL);
                DoUseDoorOrButton(GO_HODIR_EXIT);

                DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_OF_WINTER_10 : GO_CACHE_OF_WINTER_25, GO_FLAG_NO_INTERACT, false);
                if (GetData(TYPE_HODIR_HARD) == DONE)
                    DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_OF_RARE_WINTER_10 : GO_CACHE_OF_RARE_WINTER_25, GO_FLAG_NO_INTERACT, false);

                SpawnFriendlyKeeper(NPC_KEEPER_HODIR);
                DoOpenMadnessDoorIfCan();
            }
            else if (uiData == FAIL)
            {
                if (GameObject* pChest = GetSingleGameObjectFromStorage(instance->IsRegularDifficulty() ? GO_CACHE_OF_RARE_WINTER_10 : GO_CACHE_OF_RARE_WINTER_25))
                    pChest->Respawn();

                if (Player* pPlayer = GetPlayerInMap())
                    DoSpawnHodirNpcs(pPlayer);

                SetData(TYPE_HODIR_HARD, FAIL);
            }
            else if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CHEESE_FREEZE, true);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_COOL_FRIENDS, true);
            }
            break;
        case TYPE_THORIM:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_LIGHTNING_FIELD);
            if (uiData == IN_PROGRESS)
                DoToggleGameObjectFlags(GO_DOOR_LEVER, GO_FLAG_NO_INTERACT, false);
            else if (uiData == DONE)
            {
                if (GetData(TYPE_THORIM_HARD) == DONE)
                {
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10_H : GO_CACHE_OF_STORMS_25_H, 30 * MINUTE);
                    DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10_H : GO_CACHE_OF_STORMS_25_H, GO_FLAG_NO_INTERACT, false);
                }
                else
                {
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10 : GO_CACHE_OF_STORMS_25, 30 * MINUTE);
                    DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_OF_STORMS_10 : GO_CACHE_OF_STORMS_25, GO_FLAG_NO_INTERACT, false);
                }

                SpawnFriendlyKeeper(NPC_KEEPER_THORIM);
                DoOpenMadnessDoorIfCan();
            }
            else if (uiData == FAIL)
            {
                DoToggleGameObjectFlags(GO_DOOR_LEVER, GO_FLAG_NO_INTERACT, true);
                if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_RUNED_STONE_DOOR))
                    pDoor->ResetDoorOrButton();
                if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_THORIM_STONE_DOOR))
                    pDoor->ResetDoorOrButton();

                if (Player* pPlayer = GetPlayerInMap())
                    DoSpawnThorimNpcs(pPlayer);

                m_uiSlayedArenaMobs = 0;
            }
            break;
        case TYPE_FREYA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                SpawnFriendlyKeeper(NPC_KEEPER_FREYA);
                DoOpenMadnessDoorIfCan();
            }
            break;

            // Ulduar Prison
        case TYPE_VEZAX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(GO_VEZAX_GATE);
            break;
        case TYPE_YOGGSARON:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_YOGG_GATE);
            break;

            // Celestial Planetarium
        case TYPE_ALGALON:
            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
            {
                // environment gameobjects
                DoUseDoorOrButton(GO_AZEROTH_GLOBE);
                DoUseDoorOrButton(GO_UNIVERSE_FLOOR);
                DoUseDoorOrButton(GO_UNIVERSE_FLOOR_COMBAT);
                DoUseDoorOrButton(GO_CELESTIAL_DOOR_COMBAT);
            }
            if (uiData == DONE)
            {
                DoUpdateWorldState(WORLD_STATE_TIMER, 0);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_GIFT_OF_OBSERVER_10 : GO_GIFT_OF_OBSERVER_25, 30 * MINUTE);
            }
            else if (uiData == FAIL)
            {
                // only despawn when time is over
                if (GetData(TYPE_ALGALON_TIMER) == 0)
                {
                    DoUpdateWorldState(WORLD_STATE_TIMER, 0);
                    if (Creature* pAlgalon = GetSingleCreatureFromStorage(NPC_ALGALON))
                        pAlgalon->AI()->SendAIEvent(AI_EVENT_CUSTOM_A, pAlgalon, pAlgalon);
                }
            }
            break;
        case TYPE_ALGALON_TIMER:
            m_auiEncounter[uiType] = uiData;
            DoUpdateWorldState(WORLD_STATE_TIMER_COUNT, m_auiEncounter[uiType]);
            break;

            // Hard modes (not saved)
        case TYPE_LEVIATHAN_HARD:
            m_auiHardBoss[0] = uiData;
            return;
        case TYPE_XT002_HARD:
            m_auiHardBoss[1] = uiData;
            return;
        case TYPE_HODIR_HARD:
            m_auiHardBoss[2] = uiData;
            return;
        case TYPE_THORIM_HARD:
            m_auiHardBoss[3] = uiData;
            return;
        case TYPE_MIMIRON_HARD:
            m_auiHardBoss[4] = uiData;
            return;
        case TYPE_VEZAX_HARD:
            m_auiHardBoss[5] = uiData;
            return;
        case TYPE_YOGGSARON_HARD:
            m_auiHardBoss[6] = uiData;
            return;

            // Ulduar keepers
        case TYPE_KEEPER_HODIR:
            m_auiUlduarKeepers[0] = uiData;
            break;
        case TYPE_KEEPER_THORIM:
            m_auiUlduarKeepers[1] = uiData;
            break;
        case TYPE_KEEPER_FREYA:
            m_auiUlduarKeepers[2] = uiData;
            break;
        case TYPE_KEEPER_MIMIRON:
            m_auiUlduarKeepers[3] = uiData;
            break;

            // Ulduar towers
        case TYPE_TOWER_HODIR:
            if (m_auiUlduarTowers[0] == uiData)
                return;
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_HODIR_CRYSTAL);
            m_auiUlduarTowers[0] = uiData;
            break;
        case TYPE_TOWER_THORIM:
            if (m_auiUlduarTowers[1] == uiData)
                return;
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_THORIM_CRYSTAL);
            m_auiUlduarTowers[1] = uiData;
            break;
        case TYPE_TOWER_FREYA:
            if (m_auiUlduarTowers[2] == uiData)
                return;
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_FREYA_CRYSTAL);
            m_auiUlduarTowers[2] = uiData;
            break;
        case TYPE_TOWER_MIMIRON:
            if (m_auiUlduarTowers[3] == uiData)
                return;
            if (uiData == FAIL)
                DoUseDoorOrButton(GO_MIMIRON_CRYSTAL);
            m_auiUlduarTowers[3] = uiData;
            break;

            // Other types - not saved
        case TYPE_LEVIATHAN_GAUNTLET:
            m_uiGauntletStatus = uiData;
            return;
    }

    if (uiData == DONE || uiData == FAIL || uiData == SPECIAL || uiType == TYPE_ALGALON_TIMER)
    {
        OUT_SAVE_INST_DATA;

        // Save all encounters, hard bosses, keepers and teleporters
        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] << " "
                   << m_auiUlduarKeepers[0] << " " << m_auiUlduarKeepers[1] << " " << m_auiUlduarKeepers[2] << " "
                   << m_auiUlduarKeepers[3] << " " << m_auiUlduarTowers[0] << " " << m_auiUlduarTowers[1] << " "
                   << m_auiUlduarTowers[2] << " " << m_auiUlduarTowers[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_pinnacle::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_SVALA:
            if (uiData == IN_PROGRESS || uiData == FAIL)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_INCREDIBLE_HULK, false);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GORTOK:
            if (uiData == IN_PROGRESS)
            {
                if (Creature* pOrb = instance->GetCreature(m_gortokEventTriggerGuid))
                {
                    pOrb->SetLevitate(true);
                    pOrb->CastSpell(pOrb, SPELL_ORB_VISUAL, TRIGGERED_OLD_TRIGGERED);
                    pOrb->GetMotionMaster()->MovePoint(0, aOrbPositions[0][0], aOrbPositions[0][1], aOrbPositions[0][2]);

                    m_uiGortokOrbTimer = 2000;
                }
            }
            else if (uiData == FAIL)
            {
                if (Creature* pOrb = instance->GetCreature(m_gortokEventTriggerGuid))
                {
                    if (!pOrb->isAlive())
                        pOrb->Respawn();
                    else
                        pOrb->RemoveAllAuras();

                    // For some reasone the Orb doesn't evade automatically
                    pOrb->GetMotionMaster()->MoveTargetedHome();
                }

                for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                {
                    // Reset each miniboss
                    if (Creature* pTemp = GetSingleCreatureFromStorage(aGortokMiniBosses[i]))
                    {
                        if (!pTemp->isAlive())
                            pTemp->Respawn();

                        pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                }

                m_uiGortokOrbPhase = 0;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_SKADI:
            // Don't process the event twice
            if (m_auiEncounter[uiType] == uiData)
                return;
            switch (uiData)
            {
                case DONE:
                    DoUseDoorOrButton(GO_DOOR_SKADI);
                    break;
                case SPECIAL:
                    // Prepare achievements
                    SetSpecialAchievementCriteria(TYPE_ACHIEV_LOVE_SKADI, true);
                    DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_SKADI_ID);

                    m_auiEncounter[uiType] = uiData;
                    return;
                case FAIL:
                    // Handle Grauf evade - if event is in phase 1
                    if (Creature* pGrauf = GetSingleCreatureFromStorage(NPC_GRAUF))
                        pGrauf->AI()->EnterEvadeMode();

                    // no break;
                case NOT_STARTED:
                    // Despawn all summons
                    for (GuidList::const_iterator itr = m_lskadiGauntletMobsList.begin(); itr != m_lskadiGauntletMobsList.end(); ++itr)
                    {
                        if (Creature* pYmirjar = instance->GetCreature(*itr))
                            pYmirjar->ForcedDespawn();
                    }

                    // Reset position
                    if (Creature* pGrauf = GetSingleCreatureFromStorage(NPC_GRAUF))
                        pGrauf->GetMotionMaster()->MoveTargetedHome();

                    // no break;
                case IN_PROGRESS:

                    // Remove the summon aura on phase 2 or fail
                    if (Creature* pTrigger = instance->GetCreature(m_skadiMobsTriggerGuid))
                        pTrigger->RemoveAllAuras();
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_YMIRON:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_YMIRON);
            else if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KINGS_BANE, true);
            else if (uiData == SPECIAL)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KINGS_BANE, false);
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            script_error_log("Instance Pinnacle: SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            return;
    }

    // Saving also SPECIAL for this instance
    if (uiData == DONE || uiData == SPECIAL)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_naxxramas::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_ANUB_REKHAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_ANUB_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_ANUB_GATE);
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_MAEXXNA_ID);
            }
            break;
        case TYPE_FAERLINA:
            DoUseDoorOrButton(GO_ARAC_FAER_WEB);
            if (uiData == IN_PROGRESS)
            {
                if (Creature* pFaerlina = GetSingleCreatureFromStorage(NPC_FAERLINA))
                    if (Unit* pVictim = pFaerlina->getVictim())
                        for (GUIDList::const_iterator itr = m_lFaerlinaAddGUIDs.begin(); itr != m_lFaerlinaAddGUIDs.end(); ++itr)
                            if (Creature* pFaerlenaAdd = instance->GetCreature(*itr))
                                pFaerlenaAdd->AI()->AttackStart(pVictim);
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_YOU_OUT, true);
            }
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_FAER_DOOR);
                DoUseDoorOrButton(GO_ARAC_MAEX_OUTER_DOOR);
            }
            if (uiData == FAIL)
            {
                for (GUIDList::const_iterator itr = m_lFaerlinaAddGUIDs.begin(); itr != m_lFaerlinaAddGUIDs.end(); ++itr)
                {
                    Creature* pAdd = instance->GetCreature(*itr);
                    if (pAdd && !pAdd->isAlive())
                        pAdd->Respawn();
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MAEXXNA:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_MAEX_INNER_DOOR, uiData);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_EYE_RAMP);
                DoRespawnGameObject(GO_ARAC_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_NOTH:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_NOTH_ENTRY_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_NOTH_EXIT_DOOR);
                DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            }
            break;
        case TYPE_HEIGAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            // uncomment when eruption is implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SAFETY_DANCE, true);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_PLAG_HEIG_EXIT_DOOR);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_LOAT_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SPORE_LOSER, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_EYE_RAMP);
                DoRespawnGameObject(GO_PLAG_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_RAZUVIOUS:
            switch(uiData)
            {
                case IN_PROGRESS:
                {
                    if (Creature* pRazuvious = GetSingleCreatureFromStorage(NPC_RAZUVIOUS))
                        if (Unit* pVictim = pRazuvious->getVictim())
                            for (GUIDList::iterator itr = m_lRazuUnderstudyGUIDs.begin(); itr != m_lRazuUnderstudyGUIDs.end(); ++itr)
                                if (Creature* pUnderstudy = instance->GetCreature(*itr))
                                    pUnderstudy->AI()->AttackStart(pVictim);
                    break;
                }
                case FAIL:
                {
                    for (GUIDList::iterator itr = m_lRazuUnderstudyGUIDs.begin(); itr != m_lRazuUnderstudyGUIDs.end(); ++itr)
                        if (Creature* pUnderstudy = instance->GetCreature(*itr))
                            if (!pUnderstudy->isAlive())
                                pUnderstudy->Respawn();
                    break;
                }
                default: break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GOTHIK:
            switch(uiData)
            {
                case IN_PROGRESS:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case SPECIAL:
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case FAIL:
                    if (m_auiEncounter[uiType] == IN_PROGRESS)
                        DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);

                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    break;
                case DONE:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_EXIT_GATE);
                    DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_MILI_EYE_RAMP);
                DoRespawnGameObject(GO_MILI_PORTAL, 30*MINUTE);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CHEST_HORSEMEN_NORM : GO_CHEST_HORSEMEN_HERO, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_PATCHWERK:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_PATCHWERK_ID);
                // call all creatures in area
                if (Creature* pPatchwerk = GetSingleCreatureFromStorage(NPC_PATCHWERK))
                    if (Unit* pVictim = pPatchwerk->getVictim())
                        for (GUIDList::iterator itr = m_lPatchwerkAddGUIDs.begin(); itr != m_lPatchwerkAddGUIDs.end(); ++itr)
                            if (Creature* pPatchwerkAdd = instance->GetCreature(*itr))
                                pPatchwerkAdd->AI()->AttackStart(pVictim);
            }
            if (uiData == DONE)
                DoUseDoorOrButton(GO_CONS_PATH_EXIT_DOOR);
            break;
        case TYPE_GROBBULUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GLUTH:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_GLUT_EXIT_DOOR);
                DoUseDoorOrButton(GO_CONS_THAD_DOOR);
            }
            break;
        case TYPE_THADDIUS:
            // Only process real changes here
            if (m_auiEncounter[uiType] == uiData)
                return;

            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_CONS_THAD_DOOR, uiData);
            // Uncomment when this achievement is implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SHOCKING, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_EYE_RAMP);
                DoRespawnGameObject(GO_CONS_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[uiType] = uiData;
            // Uncomment when achiev check implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_HUNDRED_CLUB, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_KELTHUZAD_WATERFALL_DOOR);
                m_dialogueHelper.StartNextDialogueText(SAY_SAPP_DIALOG1);
            }
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_KELTHUZAD_EXIT_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_GET_ENOUGH, false);
            break;
        case TYPE_UNDYING_FAILED:
            m_auiEncounter[uiType] = uiData;
            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] << " " << m_auiEncounter[15];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ulduar::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
    case TYPE_LEVIATHAN:
        m_auiEncounter[uiType] = uiData;
        DoUseDoorOrButton(GO_SHIELD_WALL);
        if (uiData == DONE)
            OpenDoor(GO_LEVIATHAN_GATE);
        break;
    case TYPE_IGNIS:
        m_auiEncounter[uiType] = uiData;
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_SHATTERED, false);
            DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_IGNIS_ID);
        }
        // Add respawn and kill
        if (uiData == FAIL)
        {
            for (GUIDList::iterator itr = m_lIronConstructsGuids.begin(); itr != m_lIronConstructsGuids.end(); ++itr)
            {
                if (Creature *pAdd = instance->GetCreature(*itr))
                    if (!pAdd->isAlive())
                        pAdd->Respawn();
            }
        }
        if (uiData == DONE)
        {
            for (GUIDList::iterator itr = m_lIronConstructsGuids.begin(); itr != m_lIronConstructsGuids.end(); ++itr)
            {
                if (Creature *pAdd = instance->GetCreature(*itr))
                    if (pAdd->isAlive())
                        pAdd->DealDamage(pAdd, pAdd->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);
            }
        }
        break;
    case TYPE_RAZORSCALE:
        m_auiEncounter[uiType] = uiData;
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_QUICK_SHAVE, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_IRON_DWARF_MEDIUM_RARE, false);
        }
        break;
    case TYPE_XT002:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE || uiData == FAIL)
            OpenDoor(GO_XT002_GATE);
        else if (uiData == IN_PROGRESS)
        {
            CloseDoor(GO_XT002_GATE);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_NERF_ENGINEERING, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_HEARTBREAKER, false);
            DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_XT_002_ID);
        }
        break;
    case TYPE_ASSEMBLY:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
        {
            OpenDoor(GO_IRON_ENTRANCE_DOOR);
            OpenDoor(GO_ARCHIVUM_DOOR);
            OpenDoor(GO_SHATTERED_DOOR);
        }
        else if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_YOU_BRUNDIR, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_YOU_MOLGEIM, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_YOU_STEELBREAKER, true);
            CloseDoor(GO_IRON_ENTRANCE_DOOR);
        }
        else if (uiData == FAIL)
        {
            if (Creature* pBrundir = GetSingleCreatureFromStorage(NPC_BRUNDIR))
            {
                if (!pBrundir->isAlive())
                    pBrundir->Respawn();
            }
            if (Creature* pMolgeim = GetSingleCreatureFromStorage(NPC_MOLGEIM))
            {
                if (!pMolgeim->isAlive())
                    pMolgeim->Respawn();
            }
            if (Creature* pSteelbreaker = GetSingleCreatureFromStorage(NPC_STEELBREAKER))
            {
                if (!pSteelbreaker->isAlive())
                    pSteelbreaker->Respawn();
            }
            OpenDoor(GO_IRON_ENTRANCE_DOOR);
        }
        break;
    case TYPE_KOLOGARN:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
        {
            if (instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_CACHE_OF_LIVING_STONE, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_CACHE_OF_LIVING_STONE_H, 30*MINUTE);
            }
            if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_KOLOGARN_BRIDGE))
            {
                pGo->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                pGo->SetGoState(GO_STATE_READY);
            }
        }
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_DISARMED, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_OPEN_ARMS, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_RUBBLE_AND_ROLL, false);
        }
        break;
    case TYPE_AURIAYA:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
        {
            if (GameObject* pGO = GetSingleGameObjectFromStorage(GO_MIMIRON_TRAM))
            {
                pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                pGO->SetGoState(GO_STATE_READY);
            }
        }
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_NINE_LIVES, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_CRAZY_CAT_LADY, true);
        }
        break;
    // Keepers
    case TYPE_MIMIRON:
        m_auiEncounter[uiType] = uiData;
        DoUseDoorOrButton(GO_MIMIRON_DOOR_1);
        DoUseDoorOrButton(GO_MIMIRON_DOOR_2);
        DoUseDoorOrButton(GO_MIMIRON_DOOR_3);
        if (uiData == DONE)
        {
            if (m_auiHardBoss[3] != DONE)
            {
                if (instance->IsRegularDifficulty())
                {
                    DoRespawnGameObject(GO_CACHE_OF_INOV, 30*MINUTE);
                }
                else
                {
                    DoRespawnGameObject(GO_CACHE_OF_INOV_H, 30*MINUTE);
                }
            }
            // used to make the friendly keeper visible
            if(Creature* pImage = GetSingleCreatureFromStorage(KEEPER_MIMIRON))
                pImage->SetVisibility(VISIBILITY_ON);
            DoOpenMadnessDoorIfCan();
        }
        if (uiData == IN_PROGRESS)
            SetSpecialAchievementCriteria(TYPE_ACHIEV_FIREFIGHTER, false);
        break;
    case TYPE_HODIR:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
        {
            OpenDoor(GO_HODIR_ENTER);
            DoUseDoorOrButton(GO_HODIR_ICE_WALL);
            DoUseDoorOrButton(GO_HODIR_EXIT);
            if(instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_CACHE_OF_WINTER, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_CACHE_OF_WINTER_H, 30*MINUTE);
            }
            // used to make the friendly keeper visible
            if(Creature* pImage = GetSingleCreatureFromStorage(KEEPER_HODIR))
                pImage->SetVisibility(VISIBILITY_ON);

            DoOpenMadnessDoorIfCan();
        }
        else if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_CHEESE_FREEZE, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_COOLEST_FRIEND, true);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_RARE_CACHE, true);
            CloseDoor(GO_HODIR_ENTER);
        }
        else if (uiData == FAIL)
            OpenDoor(GO_HODIR_ENTER);
        break;
    case TYPE_THORIM:
        m_auiEncounter[uiType] = uiData;
        DoUseDoorOrButton(GO_LIGHTNING_FIELD);
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_SIFFED, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_LOSE_YOUR_ILLUSION, false);
            DoUseDoorOrButton(GO_DARK_IRON_PORTCULIS);
        }
        if (uiData == DONE)
        {
            if(m_auiHardBoss[5] != DONE)
            {
                if (instance->IsRegularDifficulty())
                {
                    DoRespawnGameObject(GO_CACHE_OF_STORMS, 30*MINUTE);
                }
                else
                {
                    DoRespawnGameObject(GO_CACHE_OF_STORMS_H, 30*MINUTE);
                }
            }
            // used to make the friendly keeper visible
            if(Creature* pImage = GetSingleCreatureFromStorage(KEEPER_THORIM))
                pImage->SetVisibility(VISIBILITY_ON);
            DoOpenMadnessDoorIfCan();
        }
        break;
    case TYPE_FREYA:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
        {
            // do this in order to see how many elders were alive and spawn the correct chest
            // hard mode drop
            if(m_auiHardBoss[6] != DONE)
            {
                if (instance->IsRegularDifficulty())
                {
                    DoRespawnGameObject(GO_FREYA_GIFT, 30*MINUTE);
                }
                else
                {
                    DoRespawnGameObject(GO_FREYA_GIFT_H, 30*MINUTE);
                }
            }
            // used to make the friendly keeper visible
            if(Creature* pImage = GetSingleCreatureFromStorage(KEEPER_FREYA))
                pImage->SetVisibility(VISIBILITY_ON);
            DoOpenMadnessDoorIfCan();
        }
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_BACK_TO_NATURE, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_WOOD, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_KNOCK_WOOD, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_KNOCK_KNOCK_WOOD, false);
        }
        break;
    // Prison
    case TYPE_VEZAX:
        m_auiEncounter[uiType] = uiData;
        if (uiData == DONE)
            DoUseDoorOrButton(GO_VEZAX_GATE);
        if (uiData == IN_PROGRESS)
        {
            SetSpecialAchievementCriteria(TYPE_ACHIEV_MORNING_SARONITE, false);
        }
        break;
    case TYPE_YOGGSARON:
        m_auiEncounter[uiType] = uiData;
        DoUseDoorOrButton(GO_YOGG_GATE);
        if (uiData == IN_PROGRESS)
        {
            DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_YOGG_SARON_ID);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_THREE_LIGHTS, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_TWO_LIGHTS, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_ONE_LIGHT, false);
            SetSpecialAchievementCriteria(TYPE_ACHIEV_ALONE, false);
        }
        if (uiData == FAIL)
        {
            // respawn clouds
            for(GUIDList::iterator iter = m_lCLoudGuids.begin(); iter != m_lCLoudGuids.end(); ++iter)
                if (Creature *pTmp = instance->GetCreature(*iter))
                    pTmp->Respawn();
            // respawn Sara
            if(Creature* pSara = GetSingleCreatureFromStorage(NPC_SARA))
            {
                if (!pSara->isAlive())
                    pSara->Respawn();
                else
                    pSara->AI()->EnterEvadeMode();
            }
            if (Creature* pYoggBrain = GetSingleCreatureFromStorage(NPC_YOGG_BRAIN))
            {
                if(!pYoggBrain->isAlive())
                    pYoggBrain->Respawn();
                else
                    pYoggBrain->AI()->EnterEvadeMode();
            }
        }
        break;

    // Celestial Planetarium
    case TYPE_ALGALON:
        m_auiEncounter[uiType] = uiData;
        DoUseDoorOrButton(GO_CELESTIAL_DOOR);
        DoUseDoorOrButton(GO_UNIVERSE_FLOOR_CELESTIAL);
        if (uiData == DONE)
            DoRespawnGameObject(GO_GIFT_OF_OBSERVER, 30*MINUTE);
        break;

    // Hard modes
    case TYPE_LEVIATHAN_HARD:
        m_auiHardBoss[0] = uiData;
        break;
    case TYPE_XT002_HARD:
        m_auiHardBoss[1] = uiData;
        break;
    case TYPE_ASSEMBLY_HARD:
        m_auiHardBoss[2] = uiData;
        break;
    case TYPE_MIMIRON_HARD:
        m_auiHardBoss[3] = uiData;
        if(uiData == DONE)
        {
            if (instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_CACHE_OF_INOV_HARD, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_CACHE_OF_INOV_HARD_H, 30*MINUTE);
            }
        }
        break;
    case TYPE_HODIR_HARD:
        m_auiHardBoss[4] = uiData;
        if(uiData == DONE)
        {
            if (instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_CACHE_OF_RARE_WINTER, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_CACHE_OF_RARE_WINTER_H, 30*MINUTE);
            }
        }
        break;
    case TYPE_THORIM_HARD:
        m_auiHardBoss[5] = uiData;
        if(uiData == DONE)
        {
            if (instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_CACHE_OF_RARE_STORMS, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_CACHE_OF_RARE_STORMS_H, 30*MINUTE);
            }
        }
        break;
    case TYPE_FREYA_HARD:
        m_auiHardBoss[6] = uiData;
        if(uiData == DONE)
        {
            if (instance->IsRegularDifficulty())
            {
                DoRespawnGameObject(GO_FREYA_GIFT_HARD, 30*MINUTE);
            }
            else
            {
                DoRespawnGameObject(GO_FREYA_GIFT_HARD_H, 30*MINUTE);
            }
        }
        break;
    case TYPE_VEZAX_HARD:
        m_auiHardBoss[7] = uiData;
        break;
    case TYPE_YOGGSARON_HARD:
        m_auiHardBoss[8] = uiData;
        break;

    // Ulduar keepers
    case TYPE_KEEPER_HODIR:
        m_auiUlduarKeepers[0] = uiData;
        break;
    case TYPE_KEEPER_THORIM:
        m_auiUlduarKeepers[1] = uiData;
        break;
    case TYPE_KEEPER_FREYA:
        m_auiUlduarKeepers[2] = uiData;
        break;
    case TYPE_KEEPER_MIMIRON:
        m_auiUlduarKeepers[3] = uiData;
        break;

    // teleporters
    case TYPE_LEVIATHAN_TP:
        m_auiUlduarTeleporters[0] = uiData;
        break;
    case TYPE_XT002_TP:
        m_auiUlduarTeleporters[1] = uiData;
        break;
    case TYPE_MIMIRON_TP:
        m_auiUlduarTeleporters[2] = uiData;
        break;

    // mini boss
    case TYPE_RUNIC_COLOSSUS:
        m_auiMiniBoss[0] = uiData;
        if (uiData == DONE)
            OpenDoor(GO_RUNED_STONE_DOOR);
        else
            CloseDoor(GO_RUNED_STONE_DOOR);
        break;
    case TYPE_RUNE_GIANT:
        m_auiMiniBoss[1] = uiData;
        if (uiData == DONE)
            OpenDoor(GO_THORIM_STONE_DOOR);
        else
            CloseDoor(GO_THORIM_STONE_DOOR);
        break;
    case TYPE_LEVIATHAN_MK:
        m_auiMiniBoss[2] = uiData;
        break;
    case TYPE_VX001:
        m_auiMiniBoss[3] = uiData;
        /*if (uiData == DONE)     // just for animation :)
        {
            for(uint8 i = 0; i < 9; i++)
                DoUseDoorOrButton(m_uiMimironTelGUID[i]);
        }*/
        break;
    case TYPE_AERIAL_UNIT:
        m_auiMiniBoss[4] = uiData;
        break;
    case TYPE_YOGG_BRAIN:
        m_auiMiniBoss[5] = uiData;
        break;

    //phases
    case TYPE_MIMIRON_PHASE:
        m_uiMimironPhase = uiData;
        break;
    case TYPE_YOGG_PHASE:
        m_uiYoggPhase = uiData;
        break;
    case TYPE_VISION_PHASE:
        m_uiVisionPhase = uiData;
        break;
    }

    if (uiData == DONE || uiData == FAIL)
    {
        OUT_SAVE_INST_DATA;

        // save all encounters, hard bosses and keepers
        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_auiHardBoss[0] << " "
                   << m_auiHardBoss[1] << " " << m_auiHardBoss[2] << " " << m_auiHardBoss[2] << " "
                   << m_auiHardBoss[4] << " " << m_auiHardBoss[5] << " " << m_auiHardBoss[6] << " "
                   << m_auiHardBoss[7] << " " << m_auiHardBoss[8] << " " << m_auiUlduarKeepers[0] << " "
                   << m_auiUlduarKeepers[1] << " " << m_auiUlduarKeepers[2] << " " << m_auiUlduarKeepers[3] << " "
                   << m_auiUlduarTeleporters[0] << " " << m_auiUlduarTeleporters[1] << " " << m_auiUlduarTeleporters[2];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
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 TYPE_FAERLINA:
            DoUseDoorOrButton(m_uiFaerWebGUID);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_YOU_OUT, true);
            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);
            // uncomment when eruption is implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SAFETY_DANCE, true);
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiHeigExitDoorGUID);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[5] = uiData;
            DoUseDoorOrButton(m_uiLoathebDoorGUID);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SPORE_LOSER, true);
            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:
            // Only process real changes here
            if (m_auiEncounter[12] == uiData)
                return;

            m_auiEncounter[12] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(m_uiThadDoorGUID, uiData);
            // Uncomment when this achievement is implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SHOCKING, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(m_uiConsEyeRampGUID);
                DoRespawnGameObject(m_uiConsPortalGUID, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[13] = uiData;
            // Uncomment when achiev check implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_HUNDRED_CLUB, true);
            if (uiData == DONE)
                DoUseDoorOrButton(m_uiKelthuzadDoorGUID);
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[14] = uiData;
            DoUseDoorOrButton(m_uiKelthuzadExitDoorGUID);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_GET_ENOUGH, false);
            break;
        case TYPE_UNDYING_FAILED:
            m_auiEncounter[15] = uiData;
            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] << " " << m_auiEncounter[15];

        strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ulduar::OnCreatureDeath(Creature* pCreature)
{
    switch (pCreature->GetEntry())
    {
        case NPC_SANCTUM_SENTRY:
            if (GetData(TYPE_AURIAYA) == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CAT_LADY, false);
            break;
        case NPC_ULDUAR_COLOSSUS:
            {
                if (m_sColossusGuidSet.find(pCreature->GetObjectGuid()) != m_sColossusGuidSet.end())
                    m_sColossusGuidSet.erase(pCreature->GetObjectGuid());

                // start pre Leviathan event
                if (m_sColossusGuidSet.empty())
                {
                    StartNextDialogueText(SAY_PRE_LEVIATHAN_1);
                    SetData(TYPE_LEVIATHAN, SPECIAL);
                    SetData(TYPE_LEVIATHAN_GAUNTLET, DONE);
                    pCreature->SummonCreature(NPC_LEVIATHAN, afLeviathanSpawnPos[0], afLeviathanSpawnPos[1], afLeviathanSpawnPos[2], afLeviathanSpawnPos[3], TEMPSUMMON_DEAD_DESPAWN, 0, true);
                }
            }
            break;
        case NPC_DRUID_HORDE_N:
        case NPC_DRUID_HORDE_H:
        case NPC_SHAMAN_HORDE_N:
        case NPC_SHAMAN_HORDE_H:
        case NPC_MAGE_HORDE_N:
        case NPC_MAGE_HORDE_H:
        case NPC_PRIEST_HORDE_N:
        case NPC_PRIEST_HORDE_H:
        case NPC_DRUID_ALLIANCE_N:
        case NPC_DRUID_ALLIANCE_H:
        case NPC_SHAMAN_ALLIANCE_N:
        case NPC_SHAMAN_ALLIANCE_H:
        case NPC_MAGE_ALLIANCE_N:
        case NPC_MAGE_ALLIANCE_H:
        case NPC_PRIEST_ALLIANCE_N:
        case NPC_PRIEST_ALLIANCE_H:
            if (GetData(TYPE_HODIR) == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_COOL_FRIENDS, false);
            break;
        case NPC_JORMUNGAR_BEHEMOTH:
        case NPC_SOLDIER_ALLIANCE:
        case NPC_CAPTAIN_ALLIANCE:
        case NPC_SOLDIER_HORDE:
        case NPC_CAPTAIN_HORDE:
            ++m_uiSlayedArenaMobs;

            // start combat when all 4 faction soldiers and the Jormungar are dead
            if (m_uiSlayedArenaMobs == 5)
            {
                if (Creature* pThorim = GetSingleCreatureFromStorage(NPC_THORIM))
                    pThorim->SetInCombatWithZone();
            }
            break;
        case NPC_RUNIC_COLOSSUS:
            DoUseDoorOrButton(GO_RUNED_STONE_DOOR);
            break;
        case NPC_RUNE_GIANT:
            DoUseDoorOrButton(GO_THORIM_STONE_DOOR);
            break;
    }
}
Exemple #18
0
void instance_naxxramas::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_ANUB_REKHAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_ANUB_DOOR);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_ARAC_ANUB_GATE);
            break;
        case TYPE_FAERLINA:
            DoUseDoorOrButton(GO_ARAC_FAER_WEB);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_YOU_OUT, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_FAER_DOOR);
                DoUseDoorOrButton(GO_ARAC_MAEX_OUTER_DOOR);
            }
            if (uiData == FAIL)
            {
                for (GUIDList::const_iterator itr = m_lFaerlinaAddGUIDs.begin(); itr != m_lFaerlinaAddGUIDs.end(); ++itr)
                {
                    Creature* pAdd = instance->GetCreature(*itr);
                    if (pAdd && !pAdd->isAlive())
                        pAdd->Respawn();
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MAEXXNA:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_MAEX_INNER_DOOR, uiData);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_EYE_RAMP);
                DoRespawnGameObject(GO_ARAC_PORTAL, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_NOTH:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_NOTH_ENTRY_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_NOTH_EXIT_DOOR);
                DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            }
            break;
        case TYPE_HEIGAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            // not used, achievement handled by heigan script
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SAFETY_DANCE, true);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_PLAG_HEIG_EXIT_DOOR);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_LOAT_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SPORE_LOSER, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_EYE_RAMP);
                DoRespawnGameObject(GO_PLAG_PORTAL, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_RAZUVIOUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GOTHIK:
            switch(uiData)
            {
                case IN_PROGRESS:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case SPECIAL:
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case FAIL:
                    if (m_auiEncounter[uiType] == IN_PROGRESS)
                        DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);

                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    break;
                case DONE:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_EXIT_GATE);
                    DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_MILI_EYE_RAMP);
                DoRespawnGameObject(GO_MILI_PORTAL, 30*MINUTE);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CHEST_HORSEMEN_NORM : GO_CHEST_HORSEMEN_HERO, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_PATCHWERK:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_PATCHWERK_ID);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_CONS_PATH_EXIT_DOOR);
            break;
        case TYPE_GROBBULUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GLUTH:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_GLUT_EXIT_DOOR);
                DoUseDoorOrButton(GO_CONS_THAD_DOOR);
            }
            break;
        case TYPE_THADDIUS:
            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_CONS_THAD_DOOR, uiData);
            // Uncomment when Thaddius (and this achievement is implemented)
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SHOCKING, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_EYE_RAMP);
                DoRespawnGameObject(GO_CONS_PORTAL, 30*MINUTE);
                DoTaunt();
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[uiType] = uiData;
            // Uncomment when achiev check implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_HUNDRED_CLUB, true);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_KELTHUZAD_WATERFALL_DOOR);
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_KELTHUZAD_EXIT_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_KELTHUZAD_WINDOW_1);
                DoUseDoorOrButton(GO_KELTHUZAD_WINDOW_2);
                DoUseDoorOrButton(GO_KELTHUZAD_WINDOW_3);
                DoUseDoorOrButton(GO_KELTHUZAD_WINDOW_4);
            }
            else if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_GET_ENOUGH, false);
            break;
        case TYPE_UNDYING_FAILED:
            m_auiEncounter[uiType] = uiData;
            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] << " " << m_auiEncounter[15];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemple #19
0
void instance_nexus::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_TELESTRA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SPLIT_PERSONALITY, true);
            if (uiData == DONE)
            {
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_TELESTRA))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            }
            break;
        case TYPE_ANOMALUS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CHAOS_THEORY, true);
            if (uiData == DONE)
            {
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_ANOMALUS))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            }
            break;
        case TYPE_ORMOROK:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                if (GameObject* pGo = GetSingleGameObjectFromStorage(GO_CONTAINMENT_SPHERE_ORMOROK))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT);
            }
            break;
        case TYPE_KERISTRASZA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_sIntenseColdFailPlayers.clear();
            break;
        case TYPE_INTENSE_COLD_FAILED:
            // Insert the players who fail the achiev and haven't been already inserted in the set
            if (m_sIntenseColdFailPlayers.find(uiData) == m_sIntenseColdFailPlayers.end())
                m_sIntenseColdFailPlayers.insert(uiData);
            break;
        default:
            error_log("SD2: Instance Nexus: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            return;
    }

    if (m_auiEncounter[TYPE_TELESTRA] == SPECIAL && m_auiEncounter[TYPE_ANOMALUS] == SPECIAL && m_auiEncounter[TYPE_ORMOROK] == SPECIAL)
    {
        // release Keristrasza from her prison here
        m_auiEncounter[TYPE_KERISTRASZA] = SPECIAL;

        Creature* pCreature = GetSingleCreatureFromStorage(NPC_KERISTRASZA);
        if (pCreature && pCreature->isAlive())
        {
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE | UNIT_FLAG_OOC_NOT_ATTACKABLE
                                  | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
            pCreature->RemoveAurasDueToSpell(SPELL_FROZEN_PRISON);
        }
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " " << m_auiEncounter[3];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_naxxramas::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_ANUB_REKHAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_ANUB_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_ANUB_GATE);
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_MAEXXNA_ID);
            }
            break;
        case TYPE_FAERLINA:
            DoUseDoorOrButton(GO_ARAC_FAER_WEB);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_KNOCK_YOU_OUT, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_FAER_DOOR);
                DoUseDoorOrButton(GO_ARAC_MAEX_OUTER_DOOR);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MAEXXNA:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ARAC_MAEX_INNER_DOOR, uiData);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ARAC_EYE_RAMP);
                DoRespawnGameObject(GO_ARAC_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_NOTH:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_NOTH_ENTRY_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_NOTH_EXIT_DOOR);
                DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            }
            break;
        case TYPE_HEIGAN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_HEIG_ENTRY_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SAFETY_DANCE, true);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_PLAG_HEIG_EXIT_DOOR);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_LOAT_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_SPORE_LOSER, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_EYE_RAMP);
                DoRespawnGameObject(GO_PLAG_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_RAZUVIOUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GOTHIK:
            switch(uiData)
            {
                case IN_PROGRESS:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case SPECIAL:
                    DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);
                    break;
                case FAIL:
                    if (m_auiEncounter[uiType] == IN_PROGRESS)
                        DoUseDoorOrButton(GO_MILI_GOTH_COMBAT_GATE);

                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    break;
                case DONE:
                    DoUseDoorOrButton(GO_MILI_GOTH_ENTRY_GATE);
                    DoUseDoorOrButton(GO_MILI_GOTH_EXIT_GATE);
                    DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_MILI_EYE_RAMP);
                DoRespawnGameObject(GO_MILI_PORTAL, 30*MINUTE);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CHEST_HORSEMEN_NORM : GO_CHEST_HORSEMEN_HERO, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_PATCHWERK:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_PATCHWERK_ID);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_CONS_PATH_EXIT_DOOR);
            break;
        case TYPE_GROBBULUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_GLUTH:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_GLUT_EXIT_DOOR);
                DoUseDoorOrButton(GO_CONS_THAD_DOOR);
            }
            break;
        case TYPE_THADDIUS:
            // Only process real changes here
            if (m_auiEncounter[uiType] == uiData)
                return;

            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_CONS_THAD_DOOR, uiData);
            // Uncomment when this achievement is implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_SHOCKING, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_EYE_RAMP);
                DoRespawnGameObject(GO_CONS_PORTAL, 30*MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[uiType] = uiData;
            // Uncomment when achiev check implemented
            //if (uiData == IN_PROGRESS)
            //    SetSpecialAchievementCriteria(TYPE_ACHIEV_HUNDRED_CLUB, true);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_KELTHUZAD_WATERFALL_DOOR);
                m_dialogueHelper.StartNextDialogueText(SAY_SAPP_DIALOG1);
            }
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_KELTHUZAD_EXIT_DOOR);
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_GET_ENOUGH, false);
            break;
        case TYPE_UNDYING_FAILED:
            m_auiEncounter[uiType] = uiData;
            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] << " " << m_auiEncounter[15];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_icecrown_citadel::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_TELEPORT:
            break;
        case TYPE_MARROWGAR:
            m_auiEncounter[TYPE_MARROWGAR] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_ICEWALL_1);
                DoOpenDoor(GO_ICEWALL_2);
                DoOpenDoor(GO_ORATORY_DOOR);
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_MARROWGAR_DOOR);
                SetSpecialAchievementCriteria(TYPE_BONED, true);
            }
            else
                DoOpenDoor(GO_MARROWGAR_DOOR);
            break;
         case TYPE_DEATHWHISPER:
            m_auiEncounter[TYPE_DEATHWHISPER] = uiData;

            if (uiData == DONE)
            {
                if (GameObject* pGO = GetSingleGameObjectFromStorage(GO_DEATHWHISPER_ELEVATOR))
                {
                      pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                      pGO->SetGoState(GO_STATE_READY);
                }
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_ORATORY_DOOR);
            }
            else
                DoOpenDoor(GO_ORATORY_DOOR);
            break;
         case TYPE_FLIGHT_WAR:
            /*if (uiData == DONE && m_auiEncounter[TYPE_FLIGHT_WAR] != DONE) // add when implemented
            {
                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiGunshipArmoryA_ID))
                {
                    if (pChest && !pChest->isSpawned())
                    {
                        pChest->SetRespawnTime(7*DAY);
                    }
                }
                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiGunshipArmoryH_ID))
                {
                    if (pChest && !pChest->isSpawned())
                    {
                        pChest->SetRespawnTime(7*DAY);
                    }
                }
            }*/
            m_auiEncounter[TYPE_FLIGHT_WAR] = uiData;
            break;
         case TYPE_SAURFANG:
            m_auiEncounter[TYPE_SAURFANG] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_SAURFANG_DOOR);

                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiSaurfangCache))
                {
                    if (pChest && !pChest->isSpawned())
                        pChest->SetRespawnTime(7*DAY);
                }
            }
            if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_IVE_MADE_AND_MESS, true);
            }
            break;
         case TYPE_FESTERGUT:
            m_auiEncounter[TYPE_FESTERGUT] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_ORANGE_TUBES);
                /*if (m_auiEncounter[TYPE_ROTFACE] == DONE)
                {
                    DoUseDoorOrButton(GO_SCIENTIST_DOOR_ORANGE, 0, true);
                    DoUseDoorOrButton(GO_SCIENTIST_DOOR_GREEN, 0, true);
                    DoOpenDoor(GO_SCIENTIST_DOOR_COLLISION);
                }*/
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_ORANGE_PLAGUE);
                SetSpecialAchievementCriteria(TYPE_FLU_SHORT_SHORTAGE, true);
            }
            else
                DoOpenDoor(GO_ORANGE_PLAGUE);
            break;
         case TYPE_ROTFACE:
            m_auiEncounter[TYPE_ROTFACE] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_GREEN_TUBES);
                /*if (m_auiEncounter[TYPE_FESTERGUT] == DONE)
                {
                    DoUseDoorOrButton(GO_SCIENTIST_DOOR_ORANGE, 0, true);
                    DoUseDoorOrButton(GO_SCIENTIST_DOOR_GREEN, 0, true);
                    DoOpenDoor(GO_SCIENTIST_DOOR_COLLISION);
                }*/
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_GREEN_PLAGUE);
                SetSpecialAchievementCriteria(TYPE_DANCES_WITH_OOZES, true);
            }
            else
                DoOpenDoor(GO_GREEN_PLAGUE);
            break;
         case TYPE_PUTRICIDE:
            m_auiEncounter[TYPE_PUTRICIDE] = uiData;

            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_SINDRAGOSA] == DONE &&
                    m_auiEncounter[TYPE_LANATHEL] == DONE)
                {
                    m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
            }
            if (uiData == IN_PROGRESS || uiData == SPECIAL)
            {
                DoCloseDoor(GO_SCIENTIST_DOOR);
                SetSpecialAchievementCriteria(TYPE_NAUSEA_HEATBURN_INDIGESTION, true);
            }
            else
                DoOpenDoor(GO_SCIENTIST_DOOR);
            break;
         case TYPE_BLOOD_COUNCIL:
            m_auiEncounter[TYPE_BLOOD_COUNCIL] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_COUNCIL_DOOR_1);
                DoOpenDoor(GO_COUNCIL_DOOR_2);
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_CRIMSON_HALL_DOOR);
                SetSpecialAchievementCriteria(TYPE_ORB_WHISPERER, true);
            }
            else
                DoOpenDoor(GO_CRIMSON_HALL_DOOR);
            break;
         case TYPE_LANATHEL:
            m_auiEncounter[TYPE_LANATHEL] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_ICECROWN_GRATE);

                if (m_auiEncounter[TYPE_PUTRICIDE] == DONE &&
                    m_auiEncounter[TYPE_SINDRAGOSA] == DONE)
                {
                    m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
            }
            if (uiData == IN_PROGRESS)
                DoCloseDoor(GO_BLOODPRINCE_DOOR);
            else
                DoOpenDoor(GO_BLOODPRINCE_DOOR);
            break;
         case TYPE_VALITHRIA:
            m_auiEncounter[TYPE_VALITHRIA] = uiData;

            if (uiData == DONE)
            {
                DoOpenDoor(GO_GREEN_DRAGON_DOOR_2);

                DoOpenDoor(GO_SINDRAGOSA_DOOR_1);
                DoOpenDoor(GO_SINDRAGOSA_DOOR_2);

                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiValithriaCache))
                {
                    if (pChest && !pChest->isSpawned())
                        pChest->SetRespawnTime(7*DAY);
                }
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_GREEN_DRAGON_DOOR_1);
                DoOpenDoor(GO_VALITHRIA_DOOR_1);
                DoOpenDoor(GO_VALITHRIA_DOOR_2);

                if (instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL ||
                    instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_HEROIC)
                {
                    DoOpenDoor(GO_VALITHRIA_DOOR_3);
                    DoOpenDoor(GO_VALITHRIA_DOOR_4);
                }
                SetSpecialAchievementCriteria(TYPE_PORTAL_JOCKEY, false); // should be true when implemented
            }
            else
            {
                DoOpenDoor(GO_GREEN_DRAGON_DOOR_1);
                DoCloseDoor(GO_VALITHRIA_DOOR_1);
                DoCloseDoor(GO_VALITHRIA_DOOR_2);

                if (instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL ||
                    instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_HEROIC)
                {
                    DoCloseDoor(GO_VALITHRIA_DOOR_3);
                    DoCloseDoor(GO_VALITHRIA_DOOR_4);
                }
            }
            break;
         case TYPE_SINDRAGOSA:
            m_auiEncounter[TYPE_SINDRAGOSA] = uiData;

            if (uiData == DONE)
            {
                if (m_auiEncounter[TYPE_PUTRICIDE] == DONE &&
                    m_auiEncounter[TYPE_LANATHEL] == DONE)
                {
                    m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
            }
            if (uiData == IN_PROGRESS)
            {
                DoCloseDoor(GO_SINDRAGOSA_ICEWALL);
                SetSpecialAchievementCriteria(TYPE_ALL_YOU_CAN_EAT, true);
            }
            else
                DoOpenDoor(GO_SINDRAGOSA_ICEWALL);

            break;
         case TYPE_LICH_KING:
            m_auiEncounter[TYPE_LICH_KING] = uiData;
            if (uiData == IN_PROGRESS)
            {
                SetSpecialAchievementCriteria(TYPE_NECK_DEEP_IN_VILE, true);
                SetSpecialAchievementCriteria(TYPE_BEEN_WAITING_A_LONG_TIME, false);
            }
            break;
         case TYPE_FROSTMOURNE_ROOM:
             m_auiEncounter[TYPE_FROSTMOURNE_ROOM] = uiData;
             break;
         case TYPE_ICECROWN_QUESTS:
             m_auiEncounter[TYPE_ICECROWN_QUESTS] = uiData;
             break;
         case TYPE_STINKY:
             m_auiEncounter[TYPE_STINKY] = uiData;
             break;
         case TYPE_PRECIOUS:
             m_auiEncounter[TYPE_PRECIOUS] = uiData;
             break;
         case TYPE_SVALNA:
             m_auiEncounter[TYPE_SVALNA] = uiData;
             if (uiData == DONE)
                 DoOpenDoor(GO_GREEN_DRAGON_DOOR_1);
             break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;

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

        strSaveData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}