// ZZ> This function makes the character wanders around its enemy
IfKilled				// This reduces the height of the char
  tmpargument = 40			  //
  SetBumpSize				  //
  tmpargument = 45			  //
  SetBumpHeight				  //
  tmpargument = 65535			  // Drop money
  DropMoney				  //
  tmpargument = 0			  //
  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

  // Fix the end text
  ClearEndMessage
  tmpargument = 2
  AddEndMessage
  tmpargument = 3
  AddEndMessage
  tmpargument = 4
  AddEndMessage
  tmpargument = 5
  AddEndMessage

  //Victory tune
  tmpargument = 14
  tmpdistance = 0
  PlayMusic


//  PlaySound				  //
IfAttacked				// Counter attack
  SetTargetToWhoeverAttacked		  //
    IfTargetIsOnHatedTeam		    //
      BecomeLeader			      //
      tmpargument = 1			      // Enter combat mode
      SetState				      //
      SetTurnModeToWatchTarget
    Else				    //
      SetTargetToOldTarget		      //
  tmpargument = rand & 1 + 1		  //
  PlaySound

				  //
IfTargetKilled				// Return to watch 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				  //
  
  //Boss music
  IfKilled
    DoNothing
  Else
    SetTargetToWideEnemy
      tmpargument = 6
      tmpdistance = 0
      PlayMusic
End					// Finished with this character
