// This pops some ghouls in a given area, if the detection area is blocked


//!!!BAD!!!
//IfSpawned
//  tmpargument = passage
//  tmpdistance = 220
//  FlashPassage
//  tmpargument = passage + 1
//  tmpdistance = 255
//  FlashPassage
//!!!BAD!!!


IfTimeOut
  // Check the detection passage...
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
    IfTargetIsOnHatedTeam
      // Little music blurb
      tmpargument = 0
      tmpdistance = 11025
      PlayFullSound


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


      // Pop another
      tmpargument = passage + 1
      tmpdistance = 60
      FindTileInPassage
        // Replace the tile
        tmpargument = 61
        SetTileXY
        // Spawn a ghoul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride


      // Pop another
      tmpargument = passage + 1
      tmpdistance = 60
      FindTileInPassage
        // Replace the tile
        tmpargument = 61
        SetTileXY
        // Spawn a ghoul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride


      // Pop another
      tmpargument = passage + 1
      tmpdistance = 60
      FindTileInPassage
        // Replace the tile
        tmpargument = 61
        SetTileXY
        // Spawn a ghoul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride


      // Pop another
      tmpargument = passage + 1
      tmpdistance = 60
      FindTileInPassage
        // Replace the tile
        tmpargument = 61
        SetTileXY
        // Spawn a ghoul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride


      // Pop another
      tmpargument = passage + 1
      tmpdistance = 60
      FindTileInPassage
        // Replace the tile
        tmpargument = 61
        SetTileXY
        // Spawn a ghoul
        tmpargument = 98
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Popper is no longer needed...
      GoPoof


  // Wait a bit before checking again
  tmpargument = 10
  SetTime
End					// All done
