void instance_ruins_of_ahnqiraj::OnPlayerEnter(Player* /*pPlayer*/)
{
    // Spawn andorov if necessary
    if (m_auiEncounter[TYPE_KURINNAXX] == DONE)
    {
        DoSapwnAndorovIfCan();
    }
}
void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_KURINNAXX:
            if (uiData == DONE)
            {
                DoSapwnAndorovIfCan();

                // Yell after kurinnaxx
                DoOrSimulateScriptTextForThisInstance(SAY_OSSIRIAN_INTRO, NPC_OSSIRIAN);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_RAJAXX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                DoSortArmyWaves();
            }
            if (uiData == DONE)
            {
                if (Creature* pAndorov = GetSingleCreatureFromStorage(NPC_GENERAL_ANDOROV))
                {
                    if (pAndorov->IsAlive())
                    {
                        pAndorov->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                    }
                }
            }
            break;
        case TYPE_MOAM:
        case TYPE_BURU:
        case TYPE_AYAMISS:
        case TYPE_OSSIRIAN:
            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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
    case TYPE_KURINNAXX:
        if (uiData == DONE)
        {
            DoSapwnAndorovIfCan();

            // Yell after kurinnaxx
            DoOrSimulateScriptTextForThisInstance(SAY_OSSIRIAN_INTRO, NPC_OSSIRIAN);
        }
        m_auiEncounter[uiType] = uiData;
        break;
    case TYPE_RAJAXX:
    case TYPE_MOAM:
    case TYPE_BURU:
    case TYPE_AYAMISS:
    case TYPE_OSSIRIAN:
        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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
void instance_ruins_of_ahnqiraj::OnPlayerEnter(Player* pPlayer)
{
    // Spawn andorov if necessary
    DoSapwnAndorovIfCan();
}
void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_KURINNAXX:
            if (uiData == DONE)
            {
                DoSapwnAndorovIfCan();

                // Yell after kurinnaxx
                if (m_auiEncounter[uiType] != DONE)
				    DoOrSimulateScriptTextForThisInstance(YELL_OSSIRIAN_BREACHED, NPC_OSSIRIAN);
            }
            m_auiEncounter[uiType] = uiData;
            break;
        case TYPE_RAJAXX:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                m_hasResetRajaxx = false;
                DoSortArmyWaves();
            }
            if (uiData == DONE)
            {
                Map::PlayerList const &PlayerList = instance->GetPlayers();
                for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
                {
                    if (itr->getSource() && itr->getSource()->IsInWorld())
                        itr->getSource()->SetCombatTimer(0);
                }

                if (Creature* pAndorov = GetSingleCreatureFromStorage(NPC_GENERAL_ANDOROV))
                {
                    if (pAndorov->isAlive() && m_auiEncounter[TYPE_ANDOROV] != FAIL)
                    {
#if AQ_PATCH >= 10
                        pAndorov->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
#else
                        pAndorov->ForcedDespawn();
#endif
                        Map::PlayerList const& lPlayers = this->instance->GetPlayers();
                        
                        if (!lPlayers.isEmpty())
                            for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
                            {
                                if (Player* pPlayer = itr->getSource())
                                    pPlayer->RewardReputation(609, 150);
                            }
                    }
                }
            }
            break;
        case TYPE_MOAM:
        case TYPE_BURU:
        case TYPE_AYAMISS:
        case TYPE_OSSIRIAN:
        case TYPE_ANDOROV:
            m_auiEncounter[uiType] = uiData;
            break;
    }

    if (uiData == DONE || (uiType == TYPE_RAJAXX && uiData == IN_PROGRESS) || (uiType == TYPE_ANDOROV && 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_auiEncounter[6];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}