//------------------------------------------------------------------------------
//STATUE AI
IfSpawned
  tmpargument = 1
  ChangeArmor
  KeepAction
  tmpx = selfspawnx
  tmpy = selfspawny
  ClearWaypoints
  AddWaypoint
  tmpargument = 255
  SetLight

//------------------------------------------------------------------------------
//BOSS AI
tmpargument = 1
IfArmorIs
  IfOrdered
    tmpx = [WIER]           //Become alive?
    tmpy = selforder
    IfXIsEqualToY
      tmpargument = 0
      ChangeArmor
      UnkeepAction
      tmpargument = 254
      SetLight
Else
  // Make a small splash
  IfScoredAHit
    tmpargument = 6
    tmpdistance = GRIPLEFT
    SpawnAttachedParticle

  IfKilled
    // Tell the players
    tmpargument = 1
    IfTargetIsOnHatedTeam
      tmpargument = 0
    SendMessage

    // Make a noise
    tmpargument = 2
    PlaySound

    // Do splash...
    tmpargument = 1
    tmpdistance = 8
    SpawnAttachedParticle
    tmpdistance = 14
    SpawnAttachedParticle
    tmpdistance = 20
    SpawnAttachedParticle
    tmpdistance = 26
    SpawnAttachedParticle
    tmpdistance = 32
    SpawnAttachedParticle
    tmpdistance = 38
    SpawnAttachedParticle
    tmpdistance = 44
    SpawnAttachedParticle
    tmpdistance = 50
    SpawnAttachedParticle
    tmpdistance = 56
    SpawnAttachedParticle
    tmpdistance = 62
    SpawnAttachedParticle
    tmpdistance = 68
    SpawnAttachedParticle
    tmpdistance = 72
    SpawnAttachedParticle

    //Tell the dracolich we are dead
    tmpargument = [BDIE]
    IssueOrder

  IfAttacked
    // Just in case it was in the middle of a throw
    SetTurnModeToWatchTarget

    // Make a noise
    tmpargument = 3
    PlaySound


  IfBumped
    IfStateIs0
      SetTargetToWhoeverBumped
      IfTargetIsOnHatedTeam
        tmpx = targetx
        tmpy = targety
        tmpdistance = 0 - 1000
        tmpturn = rand
        Compass
        tmpargument = 30
        SetTime
        ClearWaypoints
        AddWaypoint
      Else
        tmpx = rand & 255 + targetx - 128
        tmpy = rand & 255 + targety - 128
        ClearWaypoints
        AddWaypoint
        SetTargetToOldTarget



  // Make the bottom fade out
  tmpturn = 0		// Use this intensity
  tmpx = 1200		// Below this height,
  tmpdistance = 255	// Use this intensity
  tmpy = 5000		// Above this height,
  FlashVariableHeight	// Interpolate between



  //Main AI loop
  IfTimeOut

    // Throw the target
    IfStateIs3
      tmpx = 0
      tmpy = 0
      tmpturn = selfturn
      tmpdistance = 50        //speed
      Compass
      AccelerateTarget
      tmpargument = 0
      SetState
      tmpargument = rand & 1023 + 1024  // 4-8 damage
      DamageTarget
      SetTurnModeToWatchTarget

    // Find an enemy
    IfStateIs0
      SetOldTarget
      SetTargetToSelf
      SetTargetToTargetLeftHand
        SetTargetToOldTarget
        // There's an in hand enemy...  Throw 'im
        tmpargument = ACTIONUC
        DoAction
          tmpargument = 3
          SetState
          SetTurnModeToSpin

          // Make a noise
          tmpargument = 1
          PlaySound
      Else
        SetTargetToOldTarget
        // Look for other enemies
        tmpdistance = 128*10
        SetTargetToDistantEnemy
          // Close enough to attack?
          tmpx = targetdistance
          tmpy = 500
          IfXIsLessThanY
            tmpy = 220
            IfXIsMoreThanY
              IfFacingTarget
                // Choose grab or smash...
                tmpx = rand & 7
                tmpy = 5
                IfXIsLessThanY
                  // Grab
                  tmpargument = ACTIONUA
                  DoAction
                    // Make a noise
                    tmpargument = 1
                    PlaySound
                Else
                  // Smash
                  tmpargument = rand & 2 + ACTIONUB
                  DoAction
                    // Make a noise
                    tmpargument = 1
                    PlaySound

                    // Do damage
                    tmpargument = 0
                    tmpdistance = GRIPLEFT
                    SpawnAttachedParticle
        tmpargument = rand & 15 + 10  // Time
        SetTime

      // Follow the enemy
      IfTargetIsOnHatedTeam
        tmpx = targetdistance
        tmpy = 350
        IfXIsLessThanY      //Too close! Get away fast
          tmpx = rand & 1023 + selfspawnx - 512
          tmpy = rand & 1023 + selfspawny - 512
          tmpturn = xyturnto
          tmpdistance = 1500
          tmpargument = 50
        Else
          tmpx = targetx
          tmpy = targety
          tmpdistance = 0 - 350
          tmpturn = targetturnto
        Compass
      Else
        // No enemies around...
        tmpx = selfspawnx
        tmpy = selfspawny
        SetTurnModeToVelocity

      //Throwing something overrides the above
      IfStateIs3
        tmpx = selfx
        tmpy = selfy
        tmpargument = 23 // Time before accel
        SetTime

      ClearWaypoints
      AddWaypoint


// All done
End

  