// 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
  tmpdistance = 22050
  PlaySound
  tmpargument = [WAKE]
  tmpdistance = [WAKE]
  OrderSpecialID
IfCrushed
  tmpargument = MESSAGEDEATH
  SendMessageNear
  SpawnPoof
  tmpargument = 1
  tmpdistance = 22050
  PlaySound
  tmpargument = [WAKE]
  tmpdistance = [WAKE]
  OrderSpecialID


// Chase good guys
IfTimeOut
  IfTargetIsSelf
    tmpdistance = 90000  // Square of range
    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
  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 = 250
        SetTargetReloadTime
        tmpargument = 40
        SetTime
        tmpargument = 2
        tmpdistance = 30870
        PlaySound
    tmpturn = targetturnto + 32768
    tmpx = selfx
    tmpy = selfy
    tmpdistance = 300
    Compass
    ClearWaypoints
    AddWaypoint
    SetTargetToSelf


// All Done
End
