// ZZ> This function makes the character wanders around its enemy
IfKilled				// This reduces the height of the char
  tmpargument = 0			    //
  SendMessageNear			    //
  tmpargument = 40			  //
  SetBumpSize				  //
  tmpargument = 45			  //
  SetBumpHeight				  //
  tmpargument = 65535			  // Drop money
  DropMoney				  //
  tmpargument = 0			  //
  tmpdistance = rand & 2047 + 10000	  //
  PlaySound
  SpawnPoof

// ZZ> Death and let the player team win
IfKilled
  tmpargument = 35
  SetBumpHeight
  IfTargetIsOnHatedTeam
    tmpargument = 0
    SendMessageNear


  // Award quest experience
  tmpargument = 100
  tmpdistance = EXPQUEST
  GiveExperienceToTargetTeam


  // Finish it up
  BeatModule
  EnableExport
  // Mark this module as beaten, hidden modules may open up
  tmpargument = [BEAT]
  AddIDSZ
  // Fix the end text
  ClearEndMessage
  tmpargument = 2
  AddEndMessage
  tmpargument = 3
  AddEndMessage
  tmpargument = 4
  AddEndMessage
  tmpargument = 5
  AddEndMessage


//  PlaySound				  //
IfAttacked				// Counter attack
  SetTargetToWhoeverAttacked		  //
    IfTargetIsOnHatedTeam		    //
      BecomeLeader			      //
      tmpargument = 1			      // Enter combat mode
      SetState				      //
    Else				    //
      SetTargetToOldTarget		      //
  tmpargument = rand & 1		  //
  tmpdistance = rand & 4095 + 8000	  //
//  PlaySound				  //
IfTargetKilled				// Return to follow mode
  tmpargument = 0			  //
  SetState				  //
IfBumped				// Attack whoever it bumped
  SetTargetToWhoeverBumped		  //
  IfTargetIsOnHatedTeam			  // Make sure it's an enemy
    IfHoldingMeleeWeapon                    // Got Weapon?
      PressLatchButton			      //
  Else					  // Scooch around friendly
    tmpx = rand & 255 + targetx - 128	    //
    tmpy = rand & 255 + targety - 128	    //
    ClearWaypoints			    //
    AddWaypoint				    //
    SetTargetToOldTarget		    //
IfTimeOut				// This is done every so often
  IfStateIs0
    tmpx = selfx
    tmpy = selfy
    SetTargetToNearestEnemy
      IfFacingTarget
        SetTurnModeToWatchTarget
        tmpargument = 1
        SetState
      Else
        SetTurnModeToSpin
  IfStateIs1
    tmpx = targetdistance
    tmpy = 1000
    IfXIsLessThanY
      tmpx = targetx
      tmpy = targety
    Else
      tmpx = selfx
      tmpy = selfy
      tmpargument = 0
      SetState
  ClearWaypoints			  //
  AddWaypoint				  //
  tmpargument = rand & 15 + 30		  // Wait a while and try again
  SetTime				  //
End					// Finished with this character
