home *** CD-ROM | disk | FTP | other *** search
/ Beyond the 3rd Dimension / BEYOND3D.bin / ai / aiplane2.ait < prev    next >
Text File  |  1997-09-16  |  3KB  |  116 lines

  1. : Flying AI / smooth taking off and landing up-flat-down  flog, spaceship
  2.       
  3. : STATE Init // initialization STATE
  4.      : RUN SAVEPOS 3 0  // save current posiition to reg 3-5
  5.      : RUN SAVEPOS 6 0  // save current posiition to reg 6-8
  6.      : RUN SETREG 4 TIME  // used for timer
  7.      : RUN ADDREG 4 3000
  8.      : RUN RNDREG 0 1000
  9.      : RUN SUBREG 0 500
  10.      : RUN ADDREG 4 REG0
  11.      : RUN SETSTATE FindPlace 0
  12.  
  13. : STATE FindPlace
  14.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  15.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF  // wait first
  16.      : RUN RNDREG 0 80
  17.      : RUN SUBREG 0 40  // x = -10..10
  18.      : RUN ADDREG 0 REG3  // center x
  19.      : RUN RNDREG 2 80
  20.      : RUN SUBREG 2 40  // x = -10..10
  21.      : RUN ADDREG 2 REG5  // center z
  22.      : IF OUTRANGE REG0 REG2 THEN RETURN 0 0 ENDIF
  23.      : IF OPENSPACE REG0 REG2 THEN GOTOLABEL found 0 ENDIF
  24.      : RUN RETURN 0 0
  25.  
  26.  * found
  27.      : RUN SETREG 1  REG0  //calculate mid point
  28.      : RUN MULREG 1  0.2
  29.      : RUN SETREG 4  REG6  //calculate mid point
  30.      : RUN MULREG 4  0.8
  31.      : RUN ADDREG 1  REG4
  32.      : RUN SETVAL POSX REG1
  33.  
  34.      : RUN SETREG 1  REG2  //calculate mid point
  35.      : RUN MULREG 1  0.2
  36.      : RUN SETREG 4  REG8  //calculate mid point
  37.      : RUN MULREG 4  0.8
  38.      : RUN ADDREG 1  REG4
  39.      : RUN SETVAL POSZ REG1
  40.  
  41.      : RUN SETVAL POSY 5
  42.      : RUN MOVE   1000 0  // use POSX-Z as goal osistion and duration -1
  43.  
  44.      : RUN SETREG 1 REG0
  45.      : RUN SUBREG 1 REG6
  46.      : RUN SETVAL POSX REG1
  47.      : RUN SETREG 1 REG2
  48.      : RUN SUBREG 1 REG8
  49.      : RUN SETVAL POSZ REG1  // y is the same
  50.      : RUN SETVAL POSY 5
  51.  
  52.      : RUN SETVAL ORNX 0
  53.      : RUN SETVAL ORNY 1.0
  54.      : RUN SETVAL ORNZ 0
  55.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  56.      : RUN SETREG 4 TIME
  57.      : RUN ADDREG 4 1001
  58.      : RUN SETSTATE Fly 0
  59.      : RUN RETURN 0 0
  60.  
  61. : STATE Fly
  62.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  63.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  64.  
  65.      : RUN SETREG 1  REG0  //calculate mid point
  66.      : RUN MULREG 1  0.75
  67.      : RUN SETREG 4  REG6  //calculate mid point
  68.      : RUN MULREG 4  0.25
  69.      : RUN ADDREG 1  REG4
  70.      : RUN SETVAL POSX REG1
  71.  
  72.      : RUN SETREG 1  REG2  //calculate mid point
  73.      : RUN MULREG 1  0.75
  74.      : RUN SETREG 4  REG8  //calculate mid point
  75.      : RUN MULREG 4  0.25
  76.      : RUN ADDREG 1  REG4
  77.      : RUN SETVAL POSZ REG1
  78.  
  79.      : RUN SETVAL POSY 5
  80.      : RUN MOVE   3500 0  // use POSX-Z as goal osistion and duration -1
  81.  
  82.      : RUN SETREG 1 REG0
  83.      : RUN SUBREG 1 REG6
  84.      : RUN SETVAL POSX REG1
  85.      : RUN SETREG 1 REG2
  86.      : RUN SUBREG 1 REG8
  87.      : RUN SETVAL POSZ REG1  // y is the same
  88.      : RUN SETVAL POSY 0.0
  89.  
  90.      : RUN SETVAL ORNX 0
  91.      : RUN SETVAL ORNY 1.0
  92.      : RUN SETVAL ORNZ 0
  93.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  94.  
  95.      : RUN SETREG 4 TIME
  96.      : RUN ADDREG 4 3501  // wait one second after landing and take off again
  97.      : RUN SETSTATE  Land 0
  98.      : RUN RETURN 0 0
  99.  
  100. : STATE  Land
  101.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  102.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  103.      : RUN SETVAL POSX REG0
  104.      : RUN SETVAL POSY 0
  105.      : RUN SETVAL POSZ REG2  
  106.      : RUN MOVE   1000 0  // use POSX-Z as goal osistion and duration -1
  107.  
  108.      : RUN SETREG 4 TIME
  109.      : RUN ADDREG 4 2500  // wait one second after landing and take off again
  110.      : RUN RNDREG 0 1000
  111.      : RUN SUBREG 0 500
  112.      : RUN ADDREG 4 REG0
  113.      : RUN SETSTATE  FindPlace 0
  114.      : RUN RETURN 0 0
  115. : END
  116.