What if you're using Move Object commands? Here's my function:
function AI_Random_Walk(object, enemy)
X# = object position x(object)
Y# = object position y(object)
Z# = object position z(object)
if X# < 800 AND X# > 300 AND Z# < 800 AND Z# > 200
` Move unit in a random pattern
print "Enemy is roaming...",Direction(enemy)
if DirectionTime(enemy) > 0 then dec DirectionTime(enemy) else Direction(enemy) = rnd(7) : DirectionTime(enemy) = rnd(200)+30
if ManeuverTime(enemy) > 0 then dec ManeuverTime(enemy) else Calm_Selection(object, enemy):ManeuverTimeStart(enemy)=0
rem Move player (eight-directional movement)
If Direction(enemy)=0
`yrotate object model,45
yrotate object object,curveangle(45,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=1
`yrotate object model,-45
yrotate object object,curveangle(-45,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=2
`yrotate object model,135
yrotate object object,curveangle(135,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=3
`yrotate object model,-135
yrotate object object,curveangle(-135,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=4
`yrotate object model,180
yrotate object object,curveangle(180,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=5
`yrotate object model,360
yrotate object object,curveangle(360,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=6
`yrotate object model,90
yrotate object object,curveangle(90,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
If Direction(enemy)=7
`yrotate object model,270
yrotate object object,curveangle(270,object angle y(object),10)
Move Object object, 2.5
enemy_state(enemy)=1
else
enemy_state(enemy)=0
endif : endif : endif: endif : endif : endif : endif : endif
else
?? ? ? ? ? ? ?
endif
The problem with that method is that it's jumpy. I need the model to just return (probably via
move object or a similar command) back to any X/Z point that's within the range.
Currently working on - Enemy AI and Action Battle System
the sig limit needs to be raised...