tmpx = selfz
tmpy = 0
IfXIsLessThanY
  tmpargument = 40
  SetFlyHeight

//When Spawned
IfSpawned
  tmpargument = rand & 75 + 40
  SetFlyHeight					//Randomize Z position

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

    tmpargument = 1
    tmpx = 69 < 7
    tmpy = 102 < 7
    SetXY

    tmpargument = 2
    tmpx = 74 < 7
    tmpy = 106 < 7
    SetXY

    tmpargument = 3
    SetRedShift

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

    tmpargument = 1
    tmpx = 75 < 7
    tmpy = 100 < 7
    SetXY

    tmpargument = 2
    tmpx = 78 < 7
    tmpy = 105 < 7
    SetXY

    tmpargument = 3
    SetGreenShift

  //From small isle (YELLOW)
  tmpargument = 3
  IfContentIs
    tmpargument = 0
    tmpx = 78 < 7
    tmpy = 105 < 7
    SetXY

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

    tmpargument = 2
    tmpx = 78 < 7
    tmpy = 98 < 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

  //Chest reward secret (NORMAL)
  tmpargument = 6
  IfContentIs
    tmpargument = 0
    tmpx = 82 < 7
    tmpy = 95 < 7
    SetXY

    tmpargument = 1
    tmpx = 85 < 7
    tmpy = 100 < 7
    SetXY

    tmpargument = 2
    tmpx = 86 < 7
    tmpy = 106 < 7
    SetXY

  //Final platform (BLUE)
  tmpargument = 7
  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 = rand % 2047 + selfspawnx - 1023
    tmpy = rand % 2047 + selfspawny - 1023
    ClearWaypoints
    AddWaypoint
    tmpargument = rand % 200
    SetTime

//Prespecified AI
Else
  tmpargument = selfstate
  GetXY
  ClearWaypoints
  AddWaypoint

  IfAtLastWaypoint
    IfStateIs2
      tmpargument = 7
      IfContentIs		//Last platform is special, it teleports!
        tmpargument = 0
        GetXY
        SpawnPoof
        Teleport
        SpawnPoof
        tmpargument = 0
        PlaySound
      tmpargument = 0
    Else
      tmpargument = selfstate + 1
    SetState

//Don't get stuck in other platforms
IfBumped
  SetTargetToWhoeverBumped
  tmpargument = [PLAT]
  IfTargetHasID
    tmpargument = rand & 63 + targetz - 32	//Fudge until success!
    SetFlyHeight


// All Done
End
