// Check for a kill order
IfOrdered
  tmpx = selforder
  tmpy = [UNDO]
  IfXIsEqualToY
    UndoEnchant

// Undead are sustained by magic
IfSpawned
  MakeCrushValid
  EnchantTarget // target is self...

// Make ping as if it were invincible
IfHealed
  IfStateIs0
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpargument = 4
    SpawnExactParticle
    tmpargument = 1
    SetState
    tmpargument = 20
    SetTime

// Die and poof
IfKilled
  tmpargument = MESSAGEDEATH
  SendMessageNear
  SpawnPoof
  tmpargument = 1
  PlaySound
  tmpargument = [WAKE]
  tmpdistance = [WAKE]
  OrderSpecialID

//What to do if mooshed in a passage
IfCrushed
  tmpargument = MESSAGEDEATH
  SendMessageNear
  SpawnPoof
  tmpargument = 1
  PlaySound
  tmpargument = [WAKE]
  tmpdistance = [WAKE]
  OrderSpecialID
  GoPoof

// Chase good guys
IfTimeOut
  IfTargetIsSelf
    tmpdistance = 128*10
    SetTargetToDistantEnemy
    tmpx = rand & 511 - 256 + selfspawnx
    tmpy = rand & 511 - 256 + selfspawny
  Else
    tmpx = targetdistance
    tmpy = 700
    IfXIsMoreThanY
      SetTargetToSelf
      tmpx = rand & 511 - 256 + selfx
      tmpy = rand & 511 - 256 + selfy
    Else
      tmpx = targetx
      tmpy = targety
      tmpturn = targetturnto
      tmpdistance = 200
      Compass
  ClearWaypoints
  AddWaypoint
  tmpargument = 20
  SetTime
  tmpargument = 0
  SetState

// Find a new target
IfTargetKilled
  SetTargetToSelf
  tmpargument = 0
  SetTime

// Make good guys unable to attack
IfBumped
  IfStateIs0
    SetTargetToWhoeverBumped
    IfTargetIsOnHatedTeam
      tmpargument = [HUMA]
      IfTargetHasID
        tmpargument = 1
        SendMessageNear
        tmpargument = 1
        SetState
        tmpargument = selflevel * 15 + 250     //5 seconds + 0.3 seconds per level
        SetTargetReloadTime
        tmpargument = 40
        SetTime
        tmpargument = 2
        PlaySound
    tmpturn = targetturnto + 32768
    tmpx = selfx
    tmpy = selfy
    tmpdistance = 300
    Compass
    ClearWaypoints
    AddWaypoint
    SetTargetToSelf

// All Done
End
