//------------------------------------------------------------------------------
// This function makes the character recognize a master
IfSpawned
  MakeCrushValid
  SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOwnerToTarget
      JoinTargetTeam
      MakeNameKnown
      
//------------------------------------------------------------------------------
//Say hello
IfGrabbed
  MakeCrushInvalid
  IfNameIsKnown
    SetTargetToWhoeverIsHolding
    IfTargetIsAPlayer
      SetOldTarget
      SetTargetToOwner
      IfTargetIsOldTarget
        tmpargument = 5             //ello' boss
      Else
        tmpargument = 6             //You're not the boss!
      SendMessageNear
  Else
    SetTargetToWhoeverIsHolding     //New boss =)
    IfTargetIsAPlayer
      SetOwnerToTarget
      JoinTargetTeam
      MakeNameKnown
      tmpargument = 3
      SendMessageNear
      tmpargument = 4
      SendMessageNear
      
//------------------------------------------------------------------------------
IfDropped
  SetTargetToSelf
  StopTargetMovement
  UnkeepAction
IfUsed
  SetTargetToWhoeverIsHolding
  tmpargument = 25
  SetTargetReloadTime
  IfTargetIsAPlayer
    // =name=
    SetTargetToSelf
    tmpargument = 7
    SendMessageNear

    // Level
    tmpx = targetlevel
    tmpy = 2
    IfXIsMoreThanY
      tmpx = 2
    tmpargument = 8 + tmpx
    SendMessageNear

    // Stats
    tmpx = targetlife > 9
    tmpy = 2
    IfXIsMoreThanY
      tmpx = 3
    tmpargument = 12 + tmpx
    tmpx = selfstr > 8
    tmpy = selfwis > 8
    SendMessageNear

    // Stats
    tmpx = selfint > 8
    tmpy = selfdex > 8
    tmpdistance = targetexp
    tmpargument = 16
    SendMessageNear
    
IfCrushed
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 1
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof
  tmpargument = 2
  SendMessageNear
IfCleanedUp				// Respawn
  IfTargetIsAlive			  // Make sure killer is away
    tmpx = 1100				    //
    tmpy = targetdistance		    //
    IfXIsLessThanY			    //
      RespawnCharacter			      //
  Else					  // Killer is far away
    RespawnCharacter			    //

IfKilled				// This reduces the height of the char
  IfNameIsKnown
    SetOldTarget
    SetTargetToOwner
    IfTargetIsAlive
      tmpargument = 0
      SendMessageNear
    SetTargetToOldTarget
  Else
    tmpargument = 1
    SendMessageNear
  
  tmpargument = 30			  // Dead height
  SetBumpHeight				  //
  tmpargument = 1			  // Sound
  PlaySound				  //
  
IfAttacked				// Don't take kindly to attackers
  SetTargetToWhoeverAttacked		  //
    tmpargument = 0			    // Sound
    PlaySound				    //
    
IfBumped				// Attack whoever it bumped
  SetTargetToWhoeverBumped		  //
  IfTargetIsOnHatedTeam			  // Make sure it's an enemy
    tmpargument = ACTIONUA		    // Bite 'em
    DoAction			    //
  tmpx = rand & 1023 + targetx - 512      //
  tmpy = rand & 1023 + targety - 512      //
  ClearWaypoints			    //
  AddWaypoint				    //
  SetTargetToOldTarget		    //
    
IfTimeOut				// This is done every so often
  tmpargument = rand & 15 + 30
  SetTime

  IfHeld
    // Don't bother moving around if held
    DoNothing
  Else
    SetTargetToOwner
    IfTargetIsSelf
      tmpx = rand & 1023 - 512 + selfx
      tmpy = rand & 1023 - 512 + selfy
    Else
      SetTargetToNearbyEnemy
        tmpargument = 15
        SetTime
        tmpx = targetx	    //
        tmpy = targety	    //
        tmpturn = targetturnto
        tmpdistance = 600
        Compass
      Else       
        // No enemies around, so follow owner
        tmpx = rand & 1023 - 512 + ownerx   //
        tmpy = rand & 1023 - 512 + ownery   //
    ClearWaypoints			  //
    AddWaypoint				  //
End					// Finished with this character
