// Get mean if characters wanna be bad
IfAttacked
  Run
  CallForHelp
  JoinEvilTeam
  tmpargument = 2
  SetState
IfCalledForHelp
  JoinEvilTeam
  Walk
IfKilled
  CallForHelp			//Warn friends

IfSpawned
  Sneak				//Dont run around

//------------------------------------------------------------------------------
// ZZ> Handle normal state
IfTimeOut
  tmpargument = 150
  SetTime

//WAIT AND TALK
  IfStateIs0
    tmpx = selfspawnx			//Return to where it was spawned
    tmpy = selfspawny
    ClearWaypoints
    AddWaypoint
    SetTargetToNearbyEnemy		//Enemy near, go combat mode
      tmpargument = 2
      SetState
      CallForHelp

  IfStateIs1
    tmpargument = 0
    SetState

//IN COMBAT
  IfStateIs2
    SetTargetToNearbyEnemy
      IfFacingTarget			//Attack enemy?
        tmpx = targetdistance
        tmpy = 100
        IfXIsLessThanY
          tmpargument = LATCHRIGHT
          PressLatchButton
      Else
        tmpx = targetx			//Get in combat position
        tmpy = targety
        tmpturn = targetturnto
        tmpdistance = 200
        Compass
        ClearWaypoints
        AddWaypoint
    Else
      tmpx = rand & 2023 + selfx - 1000			//Run!
      tmpy = rand & 2023 + selfy - 1000	
      ClearWaypoints
      AddWaypoint
    tmpargument = 60
    SetTime

//What to do if bumped
IfBumped
  SetTargetToWhoeverBumped
  IfTargetIsOnHatedTeam
    DoNothing
  Else
    IfStateIs0
      IfTargetIsAPlayer

        tmpargument = rand % 3 + 1
        PlaySound

        //The graveyard man
        GetContent
        tmpx = tmpargument
        tmpy = 6
        IfXIsLessThanY
          SendMessageNear
          tmpx = tmpargument
          tmpy = 5
          IfXIsLessThanY
            tmpargument = tmpargument +1
            SetContent
          tmpargument = 1
          SetState
          
          //Activate quest
          tmpargument = 5
          IfContentIs
            tmpargument = [CRYP]
            IssueOrder

//------------------------------------------------------------------------------
End
//------------------------------------------------------------------------------

