//------------------------------------------------------------------------------
// ZZ> Mimics have an enchantment sustaining them
IfSpawned
  EnchantTarget  // Enchant self...


//------------------------------------------------------------------------------
// ZZ> Someone cast an unlock spell
IfOrdered
  tmpx = selforder
  tmpy = 491  // The unique code for an unlock order
  IfXIsEqualToY
    // Die
    SetTargetToSelf
    KillTarget
    tmpargument = 3
    SendMessageNear

//------------------------------------------------------------------------------
// ZZ> This function makes the character wait for the enemy to open it
IfBumped				// Attack whoever it bumped
  SetTargetToWhoeverBumped		  //
  IfTargetIsOnHatedTeam			  // Make sure it's an enemy
    tmpargument = 0			    //
    IfStateIs				    // Enter combat mode
      IfTargetIsAPlayer			      // Advice
        tmpargument = 1			        //
        SendMessageNear			        //
      SetState				      // Combat
    tmpargument = 1			    // Attack Left = 1
    PressLatchButton			    //


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

  tmpargument = 0			    //
  SendMessageNear			    // Kill message
  GetBumpHeight				  //
  tmpargument = tmpargument / 2	  //
  SetBumpHeight				  //
  tmpargument = selfmoney			  // Drop money
  DropMoney				  //
  DropItems

IfTargetKilled				// Check for more food
  tmpargument = 0			  //
  SetTargetToNearbyEnemy		  // Get the other enemy
    tmpargument = 1			    //
  SetState				  //

IfAttacked				// Retaliation
  tmpargument = 0
  PlaySound
  SetTargetToWhoeverAttacked		  // Get the enemy
    tmpargument = 0			    //
    IfStateIs				    // Enter combat mode
      tmpargument = 1			      //
      SetState				      //
      IfTargetIsAPlayer			      //
        tmpargument = 2			        //
        SendMessageNear			        // Advice

IfTimeOut				// This is done every so often
  tmpargument = 0			  //
  IfStateIs				  // State 0 ( Lurk )
    tmpx = selfx			    //
    tmpy = selfy			    //
  Else					  // State 1 ( Combat )
    tmpx = 2000				    // Too far?
    tmpy = targetdistance		    //
    IfXIsLessThanY			    //
      SetState				      // Revert to lurk mode
    tmpx = tmpy				    // In attack range?
    tmpy = 250				    //
    IfXIsLessThanY			    // Stick and move
      tmpargument = 2
      PlaySound

      tmpargument = 1			      // Attack Left = 1
      PressLatchButton			      //
      tmpx = rand & 511 - 256 + targetx	      //
      tmpy = rand & 511 - 256 + targety	      //
    Else				    // Get closer
      tmpargument = 1
      PlaySound

      tmpx = targetx			      //
      tmpy = targety			      //
      tmpturn = targetturnto		      //
      tmpdistance = 200			      //
      Compass				      //
  ClearWaypoints			  //
  AddWaypoint				  //
  tmpargument = rand & 31 + 20		  // Wait a while and try again
  SetTime				  //

//------------------------------------------------------------------------------
// Finished with this character
End
