//This object is a tool controlled by setting its content value to a specified number.
//(Set in spawn.txt). Object is module specified and must be modified to be used
//elsewhere...
//Content commands:
//0 = play music
//Module Setting: Catacombs

//------------------------------------------------------------------------------------
//Play Music
IfSpawned
  tmpargument = 14
  tmpdistance = 0
  PlayMusic

//Music when they enter the real dungeon
IfSpawned
  tmpdistance = 10
  tmpargument = 3
  SetMusicPassage

//Enable deadfall pits
IfSpawned
  PitsKill

// This pops some ghouls in a given area, if the detection area is blocked
IfTimeOut
  // Check the detection passage...
  tmpargument = 12
  SetTargetToWhoeverIsInPassage
    IfTargetIsOnHatedTeam
      // Little music blurb
      tmpargument = 0
      PlayFullSound

      // Pop the baddies
      tmpargument = 13		// 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 ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = 13
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = 13
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = 13
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = 13
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Pop another
      tmpargument = 13
      tmpdistance = 244
      FindTileInPassage
        // Replace the tile
        tmpargument = 246
        SetTileXY
        // Spawn a ghoul
        tmpargument = 66
        tmpdistance = 0
        tmpturn = rand
        SpawnExactCharacterXYZ
          tmpargument = 0
          SpawnExactParticle
          tmpargument = ACTIONJB
          ChildDoActionOverride

      // Popper is no longer needed...
      GoPoof

  // Wait a bit before checking again
  tmpargument = rand & 7 + 10
  SetTime

//------------------------------------------------------------------------------------
End					// All done
//------------------------------------------------------------------------------------
