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

// Chase good guys
IfTimeOut
  IfTargetIsSelf
    tmpdistance = 128*6  // 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
      tmpdistance = 1500
      tmpturn = targetturnto
      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 = 250
        SetTargetReloadTime
        tmpargument = 80
        SetTime
        tmpargument = 2
        PlaySound
        tmpargument = rand & 255 + 768  //3-4 damage
        DamageTarget
    tmpturn = targetturnto + 32768
    tmpx = selfx
    tmpy = selfy
    tmpdistance = 750
    Compass
    ClearWaypoints
    AddWaypoint
    SetTargetToSelf

// All Done
End
