void OnPlayerEnter(Player* player)
    {
        if (player->isGameMaster())
            return;

        UpdateOHWorldState();

        if (summon == NOT_SUMMONED)
            summon = WAIT_FOR_SUMMON;
    }
    void SetData(uint32 type, uint32 data)
    {
        Player *player = GetPlayerInMap();

        if (!player)
        {
            debug_log("OSCR: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player.", type, data);
            return;
        }

        switch(type)
        {
            case TYPE_BARREL_DIVERSION:
            {
                if (data == IN_PROGRESS)
                {
                    if (mBarrelCount >= 5)
                        return;

                    ++mBarrelCount;
                    UpdateOHWorldState();

                    debug_log("OSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount);

                    Encounter[0] = IN_PROGRESS;

                    if (mBarrelCount == 5)
                    {
                    player->SummonCreature(DRAKE_ENTRY,2128.43f,71.01f,64.42f,1.74f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
                    Encounter[0] = DONE;
                    }
                }
                break;
            }
            case TYPE_THRALL_EVENT:
            {
                if (data == FAIL)
                {
                    if (mThrallEventCount <= 20)
                    {
                        mThrallEventCount++;
                        Encounter[1] = NOT_STARTED;
                        debug_log("OSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount);
                        Encounter[2] = NOT_STARTED;
                        Encounter[3] = NOT_STARTED;
                        Encounter[4] = NOT_STARTED;
                        Encounter[5] = NOT_STARTED;
                    }
                    else if (mThrallEventCount > 20)
                    {
                        Encounter[1] = data;
                        Encounter[2] = data;
                        Encounter[3] = data;
                        Encounter[4] = data;
                        Encounter[5] = data;
                        debug_log("OSCR: Instance Old Hillsbrad: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount);
                    }
                }
                else
                    Encounter[1] = data;
                debug_log("OSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.",data);
                break;
            }
            case TYPE_THRALL_PART1:
                Encounter[2] = data;
                debug_log("OSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.",data);
                break;
            case TYPE_THRALL_PART2:
                Encounter[3] = data;
                debug_log("OSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.",data);
                break;
            case TYPE_THRALL_PART3:
                Encounter[4] = data;
                debug_log("OSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.",data);
                break;
            case TYPE_THRALL_PART4:
                Encounter[5] = data;
                 debug_log("OSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.",data);
                break;
        }
    }
    void SetData(uint32 type, uint32 data)
    {
        Player *player = GetPlayerInMap();

        if (!player)
        {
            debug_log("TSCR: Instance Old Hillsbrad: SetData (Type: %u Data %u) cannot find any player.", type, data);
            return;
        }

        switch(type)
        {
            case TYPE_BARREL_DIVERSION:
            {
                if (data == IN_PROGRESS)
                {
                    if (BarrelCount > 5)
                        return;

                    ++BarrelCount;
                    UpdateOHWorldState();

                    debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u", BarrelCount);

                    Encounter[0] = IN_PROGRESS;

                    if (BarrelCount == 5)
                    {
                        if (Creature* drake = player->SummonCreature(DRAKE_ENTRY, 2128.43f, 71.01f, 64.42, 1.74f, TEMPSUMMON_DEAD_DESPAWN, 15000))
                            DoScriptText(SAY_DRAKE_ENTER, drake, player);

                        Encounter[0] = DONE;
                        Position OrcLocPos;

                        for (std::list<GameObject*>::iterator itr = RoaringFlamesList.begin(); itr != RoaringFlamesList.end(); ++itr)
                        {
                            // move the orcs outside the houses
                            float x, y, z;
                            for (std::list<uint64>::iterator it = RightPrisonersList.begin(); it != RightPrisonersList.end(); ++it)
                            {
                                if (Creature* Orc = instance->GetCreature(*it))
                                {
                                    OrcLocPos.Relocate(OrcLoc[0][0], OrcLoc[0][1], OrcLoc[0][2]);
                                    Orc->GetRandomPoint(OrcLocPos, 10.0f, x, y, z);
                                    Orc->SetWalk(false);
                                    Orc->GetMotionMaster()->MovePoint(0, x, y, z);
                                }
                            }

                            for (std::list<uint64>::iterator il = LeftPrisonersList.begin(); il != LeftPrisonersList.end(); ++il)
                            {
                                if (Creature* Orc = instance->GetCreature(*il))
                                {
                                    OrcLocPos.Relocate(OrcLoc[1][0], OrcLoc[1][1], OrcLoc[1][2]);
                                    Orc->GetRandomPoint(OrcLocPos, 10.0f, x, y, z);
                                    Orc->SetWalk(false);
                                    Orc->GetMotionMaster()->MovePoint(0, x, y, z);
                                }
                            }
                            (*itr)->SetRespawnTime(1800);
                            (*itr)->UpdateObjectVisibility();
                        }
                    }
                }
                break;
            }
            case TYPE_THRALL_EVENT:
            {
                if (data == FAIL)
                {
                    if (ThrallEventCount <= 20)
                    {
                        ThrallEventCount++;
                        debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times.", ThrallEventCount);

                        Encounter[1] = NOT_STARTED;

                        if (Encounter[2] == IN_PROGRESS)
                            Encounter[2] = NOT_STARTED;

                        if (Encounter[3] == IN_PROGRESS)
                            Encounter[3] = NOT_STARTED;

                        if (Encounter[4] == IN_PROGRESS)
                            Encounter[4] = NOT_STARTED;

                        if (Encounter[5] == IN_PROGRESS)
                            Encounter[5] = NOT_STARTED;
                    }
                    else if (ThrallEventCount > 20)
                    {
                        Encounter[0] = DONE;
                        Encounter[1] = DONE;
                        Encounter[2] = DONE;
                        Encounter[3] = DONE;
                        Encounter[4] = DONE;
                        Encounter[5] = DONE;
                        Encounter[6] = DONE;
                        Encounter[7] = DONE;
                        Encounter[8] = DONE;
                        debug_log("TSCR: Instance Old Hillsbrad: Thrall event failed %u times. This is the end.", ThrallEventCount);
                    }
                }
                else
                    Encounter[1] = data;
                debug_log("TSCR: Instance Old Hillsbrad: Thrall escort event adjusted to data %u.", data);
                break;
            }
            case TYPE_THRALL_PART1:
                Encounter[2] = data;
                debug_log("TSCR: Instance Old Hillsbrad: Thrall event part I adjusted to data %u.", data);
                break;
            case TYPE_THRALL_PART2:
                Encounter[3] = data;
                debug_log("TSCR: Instance Old Hillsbrad: Thrall event part II adjusted to data %u.", data);
                break;
            case TYPE_THRALL_PART3:
                Encounter[4] = data;
                debug_log("TSCR: Instance Old Hillsbrad: Thrall event part III adjusted to data %u.", data);
                break;
            case TYPE_THRALL_PART4:
                Encounter[5] = data;
                 debug_log("TSCR: Instance Old Hillsbrad: Thrall event part IV adjusted to data %u.", data);
                break;
            case DATA_SKARLOC_DEATH:
                if (Encounter[6] != DONE)
                    Encounter[6] = data;
                break;
            case DATA_DRAKE_DEATH:
                if (Encounter[7] != DONE)
                    Encounter[7] = data;
                break;
            case DATA_EPOCH_DEATH:
                if (Encounter[8] != DONE)
                    Encounter[8] = data;
                break;
        }

        if (data == DONE)
            SaveToDB();
    }