home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beyond the 3rd Dimension
/
BEYOND3D.bin
/
ai
/
aiduck.ait
< prev
next >
Wrap
Text File
|
1997-12-09
|
2KB
|
50 lines
: Fish AI , will do random walk , handles the collision too
: STATE Init // initialization STATE
: RUN SAVEPOS 6 0 // save current posiition to reg 6-8
: 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
: IF OUTRANGE POSX POSZ THEN GOTOLABEL OutRange 0 ENDIF
: RUN RNDREG 0 300
: IF LE REG0 1 THEN GOTOLABEL RandomWalk 0 ENDIF
: IF COLLIDE 0 0 THEN GOTOLABEL RandomWalk 0 ELSE GOTOLABEL nocollide 0 ENDIF
* OutRange // not posx and posz store the inrange position
: RUN MOVE 0 0 // move it inside the range
: RUN SAVEPOS 6 0 // save
: RUN FREEZE 1 0 // delete rotation callbacks
: RUN GOTOLABEL NewVec 0
* RandomWalk
: RUN FREEZE 1 0 // delete rotation callbacks
: RUN MOVEBACK 6 0
* NewVec
: 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.05 // 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 SETVAL ORNX 0
: RUN SETVAL ORNY 1.0
: RUN SETVAL ORNZ 0
: RUN ORIENT 1000 // 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