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

  1. : Walking AI
  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 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 Wait1 0
  12.  
  13. : STATE  Land
  14.      : RUN SAVEPOS 6 0  // save current posiition to reg 3-5
  15.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  16.      : IF OPENSPACE POSX POSZ THEN GOTOLABEL landok 0 ENDIF
  17.      : RUN SETSTATE FindPlace 0
  18.      : RUN RETURN 0 0
  19.  
  20. * landok
  21.      : RUN SETVAL POSY 0
  22.      : RUN MOVE 1500 0
  23.      : RUN SETREG 4 TIME
  24.      : RUN ADDREG 4 3000
  25.      : RUN RNDREG 0 1000
  26.      : RUN SUBREG 0 500
  27.      : RUN ADDREG 4 REG0
  28.      : RUN SETSTATE  Wait1 0
  29.      : RUN RETURN 0 0
  30.  
  31. : STATE Wait1
  32.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  33.       RUN SETREG 1 POSY
  34.       RUN ADDREG 1 4.0  // taking off
  35.       RUN SETVAL POSY REG1
  36.      : RUN RNDREG 0 3
  37.      : RUN ADDREG 0 3
  38.      : RUN SETVAL POSY REG0
  39.      : RUN MOVE 1000 0
  40.      : RUN SETREG 4 TIME
  41.      : RUN ADDREG 4 2000
  42.      : RUN SETSTATE Wait2 0
  43.      : RUN RETURN 0 0
  44.  
  45. : STATE Wait2
  46.      : IF GT REG4 TIME THEN RETURN 0 0 ENDIF
  47.      : RUN SETSTATE FindPlace 0
  48.      : RUN RETURN 0 0
  49.  
  50. : STATE FindPlace
  51.      : RUN SAVEPOS 6 0  // save current posiition to reg 0-2
  52.      : RUN RNDREG 0 100
  53.      : RUN SUBREG 0 50  // x = -10..10
  54.      : RUN ADDREG 0 REG3  // center x
  55.      : RUN RNDREG 2 100
  56.      : RUN SUBREG 2 50  // x = -10..10
  57.      : RUN ADDREG 2 REG5  // center z
  58.      : IF OUTRANGE REG0 REG2 THEN RETURN 0 0 ENDIF
  59.      : IF OPENSPACE REG0 REG2 THEN GOTOLABEL found 0 ENDIF
  60.      : RUN RETURN 0 0
  61.  
  62.  * found
  63.      : RUN SETVAL POSX REG0
  64.      : RUN SETVAL POSZ REG2  // y is the same
  65.      : RUN MOVE   5000 0  // use POSX-Z as goal osistion and duration -1
  66.  
  67.      : RUN SAVEPOS 6 0  // save current posiition to reg 0-2
  68.      : RUN SUBREG 0 REG6
  69.      : RUN SUBREG 2 REG8
  70.      : RUN SETVAL POSX REG0
  71.      : RUN SETVAL POSY 0
  72.      : RUN SETVAL POSZ REG2  // y is the same
  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.      : RUN SETREG 4 TIME
  79.      : RUN ADDREG 4 6000
  80.      : RUN SETSTATE Land 0
  81.      : RUN RETURN 0 0
  82. : END
  83.