// ZZ> This function makes the character wanders around its enemy
IfSpawned				// Make it able to be crushed
  MakeCrushValid			  //
IfCrushed
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 4
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  tmpargument = 1
  SendMessageNear
  GoPoof
IfKilled				// This reduces the height of the char
  IfTargetIsOnHatedTeam			  // Final words
    tmpargument = 0			    //
    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 = LATCHLEFT		    // Bite 'em
    PressLatchButton			    //
  Else					  // Scooch around friendly
    tmpx = rand & 1023 + targetx - 512      //
    tmpy = rand & 1023 + targety - 512      //
    ClearWaypoints			    //
    AddWaypoint				    //
    SetTargetToOldTarget		    //
IfTimeOut				// This is done every so often
  SetTargetToNearbyEnemy		  // Look for enemies
    tmpx = rand & 511 - 256 + targetx	    //
    tmpy = rand & 511 - 256 + targety	    //
  Else					  // Wander around home position
    tmpx = rand & 1023 - 512 + selfspawnx   //
    tmpy = rand & 1023 - 512 + selfspawny   //
    
    //Try to find some metal to eat
    tmpargument = [NONE]
    tmpdistance = BLAHITEMS
    SetTargetToWideBlahID
    IfTargetHasVulnerabilityID
      tmpx = targetx
      tmpy = targety
      
  ClearWaypoints
  AddWaypoint
  tmpargument = rand & 63 + 20		  // Wait a while and try again
  SetTime				  //

  //Eat metal stuff
  tmpargument = [RUST]
  IfTargetHasVulnerabilityID
    tmpx = targetdistance
    tmpy = 80
    IfXIsLessThanY
      tmpargument = 2         //Do message first so that AI 'target' isnt poofed
      SendMessage
      PoofTarget
        
        tmpx = selfx
        tmpy = selfy
        tmpdistance = selfz
        tmpargument = 5
        SpawnExactParticle
        
        //Heal 2 life when eating metal
        tmpargument = 512
        HealSelf
        tmpargument = 2
        PlaySound

End					// Finished with this character
