IfSpawned
  // Place the mine tile over the existing tile
  GetContent  // The tile to use
  tmpx = selfx
  tmpy = selfy
  tmpturn = tmpargument // Save for swap
  GetTileXY
  SetContent
  tmpargument = tmpturn
  SetTileXY

// This explodes if it's touched ( may be disarmed )
IfTimeOut
  tmpargument = rand & 3 + 2
  SetTime
  
  SetTargetToNearestLifeform
    tmpx = targetdistance
    tmpy = 64
    IfXIsLessThanY

      // Can they disarm the trap?
      tmpx = 0
      tmpy = 10000  // 50% chance at 23 Dex
      tmpargument = [DISA]
      IfTargetHasSkillID
        tmpx = rand & 8191 + targetdex

      IfXIsLessThanY
        // The trap has exploded
        tmpargument = 0
        IfTargetIsSelf
          tmpargument = 2
        SendMessageNear

        // Spawn the explosion
        tmpx = selfx
        tmpy = selfy
        tmpdistance = selfz
        tmpargument = 0
        SpawnExactParticle

        // Give experience
        tmpargument = 5
        tmpdistance = EXPDARE
        GiveExperienceToTarget

        // Increment the tile
        tmpx = selfx
        tmpy = selfy
        GetTileXY
        tmpargument = tmpargument + 1
        SetTileXY
      Else
        // The trap has been disarmed
        tmpargument = 1
        SendMessageNear

        // Make target crouch
        tmpargument = ACTIONMG
        TargetDoAction

        // Give experience
        tmpargument = 25
        tmpdistance = EXPROLEPLAY
        GiveExperienceToTarget

        // Replace the original tile
        GetContent
        tmpx = selfx
        tmpy = selfy
        SetTileXY

      GoPoof
      
End					// All done
