
// 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
  GoPoof

  tmpargument = 1
  SendMessageNear

IfKilled				// This reduces the height of the char
  DropKeys
  IfTargetIsOnHatedTeam			  // Final words
    tmpargument = 0			    //
    SendMessageNear			    //
  tmpargument = 30			  // Dead height
  SetBumpHeight				  //

  //Death sound
  tmpargument = 1			  // Sound
  PlaySound				  //
  tmpargument = 2
  PlaySound
  SendMessageNear
  
  //Victory tune
  tmpargument = 14
  tmpdistance = 0
  PlayMusic
  
  //Awards
  tmpargument = 100
  tmpdistance = EXPQUEST
  GiveExperienceToGoodTeam
  BeatModule
  tmpargument = 3           //TODO: QuestBeaten
  AddQuestAllPlayers
  EnableExport
  
  //End message
  ClearEndMessage
  tmpargument = 3
  AddEndMessage
  tmpargument = 4
  AddEndMessage
  tmpargument = 5
  AddEndMessage
  
  //Bludy death!
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  tmpargument = 4
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  SpawnExactParticle
  GoPoof

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			    //
    
IfTimeOut				// This is done every so often
  SetTargetToWideEnemy		  // Look for enemies
    tmpx = rand & 255 - 128 + targetx	    //
    tmpy = rand & 255 - 128 + targety	    //
    
    //Play the boss music
    tmpargument = 25
    tmpdistance = 500
    PlayMusic
  
  Else					  // Wander around home position
    tmpx = rand & 1023 - 512 + selfspawnx   //
    tmpy = rand & 1023 - 512 + selfspawny   //
    
    
    //Play the normal music
    tmpargument = 11
    tmpdistance = 1500
    PlayMusic
    
  ClearWaypoints			  //
  AddWaypoint				  //
  tmpargument = rand & 31 + 25		  // Wait a while and try again
  SetTime				  //

End					// Finished with this character
