#include "NW_O2_CONINCLUDE"
void main()
{
    // Set respawntime float to the number of seconds.
    float respawntime = 3600.00;
    if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
    {
       return;
    }
    object oLastOpener = GetLastOpener();
    location llocation = GetLocation(OBJECT_SELF);
//    GenerateHighTreasure(oLastOpener, OBJECT_SELF);

    int nTChance = d20(1);

    if(nTChance == 1) {
      CreateItemOnObject("hairofthedog", OBJECT_SELF, 1);
    }
    if(nTChance == 2) {
      object oStirg1 = CreateObject(OBJECT_TYPE_CREATURE, "wraith001", llocation, FALSE);
      object oStirg2 = CreateObject(OBJECT_TYPE_CREATURE, "wraith001", llocation, FALSE);
      object oStirg3 = CreateObject(OBJECT_TYPE_CREATURE, "wraith001", llocation, FALSE);
      object oStirg4 = CreateObject(OBJECT_TYPE_CREATURE, "wraith001", llocation, FALSE);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance == 3) {
      object oStirg1 = CreateObject(OBJECT_TYPE_CREATURE, "golbone002", llocation, FALSE);
      object oStirg2 = CreateObject(OBJECT_TYPE_CREATURE, "golbone002", llocation, FALSE);
      object oStirg3 = CreateObject(OBJECT_TYPE_CREATURE, "golbone002", llocation, FALSE);
      object oStirg4 = CreateObject(OBJECT_TYPE_CREATURE, "golbone002", llocation, FALSE);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance == 4) {
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance > 4 && nTChance < 8) {
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance > 7 && nTChance < 11) {
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance > 10 && nTChance < 20) {
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
      GenerateHighTreasure(oLastOpener, OBJECT_SELF);
    }
    if(nTChance == 20) {
      int nGenieChance = d20(1);
      if(nGenieChance > 10) {
        object oGenie = CreateObject(OBJECT_TYPE_CREATURE, "agenie", llocation, FALSE);
      } else {
        GenerateHighTreasure(oLastOpener, OBJECT_SELF);
        GenerateHighTreasure(oLastOpener, OBJECT_SELF);
        GenerateHighTreasure(oLastOpener, OBJECT_SELF);
        GenerateHighTreasure(oLastOpener, OBJECT_SELF);
        GenerateHighTreasure(oLastOpener, 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) ) );
    AssignCommand( OBJECT_SELF, DelayCommand(360.0, SetLocked(OBJECT_SELF, TRUE)) );
}


