Exemplo n.º 1
0
void instance_serpentshrine_cavern::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_HYDROSS_EVENT:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_LEOTHERAS_EVENT:
            m_auiEncounter[1] = uiData;
            if (uiData == FAIL)
            {
                for (GuidList::const_iterator itr = m_lSpellBindersGUIDList.begin(); itr != m_lSpellBindersGUIDList.end(); ++itr)
                {
                    if (Creature* pSpellBinder = instance->GetCreature(*itr))
                        pSpellBinder->Respawn();
                }

                m_uiSpellBinderCount = 0;
            }
            break;
        case TYPE_THELURKER_EVENT:
        case TYPE_KARATHRESS_EVENT:
        case TYPE_MOROGRIM_EVENT:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_LADYVASHJ_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                // interrupt the shield
                for (GuidList::const_iterator itr = m_lShieldGeneratorGUIDList.begin(); itr != m_lShieldGeneratorGUIDList.end(); ++itr)
                {
                    if (Creature* pGenerator = instance->GetCreature(*itr))
                        pGenerator->InterruptNonMeleeSpells(false);
                }

                // reset generators
                DoToggleGameObjectFlags(GO_SHIELD_GENERATOR_1, GO_FLAG_NO_INTERACT, false);
                DoToggleGameObjectFlags(GO_SHIELD_GENERATOR_2, GO_FLAG_NO_INTERACT, false);
                DoToggleGameObjectFlags(GO_SHIELD_GENERATOR_3, GO_FLAG_NO_INTERACT, false);
                DoToggleGameObjectFlags(GO_SHIELD_GENERATOR_4, GO_FLAG_NO_INTERACT, false);
            }
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_steam_vault::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_HYDROMANCER_THESPIA:
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_ACCESS_PANEL_HYDRO, GO_FLAG_NO_INTERACT, false);
            if (uiData == SPECIAL)
            {
                if (GetData(TYPE_MEKGINEER_STEAMRIGGER) == SPECIAL)
                    DoUseDoorOrButton(GO_MAIN_CHAMBERS_DOOR);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MEKGINEER_STEAMRIGGER:
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_ACCESS_PANEL_MEK, GO_FLAG_NO_INTERACT, false);
            if (uiData == SPECIAL)
            {
                if (GetData(TYPE_HYDROMANCER_THESPIA) == SPECIAL)
                    DoUseDoorOrButton(GO_MAIN_CHAMBERS_DOOR);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_WARLORD_KALITHRESH:
            DoUseDoorOrButton(GO_MAIN_CHAMBERS_DOOR);
            if (uiData == FAIL)
            {
                // Reset Distiller flags - respawn is handled by DB
                for (GuidList::const_iterator itr = m_lNagaDistillerGuidList.begin(); itr != m_lNagaDistillerGuidList.end(); ++itr)
                {
                    if (Creature* pDistiller = instance->GetCreature(*itr))
                    {
                        if (!pDistiller->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
                            pDistiller->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
    }

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

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

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 3
0
void instance_dire_maul::OnPlayerEnter(Player* pPlayer)
{
    // figure where to enter to set library doors accordingly
    // Enter DM North first
    if (pPlayer->IsWithinDist2d(260.0f, -20.0f, 20.0f) && m_auiEncounter[TYPE_WARPWOOD] != DONE)
        m_bDoNorthBeforeWest = true;
    else
        m_bDoNorthBeforeWest = false;

    DoToggleGameObjectFlags(GO_WEST_LIBRARY_DOOR, GO_FLAG_NO_INTERACT, m_bDoNorthBeforeWest);
    DoToggleGameObjectFlags(GO_WEST_LIBRARY_DOOR, GO_FLAG_LOCKED, !m_bDoNorthBeforeWest);
}
void instance_ramparts::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Ramparts: SetData received for type %u with data %u",uiType,uiData);

    switch (uiType)
    {
        case TYPE_VAZRUDEN:
            if (uiData == DONE && m_auiEncounter[1] == DONE)
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_FEL_IRON_CHEST : GO_FEL_IRON_CHEST_H, HOUR);
            if (uiData == FAIL && m_auiEncounter[0] != FAIL)
                DoFailVazruden();
            m_auiEncounter[0] = uiData;
            break;
        case TYPE_NAZAN:
            if (uiData == SPECIAL)
            {
                ++m_uiSentryCounter;

                if (m_uiSentryCounter == 2)
                    m_auiEncounter[1] = uiData;

                return;
            }
            if (uiData == DONE && m_auiEncounter[0] == DONE)
            {
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_FEL_IRON_CHEST : GO_FEL_IRON_CHEST_H, HOUR);
                DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_FEL_IRON_CHEST : GO_FEL_IRON_CHEST_H, GO_FLAG_NO_INTERACT, false);
            }
            if (uiData == FAIL && m_auiEncounter[1] != FAIL)
                DoFailVazruden();

            m_auiEncounter[1] = uiData;
            break;
    }
}
Exemplo n.º 5
0
void instance_sunken_temple::DoUpdateFlamesFlags(bool bRestore)
{
    for (GuidList::const_iterator itr = m_luiFlameGUIDs.begin(); itr != m_luiFlameGUIDs.end(); ++itr)
    {
        DoToggleGameObjectFlags(*itr, GO_FLAG_NO_INTERACT, bRestore);
    }
}
Exemplo n.º 6
0
void instance_oculus::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
    case TYPE_DRAKOS:
        m_auiEncounter[TYPE_DRAKOS] = uiData;
        break;
    case TYPE_VAROS:
        m_auiEncounter[TYPE_VAROS] = uiData;
        break;
    case TYPE_UROM:
        m_auiEncounter[TYPE_UROM] = uiData;
        break;
    case TYPE_EREGOS:
        m_auiEncounter[TYPE_EREGOS] = uiData;
        if (uiData == DONE)
            DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_EREGOS : GO_CACHE_EREGOS_H, GO_FLAG_NO_INTERACT, false);
        break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[TYPE_DRAKOS] << " " << m_auiEncounter[TYPE_VAROS] << " " << m_auiEncounter[TYPE_UROM] << " " << m_auiEncounter[TYPE_EREGOS];

        strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
/// Function that uses a door or button that is stored in m_mGoEntryGuidStore
void ScriptedInstance::DoToggleGameObjectFlags(uint32 uiEntry, uint32 uiGOflags, bool bApply)
{
    EntryGuidMap::iterator find = m_mGoEntryGuidStore.find(uiEntry);
    if (find != m_mGoEntryGuidStore.end())
        DoToggleGameObjectFlags(find->second, uiGOflags, bApply);
    else
        // Output log, possible reason is not added GO to storage, or not yet loaded
        debug_log("SD2: Script call ToogleTameObjectFlags (by Entry), but no gameobject of entry %u was created yet, or it was not stored by script for map %u.", uiEntry, instance->GetId());
}
void instance_blackwing_lair::OnCreatureDeath(Creature* pCreature)
{
    if (pCreature->GetEntry() == NPC_GRETHOK_CONTROLLER)
    {
        DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, false);

        if (Creature* pOrbTrigger = GetSingleCreatureFromStorage(NPC_BLACKWING_ORB_TRIGGER))
            pOrbTrigger->InterruptNonMeleeSpells(false);
    }
}
void instance_blackwing_lair::OnCreatureDeath(Creature* pCreature)
{
    switch (pCreature->GetEntry())
    {
        case NPC_GRETHOK_CONTROLLER:
            // Allow orb to be used
            DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, false);

            if (Creature* pOrbTrigger = GetSingleCreatureFromStorage(NPC_BLACKWING_ORB_TRIGGER))
                pOrbTrigger->InterruptNonMeleeSpells(false);
            break;
        case NPC_RAZORGORE:
            // Only set the event as done if Razorgore dies in last phase
            if (GetData(TYPE_RAZORGORE) == SPECIAL)
            {
                SetData(TYPE_RAZORGORE, DONE);
                break;
            }

            // If the event is not already failed in Razorgore script, then force group wipe by making the boss trigger an AoE
            // this is basically a duplicate of what is in Razorgore script because when the boss is Mind Controlled the AI is overriden
            // So we have to handle it in the instance script instead to prevent the event to be stucked or exploited
            if (GetData(TYPE_RAZORGORE) != FAIL)
            {
                if (Creature* pRazorgore = GetSingleCreatureFromStorage(NPC_RAZORGORE))
                {
                    pRazorgore->CastSpell(pRazorgore, SPELL_FIREBALL, TRIGGERED_OLD_TRIGGERED);
                    SetData(TYPE_RAZORGORE, FAIL);
                    DoScriptText(SAY_RAZORGORE_DEATH, pRazorgore);
                    pRazorgore->ForcedDespawn();
                }
                if (Creature* pOrbTrigger = GetSingleCreatureFromStorage(NPC_BLACKWING_ORB_TRIGGER))
                    pOrbTrigger->CastSpell(pOrbTrigger, SPELL_EXPLODE_ORB, TRIGGERED_IGNORE_UNATTACKABLE_FLAG);
            }
            break;
        case NPC_BLACKWING_LEGIONNAIRE:
        case NPC_BLACKWING_MAGE:
            m_uiBlackwingDefCount--;
            break;
        case NPC_DRAGONSPAWN:
            m_uiDragonspawnCount--;
            break;
    }
}
Exemplo n.º 10
0
void instance_sethekk_halls::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_SYTH:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_ANZU:
            m_auiEncounter[uiType] = uiData;
            // Respawn the Raven's Claw if event fails
            if (uiData == FAIL)
            {
                if (GameObject* pClaw = GetSingleGameObjectFromStorage(GO_RAVENS_CLAW))
                    pClaw->Respawn();
            }
            break;
        case TYPE_IKISS:
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_IKISS_DOOR, DAY);
                DoToggleGameObjectFlags(GO_IKISS_CHEST, GO_FLAG_NO_INTERACT | GO_FLAG_INTERACT_COND, false);
            }
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_blackwing_lair::SetData64(uint32 uiData, uint64 uiGuid)
{
    if (uiData == DATA_DRAGON_EGG)
    {
        if (GameObject* pEgg = instance->GetGameObject(ObjectGuid(uiGuid)))
            m_lUsedEggsGuids.push_back(pEgg->GetObjectGuid());

        // If all eggs are destroyed, then allow Razorgore to be attacked
        if (m_lUsedEggsGuids.size() == m_lDragonEggsGuids.size())
        {
            SetData(TYPE_RAZORGORE, SPECIAL);
            DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, true);

            // Emote for the start of the second phase
            if (Creature* pTrigger = GetSingleCreatureFromStorage(NPC_NEFARIANS_TROOPS))
            {
                DoScriptText(EMOTE_ORB_SHUT_OFF, pTrigger);
                DoScriptText(EMOTE_TROOPS_FLEE, pTrigger);
            }

            // Break mind control and set max health
            if (Creature* pRazorgore = GetSingleCreatureFromStorage(NPC_RAZORGORE))
            {
                pRazorgore->RemoveAllAuras();
                pRazorgore->CastSpell(pRazorgore, SPELL_WARMING_FLAMES, TRIGGERED_OLD_TRIGGERED);
            }

            // All defenders evade and despawn
            for (GuidList::const_iterator itr = m_lDefendersGuids.begin(); itr != m_lDefendersGuids.end(); ++itr)
            {
                if (Creature* pDefender = instance->GetCreature(*itr))
                {
                    pDefender->AI()->EnterEvadeMode();
                    pDefender->ForcedDespawn(10000);
                }
            }
            m_uiBlackwingDefCount = 0;
            m_uiDragonspawnCount = 0;
        }
    }
}
Exemplo n.º 12
0
void instance_magtheridons_lair::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
    case TYPE_MAGTHERIDON_EVENT:
        switch (uiData)
        {
        case FAIL:
            // Reset channelers
            for (GuidList::const_iterator itr = m_lChannelerGuidList.begin(); itr != m_lChannelerGuidList.end(); ++itr)
            {
                if (Creature* pChanneler = instance->GetCreature(*itr))
                {
                    if (!pChanneler->isAlive())
                        pChanneler->Respawn();
                }
            }

            // Reset columns
            for (GuidList::const_iterator itr = m_lColumnGuidList.begin(); itr != m_lColumnGuidList.end(); ++itr)
            {
                if (GameObject* pColumn = instance->GetGameObject(*itr))
                    pColumn->ResetDoorOrButton();
            }

            // Reset cubes
            for (GuidList::const_iterator itr = m_lCubeGuidList.begin(); itr != m_lCubeGuidList.end(); ++itr)
                DoToggleGameObjectFlags(*itr, GO_FLAG_NO_INTERACT, true);

            // Reset timers and doors
            SetData(TYPE_CHANNELER_EVENT, NOT_STARTED);
            m_uiCageBreakTimer = 0;
            m_uiCageBreakStage = 0;

        // no break;
        case DONE:
            // Reset door on Fail or Done
            if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_DOODAD_HF_MAG_DOOR01))
                pDoor->ResetDoorOrButton();
            break;
        case IN_PROGRESS:
            // Set boss in combat
            if (Creature* pMagtheridon = GetSingleCreatureFromStorage(NPC_MAGTHERIDON))
            {
                if (pMagtheridon->isAlive())
                {
                    pMagtheridon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    pMagtheridon->SetInCombatWithZone();
                }
            }
            // Enable cubes
            for (GuidList::const_iterator itr = m_lCubeGuidList.begin(); itr != m_lCubeGuidList.end(); ++itr)
                DoToggleGameObjectFlags(*itr, GO_FLAG_NO_INTERACT, false);
            break;
        case SPECIAL:
            // Collapse the hall - don't store this value
            for (GuidList::const_iterator itr = m_lColumnGuidList.begin(); itr != m_lColumnGuidList.end(); ++itr)
                DoUseDoorOrButton(*itr);
            // return, don't set encounter as special
            return;
        }
        m_auiEncounter[uiType] = uiData;
        break;
    case TYPE_CHANNELER_EVENT:
        // don't set the same data twice
        if (m_auiEncounter[1] == uiData)
            break;
        // stop the event timer on fail
        if (uiData == FAIL)
        {
            m_uiCageBreakTimer = 0;
            m_uiCageBreakStage = 0;

            // Reset door on Fail
            if (GameObject* pDoor = GetSingleGameObjectFromStorage(GO_DOODAD_HF_MAG_DOOR01))
                pDoor->ResetDoorOrButton();

            // Reset Magtheridon
            if (Creature* pMagtheridon = GetSingleCreatureFromStorage(NPC_MAGTHERIDON))
            {
                if (pMagtheridon->isAlive())
                    pMagtheridon->AI()->EnterEvadeMode();
            }
        }
        // prepare Magtheridon for release
        if (uiData == IN_PROGRESS)
        {
            if (Creature* pMagtheridon = GetSingleCreatureFromStorage(NPC_MAGTHERIDON))
            {
                if (pMagtheridon->isAlive())
                {
                    DoScriptText(EMOTE_EVENT_BEGIN, pMagtheridon);
                    m_uiCageBreakTimer = MINUTE*IN_MILLISECONDS;
                }
            }

            // combat door
            DoUseDoorOrButton(GO_DOODAD_HF_MAG_DOOR01);
        }
        m_auiEncounter[uiType] = uiData;
        break;
    }

    // Instance save isn't needed for this one
}
Exemplo n.º 13
0
void instance_oculus::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_DRAKOS:
            m_auiEncounter[TYPE_DRAKOS] = uiData;
            if (uiData == DONE)
            {
                // Open all cages
                for (GuidList::const_iterator itr = m_lCageDoorGUIDs.begin(); itr != m_lCageDoorGUIDs.end(); ++itr)
                    DoUseDoorOrButton(*itr);

                // Notes: The dialogue is handled by DB script
                // Also the Centrifuge Constructs and the related npcs should be summoned - requires additional research

                // Activate the world state - the Centrifuge contructs should be loaded by now
                DoUpdateWorldState(WORLD_STATE_CONSTRUCTS, 1);
                DoUpdateWorldState(WORLD_STATE_CONSTRUCTS_COUNT, m_sConstructsAliveGUIDSet.size());

                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_EREGOS_ID);
            }
            break;
        case TYPE_VAROS:
            m_auiEncounter[TYPE_VAROS] = uiData;
            if (uiData == DONE)
            {
                // Note: Image of Belgaristrasz dialogue is handled by DB script
                DoSpawnNextBossIfCan();
                DoUpdateWorldState(WORLD_STATE_CONSTRUCTS, 0);
            }
            break;
        case TYPE_UROM:
            m_auiEncounter[TYPE_UROM] = uiData;
            // Note: Image of Belgaristrasz dialogue is handled by DB script
            if (uiData == DONE)
                DoSpawnNextBossIfCan();
            break;
        case TYPE_EREGOS:
            m_auiEncounter[TYPE_EREGOS] = uiData;
            // Note: Image of Belgaristrasz teleports to the Cache location and does more dialogue - requires additional research
            if (uiData == DONE)
            {
                // The data about the cache isn't consistent, so it's better to handle both cases
                DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_CACHE_EREGOS : GO_CACHE_EREGOS_H, GO_FLAG_NO_INTERACT, false);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CACHE_EREGOS : GO_CACHE_EREGOS_H, 30 * MINUTE);
            }
            break;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[TYPE_DRAKOS] << " " << m_auiEncounter[TYPE_VAROS] << " " << m_auiEncounter[TYPE_UROM] << " " << m_auiEncounter[TYPE_EREGOS];

        strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 14
0
void instance_karazhan::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_ATTUMEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                // Respawn Midnight on Fail
                if (Creature* pMidnight = GetSingleCreatureFromStorage(NPC_MIDNIGHT))
                {
                    if (!pMidnight->isAlive())
                        pMidnight->Respawn();
                }
            }
            break;
        case TYPE_MOROES:
        case TYPE_MAIDEN:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_OPERA:
            // Don't store the same data twice
            if (uiData == m_auiEncounter[uiType])
                break;
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_uiOzDeathCount = 0;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_STAGE_DOOR_LEFT);
                DoUseDoorOrButton(GO_STAGE_DOOR_RIGHT);
                DoToggleGameObjectFlags(GO_SIDE_ENTRANCE_DOOR, GO_FLAG_LOCKED, false);
            }
            // use curtain only for event start or fail
            else
                DoUseDoorOrButton(GO_STAGE_CURTAIN);
            break;
        case TYPE_CURATOR:
        case TYPE_TERESTIAN:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_ARAN:
            if (uiData == FAIL || uiData == DONE)
                DoToggleGameObjectFlags(GO_PRIVATE_LIBRARY_DOOR, GO_FLAG_LOCKED, false);
            if (uiData == IN_PROGRESS)
                DoToggleGameObjectFlags(GO_PRIVATE_LIBRARY_DOOR, GO_FLAG_LOCKED, true);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_NETHERSPITE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MASSIVE_DOOR);
            break;
        case TYPE_CHESS:
            if (uiData == DONE)
            {
                // doors and loot are not handled for friendly games
                if (GetData(TYPE_CHESS) != SPECIAL)
                {
                    DoUseDoorOrButton(GO_GAMESMANS_HALL_EXIT_DOOR);
                    DoRespawnGameObject(GO_DUST_COVERED_CHEST, DAY);
                    DoToggleGameObjectFlags(GO_DUST_COVERED_CHEST, GO_FLAG_NO_INTERACT, false);
                }

                // cast game end spells
                if (Creature* pMedivh = GetSingleCreatureFromStorage(NPC_ECHO_MEDIVH))
                {
                    pMedivh->CastSpell(pMedivh, SPELL_FORCE_KILL_BUNNY, TRIGGERED_OLD_TRIGGERED);
                    pMedivh->CastSpell(pMedivh, SPELL_GAME_OVER, TRIGGERED_OLD_TRIGGERED);
                    pMedivh->CastSpell(pMedivh, SPELL_CLEAR_BOARD, TRIGGERED_OLD_TRIGGERED);
                }
                if (Creature* pController = GetSingleCreatureFromStorage(NPC_CHESS_VICTORY_CONTROLLER))
                    pController->CastSpell(pController, SPELL_VICTORY_VISUAL, TRIGGERED_OLD_TRIGGERED);

                // remove silence debuff
                Map::PlayerList const& players = instance->GetPlayers();
                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                {
                    if (Player* pPlayer = itr->getSource())
                        pPlayer->RemoveAurasDueToSpell(SPELL_GAME_IN_SESSION);
                }

                m_bFriendlyGame = false;
                m_uiChessResetTimer = 35000;
            }
            else if (uiData == FAIL)
            {
                // clean the board for reset
                if (Creature* pMedivh = GetSingleCreatureFromStorage(NPC_ECHO_MEDIVH))
                {
                    pMedivh->CastSpell(pMedivh, SPELL_GAME_OVER, TRIGGERED_OLD_TRIGGERED);
                    pMedivh->CastSpell(pMedivh, SPELL_CLEAR_BOARD, TRIGGERED_OLD_TRIGGERED);
                }

                // remove silence debuff
                Map::PlayerList const& players = instance->GetPlayers();
                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                {
                    if (Player* pPlayer = itr->getSource())
                        pPlayer->RemoveAurasDueToSpell(SPELL_GAME_IN_SESSION);
                }

                m_uiChessResetTimer = 35000;
            }
            else if (uiData == IN_PROGRESS || uiData == SPECIAL)
                DoPrepareChessEvent();
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MALCHEZZAR:
            DoUseDoorOrButton(GO_NETHERSPACE_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_NIGHTBANE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MASTERS_TERRACE_DOOR_1);
            DoUseDoorOrButton(GO_MASTERS_TERRACE_DOOR_2);

            // reset event on timer
            if (uiData == FAIL)
                m_uiNightbaneResetTimer = 30000;
            break;
        // Store the event type for the Opera
        case TYPE_OPERA_PERFORMANCE:
            m_uiOperaEvent = uiData;
            break;
    }

    // Also save the opera performance, once it's set
    if (uiData == DONE || uiType == TYPE_OPERA_PERFORMANCE)
    {
        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_uiOperaEvent;

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 15
0
void instance_ahnkahet::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: Instance Ahn'Kahet: SetData received for type %u with data %u", uiType, uiData);

    switch (uiType)
    {
        case TYPE_NADOX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_bRespectElders = true;
            else if (uiData == SPECIAL)
                m_bRespectElders = false;
            else if (uiData == DONE)
            {
                DoToggleGameObjectFlags(GO_ANCIENT_DEVICE_L, GO_FLAG_NO_INTERACT, false);
                DoToggleGameObjectFlags(GO_ANCIENT_DEVICE_R, GO_FLAG_NO_INTERACT, false);
            }
            break;
        case TYPE_TALDARAM:
            if (uiData == SPECIAL)
            {
                ++m_uiDevicesActivated;

                if (m_uiDevicesActivated == 2)
                {
                    m_auiEncounter[uiType] = uiData;
                    DoUseDoorOrButton(GO_VORTEX);

                    // Lower Taldaram
                    if (Creature* pTaldaram = GetSingleCreatureFromStorage(NPC_TALDARAM))
                        pTaldaram->GetMotionMaster()->MovePoint(1, aTaldaramLandingLoc[0], aTaldaramLandingLoc[1], aTaldaramLandingLoc[2]);

                    // Interrupt the channeling
                    for (GuidList::const_iterator itr = m_lJedogaControllersGuidList.begin(); itr != m_lJedogaControllersGuidList.end(); ++itr)
                    {
                        if (Creature* pTemp = instance->GetCreature(*itr))
                            pTemp->InterruptNonMeleeSpells(false);
                    }
                }
            }
            else if (uiData == DONE)
            {
                m_auiEncounter[uiType] = uiData;
                DoUseDoorOrButton(GO_DOOR_TALDARAM);
            }
            break;
        case TYPE_JEDOGA:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_bVolunteerWork = true;
            else if (uiData == SPECIAL)
                m_bVolunteerWork = false;
            else if (uiData == FAIL)
                m_uiInitiatesKilled = 0;
            break;
        case TYPE_AMANITAR:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_VOLAZJ:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                m_uiTwistedVisageCount = 0;
                m_lInsanityPlayersGuidList.clear();
            }
            break;

        default:
            script_error_log("Instance Ahn'Kahet: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            break;
    }

    // For some encounters Special data needs to be saved
    if (uiData == DONE || (uiData == SPECIAL && uiType == TYPE_TALDARAM))
    {
        OUT_SAVE_INST_DATA;

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

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_magisters_terrace::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_SELIN:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_SELIN_DOOR);
            if (uiData == FAIL)
            {
                // Reset crystals - respawn and kill is handled by creature linking
                for (GuidList::const_iterator itr = m_lFelCrystalGuid.begin(); itr != m_lFelCrystalGuid.end(); ++itr)
                {
                    if (Creature* pTemp = instance->GetCreature(*itr))
                    {
                        if (!pTemp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
                            pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

                        if (pTemp->isAlive())
                            pTemp->AI()->EnterEvadeMode();
                    }
                }
            }
            if (uiData == IN_PROGRESS)
            {
                // Stop channeling when the fight starts
                for (GuidList::const_iterator itr = m_lFelCrystalGuid.begin(); itr != m_lFelCrystalGuid.end(); ++itr)
                {
                    if (Creature* pTemp = instance->GetCreature(*itr))
                        pTemp->InterruptNonMeleeSpells(false);
                }
            }
            DoUseDoorOrButton(GO_SELIN_ENCOUNTER_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_VEXALLUS:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_VEXALLUS_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_DELRISSA:
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DELRISSA_DOOR);
            if (uiData == IN_PROGRESS)
                m_uiDelrissaDeathCount = 0;
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_KAELTHAS:
            DoUseDoorOrButton(GO_KAEL_DOOR);
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_ESCAPE_QUEL_DANAS, GO_FLAG_NO_INTERACT, false);
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 17
0
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_blackwing_lair::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_RAZORGORE:
            m_auiEncounter[uiType] = uiData;
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_DOOR_RAZORGORE_ENTER);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_RAZORGORE_EXIT);
            else if (uiData == FAIL)
            {
                m_uiResetTimer = 30000;

                // Reset the Orb of Domination and the eggs
                DoToggleGameObjectFlags(GO_ORB_OF_DOMINATION, GO_FLAG_NO_INTERACT, true);
                if (Creature* pOrb = GetSingleCreatureFromStorage(NPC_BLACKWING_ORB_TRIGGER))
                {
                    if (pOrb->isAlive())
                        pOrb->AI()->EnterEvadeMode();
                }

                // Reset defenders
                for (GuidList::const_iterator itr = m_lDefendersGuids.begin(); itr != m_lDefendersGuids.end(); ++itr)
                {
                    if (Creature* pDefender = instance->GetCreature(*itr))
                        pDefender->ForcedDespawn();
                }

                m_lUsedEggsGuids.clear();
                m_lDefendersGuids.clear();
                m_uiBlackwingDefCount = 0;
                m_uiDragonspawnCount = 0;
            }
            break;
        case TYPE_VAELASTRASZ:
            m_auiEncounter[uiType] = uiData;
            // Prevent the players from running back to the first room; use if the encounter is not special
            if (uiData != SPECIAL)
                DoUseDoorOrButton(GO_DOOR_RAZORGORE_EXIT);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_VAELASTRASZ);
            break;
        case TYPE_LASHLAYER:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_LASHLAYER);
            break;
        case TYPE_FIREMAW:
        case TYPE_EBONROC:
        case TYPE_FLAMEGOR:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_CHROMAGGUS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_CHROMAGGUS_EXIT);
            break;
        case TYPE_NEFARIAN:
            // If epic quest for Scepter of the Shifting Sands is in progress when Nefarian is defeated mark it as complete
            if (uiData == DONE && GetData(TYPE_QUEST_SCEPTER) == IN_PROGRESS)
                SetData(TYPE_QUEST_SCEPTER, DONE);

            // Don't store the same thing twice
            if (m_auiEncounter[uiType] == uiData)
                break;

            if (uiData == SPECIAL)
            {
                // handle missing spell 23362
                Creature* pNefarius = GetSingleCreatureFromStorage(NPC_LORD_VICTOR_NEFARIUS);
                if (!pNefarius)
                    break;

                for (GuidList::const_iterator itr = m_lDrakonidBonesGuids.begin(); itr != m_lDrakonidBonesGuids.end(); ++itr)
                {
                    // The Go script will handle the missing spell 23361
                    if (GameObject* pGo = instance->GetGameObject(*itr))
                        pGo->Use(pNefarius);
                }
                // Don't store special data
                break;
            }
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_DOOR_NEFARIAN);
            // Cleanup the drakonid bones
            if (uiData == FAIL)
            {
                for (GuidList::const_iterator itr = m_lDrakonidBonesGuids.begin(); itr != m_lDrakonidBonesGuids.end(); ++itr)
                {
                    if (GameObject* pGo = instance->GetGameObject(*itr))
                        pGo->SetLootState(GO_JUST_DEACTIVATED);
                }

                m_lDrakonidBonesGuids.clear();
            }
            break;
        case TYPE_QUEST_SCEPTER:
            m_auiEncounter[uiType] = uiData;
            // Start 5 hours timer (various steps are handled in Update()
            if (uiData == IN_PROGRESS)
            {
                m_uiScepterEpicTimer = 2000;
                m_uiScepterQuestStep = 0;
            }
            // Stop timer
            if (uiData == DONE)
                m_uiScepterEpicTimer = 0;
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 19
0
void instance_sunwell_plateau::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_KALECGOS:
            m_auiEncounter[uiType] = uiData;
            // combat doors
            DoUseDoorOrButton(GO_FORCEFIELD);
            DoUseDoorOrButton(GO_BOSS_COLLISION_1);
            DoUseDoorOrButton(GO_BOSS_COLLISION_2);
            if (uiData == FAIL)
            {
                m_uiKalecRespawnTimer = 20000;

                if (Creature* pKalecDragon = GetSingleCreatureFromStorage(NPC_KALECGOS_DRAGON))
                    pKalecDragon->ForcedDespawn();
                if (Creature* pKalecHuman = GetSingleCreatureFromStorage(NPC_KALECGOS_HUMAN))
                    pKalecHuman->ForcedDespawn();
                if (Creature* pSathrovarr = GetSingleCreatureFromStorage(NPC_SATHROVARR))
                    pSathrovarr->AI()->EnterEvadeMode();
            }
            break;
        case TYPE_BRUTALLUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FELMYST:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                StartNextDialogueText(NPC_KALECGOS_MADRIGOSA);
            else if (uiData == IN_PROGRESS)
                DoSortFlightTriggers();
            break;
        case TYPE_EREDAR_TWINS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                if (Player* pPlayer = GetPlayerInMap())
                    pPlayer->SummonCreature(NPC_MURU, afMuruSpawnLoc[0], afMuruSpawnLoc[1], afMuruSpawnLoc[2], afMuruSpawnLoc[3], TEMPSUMMON_DEAD_DESPAWN, 0, true);
            }
            break;
        case TYPE_MURU:
            m_auiEncounter[uiType] = uiData;
            // combat door
            DoUseDoorOrButton(GO_MURU_ENTER_GATE);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_MURU_EXIT_GATE);
            else if (uiData == IN_PROGRESS)
                m_uiMuruBerserkTimer = 10 * MINUTE * IN_MILLISECONDS;
            if (uiData == FAIL || uiData == DONE)
            {
                // clear all the trash mobs
                for (GuidList::const_iterator itr = m_lMuruTrashGuidList.begin(); itr != m_lMuruTrashGuidList.end(); ++itr)
                {
                    if (Creature* pTrash = instance->GetCreature(*itr))
                        pTrash->ForcedDespawn();
                }

                m_lMuruTrashGuidList.clear();
            }
            break;
        case TYPE_KILJAEDEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                m_uiDeceiversKilled = 0;

                // Reset Orbs
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_1, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_2, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_3, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_4, GO_FLAG_NO_INTERACT, true);

                // Respawn deceivers
                for (GuidList::const_iterator itr = m_lDeceiversGuidList.begin(); itr != m_lDeceiversGuidList.end(); ++itr)
                {
                    if (Creature* pDeceiver = instance->GetCreature(*itr))
                    {
                        if (!pDeceiver->isAlive())
                            pDeceiver->Respawn();
                    }
                }
            }
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_sunwell_plateau::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_KALECGOS:
            m_auiEncounter[uiType] = uiData;
            // combat doors
            DoUseDoorOrButton(GO_FORCEFIELD);
            DoUseDoorOrButton(GO_BOSS_COLLISION_1);
            DoUseDoorOrButton(GO_BOSS_COLLISION_2);
            if (uiData == FAIL)
            {
                m_uiKalecRespawnTimer = 20000;

                if (Creature* pKalecDragon = GetSingleCreatureFromStorage(NPC_KALECGOS_DRAGON))
                    pKalecDragon->ForcedDespawn();
                if (Creature* pKalecHuman = GetSingleCreatureFromStorage(NPC_KALECGOS_HUMAN))
                    pKalecHuman->ForcedDespawn();
                if (Creature* pSathrovarr = GetSingleCreatureFromStorage(NPC_SATHROVARR))
                    pSathrovarr->AI()->EnterEvadeMode();
            }
            break;
        case TYPE_BRUTALLUS:
            m_auiEncounter[uiType] = uiData;
            // Temporary - until spells 46609 and 46637 are properly fixed
            if (uiData == SPECIAL)
                DoUseDoorOrButton(GO_ICE_BARRIER, MINUTE);
            break;
        case TYPE_FELMYST:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                StartNextDialogueText(NPC_KALECGOS);
                // Temporary - until spell 46650 is properly fixed
                DoUseDoorOrButton(GO_FIRE_BARRIER);
            }
            break;
        case TYPE_EREDAR_TWINS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_SECOND_GATE);
                DoUseDoorOrButton(GO_MURU_ENTER_GATE);
            }
            break;
        case TYPE_MURU:
            m_auiEncounter[uiType] = uiData;
            // combat door
            DoUseDoorOrButton(GO_MURU_ENTER_GATE);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_MURU_EXIT_GATE);
                DoUseDoorOrButton(GO_THIRD_GATE);
            }
            else if (uiData == IN_PROGRESS)
                m_uiMuruBerserkTimer = 10 * MINUTE * IN_MILLISECONDS;
            break;
        case TYPE_KILJAEDEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                m_uiDeceiversKilled = 0;

                // Reset Orbs
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_1, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_2, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_3, GO_FLAG_NO_INTERACT, true);
                DoToggleGameObjectFlags(GO_ORB_BLUE_FLIGHT_4, GO_FLAG_NO_INTERACT, true);

                // Respawn deceivers
                for (GuidList::const_iterator itr = m_lDeceiversGuidList.begin(); itr != m_lDeceiversGuidList.end(); ++itr)
                {
                    if (Creature* pDeceiver = instance->GetCreature(*itr))
                    {
                        if (!pDeceiver->isAlive())
                            pDeceiver->Respawn();
                    }
                }
            }
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_blackrock_depths::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_RING_OF_LAW:
            // If finished the arena event after theldren fight
            if (uiData == DONE && m_auiEncounter[0] == SPECIAL)
                DoRespawnGameObject(GO_ARENA_SPOILS, HOUR);
            else if (uiData == DONE)
            {
                for (GuidSet::const_iterator itr = m_sArenaCrowdNpcGuids.begin(); itr != m_sArenaCrowdNpcGuids.end(); ++itr)
                {
                    if (Creature* pSpectator = instance->GetCreature(*itr))
                        pSpectator->SetFactionTemporary(FACTION_ARENA_NEUTRAL, TEMPFACTION_RESTORE_RESPAWN);
                }
            }
            m_auiEncounter[0] = uiData;
            break;
        case TYPE_VAULT:
            if (uiData == SPECIAL)
            {
                ++m_uiCofferDoorsOpened;

                if (m_uiCofferDoorsOpened == MAX_RELIC_DOORS)
                {
                    SetData(TYPE_VAULT, IN_PROGRESS);

                    Creature* pConstruct = NULL;

                    // Activate vault constructs
                    for (GuidSet::const_iterator itr = m_sVaultNpcGuids.begin(); itr != m_sVaultNpcGuids.end(); ++itr)
                    {
                        pConstruct = instance->GetCreature(*itr);
                        if (pConstruct)
                            pConstruct->RemoveAurasDueToSpell(SPELL_STONED);
                    }

                    if (!pConstruct)
                        return;

                    // Summon doomgrip
                    pConstruct->SummonCreature(NPC_WATCHER_DOOMGRIP, aVaultPositions[0], aVaultPositions[1], aVaultPositions[2], aVaultPositions[3], TEMPSPAWN_DEAD_DESPAWN, 0);
                }
                // No need to store in this case
                return;
            }
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_SECRET_DOOR);
                DoToggleGameObjectFlags(GO_SECRET_SAFE, GO_FLAG_NO_INTERACT, false);
            }
            m_auiEncounter[1] = uiData;
            break;
        case TYPE_ROCKNOT:
            if (uiData == SPECIAL)
                ++m_uiBarAleCount;
            else
            {
                if (uiData == DONE)
                {
                    HandleBarPatrons(PATRON_PISSED);
                    SetBarDoorIsOpen();
                }
                m_auiEncounter[2] = uiData;
            }
            break;
        case TYPE_TOMB_OF_SEVEN:
            // Don't set the same data twice
            if (uiData == m_auiEncounter[3])
                break;
            // Combat door
            DoUseDoorOrButton(GO_TOMB_ENTER);
            // Start the event
            if (uiData == IN_PROGRESS)
                DoCallNextDwarf();
            if (uiData == FAIL)
            {
                // Reset dwarfes
                for (uint8 i = 0; i < MAX_DWARFS; ++i)
                {
                    if (Creature* pDwarf = GetSingleCreatureFromStorage(aTombDwarfes[i]))
                    {
                        if (!pDwarf->isAlive())
                            pDwarf->Respawn();
                    }
                }

                m_uiDwarfRound = 0;
                m_uiDwarfFightTimer = 0;
            }
            if (uiData == DONE)
            {
                DoRespawnGameObject(GO_CHEST_SEVEN, HOUR);
                DoUseDoorOrButton(GO_TOMB_EXIT);
            }
            m_auiEncounter[3] = uiData;
            break;
        case TYPE_LYCEUM:
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_GOLEM_ROOM_N);
                DoUseDoorOrButton(GO_GOLEM_ROOM_S);
            }
            m_auiEncounter[4] = uiData;
            break;
        case TYPE_IRON_HALL:
            switch (uiData)
            {
                case IN_PROGRESS:
                    DoUseDoorOrButton(GO_GOLEM_ROOM_N);
                    DoUseDoorOrButton(GO_GOLEM_ROOM_S);
                    break;
                case FAIL:
                    DoUseDoorOrButton(GO_GOLEM_ROOM_N);
                    DoUseDoorOrButton(GO_GOLEM_ROOM_S);
                    break;
                case DONE:
                    DoUseDoorOrButton(GO_GOLEM_ROOM_N);
                    DoUseDoorOrButton(GO_GOLEM_ROOM_S);
                    DoUseDoorOrButton(GO_THRONE_ROOM);
                    break;
            }
            m_auiEncounter[5] = uiData;
            break;
        case TYPE_QUEST_JAIL_BREAK:
            m_auiEncounter[6] = uiData;
            return;
        case TYPE_FLAMELASH:
            for (int i = 0; i < MAX_DWARF_RUNES; ++i)
                DoUseDoorOrButton(GO_DWARFRUNE_A01 + i);
            return;
        case TYPE_HURLEY:
            if (uiData == SPECIAL)
            {
                ++m_uiBrokenKegs;

                if (m_uiBrokenKegs == 3)
                {
                    if (Creature* pPlugger = GetSingleCreatureFromStorage(NPC_PLUGGER_SPAZZRING))
                    {
                        // Summon Hurley Blackbreath
                        Creature* pHurley = pPlugger->SummonCreature(NPC_HURLEY_BLACKBREATH, aHurleyPositions[0], aHurleyPositions[1], aHurleyPositions[2], aHurleyPositions[3], TEMPSPAWN_DEAD_DESPAWN, 0);

                        if (!pHurley)
                            return;

                        // Summon cronies around Hurley
                        for (uint8 i = 0; i < MAX_CRONIES; ++i)
                        {
                            float fX, fY, fZ;
                            pPlugger->GetRandomPoint(aHurleyPositions[0], aHurleyPositions[1], aHurleyPositions[2], 2.0f, fX, fY, fZ);
                            if (Creature* pSummoned = pPlugger->SummonCreature(NPC_BLACKBREATH_CRONY, fX, fY, fZ, aHurleyPositions[3], TEMPSPAWN_DEAD_DESPAWN, 0))
                            {
                                pSummoned->SetWalk(false);
                                // The cronies should not engage anyone until their boss does so
                                // the linking is done by DB
                                pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
                                // The movement toward the kegs is handled by Hurley EscortAI
                                // and we want the cronies to follow him there
                                pSummoned->GetMotionMaster()->MoveFollow(pHurley, 1.0f, 0);
                            }
                        }
                        SetData(TYPE_HURLEY, IN_PROGRESS);
                    }
                }
            }
            else
                m_auiEncounter[8] = uiData;
            break;
        case TYPE_BRIDGE:
            m_auiEncounter[9] = uiData;
            return;
        case TYPE_BAR:
            if (uiData == IN_PROGRESS)
                HandleBarPatrol(0);
            m_auiEncounter[10] = uiData;
            break;
        case TYPE_PLUGGER:
            if (uiData == SPECIAL)
            {
                if (Creature* pPlugger = GetSingleCreatureFromStorage(NPC_PLUGGER_SPAZZRING))
                {
                    ++m_uiStolenAles;
                    if (m_uiStolenAles == 3)
                        uiData = IN_PROGRESS;
                }
            }
            m_auiEncounter[11] = uiData;
            break;
        case TYPE_NAGMARA:
            m_auiEncounter[12] = 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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 22
0
void instance_karazhan::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_ATTUMEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                // Respawn Midnight on Fail
                if (Creature* pMidnight = GetSingleCreatureFromStorage(NPC_MIDNIGHT))
                {
                    if (!pMidnight->isAlive())
                    {
                        pMidnight->Respawn();
                        pMidnight->GetMotionMaster()->MoveTargetedHome();
                    }
                }
            }
            break;
        case TYPE_MOROES:
        case TYPE_MAIDEN:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_OPERA:
            // Don't store the same data twice
            if (uiData == m_auiEncounter[uiType])
                break;
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_uiOzDeathCount = 0;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_STAGE_DOOR_LEFT);
                DoUseDoorOrButton(GO_STAGE_DOOR_RIGHT);
                DoToggleGameObjectFlags(GO_SIDE_ENTRANCE_DOOR, GO_FLAG_LOCKED, false);
            }
            // use curtain only for event start or fail
            else
                DoUseDoorOrButton(GO_STAGE_CURTAIN);
            break;
        case TYPE_CURATOR:
        case TYPE_TERESTIAN:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_ARAN:
            if (uiData == FAIL || uiData == DONE)
                DoToggleGameObjectFlags(GO_PRIVATE_LIBRARY_DOOR, GO_FLAG_LOCKED, false);
            if (uiData == IN_PROGRESS)
                DoToggleGameObjectFlags(GO_PRIVATE_LIBRARY_DOOR, GO_FLAG_LOCKED, true);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_NETHERSPITE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MASSIVE_DOOR);
            break;
        case TYPE_CHESS:
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_GAMESMANS_HALL_EXIT_DOOR);
                DoRespawnGameObject(GO_DUST_COVERED_CHEST, DAY);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MALCHEZZAR:
            DoUseDoorOrButton(GO_NETHERSPACE_DOOR);
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_NIGHTBANE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MASTERS_TERRACE_DOOR_1);
            DoUseDoorOrButton(GO_MASTERS_TERRACE_DOOR_2);
            break;
        // Store the event type for the Opera
        case TYPE_OPERA_PERFORMANCE:
            m_uiOperaEvent = uiData;
            break;
    }

    // Also save the opera performance, once it's set
    if (uiData == DONE || uiType == TYPE_OPERA_PERFORMANCE)
    {
        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_uiOperaEvent;

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 23
0
void instance_halls_of_stone::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_TRIBUNAL:
            m_auiEncounter[uiType] = uiData;
            switch (uiData)
            {
                case IN_PROGRESS:
                    SortFaces();
                    break;
                case DONE:
                    // Cast achiev check spell - Note: it's not clear who casts this spell, but for the moment we'll use Abedneum
                    if (Creature* pEye = instance->GetCreature(m_aFaces[1].m_leftEyeGuid))
                        pEye->CastSpell(pEye, SPELL_ACHIEVEMENT_CHECK, true);
                    // Spawn the loot
                    DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_TRIBUNAL_CHEST : GO_TRIBUNAL_CHEST_H, 30 * MINUTE);
                    DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_TRIBUNAL_CHEST : GO_TRIBUNAL_CHEST_H, GO_FLAG_NO_INTERACT, false);
                    // Door workaround because of the missing Bran event
                    DoUseDoorOrButton(GO_DOOR_SJONNIR);
                    break;
                case FAIL:
                    for (uint8 i = 0; i < MAX_FACES; ++i)
                    {
                        // Shut down the faces
                        if (m_aFaces[i].m_bIsActive)
                            DoUseDoorOrButton(m_aFaces[i].m_goFaceGuid);
                        m_aFaces[i].m_bIsActive = false;
                        m_aFaces[i].m_uiTimer = 1000;
                    }
                    break;
                case SPECIAL:
                    for (uint8 i = 0; i < MAX_FACES; ++i)
                    {
                        m_aFaces[i].m_bIsActive = false;
                        m_aFaces[i].m_uiTimer = 1000;
                        // TODO - Check which stay red and how long (also find out how they get red..)

                        // Cleanup when finished
                        if (Creature* pEye = instance->GetCreature(m_aFaces[i].m_leftEyeGuid))
                            pEye->CastSpell(pEye, SPELL_KILL_TRIBUNAL_ADD, true);
                        if (Creature* pEye = instance->GetCreature(m_aFaces[i].m_rightEyeGuid))
                            pEye->CastSpell(pEye, SPELL_KILL_TRIBUNAL_ADD, true);
                    }
                    break;
            }
            break;
        case TYPE_MAIDEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_MAIDEN_ID);
            break;
        case TYPE_KRYSTALLUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_SJONNIR:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_DOOR_SJONNIR);
            if (uiData == IN_PROGRESS)
                m_uiIronSludgeKilled = 0;
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Exemplo n.º 24
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)
                DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_TELESTRA, GO_FLAG_NO_INTERACT, false);
            break;
        case TYPE_ANOMALUS:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                SetSpecialAchievementCriteria(TYPE_ACHIEV_CHAOS_THEORY, true);
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_ANOMALUS, GO_FLAG_NO_INTERACT, false);
            break;
        case TYPE_ORMOROK:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_CONTAINMENT_SPHERE_ORMOROK, GO_FLAG_NO_INTERACT, false);
            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:
            script_error_log("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);
            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;
    }
}
Exemplo n.º 25
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);
                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);
                DoUseDoorOrButton(GO_ARAC_EYE_BOSS);
                DoRespawnGameObject(GO_ARAC_PORTAL, 30*MINUTE);
                DoToggleGameObjectFlags(GO_ARAC_PORTAL, GO_FLAG_NO_INTERACT, false);
                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);
                DoUseDoorOrButton(GO_PLAG_EYE_BOSS);
                DoRespawnGameObject(GO_PLAG_PORTAL, 30*MINUTE);
                DoToggleGameObjectFlags(GO_PLAG_PORTAL, GO_FLAG_NO_INTERACT, false);
                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);

                    m_dialogueHelper.StartNextDialogueText(NPC_THANE);
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            // Skip if already set
            if (m_auiEncounter[uiType] == uiData)
                return;
            if (uiData == SPECIAL)
            {
                ++m_uiHorseMenKilled;

                if (m_uiHorseMenKilled == 4)
                    SetData(TYPE_FOUR_HORSEMEN, DONE);

                // Don't store special data
                break;
            }
            if (uiData == FAIL)
                m_uiHorseMenKilled = 0;
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_MILI_EYE_RAMP);
                DoUseDoorOrButton(GO_MILI_EYE_BOSS);
                DoRespawnGameObject(GO_MILI_PORTAL, 30*MINUTE);
                DoToggleGameObjectFlags(GO_MILI_PORTAL, GO_FLAG_NO_INTERACT, false);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_CHEST_HORSEMEN_NORM : GO_CHEST_HORSEMEN_HERO, 30*MINUTE);
                m_uiTauntTimer = 5000;
                // Set achiev credit
                DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEV_SPELL_FOUR_HORSEMEN);
            }
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            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);
                DoUseDoorOrButton(GO_CONS_EYE_BOSS);
                DoRespawnGameObject(GO_CONS_PORTAL, 30*MINUTE);
                DoToggleGameObjectFlags(GO_CONS_PORTAL, GO_FLAG_NO_INTERACT, false);
                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(NPC_KELTHUZAD);
            }
            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;
    }
}
Exemplo n.º 26
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 == 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);
                DoUseDoorOrButton(GO_ARAC_EYE_BOSS);
                DoRespawnGameObject(GO_ARAC_PORTAL, 30 * MINUTE);
                DoToggleGameObjectFlags(GO_ARAC_PORTAL, GO_FLAG_NO_INTERACT, false);
                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 == DONE)
                DoUseDoorOrButton(GO_PLAG_HEIG_EXIT_HALLWAY);
            break;
        case TYPE_LOATHEB:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_PLAG_LOAT_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_PLAG_EYE_RAMP);
                DoUseDoorOrButton(GO_PLAG_EYE_BOSS);
                DoRespawnGameObject(GO_PLAG_PORTAL, 30 * MINUTE);
                DoToggleGameObjectFlags(GO_PLAG_PORTAL, GO_FLAG_NO_INTERACT, false);
                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);

                    m_dialogueHelper.StartNextDialogueText(NPC_THANE);
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FOUR_HORSEMEN:
            // Skip if already set
            if (m_auiEncounter[uiType] == uiData)
                return;
            if (uiData == SPECIAL)
            {
                ++m_uiHorseMenKilled;

                if (m_uiHorseMenKilled == 4)
                    SetData(TYPE_FOUR_HORSEMEN, DONE);

                // Don't store special data
                break;
            }
            if (uiData == FAIL)
                m_uiHorseMenKilled = 0;
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MILI_HORSEMEN_DOOR);
            if (uiData == DONE)
            {
                // Despawn spirits
                if (Creature* pSpirit = GetSingleCreatureFromStorage(NPC_SPIRIT_OF_BLAUMEUX))
                    pSpirit->ForcedDespawn();
                if (Creature* pSpirit = GetSingleCreatureFromStorage(NPC_SPIRIT_OF_MOGRAINE))
                    pSpirit->ForcedDespawn();
                if (Creature* pSpirit = GetSingleCreatureFromStorage(NPC_SPIRIT_OF_KORTHAZZ))
                    pSpirit->ForcedDespawn();
                if (Creature* pSpirit = GetSingleCreatureFromStorage(NPC_SPIRIT_OF_ZELIREK))
                    pSpirit->ForcedDespawn();

                DoUseDoorOrButton(GO_MILI_EYE_RAMP);
                DoUseDoorOrButton(GO_MILI_EYE_BOSS);
                DoRespawnGameObject(GO_MILI_PORTAL, 30 * MINUTE);
                DoToggleGameObjectFlags(GO_MILI_PORTAL, GO_FLAG_NO_INTERACT, false);
                DoRespawnGameObject(GO_CHEST_HORSEMEN_NORM, 30 * MINUTE);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_PATCHWERK:
            m_auiEncounter[uiType] = uiData;
            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);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CONS_EYE_RAMP);
                DoUseDoorOrButton(GO_CONS_EYE_BOSS);
                DoRespawnGameObject(GO_CONS_PORTAL, 30 * MINUTE);
                DoToggleGameObjectFlags(GO_CONS_PORTAL, GO_FLAG_NO_INTERACT, false);
                m_uiTauntTimer = 5000;
            }
            break;
        case TYPE_SAPPHIRON:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_KELTHUZAD_WATERFALL_DOOR);
                m_dialogueHelper.StartNextDialogueText(NPC_KELTHUZAD);
            }
            // Start Sapph summoning process
            if (uiData == SPECIAL)
                m_uiSapphSpawnTimer = 22000;
            break;
        case TYPE_KELTHUZAD:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_KELTHUZAD_EXIT_DOOR);
            if (uiData == NOT_STARTED)
            {
                if (GameObject* pWindow = GetSingleGameObjectFromStorage(GO_KELTHUZAD_WINDOW_1))
                    pWindow->ResetDoorOrButton();
                if (GameObject* pWindow = GetSingleGameObjectFromStorage(GO_KELTHUZAD_WINDOW_2))
                    pWindow->ResetDoorOrButton();
                if (GameObject* pWindow = GetSingleGameObjectFromStorage(GO_KELTHUZAD_WINDOW_3))
                    pWindow->ResetDoorOrButton();
                if (GameObject* pWindow = GetSingleGameObjectFromStorage(GO_KELTHUZAD_WINDOW_4))
                    pWindow->ResetDoorOrButton();
            }
            break;
    }

    if (uiData == DONE || (uiData == SPECIAL && uiType == TYPE_SAPPHIRON))
    {
        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;
    }
}
Exemplo n.º 27
0
void instance_icecrown_citadel::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_MARROWGAR:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_MARROWGAR_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_ICEWALL_1);
                DoUseDoorOrButton(GO_ICEWALL_2);

                // Note: this door use may not be correct. In theory the door should be already opened
                DoUseDoorOrButton(GO_ORATORY_DOOR);
            }
            break;
         case TYPE_LADY_DEATHWHISPER:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ORATORY_DOOR);
            // ToDo: set the elevateor in motion when TYPE_LADY_DEATHWHISPER == DONE
            break;
         case TYPE_GUNSHIP_BATTLE:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                DoRespawnGameObject(m_uiTeam == ALLIANCE ? GO_GUNSHIP_ARMORY_A : GO_GUNSHIP_ARMORY_H, 60*MINUTE);
            break;
         case TYPE_DEATHBRINGER_SAURFANG:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_SAURFANG_DOOR);
                DoRespawnGameObject(GO_SAURFANG_CACHE, 60*MINUTE);

                // Note: these doors may not be correct. In theory the doors should be already opened
                DoUseDoorOrButton(GO_SCIENTIST_DOOR);
                DoUseDoorOrButton(GO_CRIMSON_HALL_DOOR);
                DoUseDoorOrButton(GO_GREEN_DRAGON_ENTRANCE);
            }
            break;
         case TYPE_FESTERGUT:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_ORANGE_PLAGUE);
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_ORANGE_VALVE, GO_FLAG_NO_INTERACT, false);
            break;
         case TYPE_ROTFACE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_GREEN_PLAGUE);
            if (uiData == DONE)
                DoToggleGameObjectFlags(GO_GREEN_VALVE, GO_FLAG_NO_INTERACT, false);
            break;
         case TYPE_PROFESSOR_PUTRICIDE:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_SCIENTIST_DOOR);
            break;
         case TYPE_BLOOD_PRINCE_COUNCIL:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_CRIMSON_HALL_DOOR);
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_COUNCIL_DOOR_1);
                DoUseDoorOrButton(GO_COUNCIL_DOOR_2);
            }
            break;
         case TYPE_QUEEN_LANATHEL:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_BLOODPRINCE_DOOR);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_ICECROWN_GRATE);
            break;
         case TYPE_VALITHRIA:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_GREEN_DRAGON_ENTRANCE);
            // Side doors
            DoUseDoorOrButton(GO_VALITHRIA_DOOR_1);
            DoUseDoorOrButton(GO_VALITHRIA_DOOR_2);
            // Some doors are used only in 25 man mode
            if (instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL || instance->GetDifficulty() == RAID_DIFFICULTY_25MAN_HEROIC)
            {
                DoUseDoorOrButton(GO_VALITHRIA_DOOR_3);
                DoUseDoorOrButton(GO_VALITHRIA_DOOR_4);
            }
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_GREEN_DRAGON_EXIT);
                DoUseDoorOrButton(GO_SINDRAGOSA_ENTRANCE);
                DoRespawnGameObject(GO_DREAMWALKER_CACHE, 60*MINUTE);
            }
            break;
         case TYPE_SINDRAGOSA:
            m_auiEncounter[uiType] = uiData;
            DoUseDoorOrButton(GO_SINDRAGOSA_ENTRANCE);
            break;
         case TYPE_LICH_KING:
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            error_log("SD2: Instance Icecrown Citadel: ERROR SetData = %u for type %u does not exist/not implemented.", uiType, uiData);
            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_auiEncounter[4] << " " << m_auiEncounter[5] << " "
            << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8] << " "
            << m_auiEncounter[9] << " " << m_auiEncounter[10] << " " << m_auiEncounter[11];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_halls_of_stone::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_TRIBUNAL:
            m_auiEncounter[uiType] = uiData;
            switch (uiData)
            {
                case IN_PROGRESS:
                    SortFaces();
                    break;
                case DONE:
                    DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_TRIBUNAL_CHEST : GO_TRIBUNAL_CHEST_H, GO_FLAG_NO_INTERACT, false);
                    // Door workaround because of the missing Bran event
                    DoUseDoorOrButton(GO_DOOR_SJONNIR);
                    break;
                case FAIL:
                    for (uint8 i = 0; i < MAX_FACES; ++i)
                    {
                        // Shut down the faces
                        if (m_aFaces[i].m_bIsActive)
                            DoUseDoorOrButton(m_aFaces[i].m_goFaceGuid);
                        m_aFaces[i].m_bIsActive = false;
                        m_aFaces[i].m_uiTimer = 1000;
                    }
                    break;
                case SPECIAL:
                    for (uint8 i = 0; i < MAX_FACES; ++i)
                    {
                        m_aFaces[i].m_bIsActive = false;
                        m_aFaces[i].m_uiTimer = 1000;
                        // TODO - Kill NPCs
                        // TODO - Check which stay red and how long (also find out how they get red..)
                    }
                    break;
            }
            break;
        case TYPE_MAIDEN:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                DoStartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEV_START_MAIDEN_ID);
            if (uiData == DONE)
                DoUseDoorOrButton(GO_DOOR_TRIBUNAL_2);
            break;
        case TYPE_KRYSTALLUS:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_SJONNIR:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
                m_uiOozesKilled = 0;
            DoUseDoorOrButton(GO_DOOR_SJONNIR);
            break;
        case TYPE_GOOD_GRIEF:
            m_bGoodGriefFailed = (uiData == FAIL);
        case TYPE_BRANN:
            m_bBrannFailed = (uiData == FAIL);
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_culling_of_stratholme::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_GRAIN_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == SPECIAL)
                DoUpdateWorldState(WORLD_STATE_CRATES, 1);
            else if (uiData == IN_PROGRESS)
            {
                // safety check
                if (m_uiGrainCrateCount >= MAX_GRAIN_CRATES)
                    return;

                ++m_uiGrainCrateCount;
                DoUpdateWorldState(WORLD_STATE_CRATES_COUNT, m_uiGrainCrateCount);

                if (m_uiGrainCrateCount == MAX_GRAIN_CRATES)
                {
                    m_uiRemoveCrateStateTimer = 20000;
                    SetData(TYPE_GRAIN_EVENT, DONE);
                }
            }
            break;
        case TYPE_ARTHAS_INTRO_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                m_uiScourgeWaveCount = 0;
                m_uiScourgeWaveTimer = 1000;
                DoUpdateZombieResidents();

                SetData(TYPE_MEATHOOK_EVENT, IN_PROGRESS);
            }
            break;
        case TYPE_MEATHOOK_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                m_uiScourgeWaveTimer = 20000;
                SetData(TYPE_SALRAMM_EVENT, IN_PROGRESS);
            }
            break;
        case TYPE_SALRAMM_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
                m_uiScourgeWaveTimer = 5000;
            break;
        case TYPE_ARTHAS_TOWNHALL_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                // despawn arthas and spawn him in the next point
                if (Creature* pArthas = GetSingleCreatureFromStorage(NPC_ARTHAS))
                    pArthas->ForcedDespawn();

                if (Player* pPlayer = GetPlayerInMap())
                    DoSpawnArthasIfNeeded(pPlayer);
            }
            break;
        case TYPE_EPOCH_EVENT:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_ARTHAS_ESCORT_EVENT:
            // use fail in order to respawn Arthas
            if (uiData == FAIL)
            {
                m_uiArthasRespawnTimer = 10000;

                // despawn the bosses if Arthas dies in order to avoid exploits
                if (Creature* pEpoch = GetSingleCreatureFromStorage(NPC_LORD_EPOCH, true))
                    pEpoch->ForcedDespawn();
                if (Creature* pMalganis = GetSingleCreatureFromStorage(NPC_MALGANIS, true))
                    pMalganis->ForcedDespawn();
            }
            else
                m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MALGANIS_EVENT:
            m_auiEncounter[uiType] = uiData;
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_CITY_ENTRANCE_GATE);
                DoToggleGameObjectFlags(instance->IsRegularDifficulty() ? GO_DARK_RUNED_CHEST : GO_DARK_RUNED_CHEST_H, GO_FLAG_NO_INTERACT, false);
                DoRespawnGameObject(instance->IsRegularDifficulty() ? GO_DARK_RUNED_CHEST : GO_DARK_RUNED_CHEST_H, 30 * MINUTE);

                if (Player* pPlayer = GetPlayerInMap())
                    DoSpawnChromieIfNeeded(pPlayer);
            }
            break;
        case TYPE_INFINITE_CORRUPTER_TIME:
            m_auiEncounter[uiType] = uiData;
            if (!uiData)
            {
                DoUpdateWorldState(WORLD_STATE_TIME, 0);    // Remove Timer
                DoUpdateWorldState(WORLD_STATE_TIME_COUNTER, 0);
            }
            else
                DoUpdateWorldState(WORLD_STATE_TIME_COUNTER, uiData / (MINUTE * IN_MILLISECONDS));
            break;
        case TYPE_INFINITE_CORRUPTER:
            m_auiEncounter[uiType] = uiData;
            switch (uiData)
            {
                case IN_PROGRESS:
                    if (!GetData(TYPE_INFINITE_CORRUPTER_TIME))
                    {
                        SetData(TYPE_INFINITE_CORRUPTER_TIME, MINUTE * 25 * IN_MILLISECONDS);
                        DoUpdateWorldState(WORLD_STATE_TIME, 1);
                        DoChromieWhisper(WHISPER_CHROMIE_GUARDIAN);

                        // spawn the corruptor for the first time
                        if (Creature* pArthas = GetSingleCreatureFromStorage(NPC_ARTHAS))
                            DoSpawnCorruptorIfNeeded(pArthas);
                    }
                    break;
                case DONE:
                    // event completed - epilog handled by dbscript
                    SetData(TYPE_INFINITE_CORRUPTER_TIME, 0);
                    break;
                case SPECIAL:
                    DoChromieWhisper(WHISPER_CHROMIE_HURRY);
                    break;
                case FAIL:
                    // event failed - despawn the corruptor
                    SetData(TYPE_INFINITE_CORRUPTER_TIME, 0);
                    if (Creature* pCorrupter = GetSingleCreatureFromStorage(NPC_INFINITE_CORRUPTER))
                    {
                        DoOrSimulateScriptTextForThisInstance(SAY_CORRUPTOR_DESPAWN, NPC_INFINITE_CORRUPTER);

                        if (pCorrupter->isAlive())
                            pCorrupter->ForcedDespawn();
                    }
                    break;
            }
            break;
    }

    if (uiData == DONE || uiType == TYPE_INFINITE_CORRUPTER_TIME)
    {
        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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_halls_of_reflection::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_FROSTMOURNE_INTRO:
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FALRIC:
            if (uiData == DONE)
                m_uiEventTimer = 60000;
            else if (uiData == FAIL)
                DoCleanupFrostmourneEvent();
            else if (uiData == SPECIAL)
            {
                DoUseDoorOrButton(GO_ICECROWN_DOOR_ENTRANCE);

                m_uiEventTimer = 40000;
                m_uiEventStage = 0;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_MARWYN:
            if (uiData == DONE)
            {
                DoUseDoorOrButton(GO_IMPENETRABLE_DOOR);
                DoUseDoorOrButton(GO_ICECROWN_DOOR_ENTRANCE);
                DoUpdateWorldState(WORLD_STATE_SPIRIT_WAVES, 0);

                // spawn next mini boss
                if (Player* pPlayer = GetPlayerInMap())
                    pPlayer->SummonCreature(NPC_FROSTSWORN_GENERAL, afGeneralSpawnLoc[0], afGeneralSpawnLoc[1], afGeneralSpawnLoc[2], afGeneralSpawnLoc[3], TEMPSUMMON_DEAD_DESPAWN, 0, true);
            }
            else if (uiData == FAIL)
                DoCleanupFrostmourneEvent();
            else if (uiData == SPECIAL)
            {
                DoUseDoorOrButton(GO_ICECROWN_DOOR_ENTRANCE);

                m_uiEventTimer = 60000;
                m_uiEventStage = 5;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_LICH_KING:
            if (uiData == DONE)
            {
                uint32 uiChestEntry = m_uiTeam == ALLIANCE ? (instance->IsRegularDifficulty() ? GO_CAPTAIN_CHEST_ALLIANCE : GO_CAPTAIN_CHEST_ALLIANCE_H) :
                        (instance->IsRegularDifficulty() ? GO_CAPTAIN_CHEST_HORDE : GO_CAPTAIN_CHEST_HORDE_H);
                DoToggleGameObjectFlags(uiChestEntry, GO_FLAG_NO_INTERACT, false);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_FROSTWORN_GENERAL:
            if (uiData == DONE)
            {
                // spawn creatures for last encounter
                if (Player* pPlayer = GetPlayerInMap())
                {
                    // Spawn npc for the last encounter
                    for (uint8 i = 0; i < countof(aEventKingLocations); ++i)
                    {
                        pPlayer->SummonCreature(m_uiTeam == HORDE ? aEventKingLocations[i].uiEntryHorde : aEventKingLocations[i].uiEntryAlliance,
                            aEventKingLocations[i].fX, aEventKingLocations[i].fY, aEventKingLocations[i].fZ, aEventKingLocations[i].fO, TEMPSUMMON_DEAD_DESPAWN, 0, true);
                    }
                }
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_QUEL_DELAR:
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            return;
    }

    if (uiData == DONE || uiData == FAIL)
    {
        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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}