
#include "NW_O2_CONINCLUDE"

void main()
{

  if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
    {
       return;
    }
  object oPC = GetLastUsedBy();
//  object oPC = GetLastOpener();
//  if ( GetIsPC( oPC ) )
//  {
//  effect epolymorph = EffectPolymorph( POLYMORPH_TYPE_PENGUIN );
  effect eLoseBuffs = EffectDispelMagicAll( 200 );
  ActionWait(0.5);
//  ActionCastSpellAtObject(POLYMORPH_TYPE_PENGUIN,oPC);
  ActionCastSpellAtObject(SPELL_DISPEL_MAGIC, oPC);
//  ApplyEffectToObject(DURATION_TYPE_TEMPORARY, epolymorph, oPC, 20.0);
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eLoseBuffs, oPC, 0.0);
  SendMessageToPC(oPC, "As you open the chest, all your buffs are dispelled!");
//  }

// Set respawntime float to the number of seconds.
  float respawntime = 12.00;
//  object oLastOpener = GetLastOpener();
  GenerateHighTreasure(oPC, OBJECT_SELF);
  SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
  ShoutDisturbed();
  // Command added to delay the <span class="highlight">respawn</span>
  AssignCommand( OBJECT_SELF, DelayCommand (respawntime, SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",0) ) );

}
