// Ready for monsters to spawn
IfOrdered
  tmpx = selforder
  tmpy = [SQUI]
  IfXIsEqualToY
    tmpargument = 1
    SetState

IfOrdered
  tmpx = selforder
  tmpy = [RUST]
  IfXIsEqualToY
    tmpargument = 2
    SetState

//Spawn the monster if characters are near
IfTimeOut
  tmpargument = 10
  SetTime
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
    IfTargetIsAPlayer
      IfStateIs1
         
        //Play a falling sound
        tmpargument = 0
        tmpdistance = rand % 2000 + 10000
        PlaySound
           
        GetContent  //Type of monster (Object slot)
            
        //Number 1
        tmpx = selfx
        tmpy = selfy + 100
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ
            
        //Number 2
        tmpx = selfx + 50
        tmpy = selfy
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ
               
        //Number 3
        tmpx = selfx - 50
        tmpy = selfy - 50
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ

        GoPoof

      IfStateIs2
         
        //Play a falling sound
        tmpargument = 0
        tmpdistance = rand % 2000 + 10000
        PlaySound
           
        GetContent  //Type of monster (Object slot)
            
        //Number 1
        tmpx = selfx
        tmpy = selfy + 100
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ
            
        //Number 2
        tmpx = selfx + 50
        tmpy = selfy
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ
               
        //Number 3
        tmpx = selfx + 50
        tmpy = selfy - 50
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ

        //Number 4
        tmpx = selfx - 50
        tmpy = selfy + 50
        tmpdistance = rand % 200 + 1200 
        tmpturn = rand
        SpawnExactCharacterXYZ

        GoPoof
        
    Else
      SetTargetToOldTarget
End					// All done
