示例#1
0
void instance_old_hillsbrad::SetData(uint32 uiType, uint32 uiData)
{
    switch(uiType)
    {
        case TYPE_BARREL_DIVERSION:
        {
            if (uiData == IN_PROGRESS)
            {
                if (m_uiBarrelCount >= 5)
                    return;

                ++m_uiBarrelCount;
                DoUpdateWorldState(WORLD_STATE_OH, m_uiBarrelCount);

                debug_log("SD2: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u", m_uiBarrelCount);

                m_auiEncounter[TYPE_BARREL_DIVERSION] = IN_PROGRESS;

                if (m_uiBarrelCount == 5)
                {
                    UpdateLodgeQuestCredit();

                    if (Player* pPlayer = GetPlayerInMap())
                        pPlayer->SummonCreature(NPC_DRAKE, 2128.43f, 71.01f, 64.42f, 1.74f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 1800000);
                    else
                        debug_log("SD2: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any pPlayer.", uiType, uiData);

                    m_auiEncounter[TYPE_BARREL_DIVERSION] = DONE;
                }
            }
            break;
        }
        case TYPE_THRALL_EVENT:
        {
            // nothing to do if already done and thrall respawn
            if (m_auiEncounter[TYPE_THRALL_EVENT] == DONE)
                return;

            if (uiData == FAIL)
            {
                if (m_uiThrallEventCount <= 20)
                {
                    ++m_uiThrallEventCount;
                    debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times.", m_uiThrallEventCount);

                    HandleThrallRelocation();
                }
                else if (m_uiThrallEventCount > 20)
                {
                    m_auiEncounter[TYPE_THRALL_EVENT] = uiData;
                    m_auiEncounter[TYPE_THRALL_PART1] = uiData;
                    m_auiEncounter[TYPE_THRALL_PART2] = uiData;
                    m_auiEncounter[TYPE_THRALL_PART3] = uiData;
                    m_auiEncounter[TYPE_THRALL_PART4] = uiData;
                    debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times. Reset instance required.", m_uiThrallEventCount);
                }
            }
            else
                m_auiEncounter[TYPE_THRALL_EVENT] = uiData;

            debug_log("SD2: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.",uiData);
            break;
        }
        case TYPE_THRALL_PART1:
            m_auiEncounter[TYPE_THRALL_PART1] = uiData;
            debug_log("SD2: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.",uiData);
            break;
        case TYPE_THRALL_PART2:
            m_auiEncounter[TYPE_THRALL_PART2] = uiData;
            debug_log("SD2: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.",uiData);
            break;
        case TYPE_THRALL_PART3:
            m_auiEncounter[TYPE_THRALL_PART3] = uiData;
            debug_log("SD2: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.",uiData);
            break;
        case TYPE_THRALL_PART4:
            m_auiEncounter[TYPE_THRALL_PART4] = uiData;
            debug_log("SD2: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.",uiData);
            break;
    }
}
void instance_old_hillsbrad::SetData(uint32 uiType, uint32 uiData)
{
    switch (uiType)
    {
        case TYPE_BARREL_DIVERSION:
            m_auiEncounter[uiType] = uiData;
            if (uiData == IN_PROGRESS)
            {
                if (m_uiBarrelCount >= MAX_BARRELS)
                    return;

                // Update barrels used and world state
                ++m_uiBarrelCount;
                DoUpdateWorldState(WORLD_STATE_OH, m_uiBarrelCount);

                debug_log("SD2: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u", m_uiBarrelCount);

                // Set encounter to done, and spawn Liutenant Drake
                if (m_uiBarrelCount == MAX_BARRELS)
                {
                    UpdateLodgeQuestCredit();

                    if (Player* pPlayer = GetPlayerInMap())
                    {
                        pPlayer->SummonCreature(NPC_DRAKE, aDrakeSummonLoc[0], aDrakeSummonLoc[1], aDrakeSummonLoc[2], aDrakeSummonLoc[3], TEMPSUMMON_DEAD_DESPAWN, 0);

                        // set the houses on fire
                        for (GuidList::const_iterator itr = m_lRoaringFlamesList.begin(); itr != m_lRoaringFlamesList.end(); ++itr)
                            DoRespawnGameObject(*itr, 30 * MINUTE);

                        // move the orcs outside the houses
                        float fX, fY, fZ;
                        for (GuidList::const_iterator itr = m_lRightPrisonersList.begin(); itr != m_lRightPrisonersList.end(); ++itr)
                        {
                            if (Creature* pOrc = instance->GetCreature(*itr))
                            {
                                pOrc->GetRandomPoint(afInstanceLoc[0][0], afInstanceLoc[0][1], afInstanceLoc[0][2], 10.0f, fX, fY, fZ);
                                pOrc->SetWalk(false);
                                pOrc->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                            }
                        }
                        for (GuidList::const_iterator itr = m_lLeftPrisonersList.begin(); itr != m_lLeftPrisonersList.end(); ++itr)
                        {
                            if (Creature* pOrc = instance->GetCreature(*itr))
                            {
                                pOrc->GetRandomPoint(afInstanceLoc[1][0], afInstanceLoc[1][1], afInstanceLoc[1][2], 10.0f, fX, fY, fZ);
                                pOrc->SetWalk(false);
                                pOrc->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
                            }
                        }
                    }
                    else
                        debug_log("SD2: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any pPlayer.", uiType, uiData);

                    SetData(TYPE_BARREL_DIVERSION, DONE);
                }
            }
            break;
        case TYPE_THRALL_EVENT:
            // nothing to do if already done and thrall respawn
            if (GetData(TYPE_THRALL_EVENT) == DONE)
                return;
            m_auiEncounter[uiType] = uiData;
            if (uiData == FAIL)
            {
                // despawn the bosses if necessary
                if (Creature* pSkarloc = GetSingleCreatureFromStorage(NPC_SKARLOC, true))
                    pSkarloc->ForcedDespawn();
                if (Creature* pEpoch = GetSingleCreatureFromStorage(NPC_EPOCH, true))
                    pEpoch->ForcedDespawn();

                if (m_uiThrallEventCount <= MAX_WIPE_COUNTER)
                {
                    ++m_uiThrallEventCount;
                    debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times.", m_uiThrallEventCount);

                    // reset Thrall on timer
                    m_uiThrallResetTimer = 30000;
                }
                // If we already respawned Thrall too many times, the event is failed for good
                else if (m_uiThrallEventCount > MAX_WIPE_COUNTER)
                    debug_log("SD2: Instance Old Hillsbrad: Thrall event failed %u times. Reset instance required.", m_uiThrallEventCount);
            }
            break;
        case TYPE_DRAKE:
        case TYPE_SKARLOC:
        case TYPE_ESCORT_BARN:
        case TYPE_ESCORT_INN:
        case TYPE_EPOCH:
            m_auiEncounter[uiType] = uiData;
            debug_log("SD2: Instance Old Hillsbrad: Thrall event type %u adjusted to data %u.", 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_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}