tmpx = selfz
tmpy = 0
IfXIsLessThanY
  tmpargument = 10
  SetFlyHeight

//When Spawned
IfSpawned
  tmpargument = 10
  SetFlyHeight					//Randomize Z position

  //Platform near the start (TEAL)
  tmpargument = 1
  IfContentIs
    tmpargument = 0
    tmpx = 44 < 7
    tmpy = 37 < 7
    SetXY

    tmpargument = 1
    tmpx = 49 < 7
    tmpy = 35 < 7
    SetXY

    tmpargument = 2
    tmpx = 51 < 7
    tmpy = 37 < 7
    SetXY

    tmpargument = 3
    SetRedShift

  //Second platform (PINK)
  tmpargument = 2
  IfContentIs
    tmpargument = 0
    tmpx = 51 < 7
    tmpy = 37 < 7
    SetXY

    tmpargument = 1
    tmpx = 57 < 7
    tmpy = 35 < 7
    SetXY

    tmpargument = 2
    tmpx = 56 < 7
    tmpy = 39 < 7
    SetXY

    tmpargument = 3
    SetGreenShift

  //Third platform (YELLOW)
  tmpargument = 3
  IfContentIs
    tmpargument = 0
    tmpx = 50 < 7
    tmpy = 39 < 7
    SetXY

    tmpargument = 1
    tmpx = 51 < 7
    tmpy = 35 < 7
    SetXY

    tmpargument = 2
    tmpx = 54 < 7
    tmpy = 37 < 7
    SetXY

    tmpargument = 3
    SetBlueShift

  //Shortcut (DARK RED)
  tmpargument = 4
  IfContentIs
    tmpargument = 0
    tmpx = 78 < 7
    tmpy = 100 < 7
    SetXY

    tmpargument = 1
    tmpx = 78 < 7
    tmpy = 96 < 7
    SetXY

    tmpargument = 2
    tmpx = 82 < 7
    tmpy = 94 < 7
    SetXY

    tmpargument = 0 - 3
    SetBlueShift
    SetGreenShift

  //Longway to double isle (GREEN)
  tmpargument = 5
  IfContentIs
    tmpargument = 0
    tmpx = 71 < 7
    tmpy = 91 < 7
    SetXY

    tmpargument = 1
    tmpx = 86 < 7
    tmpy = 91 < 7
    SetXY

    tmpargument = 2
    tmpx = 80 < 7
    tmpy = 99 < 7
    SetXY

    tmpargument = 0 - 3
    SetRedShift
    SetBlueShift

  //Final platform (BLUE)
  tmpargument = 6
  IfContentIs
    tmpargument = 0
    tmpx = 84 < 7
    tmpy = 94 < 7
    SetXY

    tmpargument = 1
    tmpx = 89 < 7
    tmpy = 94 < 7
    SetXY

    tmpargument = 2
    tmpx = 89 < 7
    tmpy = 100 < 7
    SetXY

    tmpargument = 0 - 1
    SetRedShift
    SetGreenShift

//Completely random platform AI
tmpargument = 0
IfContentIs
  IfTimeOut
    tmpx = selfspawnx
    tmpy = selfspawny
    ClearWaypoints
    AddWaypoint
    tmpargument = rand % 200
    SetTime

//Prespecified AI
Else
  tmpargument = selfstate
  GetXY
  ClearWaypoints
  AddWaypoint

  IfAtLastWaypoint
    tmpargument = selfstate + 1
    SetState
    IfStateIs3
      tmpargument = 0
      SetState

//Don't get stuck in other platforms
IfBumped
  tmpx = selfcontent
  tmpy = 0            //The key platform doesnt do this, unless the key falls off
  IfXIsMoreThanY
    SetTargetToWhoeverBumped
    tmpargument = [PLAT]
    IfTargetHasID
      tmpargument = rand & 63 + targetz - 32	//Fudge until success!
      SetFlyHeight


// All Done
End
