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

  1. : Crab AI  , will walk random walk sidwaya , handles the collision too
  2.       
  3. : STATE Init // initialization STATE
  4.      : RUN MOVEFOWARD 0.1 0  // use 0.1 as speed
  5.      : RUN SETREG 4 TIME  // used for timer
  6.      : RUN ADDREG 4 3000
  7.      : RUN RNDREG 0 1000
  8.      : RUN SUBREG 0 500
  9.      : RUN ADDREG 4 REG0
  10.      : RUN SETSTATE Walking 0
  11.  
  12. : STATE Walking 
  13.      : RUN RNDREG 0 100
  14.      : IF LE REG0 1 THEN GOTOLABEL RandomWalk 0 ENDIF
  15.      : IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
  16.      : IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
  17.      : IF COLLIDE 0 0 THEN NULLOP 0 0 ELSE GOTOLABEL nocollide 0 ENDIF
  18.  
  19. * RandomWalk
  20.      : RUN MOVEBACK 6 0  
  21.      : RUN RNDREG 0 20  // now generate a random vector
  22.      : RUN SUBREG 0 10  // x = -10..10
  23.      : RUN SETREG 1 0.1   // to prevent x=z =0
  24.      : RUN RNDREG 2 20
  25.      : RUN SUBREG 2 10  // z = -10..10
  26.      : RUN NORMVEC 0 0.1  // length = 0.1
  27.      : RUN SETVAL POSX REG0
  28.      : RUN SETVAL POSY 0
  29.      : RUN SETVAL POSZ REG2
  30.      : RUN MOVE   -1.0 0  // use POSX-Z as goal osistion and duration -1
  31.      : RUN MULREG 2 -1
  32.      : RUN SETVAL POSX REG2 // side way
  33.      : RUN SETVAL POSZ REG0
  34.      : RUN SETVAL ORNX 0
  35.      : RUN SETVAL ORNY 1.0
  36.      : RUN SETVAL ORNZ 0
  37.      : RUN ORIENT 3000  // orient to new driection in 1 sec  using ORN+POS
  38.      : RUN RETURN 0 0
  39.  
  40.     * nocollide
  41.      : RUN SAVEPOS 6 0  // save current posiition to reg 6-8
  42.      : RUN RETURN 0 0
  43. : END
  44.