// Get mean if characters wanna be bad
IfAttacked
  SetTargetToWhoeverAttacked
  IfTargetIsAPlayer
    tmpargument = TEAME
    TargetJoinTeam
  CallForHelp
  
//------------------------------------------------------------------------------
// ZZ> Move around...  Start at state 0
IfTimeOut
  
  //Make sheep sounds
  tmpx = rand & 63
  tmpy = 0
  IfXIsEqualToY
    tmpargument = 0
    PlaySound
    
  // Find shepherd
  IfStateIs0
    tmpargument = [SHEP]
    tmpdistance = BLAHFRIENDS
    SetTargetToNearestBlahID
      SetOwnerToTarget
      tmpargument = 1
      SetState
    tmpargument = 5
    SetTime
   
  //Follow the herd
  IfStateIs1
    SetTargetToOwner
    tmpx = ownerx
    tmpy = ownery
    tmpdistance = 100
    tmpturn = selfturn
    Compass
    tmpturn = targetturnto + 32768
    tmpdistance = 120
    Compass
    SetTargetToNearestFriend
    tmpturn = targetturnto + 32768
    tmpdistance = 70
    Compass
    tmpx = rand & 31 - 16 + tmpx
    tmpy = rand & 31 - 16 + tmpy
    ClearWaypoints
    AddWaypoint
    tmpargument = rand & 31 + 15
    SetTime

//------------------------------------------------------------------------------
//Handle death by sending a message and other stuff
IfKilled
  SetTargetToWhoeverAttacked
  IfTargetIsSelf
    tmpargument = 1
  Else
    tmpargument = 0
  SendMessage

  // Make the character body
  tmpargument = 45
  SetBumpHeight

  tmpargument = [SHEP]
  IssueOrder
  
//------------------------------------------------------------------------------
//Secret easter egg (summon black sheep if all sheep are killed)
IfOrdered
  tmpx = [SHEP]
  tmpy = selforder
  IfXIsEqualToY
    tmpargument = selfcontent + 1
    SetContent
    tmpx = selfcontent
    tmpy = 8                //How many to kill
    IfXIsEqualToY
      tmpargument = 78
      tmpx = selfx
      tmpy = selfy
      tmpdistance = 750 + selfz
      tmpturn = rand
      SpawnExactCharacterXYZ
      
//------------------------------------------------------------------------------
End
//------------------------------------------------------------------------------
