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

  1. : Flying AI, will take off, fly, and land
  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 3-5
  6.      : RUN SAVEORN 9 0
  7.          : RUN SETREG 1 0  // start
  8.          : RUN SETREG 4 TIME  // used for timer
  9.      : RUN ADDREG 4 3000
  10.      : RUN RNDREG 0 1000
  11.      : RUN SUBREG 0 500
  12.      : RUN ADDREG 4 REG0
  13.          : RUN SETSTATE Wait1 0
  14.  
  15. : STATE  Land  // reg2 should be the last reg7
  16.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  17.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  18.      : IF OPENSPACE POSX POSZ THEN GOTOLABEL landok 0 ENDIF
  19.      : RUN SETSTATE FindPlace 0
  20.      : RUN RETURN 0 0
  21.  
  22. * landok
  23.      : RUN SETVAL POSY 0
  24.      : RUN MOVE 1500 0
  25.  
  26.      : RUN COPYREG 0 9
  27.      : RUN SETVAL POSX REG0
  28.      : RUN SETVAL POSY 0
  29.      : RUN COPYREG 0 11
  30.      : RUN SETVAL POSZ REG0  // y is the same
  31.  
  32.      : RUN SETVAL ORNX 0
  33.      : RUN SETVAL ORNY 1.0
  34.      : RUN SETVAL ORNZ 0
  35.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  36.  
  37.      : RUN SETREG 4 TIME
  38.      : RUN ADDREG 4 3000
  39.      : RUN RNDREG 0 1000
  40.      : RUN SUBREG 0 500
  41.      : RUN ADDREG 4 REG0
  42.      : RUN SETSTATE Wait1 0
  43.      : RUN RETURN 0 0
  44.  
  45. : STATE Wait1   // before taking off
  46.      : RUN SAVEPOS 6 0  // save current posiition to reg 
  47.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  48.      : RUN RNDREG 0 3
  49.      : RUN ADDREG 0 3
  50.      : RUN SETVAL POSY REG0
  51.      : RUN MOVE 1000 0
  52.      : RUN SETREG 4 TIME
  53.      : RUN ADDREG 4 2000
  54.      : RUN SETSTATE Wait2 0
  55.      : RUN RETURN 0 0
  56.  
  57. : STATE Wait2
  58.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  59.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  60.      : RUN SETSTATE FindPlace 0
  61.      : RUN RETURN 0 0
  62.  
  63. : STATE FindPlace
  64.      : RUN SAVEPOS 6 0
  65.      : IF EQ REG1 1 THEN GOTOLABEL useorigin 0 ENDIF
  66.      : RUN SETREG 1 1  // set to use origin next time
  67.      : RUN RNDREG 0 120
  68.      : RUN SUBREG 0 60  // x = -10..10
  69.      : RUN ADDREG 0 REG3  // center x
  70.      : RUN RNDREG 2 120
  71.      : RUN SUBREG 2 60  // x = -10..10
  72.      : RUN ADDREG 2 REG5  // center z
  73.      : IF OUTRANGE  REG0 REG2 THEN GOTOLABEL outrng 0 ENDIF
  74.          : IF OPENSPACE REG0 REG2 THEN GOTOLABEL found 0 ENDIF
  75. * outrng
  76.      : RUN SETREG 1 0  // no origin
  77.      : RUN RETURN 0 0
  78.  
  79.  * useorigin
  80.      : RUN SETREG 1 0
  81.      : RUN SETREG 0 REG3
  82.      : RUN SETREG 2 REG5
  83.  
  84.  * found
  85.      : RUN SETVAL POSX REG0
  86.      : RUN SETVAL POSZ REG2  // y is the same
  87.      : RUN MOVE   5000 0  // use POSX-Z as goal osistion and duration -1
  88.       RUN SETVAL POSY REG7
  89.       RUN SAVEPOS 6 0  // save current posiition to reg 0-2
  90.       RUN SETREG 7 POSY
  91.      : RUN SUBREG 0 REG6  // reg6-8 is position now, 7 is not valid
  92.      : RUN SUBREG 2 REG8
  93.      : RUN SETVAL POSX REG0
  94.      : RUN SETVAL POSY 0
  95.      : RUN SETVAL POSZ REG2  // y is the same
  96.  
  97.      : RUN SETVAL ORNX 0
  98.      : RUN SETVAL ORNY 1.0
  99.      : RUN SETVAL ORNZ 0
  100.      : RUN ORIENT 1000 0  // orient to new driection in 1 sec  using ORN+POS
  101.      : RUN SETREG 4 TIME
  102.      : RUN ADDREG 4 6000
  103.       RUN SETREG 2 REG7  // save reg7 to reg2 for restore in land state
  104.      : RUN SETSTATE Land 0
  105.      : RUN RETURN 0 0
  106. : END
  107.