//Play the default module music track
IfSpawned
  tmpargument = 12
  tmpdistance = 0
  PlayMusic
  
  tmpargument = 0
  SetState
  
IfTimeOut
  tmpargument = rand & 7 + 15
  SetTime

  //Activate Chess game  
  tmpargument = 0
  IfContentIs
    tmpargument = 2
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        tmpargument = [CHES]
        tmpdistance = [CHES]
        OrderSpecialID
        tmpargument = 1   //Dont repeat
        SetContent
      
  //Open final door
  tmpargument = 21
  tmpdistance = [KEYS]
  SetTargetToPassageID
    tmpargument = [KEYS]
    CostTargetItemID
      tmpargument = 20
      OpenPassage
      
  //Close door and declear next challenge (DEFENSE)
  tmpx = selfstate
  tmpy = 1
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 0
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (CHESS)
  tmpx = selfstate
  tmpy = 5
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = selfstate + 1
        ClosePassage
        tmpargument = 1
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (MEMORY)
  tmpx = selfstate
  tmpy = 9
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 2
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (MIRROR)
  tmpx = selfstate
  tmpy = 11
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 3
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (WIT)
  tmpx = selfstate
  tmpy = 13
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 4
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (COMBAT)
  tmpx = selfstate
  tmpy = 15
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 5
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
        
  //Close door and declear next challenge (MAGIC)
  tmpx = selfstate
  tmpy = 18
  IfXIsLessThanY
    tmpargument = tmpy
    SetTargetToWhoeverIsInPassage
      IfTargetIsAPlayer
        SetState                   //dont repeat
        tmpargument = selfstate - 1
        ClosePassage
        tmpargument = 6
        SendMessage
        PlayFullSound
  Else
    tmpargument = tmpy - 1
    ClosePassage
  
End					// All done
