IfKilled
  IfTargetIsSelf
    tmpargument = 2     //Sucide!
  Else
    tmpargument = 0     //Slain
  SendMessageNear
  tmpargument = 40
  SetBumpHeight
  tmpargument = 1
  PlaySound

IfAttacked
  SetTargetToWhoeverAttacked
    tmpargument = 0
    PlaySound

IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsOnHatedTeam
    IfFacingTarget
      tmpargument = LATCHLEFT
      PressLatchButton
  Else
    tmpx = rand & 1023 - 512 + selfx
    tmpy = rand & 1023 - 512 + selfy
    ClearWaypoints
    AddWaypoint
    SetTargetToOldTarget

// Look for enemies
IfTimeOut
  SetTargetToWideEnemy
    IfFacingTarget
      tmpx = targetdistance
      tmpy = 800
      IfXIsLessThanY
        tmpx = selfaccel
        tmpy = 1
        IfXIsMoreThanY
          tmpargument = LATCHJUMP
          PressLatchButton
          
          //This makes the tranch jump forward
          tmpx = 0
          tmpy = 0
          tmpturn = targetturnto
          tmpdistance = 25
          Compass
          SetOldTarget
          SetTargetToSelf
          AccelerateTarget
          SetTargetToOldTarget
          
          //Damage particle
          tmpargument = 5
          tmpdistance = GRIPLEFT
          SpawnAttachedParticle

          // Play the sound
          tmpargument = 2
          PlaySound
      tmpx = targetx
      tmpy = targety
    Else
      tmpx = selfx
      tmpy = selfy
      tmpturn = selfturn
      tmpdistance = 500
      Compass
      tmpx = tmpx + targetx + targetx + targetx > 2
      tmpy = tmpy + targety + targety + targety > 2
    ClearWaypoints
    AddWaypoint
    
  Else      // Move towards the shrine
    tmpx = 32*128
    tmpy = 30*128
    ClearWaypoints
    AddWaypoint
  tmpargument = rand & 31 + 25
  SetTime

// All done
End
