//This spawns the portal in the beginning and starts the music
IfSpawned
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 0
  SpawnExactParticle

  tmpargument = 18
  tmpdistance = 0
  PlayMusic
  
// This pops some ghuuls in a given area, if the detection area is blocked
IfTimeOut
  // Check the detection passage...
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
    IfTargetIsOnHatedTeam
      // Little music blurb
      tmpargument = 1
      PlayFullSound

      // Pop the baddies
      tmpargument = passage + 1	// The passage to spawn
      tmpdistance = 244		// The tile to find
      tmpx = 0			// Needed for first call
      tmpy = 0			// Needed for first call
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = passage + 1
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = passage + 1
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = passage + 1
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = passage + 1
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = passage + 1
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghuul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 6
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride
          tmpargument = 0
          SetTileXY

      // Popper is no longer needed...
      GoPoof

  // Wait a bit before checking again
  tmpargument = 10
  SetTime

End					// All done
