My level loading code. Modified Inca Engine
function LoadWorld(file$,obj)
load object file$,obj
scale object obj,1,1,1
do
ln=ln+1
if limb exist(obj,ln)
properties$=limb name$(obj,ln)
objecttype$=lower$(KeyValue$(properties$,"objecttype",""))
classname$=lower$(KeyValue$(properties$,"classname",""))
select objecttype$
case "brush"
do
ln=ln+1
if limb exist(obj,ln)
subobjectproperties$=limb name$(obj,ln)
subobjecttype$=KeyValue$(subobjectproperties$,"objecttype","")
if subobjecttype$="face"
select classname$
`aiobstacle brushes are used to setup obstalces for the ai system
case "aiobstacle"
x#=limb position x(obj,ln)
y#=limb position y(obj,ln)
z#=limb position z(obj,ln)
newobj=NewObjectIndex()
make object from limb newobj,obj,ln
position object newobj,x#,y#,z#
AI add static obstacle newobj
hide object newobj
AI complete obstacles
endcase
endselect
else
ln=ln-1
exit
endif
endif
loop
endcase
case "entity"
x#=limb position x(obj,ln)
y#=limb position y(obj,ln)
z#=limb position z(obj,ln)
select classname$
`The playerstart entity tells the engine how to position and rotate the
`player when the world is loaded.
case "playerstart"
position object player,x#,y#,z#
endcase
case "monsterspawn"
position object monster,x#,y#+10,z#
endcase
case "waypointmarker"
if limb exist(obj,ln)
pathid$=KeyValue$(properties$,"path id","0")
AI path add point val(pathid$),x#,z#
endif
endcase
endselect
endcase
endselect
else
exit
endif
loop
endfunction
function NewObjectIndex()
newobjectcounter=newobjectcounter+1
endfunction newobjectcounter
My main loop
sync on
sync rate 60
global newobjectcounter=1000
global path=0
`global tl=1
AI Start
AI Set Radius 1
global player=3
global monster=2
global path
autocam off
position camera 0,100,0
xrotate camera 45
make object cone player,5
`position object player,-40,10,0
xrotate object player,90
Fix Object Pivot player
AI add player player
color object player,rgb(15,87,32)
`set object player,1,1,0
rem enemy
make object sphere monster,5
position object monster,40,0,-40
AI Add Enemy monster
AI Set Entity Speed monster,10.0
AI Set Entity Aggressive monster
AI Entity Strafe Target monster
AI Set Entity View Range monster,100
color object 2,rgb(76,12,3)
AI make path 1
LoadWorld("map/level1.dbo",1)
cx#=object position x(player)
cy#=object position y(player)
cz#=object position z(player)
`point camera cx#,cy#,cz#
do
AI Entity Assign Patrol Path monster,1
`tl=tl+1
`name$=limb name$ (1,tl)
`wait 5000
`text 0,10,name$
`remstart
text 0,0,str$(screen fps())
if upkey()=1
move object 3,0.2
endif
if downkey()=1
move object 3,-0.2
endif
if leftkey()=1
turn object left 3,5
endif
if rightkey()=1
turn object right 3,5
endif
if returnkey()=1
cx=camera position x()
cy=camera position y()
cz=camera position z()
position camera cx,cy+1,cz
endif
if controlkey()=1
cx=camera position x()
cy=camera position y()
cz=camera position z()
position camera cx,cy-1,cz
endif
if Ai entity exist(2)=1
x# = Ai get player x()
z# = Ai get player z()
if AI Get Entity Can See(2,x#,z#,1)=1
AI Entity Go To Position 2, x#, z#
endif
endif
AI Debug Show paths 5
`AI Debug Show Obstacle Bounds 0,10
AI update
x#=object position x(3)
y#=object position y(3)
z#=object position z(3)
a#=180
d#=50
h#=50
s#=100.0
set camera to follow x#,y#,z#,a#,d#,h#,s#,0
`remend
if returnkey()=1
cx=camera position x()
cy=camera position y()
cz=camera position z()
position camera cx,cy+1,cz
endif
if controlkey()=1
cx=camera position x()
cy=camera position y()
cz=camera position z()
position camera cx,cy-1,cz
endif
sync
loop
I am including my test map.
Now my problem is that my monster entity is going to follow the path but it will not follow the entire path. The monster will go about 1/4 to 1/2 of the way and just turns around. What am I doing wrong
AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB