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

  1. : Fish AI  , will do random walk , handles the collision too
  2.       
  3. : STATE Init // initialization STATE
  4.      : RUN SAVEPOS 6 0  // save current posiition to reg 6-8
  5.      : RUN MOVEFOWARD 0.1 0  // use 0.1 as speed
  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 Walking 0
  12.  
  13. : STATE Walking 
  14.      : IF OUTRANGE POSX POSZ THEN GOTOLABEL OutRange 0 ENDIF
  15.      : RUN RNDREG 0 300
  16.      : IF LE REG0 1 THEN GOTOLABEL RandomWalk 0 ENDIF
  17.      : IF COLLIDE 0 0 THEN GOTOLABEL RandomWalk 0 ELSE GOTOLABEL nocollide 0 ENDIF
  18.  
  19. * OutRange  // not posx and posz store the inrange position
  20.      : RUN MOVE 0 0      // move it inside the range
  21.      : RUN SAVEPOS 6 0   // save 
  22.      : RUN FREEZE 1 0    // delete rotation callbacks
  23.      : RUN GOTOLABEL NewVec 0 
  24.  
  25. * RandomWalk
  26.      : RUN FREEZE 1 0  // delete rotation callbacks
  27.      : RUN MOVEBACK 6 0  
  28.  
  29. * NewVec
  30.      : RUN RNDREG 0 20  // now generate a random vector
  31.      : RUN SUBREG 0 10  // x = -10..10
  32.      : RUN SETREG 1 0.1   // to prevent x=z =0
  33.      : RUN RNDREG 2 20
  34.      : RUN SUBREG 2 10  // z = -10..10
  35.      : RUN NORMVEC 0 0.1  // length = 0.1
  36.      : RUN SETVAL POSX REG0
  37.      : RUN SETVAL POSY 0
  38.      : RUN SETVAL POSZ REG2
  39.      : RUN MOVE   -1.0 0  // use POSX-Z as goal osistion and duration -1
  40.      : RUN SETVAL ORNX 0
  41.      : RUN SETVAL ORNY 1.0
  42.      : RUN SETVAL ORNZ 0
  43.      : RUN ORIENT 1000  // orient to new driection in 1 sec  using ORN+POS
  44.      : RUN RETURN 0 0
  45.  
  46. * nocollide
  47.      : RUN SAVEPOS 6 0  // save current posiition to reg 6-8
  48.      : RUN RETURN 0 0
  49. : END
  50.