#include "spawner"
void main()
{
object oPC = GetLastOpenedBy();
object oMod = GetModule();
object oItem;
object oArea = GetArea(OBJECT_SELF);
location iLocation;
int oCount = 0;
int oComplete2 = GetLocalInt(oMod, "d2_complete");
int oComplete2a = GetLocalInt(oMod, "d2a_complete");
int oComplete5 = GetLocalInt(oMod, "d5_complete");
MusicBackgroundStop(oArea);
oItem = GetFirstItemInInventory(OBJECT_SELF);
    while (GetIsObjectValid(oItem))
      {
       ++oCount;
       oItem = GetNextItemInInventory(OBJECT_SELF);
       }
   if (oCount==0)
   {
   iLocation = GetLocation(OBJECT_SELF);
   ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
   EffectVisualEffect(VFX_FNF_MYSTICAL_EXPLOSION),
   GetLocation(OBJECT_SELF));
   DestroyObject(OBJECT_SELF, 0.2);
   SetLocalInt(oMod, "chest1", 1);
   if (oComplete2==1)
   {SetLocalInt(oMod, "chest2", 1);}
   if (oComplete2a==1)
   {SetLocalInt(oMod, "chest3", 1);}
   if (oComplete5==1)
   {SetLocalInt(oMod, "chest4", 1);}
   SetLocalInt(oMod, "chest_here", 0);
   SetLocked(GetObjectByTag("arena_gate"), FALSE);
   SetLocalInt(oPC, "gate_locked", 0);
   SetLocalInt(oMod, "challenge", 0);
   SetLocalInt(oMod, "d1", 0);
   SetLocalInt(oMod, "d2", 0);
   SetLocalInt(oMod, "d2a", 0);
   SetLocalInt(oMod, "d3", 0);
   SetLocalInt(oMod, "d4", 0);
   SetLocalInt(oMod, "d5", 0);
   }
   else
   {
   PlaySound("sim_cntresist");
   FloatingTextStringOnCreature("You must loot this chest before you can continue", oPC);
   }
}