//Make attackers hostile
IfAttacked
  Run
  SetTargetToWhoeverAttacked
  IfTargetIsAPlayer
    CallForHelp
    tmpargument = TEAME
    TargetJoinTeam
  tmpargument = 2               //Combat
  SetState
IfCalledForHelp
  tmpargument = 2               //Combat
  SetState
  Run
IfKilled
  tmpargument = TEAME
  TargetJoinTeam

IfSpawned
  Sneak				//Dont run around
  tmpargument = 1
  SetContent

//------------------------------------------------------------------------------
// 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 % 2047 + selfx - 1000			//Run!
      tmpy = rand % 2047 + selfy - 1000
      ClearWaypoints
      AddWaypoint
    tmpargument = 60
    SetTime

//What to do if bumped
IfStateIs0
  IfBumped
    SetTargetToWhoeverBumped
    IfTargetIsOnSameTeam
      IfTargetIsAPlayer

        //The graveyard man says stuff
        GetContent
        PlayFullSound
        SendMessageNear
        tmpargument = 1
        SetState

        //Activate quest
        tmpargument = 5
        IfContentIs
          // Mark this module as beaten, hidden modules may open up
          tmpargument = [CRYP]
          tmpdistance = 0           //The quest level
          AddQuestAllPlayers        //Add it
        Else
          GetContent
          tmpargument = tmpargument + 1
          SetContent

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

