home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beyond the 3rd Dimension
/
BEYOND3D.bin
/
ai
/
aishark.ait
< prev
Wrap
Text File
|
1997-12-09
|
2KB
|
84 lines
: Shark AI, Will try to catch type 1 object
// reg 6-8 previous pos
// reg 0-2 local use
// reg 4 timer
// reg 3 rotation acceleration in x direction
// reg 5 rotation speed
: STATE Init // initialization STATE
: RUN SETREG 3 0.001
: RUN SETREG 5 0
: RUN SETSTATE Walking 0
: STATE Walking
: IF OUTRANGE POSX POSZ THEN GOTOLABEL RandomWalk 0 ENDIF
: IF COLLIDE 0 0 THEN NULLOP 0 0 ELSE GOTOLABEL nocollide 0 ENDIF
* RandomWalk
: RUN FREEZE 1 0
: RUN MOVEBACK 6 0
: RUN RNDREG 0 20
: 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.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
: RUN SETREG 0 6 // closest dist
: RUN GETOBJTYPE 15 6
: IF EQ REG0 0 THEN GOTOLABEL stop 0 ENDIF // not found
: IF EQ REG5 0 THEN NULLOP 0 0 ELSE GOTOLABEL fine 0 ENDIF
: RUN RNDREG 0 5
: IF LE REG0 0 THEN MULREG 3 -1 ENDIF // reverse rotation dir
*fine
: RUN ADDREG 5 REG3
: IF LE REG5 -0.01 THEN MULREG 3 -1 ENDIF
: IF GE REG5 0.01 THEN MULREG 3 -1 ENDIF
: RUN FINDOBJPOS 0 0 // store in px,py,pz
: RUN SETREG 0 POSX
: RUN SETREG 1 0.1
: RUN SETREG 2 POSZ
: RUN SUBREG 0 REG6
: RUN SUBREG 2 REG8
: RUN NORMVEC 0 0.2 // length = 0.1
: RUN ADDREG 0 ORNX
: RUN ADDREG 2 ORNZ
: RUN NORMVEC 0 0.08 // length = 0.1
: RUN ADDREG 0 REG5
: RUN SETVAL POSX REG0
: RUN SETVAL POSY 0
: RUN SETVAL POSZ REG2 // y is the same
: 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 0 0 // orient to new driection in 1 sec using ORN+POS
: RUN RETURN 0 0
*stop
: RUN SETVAL POSX 0
: RUN SETVAL POSY 0
: RUN SETVAL POSZ 0
: RUN MOVE -1.0 0 // use POSX-Z as goal osistion and duration -1
: RUN RETURN 0 0
: END