IfHealed
  // Spawn a defense ping
  IfStateIs0
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpargument = 2
    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 = 2
    SpawnExactParticle
    tmpargument = 1
    SetState
    tmpargument = 20
    SetTime

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


IfKilled
  GoPoof
  tmpargument = 0
  tmpx = selfx + rand & 40
  tmpy = selfy + rand & 40
  SpawnParticle  
  tmpargument = 0
  PlaySound

  //Is it a ghoul inside?
  tmpx = rand & 100
  tmpy = 50
  IfXIsMoreThanY
    tmpargument = 56
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpturn = selfturn
    SpawnExactCharacterXYZ
    tmpargument = 0
    SendMessageNear
    tmpargument = 1
    PlaySound

//Make it destroyable
IfSpawned
  JoinEvilTeam

//Drop items
IfKilled
  DropItems
  DropKeys
  DropMoney


End