Thanks Paul, that did it. Should have found that one myself really, but somehow I missed it.
I have another question though, if I use this code:
makechess()
`randattack=1
sync on : sync rate 60
ai start
autocam off
position camera 0,30,0
point camera 0,0,0
make object plain 1,1000,1000
xrotate object 1,90
fix object pivot 1
texture object 1,1
scale object texture 1,10,10
set object ambient 1,0
make object cone 5,10
position object 5,130,0,130
color object 5,rgb(220,0,0)
set object ambient 5,0
set object cull 5,0
xrotate object 5,90
yrotate object 5,180
fix object pivot 5
make object box 6,40,90,40
position object 6,300,0,300
color object 6,rgb(255,217,0)
AI Add Obstacle From Level 6, 10, 1, 1
AI Complete Obstacles
ai add player 5,1
`load object "media\wolf_01.X",10001
make object cone 10001,8
position object 10001,-200,0,200
color object 10001,rgb(0,0,220)
set object ambient 10001,0
set object cull 10001,0
yrotate object 10001,180
xrotate object 10001,270
fix object pivot 10001
ai add enemy 10001,0
ai set entity speed 10001,50
AI Set Entity Avoid Distance 10001, 0.001
AI Set Entity Attack Distance 10001, 10
AI Set Entity Stance 10001, 1
AI set entity can strafe 10001,0
writestate=0
dim states$(50)
states$(1)="1"
states$(2)="2"
states$(3)="3"
do
inc writestate
if writestate>50 then writestate=1
states$(writestate)=ai get entity action$(10001)
control camera using arrowkeys 0,1,1
position object 5,camera position x(0),0,camera position z(0)
rotate object 5,camera angle x(0),camera angle y(0),camera angle z(0)
move object 5,100
ai set player position object position x(5),object position z(5)
position object 10001,ai get entity x(10001),0,ai get entity z(10001)
ai entity look at position 10001,AI Get Entity Destination X (10001),AI Get Entity Destination z (10001)
rotate object 10001,object angle x(10001),ai get entity angle y(10001),object angle z(10001)
enemytarget = AI Get Entity Target ID ( 10001, 1 )
if enemytarget = 5 then POINT OBJECT 10001, object position x(5), 0, object position z(5)
randattack = rnd(2)+1
enemyaction$ = ai get entity action$(10001)
if left$(enemyaction$,6)="Moving" then loop object 10001,301,349 else loop object 10001,101,199
ai update
ink rgb(255,255,255),0
set cursor 0,0
print "AI Enemy Action: " + AI Get Entity Action$ ( 10001 )
enemytarget = AI Get Entity Target ID ( 10001, 1 )
print "Target: " + str$(enemytarget)
for states=1 to 50
print "state "+str$(states)+": " + states$(states)
next states
sync
loop
function makechess()
ink rgb(168,32,32),rgb(168,32,32)
box 0,0,127,127
box 128,128,255,255
ink rgb(240,209,36),rgb(240,209,36)
box 128,0,255,127
box 0,128,127,255
get image 1,0,0,255,255,0
endfunction
The monster will act right until I move the character out of it´s range, and for some reason it will then move over to the obstacle, and move around that for a while, until it removes the player from the target list.
Is there a way to wipe an entity´s target list manually? I don´t really want to do this, but it´s the only thing I can think of at this point. The reason I use "AI Add Obstacle From Level" is that in the main project the level file is too complex to define via the other commands.
Once again it could be a relatively easy thing I´m missing, but it might not.
I´ve tried manually forcing it to return to it´s idle point if it´s "Stopped" and still targeting object 5, but it doesn´t work - the entity will move towards it´s idle point for a few seconds, then return to the box.
Anyone have any info on this, is it a known bug, a result of some command I´m using, or? Also, despite having status as "moving forward", the object is still looking at the player entity as it slides towards the box, though I imagine that´ll be because he´s still its target, since after it drops the target and returns to it´s idle position (on it´s own), it´s once again looking the way it´s travelling.
Cheers all!