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

  1. : Shark AI, Will try to catch type 1 object
  2. // reg 6-8 previous pos
  3. // reg 0-2 local use
  4. // reg 4 timer
  5. // reg 3 rotation acceleration in x direction
  6. // reg 5 rotation speed
  7.  
  8. : STATE Init // initialization STATE
  9.      : RUN SETREG 3 0.001
  10.      : RUN SETREG 5 0
  11.      : RUN SETSTATE Walking 0
  12.  
  13. : STATE Walking 
  14.      : IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
  15.      : IF COLLIDE 0 0 THEN NULLOP 0 0 ELSE GOTOLABEL nocollide 0 ENDIF
  16.  
  17. * RandomWalk
  18.      : RUN FREEZE 1 0  
  19.      : RUN MOVEBACK 6 0
  20.      : RUN RNDREG 0 20
  21.      : RUN SUBREG 0 10  // x = -10..10
  22.      : RUN SETREG 1 0.1   // to prevent x=z =0
  23.      : RUN RNDREG 2 20
  24.      : RUN SUBREG 2 10  // z = -10..10
  25.      : RUN NORMVEC 0 0.1  // length = 0.1
  26.      : RUN SETVAL POSX REG0
  27.      : RUN SETVAL POSY 0.0
  28.      : RUN SETVAL POSZ REG2
  29.      : RUN MOVE   -1.0 0  // use POSX-Z as goal osistion and duration -1
  30.      : RUN SETVAL ORNX 0
  31.      : RUN SETVAL ORNY 1.0
  32.      : RUN SETVAL ORNZ 0
  33.      : RUN ORIENT 1000  // orient to new driection in 1 sec  using ORN+POS
  34.  : RUN RETURN 0 0
  35.  
  36. *nocollide
  37.      : RUN SAVEPOS 6 0
  38.      : RUN SETREG 0 6  // closest dist
  39.      : RUN GETOBJTYPE 15 6
  40.      : IF EQ REG0 0 THEN GOTOLABEL stop 0 ENDIF  // not found 
  41.  
  42.      : IF EQ REG5 0 THEN NULLOP 0 0 ELSE GOTOLABEL fine 0 ENDIF
  43.      : RUN RNDREG 0 5
  44.      : IF LE REG0 0 THEN MULREG 3 -1 ENDIF  // reverse rotation dir
  45.  
  46. *fine
  47.      : RUN ADDREG 5 REG3
  48.      : IF LE REG5 -0.01 THEN MULREG 3 -1 ENDIF
  49.      : IF GE REG5 0.01 THEN MULREG 3 -1 ENDIF
  50.  
  51.      : RUN FINDOBJPOS 0 0  // store in px,py,pz
  52.      : RUN SETREG 0 POSX
  53.      : RUN SETREG 1 0.1
  54.      : RUN SETREG 2 POSZ
  55.      : RUN SUBREG 0 REG6
  56.      : RUN SUBREG 2 REG8
  57.  
  58.      : RUN NORMVEC 0 0.2  // length = 0.1
  59.      : RUN ADDREG 0 ORNX
  60.      : RUN ADDREG 2 ORNZ
  61.      : RUN NORMVEC 0 0.08  // length = 0.1
  62.  
  63.      : RUN ADDREG 0 REG5
  64.  
  65.      : RUN SETVAL POSX REG0
  66.      : RUN SETVAL POSY 0
  67.      : RUN SETVAL POSZ REG2  // y is the same
  68.      : RUN MOVE   -1.0 0  // use POSX-Z as goal osistion and duration -1
  69.  
  70.      : RUN SETVAL ORNX 0
  71.      : RUN SETVAL ORNY 1.0
  72.      : RUN SETVAL ORNZ 0
  73.      : RUN ORIENT 0 0  // orient to new driection in 1 sec  using ORN+POS
  74.  : RUN RETURN 0 0
  75.  
  76.  *stop
  77.      : RUN SETVAL POSX 0
  78.      : RUN SETVAL POSY 0
  79.      : RUN SETVAL POSZ 0
  80.      : RUN MOVE   -1.0 0  // use POSX-Z as goal osistion and duration -1
  81.  : RUN RETURN 0 0
  82.  
  83. : END
  84.