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

  1. : Flying AI / smooth taking off and landing up-dwon
  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 40
  17.      : RUN SUBREG 0 20  // x = -10..10
  18.      : RUN ADDREG 0 REG3  // center x
  19.      : RUN RNDREG 2 40
  20.      : RUN SUBREG 2 20  // 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 ADDREG 1  REG6
  29.      : RUN MULREG 1  0.5
  30.      : RUN SETVAL POSX REG1
  31.  
  32.      : RUN SETREG 1 REG2
  33.      : RUN ADDREG 1 REG8
  34.      : RUN MULREG 1 0.5
  35.      : RUN SETVAL POSZ REG1
  36.  
  37.      : RUN SETVAL POSY 5
  38.      : RUN MOVE   2500 0  // use POSX-Z as goal osistion and duration -1
  39.  
  40.      : RUN SETREG 1 REG0
  41.      : RUN SUBREG 1 REG6
  42.      : RUN SETVAL POSX REG1
  43.      : RUN SETREG 1 REG2
  44.      : RUN SUBREG 1 REG8
  45.      : RUN SETVAL POSZ REG1  // y is the same
  46.      : RUN SETVAL POSY 5
  47.  
  48.      : RUN SETVAL ORNX 0
  49.      : RUN SETVAL ORNY 1.0
  50.      : RUN SETVAL ORNZ 0
  51.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  52.      : RUN SETREG 4 TIME
  53.      : RUN ADDREG 4 2501
  54.      : RUN SETSTATE Land 0
  55.      : RUN RETURN 0 0
  56.  
  57.  
  58. : STATE  Land
  59.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  60.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  61.      : RUN SETVAL POSX REG0
  62.      : RUN SETVAL POSY 0
  63.      : RUN SETVAL POSZ REG2  
  64.      : RUN MOVE   2500 0  // use POSX-Z as goal osistion and duration -1
  65.  
  66.      : RUN SETREG 1 REG0
  67.      : RUN SUBREG 1 REG6
  68.      : RUN SETVAL POSX REG1
  69.      : RUN SETREG 1 REG2
  70.      : RUN SUBREG 1 REG8
  71.      : RUN SETVAL POSZ REG1  // y is the same
  72.      : RUN SETVAL POSY 0.0
  73.  
  74.      : RUN SETVAL ORNX 0
  75.      : RUN SETVAL ORNY 1.0
  76.      : RUN SETVAL ORNZ 0
  77.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  78.  
  79.      : RUN SETREG 4 TIME
  80.      : RUN ADDREG 4 3500  // wait one second after landing and take off again
  81.      : RUN RNDREG 0 1000
  82.      : RUN SUBREG 0 500
  83.      : RUN ADDREG 4 REG0
  84.      : RUN SETSTATE  FindPlace 0
  85.      : RUN RETURN 0 0
  86. : END
  87.