void main()
{

object oObject = GetFirstObjectInArea();

object oPC=GetEnteringObject();

if (!GetIsPC(oPC))
{
return;
}

if (GetIsDM(oPC))
{
return;
}

 oObject=GetObjectByTag("jw_min32nest_door");

if (GetIsObjectValid(oObject))

{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(10),oObject);


}
int nIdx;

if (GetLocalInt(OBJECT_SELF,"donesetup")!=2)

{
    for (nIdx=1;nIdx<=5;nIdx++)
    {

 ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,ExtraordinaryEffect(EffectAreaOfEffect(AOE_PER_DARKNESS,"jw_empty_script","jw_empty_script","jw_empty_script")),GetLocation(GetObjectByTag("jw_dark_object"+IntToString(nIdx))));

    }

 for (nIdx=1;nIdx<=5;nIdx++)
    {

  ApplyEffectAtLocation(DURATION_TYPE_PERMANENT,EffectAreaOfEffect(AOE_PER_FOGFIRE,"jw_fire_smoke","jw_empty_script","jw_empty_script"),GetLocation(GetObjectByTag("jw_fire_object"+IntToString(nIdx))));

    }


 SetLocalInt(OBJECT_SELF,"donesetup",2);
}


//object oLeaving=GetExitingObject();

//if (!GetIsPC(oLeaving))
//{
//return;
//}

//object oObject = GetFirstObjectInArea();
int nPCinArea=FALSE;
location lLoc;
object oItem;


// first of all, check every object in the area and see if it is a PC.
object oTest=GetFirstPC();




while (GetIsObjectValid(oTest) == TRUE)
       {
        if ((GetArea(oTest) == OBJECT_SELF)&&(!GetIsDM(oTest))&&(oTest!=oPC))
            {
            nPCinArea = TRUE;
             return;
            }
            oTest=GetNextPC();
       }



//location lLoc;

object oGolem;

//oObject=GetFirstObjectInArea();

//while (GetIsObjectValid(oObject))
 // {
  //  if (GetIsPC(oObject)&&oObject!=oPC)
  //    {
  //    nPCinArea = TRUE;
  //    return;
  //    }
  //  oObject=GetNextObjectInArea();
 // }

  ///  this returns true if there are any PCs in the area that are NOT
  /// the object that just entered the area

if (nPCinArea != TRUE)
  {





      if (!GetIsObjectValid(GetObjectByTag("jw_song_urn")))
       {
        CreateObject(OBJECT_TYPE_PLACEABLE,"jw_song_urn",GetLocation(GetWaypointByTag("jw_song_urn_wp")));
       }

SetLocalInt(GetObjectByTag("jw_song_urn"),"active",0);


 if (!GetIsObjectValid(GetObjectByTag("jw_sarc")))
       {
        CreateObject(OBJECT_TYPE_PLACEABLE,"jw_sarc",GetLocation(GetWaypointByTag("jw_sarc_wp")));
       }


 if (!GetIsObjectValid(GetObjectByTag("jw_gridnox")))
       {
        CreateObject(OBJECT_TYPE_CREATURE,"jw_gridnox",GetLocation(GetWaypointByTag("POST_jw_gridnox")));
       }



  }



}