IfHealed
  // Spawn a defense ping
  IfStateIs0
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpargument = 0
    SpawnExactParticle
    tmpargument = 1
    SetState
    tmpargument = 20
    SetTime

IfAttacked
  // Must die in 1 hit to disallow punching it open
  tmpargument = 512
  HealSelf
  // Spawn a defense ping
  IfStateIs0
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpargument = 0
    SpawnExactParticle
    tmpargument = 1
    SetState
    tmpargument = 20
    SetTime

IfTimeOut
  // Ready the pings
  tmpargument = 0
  SetState
  tmpargument = 500
  SetTime

IfKilled
  // Smash open
  tmpargument = [GOOD]
  IfTargetHasSpecialID
    tmpargument = 20
    tmpdistance = EXPROLEPLAY
    GiveExperienceToTarget
    tmpturn = 0
  Else
    tmpturn = 1

  // Check for passages to open
  tmpx = passage
  tmpy = 0
  IfXIsEqualToY
    // Play the break sound
    tmpargument = 2
    tmpdistance = rand & 1023 + 10500
    PlaySound
  Else
    tmpargument = tmpx
    OpenPassage
    // Play the secret music
    tmpargument = 1
    tmpdistance = 11025
    PlaySound
    // Give experience
    tmpargument = 20
    tmpdistance = EXPSECRET
    GiveExperienceToTarget
    tmpturn = 2
  tmpargument = tmpturn
  SendMessageNear

  // Drop goodies
  DropItems
  tmpargument = 65535
  DropMoney

  // Replace self with an imposter...
  tmpargument = 48
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpturn = selfturn
  SpawnExactCharacterXYZ
  GoPoof
End
