//Uniqe order for monster drops for Ice Palace!
IfKilled
  tmpargument = [SQUI]
  IssueOrder

//------------------------------------------------------------------------------
// ZZ> Set up when spawned
IfSpawned
  tmpargument = 8  // sleeping
  SetState
  //AddStat
//------------------------------------------------------------------------------
// ZZ> Shhh.... I'm sleeping
IfStateIs8
  IfTimeOut
    tmpargument = ACTIONMK
    DoAction   
    KeepAction

    // Sleepy Z's
    tmpx = selfx
    tmpy = selfy
    tmpdistance = selfz
    tmpargument = 6
    SpawnExactParticle

    // Snore...
    tmpargument = rand & 3 + 4
    tmpdistance = rand & 2047 + 15000
    PlaySound
    tmpargument = 100
    SetTime

    tmpdistance = 640000
    SetTargetToDistantEnemy
      IfTargetIsSneaking
        //don't wake up
      Else
        tmpargument = 1
        SetState
        UnkeepAction
        tmpargument = 1
        SendMessage
        tmpargument = 50
        SetTime


//------------------------------------------------------------------------------
// ZZ> Attack enemy
IfBumped				// Attack whoever it bumped
  SetTargetToWhoeverBumped		  //
  IfTargetIsOnHatedTeam			  // Make sure it's an enemy
    tmpargument = LATCHLEFT		    // Bite 'em
    PressLatchButton			    //
  tmpargument = [RUST]
  IfTargetHasID
    tmpargument = 512
    HealSelf  
IfScoredAHit
  SetTargetToWhoeverWasHit
    SetTargetToTargetLeftHand           //Look for Metal to eat
      tmpargument = [RUST]
      IfTargetHasVulnerabilityID
        tmpargument = 3
        SendMessage
        PoofTarget
        tmpx = selfx
        tmpy = selfy
        tmpdistance = selfz
        tmpargument = 5
        SpawnExactParticle
      Else
        SetTargetToOldTarget
        SetTargetToTargetRightHand
          tmpargument = [RUST]
          IfTargetHasVulnerabilityID
            tmpargument = 3
            SendMessage
            PoofTarget
            tmpx = selfx
            tmpy = selfy
            tmpdistance = selfz
            tmpargument = 5
            SpawnExactParticle
    Else
      SetTargetToOldTarget
      SetTargetToTargetRightHand
        tmpargument = [RUST]
        IfTargetHasVulnerabilityID
          tmpargument = 3
          SendMessage
          PoofTarget
          tmpx = selfx
          tmpy = selfy
          tmpdistance = selfz
          tmpargument = 5
          SpawnExactParticle
    SetTargetToOldTarget

IfAttacked
  SetTargetToNearbyEnemy
    tmpargument = rand & 5
    tmpx = tmpargument
    tmpy = 2
    IfXIsLessThanY
      SetTargetToTargetLeftHand           //Look for Metal to eat
        tmpargument = [RUST]
        IfTargetHasVulnerabilityID
          tmpargument = 3
          SendMessage
          PoofTarget
          tmpx = selfx
          tmpy = selfy
          tmpdistance = selfz
          tmpargument = 5
          SpawnExactParticle
        Else
          SetTargetToOldTarget
          SetTargetToTargetRightHand
            tmpargument = [RUST]
            IfTargetHasVulnerabilityID
              tmpargument = 3
              SendMessage
              PoofTarget
              tmpx = selfx
              tmpy = selfy
              tmpdistance = selfz
              tmpargument = 5
              SpawnExactParticle
      Else
        SetTargetToOldTarget
        SetTargetToTargetRightHand
          tmpargument = [RUST]
          IfTargetHasVulnerabilityID
            tmpargument = 3
            SendMessage
            PoofTarget
            tmpx = selfx
            tmpy = selfy
            tmpdistance = selfz
            tmpargument = 5
            SpawnExactParticle
      SetTargetToOldTarget
  tmpturn = selfturn + 32768
  tmpdistance = 500
  tmpx = selfx
  tmpy = selfy
  Compass
  ClearWaypoints
  AddWaypoint

//------------------------------------------------------------------------------
//Death
IfKilled
  tmpargument = 34
  SetBumpHeight
  IfTargetIsOnHatedTeam
    tmpargument = 0
    SendMessageNear


//------------------------------------------------------------------------------
// ZZ> Handle wandering around
IfStateIs1
  // Wander around
  IfTimeOut				// This is done every so often
    tmpdistance = 640000
    SetTargetToDistantEnemy
      tmpx = rand & 511 - 256 + targetx	    //
      tmpy = rand & 511 - 256 + targety	    //
      tmpargument = rand & 64 + 50		  // Wait a while and try again
    Else					  // Wander around home position
      tmpx = rand & 1023 - 512 + selfspawnx   //
      tmpy = rand & 1023 - 512 + selfspawny   //
      tmpargument = rand & 20 + 10		  // Wait a while and try again
    ClearWaypoints			  //
    AddWaypoint				  //
    SetTime				  //



//------------------------------------------------------------------------------
End
//------------------------------------------------------------------------------
