Beispiel #1
0
 void OpenAllDoors()
 {
     if (m_auiEncounter[TYPE_RAGEFIRE] == DONE &&
         m_auiEncounter[TYPE_BALTHARUS] == DONE &&
         m_auiEncounter[TYPE_XERESTRASZA] == DONE)
         DoOpenDoor(GO_FLAME_WALLS);
     else
         DoCloseDoor(GO_FLAME_WALLS);
 }
Beispiel #2
0
void ScriptedInstance::DoOpenDoor(uint32 entry)
{
    EntryGuidMap::iterator find = m_mGoEntryGuidStore.find(entry);
    if (find != m_mGoEntryGuidStore.end())
    {
        ObjectGuid guid = find->second;
        DoOpenDoor(guid);
    }
    else
        debug_log("SD2: Script call DoOpenDoor (by Entry), but no gameobject of entry %u was created yet, or it was not stored by script for map %u.", entry, instance->GetId());
}
    void SetData(uint32 uiType, uint32 uiData)
    {
        switch(uiType)
        {
        case TYPE_STAGE:    m_auiEncounter[0] = uiData; break;
        case TYPE_BEASTS:   m_auiEncounter[1] = uiData; break;
        case TYPE_JARAXXUS: m_auiEncounter[2] = uiData; break;
        case TYPE_CRUSADERS:if (uiData == FAIL && (m_auiEncounter[3] == FAIL || m_auiEncounter[3] == NOT_STARTED))
                            m_auiEncounter[3] = NOT_STARTED;
                            else
                                m_auiEncounter[3] = uiData;
                            if (uiData == DONE) 
                            {
                               if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiCrusadersCache))
                                   if (pChest && !pChest->isSpawned())
                                         pChest->SetRespawnTime(7*DAY);
                            };
                            break;
        case TYPE_CRUSADERS_COUNT:  if (uiData == 0) --m_auiCrusadersCount;
                                         else m_auiCrusadersCount = uiData;
                                    break;
        case TYPE_VALKIRIES: if (m_auiEncounter[4] == SPECIAL && uiData == SPECIAL) uiData = DONE;
                             m_auiEncounter[4] = uiData; break;
        case TYPE_LICH_KING: m_auiEncounter[5] = uiData; break;
        case TYPE_ANUBARAK:  m_auiEncounter[6] = uiData; 
                            if (uiData == DONE) {
                            if (Difficulty == RAID_DIFFICULTY_10MAN_HEROIC)
                            {
                                if ( m_auiEncounter[7] >= 25) m_uiTributeChest1 = GO_TRIBUTE_CHEST_10H_25;
                                if ( m_auiEncounter[7] >= 45) m_uiTributeChest2 = GO_TRIBUTE_CHEST_10H_45;
                                if ( m_auiEncounter[7] >= 49) m_uiTributeChest3 = GO_TRIBUTE_CHEST_10H_50;
                                m_uiTributeChest4 = GO_TRIBUTE_CHEST_10H_99;
                            }
                            if (Difficulty == RAID_DIFFICULTY_25MAN_HEROIC){
                                if ( m_auiEncounter[7] >= 25) m_uiTributeChest1 = GO_TRIBUTE_CHEST_25H_25;
                                if ( m_auiEncounter[7] >= 45) m_uiTributeChest2 = GO_TRIBUTE_CHEST_25H_45;
                                if ( m_auiEncounter[7] >= 49) m_uiTributeChest3 = GO_TRIBUTE_CHEST_25H_50;
                                m_uiTributeChest4 = GO_TRIBUTE_CHEST_25H_99;
                            }
                            // Attention! It is (may be) not off-like, but  spawning all Tribute Chests is real
                            // reward for clearing TOC instance
                            if (m_uiTributeChest1)
                              if (GameObject* pChest1 = GetSingleGameObjectFromStorage(m_uiTributeChest1))
                                if (pChest1 && !pChest1->isSpawned()) pChest1->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest2)
                              if (GameObject* pChest2 = GetSingleGameObjectFromStorage(m_uiTributeChest2))
                                if (pChest2 && !pChest2->isSpawned()) pChest2->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest3)
                              if (GameObject* pChest3 = GetSingleGameObjectFromStorage(m_uiTributeChest3))
                                if (pChest3 && !pChest3->isSpawned()) pChest3->SetRespawnTime(7*DAY);
                            if (m_uiTributeChest4)
                              if (GameObject* pChest4 = GetSingleGameObjectFromStorage(m_uiTributeChest4))
                                if (pChest4 && !pChest4->isSpawned()) pChest4->SetRespawnTime(7*DAY);
                            };
        break;
        case TYPE_COUNTER:   m_auiEncounter[7] = uiData; uiData = DONE; break;
        case TYPE_EVENT:     m_auiEncounter[8] = uiData; uiData = NOT_STARTED; break;
        case TYPE_EVENT_TIMER:      m_auiEventTimer = uiData; uiData = NOT_STARTED; break;
        case TYPE_NORTHREND_BEASTS: m_auiNorthrendBeasts = uiData; break;
        case DATA_HEALTH_FJOLA:     m_uiDataDamageFjola = uiData; uiData = NOT_STARTED; break;
        case DATA_HEALTH_EYDIS:     m_uiDataDamageEydis = uiData; uiData = NOT_STARTED; break;
        case DATA_CASTING_VALKYRS:  m_uiValkyrsCasting = uiData; uiData = NOT_STARTED; break;
        }

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

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

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

            std::ostringstream saveStream;

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

            m_strInstData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        needsave = false;
        }
    }
    void instance_icecrown_spire::OpenAllDoors()
    {
        if (m_auiEncounter[1] == DONE) 
        {
            DoOpenDoor(GO_ICEWALL_1);
            DoOpenDoor(GO_ICEWALL_2);
            DoOpenDoor(GO_MARROWGAR_DOOR);
            DoOpenDoor(GO_ORATORY_DOOR);
        };
        if (m_auiEncounter[2] == DONE) 
        {
            if (GameObject* pGO = GetSingleGameObjectFromStorage(GO_DEATHWHISPER_ELEVATOR))
            {
                pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                pGO->SetGoState(GO_STATE_READY);
            }
        };
        if (m_auiEncounter[4] == DONE) 
        {
            //DoOpenDoor(GO_SAURFANG_DOOR);
            DoOpenDoor(GO_BLOODWING_DOOR);
            DoOpenDoor(GO_FROSTWING_DOOR);
        };
        if (m_auiEncounter[5] == DONE) 
            DoOpenDoor(GO_SCIENTIST_DOOR_ORANGE);
        if (m_auiEncounter[6] == DONE) 
            DoOpenDoor(GO_SCIENTIST_DOOR_GREEN);
        if (m_auiEncounter[6] == DONE && m_auiEncounter[5] == DONE) 
            DoOpenDoor(GO_SCIENTIST_DOOR_COLLISION);
        if (m_auiEncounter[8] == DONE) 
        {
            DoOpenDoor(GO_COUNCIL_DOOR_1);
            DoOpenDoor(GO_COUNCIL_DOOR_2);
        };
        if (m_auiEncounter[10] == DONE) 
        {
            DoOpenDoor(GO_GREEN_DRAGON_DOOR_2);
            DoOpenDoor(GO_SINDRAGOSA_DOOR_1);
            DoOpenDoor(GO_SINDRAGOSA_DOOR_2);
        };

    }
    void instance_icecrown_spire::SetData(uint32 uiType, uint32 uiData)
    {
        switch(uiType)
        {
            case TYPE_TELEPORT:
                break;
            case TYPE_MARROWGAR:
                m_auiEncounter[TYPE_MARROWGAR] = uiData;
                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(GO_MARROWGAR_DOOR);
                else DoOpenDoor(GO_MARROWGAR_DOOR);

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

                if (uiData == DONE) 
                {
                    if (GameObject* pGO = GetSingleGameObjectFromStorage(GO_DEATHWHISPER_ELEVATOR))
                    {
                          pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                          pGO->SetGoState(GO_STATE_READY);
                    }
                }
                break;
             case TYPE_FLIGHT_WAR:
                if (uiData == DONE && m_auiEncounter[TYPE_FLIGHT_WAR] != DONE  ) 
                {
                                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiGunshipArmoryA_ID))
                                    if (pChest && !pChest->isSpawned()) 
                                    {
                                        pChest->SetRespawnTime(7*DAY);
                                    };

                                if (GameObject* pChest = GetSingleGameObjectFromStorage(m_uiGunshipArmoryH_ID))
                                    if (pChest && !pChest->isSpawned()) 
                                    {
                                        pChest->SetRespawnTime(7*DAY);
                                    };
                };
                m_auiEncounter[3] = uiData; 
                break;
             case TYPE_SAURFANG:
                m_auiEncounter[TYPE_SAURFANG] = uiData; 
                if (uiData == DONE) 
                {
                    //DoOpenDoor(GO_SAURFANG_DOOR);
                    DoOpenDoor(GO_BLOODWING_DOOR);
                    DoOpenDoor(GO_FROSTWING_DOOR);

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

                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(GO_ORANGE_PLAGUE);
                else
                    DoOpenDoor(GO_ORANGE_PLAGUE);

                if (uiData == DONE)  
                {
                    DoOpenDoor(GO_ORANGE_PLAGUE);
                    if (m_auiEncounter[TYPE_ROTFACE] == DONE) 
                    {
                        DoOpenDoor(GO_SCIENTIST_DOOR_COLLISION);
                        DoOpenDoor(GO_SCIENTIST_DOOR_GREEN);
                    }
                }
                break;
             case TYPE_ROTFACE:
                m_auiEncounter[TYPE_ROTFACE] = uiData;
                if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_GREEN_PLAGUE);
                else
                    DoOpenDoor(GO_GREEN_PLAGUE);
                if (uiData == DONE)
                {
                    DoOpenDoor(GO_SCIENTIST_DOOR_GREEN);
                    if (m_auiEncounter[TYPE_FESTERGUT] == DONE) 
                    {
                        DoOpenDoor(GO_SCIENTIST_DOOR_ORANGE);
                        DoOpenDoor(GO_SCIENTIST_DOOR_COLLISION);
                    }
                }
                break;
             case TYPE_PUTRICIDE:
                m_auiEncounter[TYPE_PUTRICIDE] = uiData;
                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(GO_SCIENTIST_DOOR);
                else
                    DoOpenDoor(GO_SCIENTIST_DOOR);
                if (uiData == DONE)
                {
                    if (m_auiEncounter[TYPE_SINDRAGOSA] == DONE
                        && m_auiEncounter[TYPE_LANATHEL] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_BLOOD_COUNCIL:
                m_auiEncounter[TYPE_BLOOD_COUNCIL] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_CRIMSON_HALL_DOOR);
                else
                    DoOpenDoor(GO_CRIMSON_HALL_DOOR);

                if (uiData == DONE) 
                {
                    DoOpenDoor(GO_COUNCIL_DOOR_1);
                    DoOpenDoor(GO_COUNCIL_DOOR_2);
                }
                break;
             case TYPE_LANATHEL:
                m_auiEncounter[TYPE_LANATHEL] = uiData;

                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(GO_BLOODPRINCE_DOOR);
                else DoOpenDoor(GO_BLOODPRINCE_DOOR);

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

                    if (m_auiEncounter[TYPE_PUTRICIDE] == DONE
                        && m_auiEncounter[TYPE_SINDRAGOSA] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_VALITHRIA:
                m_auiEncounter[TYPE_VALITHRIA] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_GREEN_DRAGON_DOOR_1);
                else
                    DoOpenDoor(GO_GREEN_DRAGON_DOOR_1);

                if (uiData == DONE)
                {
                    DoOpenDoor(GO_GREEN_DRAGON_DOOR_2);
                    DoOpenDoor(GO_SINDRAGOSA_DOOR_1);
                    DoOpenDoor(GO_SINDRAGOSA_DOOR_2);
                    if (GameObject* pChest = GetSingleGameObjectFromStorage( m_uiValithriaCache))
                        if (pChest && !pChest->isSpawned()) 
                        {
                            pChest->SetRespawnTime(7*DAY);
                        };
                };
                break;
             case TYPE_SINDRAGOSA:
                m_auiEncounter[TYPE_SINDRAGOSA] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_SINDRAGOSA_ENTRANCE);
                else
                    DoOpenDoor(GO_SINDRAGOSA_ENTRANCE);

                if (uiData == DONE)
                {
                    if (m_auiEncounter[TYPE_PUTRICIDE] == DONE
                        && m_auiEncounter[TYPE_LANATHEL] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_LICH_KING:
                m_auiEncounter[TYPE_LICH_KING] = uiData;
                break;
             case TYPE_ICECROWN_QUESTS:
                m_auiEncounter[TYPE_ICECROWN_QUESTS] = uiData;
                break;
             case TYPE_COUNT:
                m_auiEncounter[TYPE_COUNT] = uiData;
                uiData = NOT_STARTED;
                break;
             case DATA_BLOOD_INVOCATION:         m_uiCouncilInvocation = uiData;
                                                 uiData = NOT_STARTED;
                                                 break;
             case DATA_DIRECTION:                m_uiDirection = uiData;
                                                 uiData = NOT_STARTED;
                                                 break;
             case TYPE_EVENT:            m_auiEvent = uiData; uiData = NOT_STARTED; break;
             case TYPE_EVENT_TIMER:      m_auiEventTimer = uiData; uiData = NOT_STARTED; break;
             case TYPE_STINKY:           m_uiStinkystate = uiData; uiData = NOT_STARTED; break;
             case TYPE_PRECIOUS:         m_uiPreciousstate = uiData; uiData = NOT_STARTED; break;
        }

        if (uiData == DONE)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;

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

            strSaveData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }
    }
Beispiel #6
0
    void SetData(uint32 uiType, uint32 uiData)
    {
        switch(uiType)
        {
            case TYPE_EVENT:
                m_auiEncounter[uiType] = uiData;
                uiData = NOT_STARTED;
                break;
            case TYPE_RAGEFIRE:
                m_auiEncounter[uiType] = uiData;
                OpenAllDoors();
                break;
            case TYPE_BALTHARUS:
                m_auiEncounter[uiType] = uiData;
                OpenAllDoors();
                break;
            case TYPE_XERESTRASZA:
                m_auiEncounter[uiType] = uiData;
                if (uiData == IN_PROGRESS)
                    DoOpenDoor(GO_FIRE_FIELD);
                else if (uiData == NOT_STARTED)
                {
                    DoCloseDoor(GO_FIRE_FIELD);
                    OpenAllDoors();
                }
                else if (uiData == DONE)
                {
                    OpenAllDoors();
                    if (m_auiEncounter[TYPE_ZARITHRIAN] == DONE)
                    {
                        m_auiEncounter[TYPE_EVENT] = 200;
                        m_auiEventTimer = 30000;
                    }
                }
                break;
            case TYPE_ZARITHRIAN:
                m_auiEncounter[uiType] = uiData;
                if (uiData == DONE)
                {
                    DoOpenDoor(GO_FLAME_WALLS);
                    m_auiEncounter[TYPE_EVENT] = 200;
                    m_auiEventTimer = 30000;
                }
                else if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_FLAME_WALLS);
                else if (uiData == FAIL)
                    DoOpenDoor(GO_FLAME_WALLS);
                    break;
            case TYPE_HALION:
                m_auiEncounter[uiType] = uiData;
                if (uiData == IN_PROGRESS)
                    DoCloseDoor(GO_FLAME_RING);
                else
                    DoOpenDoor(GO_FLAME_RING);
                break;
            case TYPE_HALION_EVENT:
                m_auiHalionEvent  = uiData;
                uiData = NOT_STARTED;
                break;
            case TYPE_EVENT_TIMER:
                m_auiEventTimer = uiData;
                uiData = NOT_STARTED;
                break;

            case DATA_ORB_DIRECTION:
                m_auiOrbDirection = uiData;
                uiData = NOT_STARTED;
                break;
            case DATA_ORB_N:
                m_auiOrbNState = uiData;
                uiData = NOT_STARTED;
                break;
            case DATA_ORB_S:
                m_auiOrbSState = uiData;
                uiData = NOT_STARTED;
                break;
            case TYPE_COUNTER:
                if (uiData == COUNTER_OFF)
                {
                    UpdateWorldState(false,0);
                }
                else
                {
                    UpdateWorldState(true,uiData);
                }
                uiData = NOT_STARTED;
                break;
        }

        if (uiData == DONE)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;

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

            strSaveData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }
    }
    void instance_icecrown_spire::SetData(uint32 uiType, uint32 uiData)
    {
        switch(uiType)
        {
            case TYPE_TELEPORT:
                break;
            case TYPE_MARROWGAR:
                m_auiEncounter[TYPE_MARROWGAR] = uiData;
                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(m_uiMarrogarDoor);
                else DoOpenDoor(m_uiMarrogarDoor);

                if (uiData == DONE) 
                {
                    DoOpenDoor(m_uiIcewall1GUID);
                    DoOpenDoor(m_uiIcewall2GUID);
                    DoOpenDoor(m_uiOratoryDoorGUID);
                }
                break;
             case TYPE_DEATHWHISPER:
                m_auiEncounter[TYPE_DEATHWHISPER] = uiData; 
                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(m_uiOratoryDoorGUID);
                else DoOpenDoor(m_uiOratoryDoorGUID);

                if (uiData == DONE) 
                {
                    if (GameObject* pGO = instance->GetGameObject(m_uiDeathWhisperElevatorGUID))
                    {
                          pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                          pGO->SetGoState(GO_STATE_READY);
                    }
                }
                break;
			 case TYPE_GUNSHIP_BATTLE:    
				 m_auiEncounter[TYPE_GUNSHIP_BATTLE] = uiData;         
				 //if (uiData == DONE)        
				 //    DoRespawnGameObject(m_uiGunshipArmoryGUID, 30*MINUTE);
				 break;
             case TYPE_FLIGHT_WAR:
                if (uiData == DONE && m_auiEncounter[TYPE_FLIGHT_WAR] != DONE  ) {
                                 if (GameObject* pChest = instance->GetGameObject(m_uiGunshipArmoryAGUID))
                                     if (pChest && !pChest->isSpawned()) {
                                          pChest->SetRespawnTime(7*DAY);
                                      };

                                 if (GameObject* pChest = instance->GetGameObject(m_uiGunshipArmoryHGUID))
                                     if (pChest && !pChest->isSpawned()) {
                                          pChest->SetRespawnTime(7*DAY);
                                      };
                                };
                m_auiEncounter[3] = uiData; 
                break;
             case TYPE_SAURFANG:
                m_auiEncounter[TYPE_SAURFANG] = uiData; 
                if (uiData == DONE) 
                {
                    DoOpenDoor(m_uiSaurfangDoorGUID);
                    DoOpenDoor(m_uiBloodwingDoorGUID);
                    DoOpenDoor(m_uiFrostwingDoorGUID);

                    if (GameObject* pChest = instance->GetGameObject(m_uiSaurfangCacheGUID))
                        if (pChest && !pChest->isSpawned()) 
                        {
                            pChest->SetRespawnTime(7*DAY);
                        };
                };
                break;
             case TYPE_FESTERGUT:
                m_auiEncounter[TYPE_FESTERGUT] = uiData;

                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(m_uiOrangePlagueGUID);
                else DoOpenDoor(m_uiOrangePlagueGUID);

                if (uiData == DONE)  
                {
                    DoOpenDoor(m_uiSDoorOrangeGUID);
                    if (m_auiEncounter[TYPE_ROTFACE] == DONE) 
                    {
                        DoOpenDoor(m_uiSDoorCollisionGUID);
                        DoOpenDoor(m_uiGreenPlagueGUID);
                    }
                }
                break;
             case TYPE_ROTFACE:
                m_auiEncounter[TYPE_ROTFACE] = uiData;
                if (uiData == IN_PROGRESS)
                    DoCloseDoor(m_uiGreenPlagueGUID);
                else
                    DoOpenDoor(m_uiGreenPlagueGUID);
                if (uiData == DONE)
                {
                    DoOpenDoor(m_uiSDoorGreenGUID);
                    if (m_auiEncounter[TYPE_FESTERGUT] == DONE) 
                    {
                        DoOpenDoor(m_uiSDoorOrangeGUID);
                        DoOpenDoor(m_uiSDoorCollisionGUID);
                    }
                }
                break;
             case TYPE_PUTRICIDE:
                m_auiEncounter[TYPE_PUTRICIDE] = uiData;
                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(m_uiScientistDoorGUID);
                else
                    DoOpenDoor(m_uiScientistDoorGUID);
                if (uiData == DONE)
                {
                    if (m_auiEncounter[TYPE_SINDRAGOSA] == DONE
                        && m_auiEncounter[TYPE_LANATHEL] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_BLOOD_COUNCIL:
                m_auiEncounter[TYPE_BLOOD_COUNCIL] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(m_uiCrimsonDoorGUID);
                else
                    DoOpenDoor(m_uiCrimsonDoorGUID);

                if (uiData == DONE) 
                {
                    DoOpenDoor(m_uiCounsilDoor1GUID);
                    DoOpenDoor(m_uiCounsilDoor2GUID);
                }
                break;
             case TYPE_LANATHEL:
                m_auiEncounter[TYPE_LANATHEL] = uiData;

                if (uiData == IN_PROGRESS) 
                    DoCloseDoor(m_uiBloodPrinceDoor);
                else DoOpenDoor(m_uiBloodPrinceDoor);

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

                    if (m_auiEncounter[TYPE_PUTRICIDE] == DONE
                        && m_auiEncounter[TYPE_SINDRAGOSA] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_VALITHRIA:
                m_auiEncounter[TYPE_VALITHRIA] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(m_uiGreenDragonDoor1GUID);
                else
                    DoOpenDoor(m_uiGreenDragonDoor1GUID);

                if (uiData == DONE)
                {
                    DoOpenDoor(m_uiGreenDragonDoor2GUID);
                    DoOpenDoor(m_uiSindragosaDoor1GUID);
                    DoOpenDoor(m_uiSindragosaDoor2GUID);
                    if (GameObject* pChest = instance->GetGameObject(m_uiValitriaCacheGUID))
                        if (pChest && !pChest->isSpawned()) 
                        {
                            pChest->SetRespawnTime(7*DAY);
                        };
                };
                break;
             case TYPE_SINDRAGOSA:
                m_auiEncounter[TYPE_SINDRAGOSA] = uiData;

                if (uiData == IN_PROGRESS)
                    DoCloseDoor(m_uiSindragosaEntrance);
                else
                    DoOpenDoor(m_uiSindragosaEntrance);

                if (uiData == DONE)
                {
                    if (m_auiEncounter[TYPE_PUTRICIDE] == DONE
                        && m_auiEncounter[TYPE_LANATHEL] == DONE)
                        m_auiEncounter[TYPE_KINGS_OF_ICC] = DONE;
                }
                break;
             case TYPE_LICH_KING:
                m_auiEncounter[TYPE_LICH_KING] = uiData;
                break;
             case TYPE_ICECROWN_QUESTS:
                m_auiEncounter[TYPE_ICECROWN_QUESTS] = uiData;
                break;
             case TYPE_COUNT:
                m_auiEncounter[TYPE_COUNT] = uiData;
                uiData = NOT_STARTED;
                break;
             case DATA_BLOOD_INVOCATION:         m_uiCouncilInvocation = uiData;
                                                 uiData = NOT_STARTED;
                                                 break;
             case DATA_DIRECTION:                m_uiDirection = uiData;
                                                 uiData = NOT_STARTED;
                                                 break;
             case TYPE_EVENT:            m_auiEvent = uiData; uiData = NOT_STARTED; break;
             case TYPE_EVENT_TIMER:      m_auiEventTimer = uiData; uiData = NOT_STARTED; break;
             case TYPE_STINKY:           m_uiStinkystate = uiData; uiData = NOT_STARTED; break;
             case TYPE_PRECIOUS:         m_uiPreciousstate = uiData; uiData = NOT_STARTED; break;
        }

        if (uiData == DONE)
        {
            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;

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

            strSaveData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
        }
    }
    void instance_icecrown_spire::OpenAllDoors()
    {
        if (m_auiEncounter[1] == DONE) {
                                        DoOpenDoor(m_uiIcewall1GUID);
                                        DoOpenDoor(m_uiIcewall2GUID);
                                        DoOpenDoor( m_uiOratoryDoorGUID);
                                        };
        if (m_auiEncounter[2] == DONE) {
                        if (GameObject* pGO = instance->GetGameObject(m_uiDeathWhisperElevatorGUID))
                            {
                              pGO->SetUInt32Value(GAMEOBJECT_LEVEL, 0);
                              pGO->SetGoState(GO_STATE_READY);
                            }
                                       };
        if (m_auiEncounter[4] == DONE) {
                                        DoOpenDoor(m_uiSaurfangDoorGUID);
                                        DoOpenDoor(m_uiBloodwingDoorGUID);
                                        DoOpenDoor(m_uiFrostwingDoorGUID);
                                        };
        if (m_auiEncounter[5] == DONE) DoOpenDoor(m_uiSDoorOrangeGUID);
        if (m_auiEncounter[6] == DONE) DoOpenDoor(m_uiSDoorGreenGUID);
        if (m_auiEncounter[6] == DONE && m_auiEncounter[5] == DONE) DoOpenDoor(m_uiSDoorCollisionGUID);
        if (m_auiEncounter[8] == DONE) {
                                        DoOpenDoor(m_uiCounsilDoor1GUID);
                                        DoOpenDoor(m_uiCounsilDoor2GUID);
                                        };
        if (m_auiEncounter[10] == DONE) 
        {
            DoOpenDoor(m_uiValithriaDoor2GUID);
            DoOpenDoor(m_uiSindragosaDoor2GUID);
            DoOpenDoor(m_uiSindragosaDoor1GUID);
        };

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

            uint32 uiCacheEntry = GO_CRUSADERS_CACHE_10;

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

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

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

                m_uiTributeChest4 = GO_TRIBUTE_CHEST_10H_99;
            }
            if (Difficulty == RAID_DIFFICULTY_25MAN_HEROIC)
            {
                if (m_auiEncounter[TYPE_COUNTER] >= 25)
                    m_uiTributeChest1 = GO_TRIBUTE_CHEST_25H_25;
                if (m_auiEncounter[TYPE_COUNTER] >= 45)
                    m_uiTributeChest2 = GO_TRIBUTE_CHEST_25H_45;
                if (m_auiEncounter[TYPE_COUNTER] > 49)
                    m_uiTributeChest3 = GO_TRIBUTE_CHEST_25H_50;

                m_uiTributeChest4 = GO_TRIBUTE_CHEST_25H_99;
            }
            // Attention! It is (may be) not off-like, but  spawning all Tribute Chests is real
            // reward for clearing TOC instance
            if (m_uiTributeChest1)
                if (GameObject* pChest1 = GetSingleGameObjectFromStorage(m_uiTributeChest1))
                    if (pChest1 && !pChest1->isSpawned())
                        pChest1->SetRespawnTime(7*DAY);

            if (m_uiTributeChest2)
                if (GameObject* pChest2 = GetSingleGameObjectFromStorage(m_uiTributeChest2))
                    if (pChest2 && !pChest2->isSpawned())
                        pChest2->SetRespawnTime(7*DAY);

            if (m_uiTributeChest3)
                if (GameObject* pChest3 = GetSingleGameObjectFromStorage(m_uiTributeChest3))
                    if (pChest3 && !pChest3->isSpawned())
                        pChest3->SetRespawnTime(7*DAY);

            if (m_uiTributeChest4)
                if (GameObject* pChest4 = GetSingleGameObjectFromStorage(m_uiTributeChest4))
                    if (pChest4 && !pChest4->isSpawned())
                        pChest4->SetRespawnTime(7*DAY);
        };
        break;
    case TYPE_COUNTER:
        m_auiEncounter[TYPE_COUNTER] = uiData;
        if (uiData < 25)
            SetSpecialAchievementCriteria(TYPE_SKILL, false);
        if (uiData < 45)
            SetSpecialAchievementCriteria(TYPE_MAD_SKILL, false);
        if (uiData < 50)
        {
            SetSpecialAchievementCriteria(TYPE_INSANITY, false);
            SetSpecialAchievementCriteria(TYPE_IMMORTALITY, false);
        }

        //uiData = DONE;
        break;
    case TYPE_DEATHS:
        m_auiEncounter[TYPE_DEATHS] += uiData;
        if (GetData(TYPE_DEATHS))
            SetSpecialAchievementCriteria(TYPE_IMMORTALITY, false);
        break;
    case TYPE_EVENT:
        m_auiEncounter[TYPE_EVENT] = uiData;
        uiData = NOT_STARTED;
        break;
    case TYPE_EVENT_TIMER:
        m_auiEventTimer = uiData;
        uiData = NOT_STARTED;
        break;
    case TYPE_NORTHREND_BEASTS:
        m_auiNorthrendBeasts = uiData;
        break;
    case DATA_HEALTH_FJOLA:
        m_uiDataDamageFjola = uiData; uiData = NOT_STARTED;
        break;
    case DATA_HEALTH_EYDIS:
        m_uiDataDamageEydis = uiData; uiData = NOT_STARTED;
        break;
    }

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

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

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

    if (uiData == FAIL && uiType != TYPE_STAGE && uiType != TYPE_EVENT && uiType != TYPE_COUNTER && uiType != TYPE_EVENT_TIMER)
    {
        if (IsRaidWiped())
        {
            //--m_auiEncounter[TYPE_COUNTER];
            SetData(TYPE_COUNTER, GetData(TYPE_COUNTER) - 1);
            needsave = true;
            UpdateWorldState();
        }
        uiData = NOT_STARTED;
    }

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

        std::ostringstream saveStream;

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

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
        needsave = false;
    }
}
Beispiel #10
0
    void SetData(uint32 uiType, uint32 uiData)
    {

        if (uiData == FAIL)
        {
            switch (uiType)
            {
                case TYPE_BEASTS:
                case TYPE_JARAXXUS:
                case TYPE_CRUSADERS:
                case TYPE_VALKIRIES:
                case TYPE_ANUBARAK:
                    if (m_auiEncounter[uiType] != FAIL)
                    {
                        if (m_uiDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC)
                        {
                            --m_auiEncounter[7];
                            needsave = true;
                            DoUpdateWorldState(UPDATE_STATE_UI_SHOW, 1);
                            DoUpdateWorldState(UPDATE_STATE_UI_COUNT, m_auiEncounter[7]);
                        }
                    }
                    break;
                default:
                    break;
            }
        }

        switch(uiType)
        {
            case TYPE_STAGE:    m_auiEncounter[0] = uiData; break;
            case TYPE_BEASTS:   m_auiEncounter[1] = uiData; break;
            case TYPE_JARAXXUS: m_auiEncounter[2] = uiData; break;
            case TYPE_CRUSADERS:
                if (uiData == FAIL && (m_auiEncounter[3] == FAIL || m_auiEncounter[3] == NOT_STARTED))
                    m_auiEncounter[3] = NOT_STARTED;
                else
                    m_auiEncounter[3] = uiData;

                if (uiData == DONE)
                {
                    uint32 uiCacheEntry = GO_CRUSADERS_CACHE_10;

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

                // remove light/dark essence and poweringup on success/wipe
                if(uiData == DONE || uiData == FAIL)
                {
                    Map::PlayerList const &players = instance->GetPlayers();

                    for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
                    {
                        if(Player* pPlayer = i->getSource())
                        {
                            if(pPlayer && pPlayer->isAlive())
                            {
                                switch(m_uiDifficulty)
                                {
                                    case RAID_DIFFICULTY_10MAN_NORMAL:
                                        pPlayer->RemoveAurasDueToSpell(SPELL_LIGHT_ESSENCE);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_DARK_ESSENCE);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_POWERUP_N10);
                                        break;
                                    case RAID_DIFFICULTY_25MAN_NORMAL:
                                        pPlayer->RemoveAurasDueToSpell(SPELL_LIGHT_ESSENCE_N25);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_DARK_ESSENCE_N25);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_POWERUP_N25);
                                        break;
                                    case RAID_DIFFICULTY_10MAN_HEROIC:
                                        pPlayer->RemoveAurasDueToSpell(SPELL_LIGHT_ESSENCE_H10);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_DARK_ESSENCE_H10);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_POWERUP_H10);
                                        break;
                                    case RAID_DIFFICULTY_25MAN_HEROIC:
                                        pPlayer->RemoveAurasDueToSpell(SPELL_LIGHT_ESSENCE_H25);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_DARK_ESSENCE_H25);
                                        pPlayer->RemoveAurasDueToSpell(SPELL_POWERUP_H25);
                                        break;
                                }
                            }
                        }
                    }

                    if (uiData == FAIL)
                    {
                        uint32 uiTwinHealt;
                        switch (m_uiDifficulty)
                        {
                        case RAID_DIFFICULTY_10MAN_NORMAL:
                            uiTwinHealt = 6066075;
                            break;
                        case RAID_DIFFICULTY_25MAN_NORMAL:
                            uiTwinHealt = 8367000;
                            break;
                        case RAID_DIFFICULTY_10MAN_HEROIC:
                            uiTwinHealt = 27890000;
                            break;
                        case RAID_DIFFICULTY_25MAN_HEROIC:
                            uiTwinHealt = 39046000;
                            break;
                        default:
                            uiTwinHealt = 5000000;
                            break;
                        }
                        m_uiDataDamageFjola = uiTwinHealt;
                        m_uiDataDamageEydis = uiTwinHealt;
                    }
                }
                m_auiEncounter[4] = uiData;
                break;
            case TYPE_LICH_KING: m_auiEncounter[5] = uiData; break;
            case TYPE_ANUBARAK:  m_auiEncounter[6] = uiData;
                if (uiData == DONE)
                {
                    if (m_uiDifficulty == RAID_DIFFICULTY_10MAN_HEROIC)
                    {
                        if (m_auiEncounter[7] == 50)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_10H_50;
                        else if (m_auiEncounter[7] >= 45)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_10H_45;
                        else if (m_auiEncounter[7] >= 25)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_10H_25;
                        else
                            m_uiTributeChest = GO_TRIBUTE_CHEST_10H_99;
                    }
                    if (m_uiDifficulty == RAID_DIFFICULTY_25MAN_HEROIC)
                    {
                        if (m_auiEncounter[7] == 50)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_25H_50;
                        else if (m_auiEncounter[7] >= 45)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_25H_45;
                        else if (m_auiEncounter[7] >= 25)
                            m_uiTributeChest = GO_TRIBUTE_CHEST_25H_25;
                        else
                            m_uiTributeChest = GO_TRIBUTE_CHEST_25H_99;
                    }
                    // reward for clearing TOC instance
                    if (m_uiTributeChest)
                    {
                        DoRespawnGameObject(GetSingleGameObjectFromStorage(m_uiTributeChest)->GetObjectGuid(), DAY);
                    }
                }
                break;
            case TYPE_COUNTER:   m_auiEncounter[7] = uiData; uiData = DONE; break;
            case TYPE_EVENT:     m_auiEncounter[8] = uiData; uiData = NOT_STARTED; break;
            case TYPE_EVENT_TIMER:      m_auiEventTimer = uiData; uiData = NOT_STARTED; break;
            case TYPE_GORMOK:
                m_auiNorthrendBeasts[0] = uiData;
                break;
            case TYPE_SNAKES:
                m_auiNorthrendBeasts[1] = uiData;
                break;
            case TYPE_ICEHOWL:
                m_auiNorthrendBeasts[2] = uiData;
                break;
            case DATA_HEALTH_FJOLA:     m_uiDataDamageFjola = uiData; uiData = NOT_STARTED; break;
            case DATA_HEALTH_EYDIS:     m_uiDataDamageEydis = uiData; uiData = NOT_STARTED; break;
            case DATA_CASTING_VALKYRS:  m_uiValkyrsCasting = uiData; uiData = NOT_STARTED; break;
        }

        if (IsEncounterInProgress())
        {
            DoCloseDoor(GO_EAST_PORTCULLIS);
            DoCloseDoor(GO_NORTH_PORTCULLIS);
            DoCloseDoor(GO_SOUTH_PORTCULLIS);
        }
        else
        {
            DoOpenDoor(GO_EAST_PORTCULLIS);
            DoOpenDoor(GO_NORTH_PORTCULLIS);
            DoOpenDoor(GO_SOUTH_PORTCULLIS);
        }

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

            std::ostringstream saveStream;

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

            m_strInstData = saveStream.str();

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

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

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

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

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

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

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

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

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

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

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

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

                DoOpenDoor(GO_SINDRAGOSA_DOOR_1);
                DoOpenDoor(GO_SINDRAGOSA_DOOR_2);

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

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

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

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

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

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;

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

        strSaveData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}