void main()
{
    object oPC = GetPCSpeaker();
    effect eCagegas = EffectAreaOfEffect(AOE_PER_FOGKILL, "ty_entergas", "ty_ingas", "ty_exitgas");
    object oCounter = GetObjectByTag("ty_cagetrigcntr");
    object oGasspot1 = GetObjectByTag("ty_gasspot1");
    object oGasspot2 = GetObjectByTag("ty_gasspot2");
    location lCageSpot1 = GetLocation(GetWaypointByTag("ty_cagepoint1"));
    location lCageSpot2 = GetLocation(GetWaypointByTag("ty_cagepoint2"));
    location lCageSpot3 = GetLocation(GetWaypointByTag("ty_cagepoint3"));
    location lCageSpot4 = GetLocation(GetWaypointByTag("ty_cagepoint4"));
    location lCageSpot5 = GetLocation(GetWaypointByTag("ty_cagepoint5"));
    location lCageSpot6 = GetLocation(GetWaypointByTag("ty_cagepoint6"));
    location lCageSpot7 = GetLocation(GetWaypointByTag("ty_cagepoint7"));
    location lCageSpot8 = GetLocation(GetWaypointByTag("ty_cagepoint8"));
    location lCageSpot9 = GetLocation(GetWaypointByTag("ty_cagepoint9"));
    location lCageSpot10 = GetLocation(GetWaypointByTag("ty_cagepoint10"));
    location lCageSpot11 = GetLocation(GetWaypointByTag("ty_cagepoint11"));
    location lCageSpot12 = GetLocation(GetWaypointByTag("ty_cagepoint12"));
    location lCageSpot13 = GetLocation(GetWaypointByTag("ty_cagepoint13"));

    if(GetLocalInt(oCounter, "triggered") != 1)
        {
            FloatingTextStringOnCreature("A large cage descends rapidly from space hidden in the ceiling and cuts off any escape!", oPC, TRUE);
            PlaySound("as_hr_x2drnoise2");
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot1, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot2, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot3, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot4, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot5, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot6, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot7, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot8, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot9, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot10, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot11, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot12, TRUE);
            CreateObject(OBJECT_TYPE_PLACEABLE, "x0_cagewall", lCageSpot13, TRUE);
            SetLocalInt(oCounter, "triggered", 1);
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eCagegas, GetLocation(oGasspot1), 160.0);
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eCagegas, GetLocation(oGasspot2), 160.0);
        }
      else
        {
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eCagegas, GetLocation(oGasspot1), 160.0);
            ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eCagegas, GetLocation(oGasspot2), 160.0);
        }
}