home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beyond the 3rd Dimension
/
BEYOND3D.bin
/
ai
/
aicrab.ait
next >
Wrap
Text File
|
1997-12-09
|
1KB
|
44 lines
: Crab AI , will walk random walk sidwaya , handles the collision too
: STATE Init // initialization STATE
: RUN MOVEFOWARD 0.1 0 // use 0.1 as speed
: RUN SETREG 4 TIME // used for timer
: RUN ADDREG 4 3000
: RUN RNDREG 0 1000
: RUN SUBREG 0 500
: RUN ADDREG 4 REG0
: RUN SETSTATE Walking 0
: STATE Walking
: RUN RNDREG 0 100
: IF LE REG0 1 THEN GOTOLABEL RandomWalk 0 ENDIF
: IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
: IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
: IF COLLIDE 0 0 THEN NULLOP 0 0 ELSE GOTOLABEL nocollide 0 ENDIF
* RandomWalk
: RUN MOVEBACK 6 0
: RUN RNDREG 0 20 // now generate a random vector
: RUN SUBREG 0 10 // x = -10..10
: RUN SETREG 1 0.1 // to prevent x=z =0
: RUN RNDREG 2 20
: RUN SUBREG 2 10 // z = -10..10
: RUN NORMVEC 0 0.1 // length = 0.1
: RUN SETVAL POSX REG0
: RUN SETVAL POSY 0
: RUN SETVAL POSZ REG2
: RUN MOVE -1.0 0 // use POSX-Z as goal osistion and duration -1
: RUN MULREG 2 -1
: RUN SETVAL POSX REG2 // side way
: RUN SETVAL POSZ REG0
: RUN SETVAL ORNX 0
: RUN SETVAL ORNY 1.0
: RUN SETVAL ORNZ 0
: RUN ORIENT 3000 // orient to new driection in 1 sec using ORN+POS
: RUN RETURN 0 0
* nocollide
: RUN SAVEPOS 6 0 // save current posiition to reg 6-8
: RUN RETURN 0 0
: END