IfKilled				// This reduces the height of the char
  tmpargument = 1
  PlaySound

  tmpargument = 0			  // Last words...
  SetState				  //
  SendMessageNear
  DropMoney				  //
  tmpargument = 45			  //
  SetBumpHeight				  //

IfTimeOut				// This is done every so often
  tmpargument = rand & 15 + 15		  // Try again later
  SetTime				  //

  SetTargetToNearestFriend
    IfTargetIsHurt
      tmpargument = 2
      SetState

  //Helper
  IfStateIs2				  // State 2 ( Helper )
    IfTargetIsHurt			    // Heal wounded
      tmpx = targetx
      tmpy = targety
      ClearWaypoints			  //
      AddWaypoint				  //
      tmpx = targetdistance		      //
      tmpy = 300			      //
      IfXIsLessThanY			      // In Range?
        tmpx = 260			        //
        tmpy = selfmana			        //
        IfXIsLessThanY				// Enough to cast?
          IfFacingTarget
            tmpargument = LATCHLEFT	          // Left Attack == 1
            PressLatchButton		          //
        Else					// Do something else
          tmpargument = 0		          //
          SetState			          //
    Else				    // Switch to follow
      tmpargument = 0			      //
      SetState				      //
    tmpx = targetx			    //
    tmpy = targety			    //
  Else					  // Find someone to bash
    SetTargetToWideEnemy
      tmpargument = 1
      SetState

  //Wander
  IfStateIs0
    tmpx = rand & 511 + selfspawnx - 256			   
    tmpy = rand & 511 + selfspawny - 256			    

  //Attack
  IfStateIs1				  // State 1 ( Combat )
    tmpx = targetdistance		    // Close enough to attack?
    tmpy = 200				    //
    IfXIsLessThanY			    //
      tmpargument = LATCHRIGHT    // Right Attack == 2
      PressLatchButton			      //
    tmpy = 700
    IfXIsMoreThanY
      tmpargument = 0
      SetState
    tmpx = targetx			    // Move towards enemy
    tmpy = targety			    //
    tmpturn = targetturnto		    //
    tmpdistance = 200			    //
    Compass				    //
  ClearWaypoints			  //
  AddWaypoint				  //

IfAttacked				// Counter attack if not healing
  SetTargetToWhoeverAttacked		    //
    IfTargetIsAlive			      //
      IfTargetIsOnHatedTeam		        // Go get 'em
        tmpargument = 1		          //
        SetState			          //
        tmpargument = rand & 1 + 2
        PlaySound
    Else				      // Attacker dead already
      SetTargetToOldTarget		        //

IfBumped				// Bumped
  SetTargetToWhoeverBumped		  //
  IfTargetIsHurt			  //
    IfTargetIsOnOtherTeam		    // Revert
      SetTargetToOldTarget		      //
    Else				    // Heal 'em
      tmpargument = 2			      // State 2 ( Helper )
      SetState				      //
  Else					  // Revert
    SetTargetToOldTarget		    //
  tmpx = rand&511+selfx-256		  //
  tmpy = rand&511+selfy-256		  //
  ClearWaypoints			  //
  AddWaypoint				  //
  tmpargument = 40			  // Try again soon
  SetTime				  //

IfTargetKilled				// Mode switch
  tmpargument = 0			  // Return to follow mode
  SetState				  //

// Heal effect
IfUsed
  tmpargument = 50
  SetReloadTime
  IfTargetIsOnSameTeam
    tmpx = targetx
    tmpy = targety
    tmpdistance = targetz
    tmpargument = 0
    SpawnExactParticle

    tmpargument = rand & 511 + 1024
    HealTarget

End					// Finished with this character
