This set viewing arc AI SET ENTITY VIEW ARC 1= straight ahead only 120 = wide angle view.
This set how far away it can see AI SET ENTITY VIEW RANGE 4= units
or 50 in view but only if facing you.
run below to see what I mean, when it turns around it can see you now.
Rem Project: Direct Integration Demo
Rem Created: Sunday, May 16, 2010
Rem ***** Main Source File *****
remstart destination of x=0, z=30
* -the entity will then return to its idle position
*
* Compiled in version 6.0
*
remend
sync on : sync rate 60
global dist# as float
AI Start
MakeBackground()
make camera 1
position camera 1,0,5,-20
set camera range .1,9999
load object "c:\Program Files\Dark Basic Professional\Help\examples\basic3d\models\model.x",1
scale object 1,200,200,200
position object 1,0,1,0
rotate object 1,0,180,0
`load object "dwarf1.dbo",1
`load object "dwarf1.dbo",1
`position object 1,0,1,0
`point object 1,30,0,30
fix object pivot 1
`color object 1,rgb(255,255,0)
AI Add Enemy 1
global waypointx# as float:waypointx#=30
global waypointz# as float:waypointz#=30
rem make a patrol path
AI Make Path 1
rem specify the points we want in our patrol in the order to visit them.
rem After the last point the first point becomes the next destination.
AI Path Add Point 1,0,0
AI Path Add Point 1,waypointx#,waypointz#
AI Set Entity Patrol Time 1,6
`AI Set Avoid Mode 1
AI Entity Assign Patrol Path 1,1
AI Set Entity Speed 1,20
AI SET ENTITY VIEW ARC 1,0,120
AI SET ENTITY VIEW RANGE 1,50
rotate object 1,0,180,0
make object sphere 2,1,25,25
scale object 2,360,.01,360
make object sphere 3,1,25,25
position object 3,0,0,0
make object sphere 4,1,25,25
position object 4,30,0,30
global iseeu
do
iseeu = ai get entity can see(1,camera position x(),camera position z(),1)
position object 2,object position x(1),object position y(1),object position z(1)
X1# = camera position x(1)
Y1# = camera position y(1)
Z1# = camera position z(1)
X2# = object position x(1)
Y2# = object position y(1)
Z2# = object position z(1)
`dist# = fml distance(X1#,Y1#,Z1#,X2#,Y2#,Z2#)
move camera 1,(keystate(17)-keystate(31))*1
turn camera left 1,(keystate(30)-keystate(32))*1
AI Update
ink 0,0
text 10,10,"objx:"+str$(object position x(1))
text 10,30,"objy:"+str$(object position y(1))
text 10,50,"objz:"+str$(object position z(1))
text 10,70,"objpitch:"+str$(object angle x(1))
text 10,90,"objyaw:"+str$(object angle y(1))
text 10,110,"objroll:"+str$(object angle z(1))
text 10,130,"attack:"+str$(attack)
text 10,150,"AI GET ENTITY MOVING:"+str$(AI GET ENTITY IS MOVING(1))
text 10,170,"AI GET ENTITY TURNING:"+str$(AI GET ENTITY IS TURNING(1))
Rem ***** Main Source File *****
text 10,190,"Enemy State: "+AI Get Entity State$(1)
text 10,210,"Actions state "+AI Get Entity Action$ ( 1 )
text 10,230,"dirction "+str$(AI Get Entity Destination X ( 1 ))
text 10,250,"dirction "+str$(AI Get Entity Destination z ( 1 ))
center text screen width()/2,screen height()/2,"iseeu:"+str$(iseeu)
sync
loop
function AI_AttackPlayer(player,obj)
local X1# as float
local Y1# as float
local Z1# as float
local X2# as float
local Y2# as float
local Z2# as float
X1# = object position x(player)
Y1# = object position y(player)
Z1# = object position z(player)
X2# = object position x(obj)
Y2# = object position y(obj)
Z2# = object position z(obj)
`dist# = fml distance(X1#,Y1#,Z1#,X2#,Y2#,Z2#)
if dist# <= 5
attack=1
endif
if dist# > 5
attack=0
endif
if attack
select attack
case 0
AI Kill Entity 1
endcase
case 1
AI TEAM FOLLOW PLAYER dist#+1
endcase
endselect
endif
endfunction
function MakeBackground()
load image "stripe5.png",1
rem create the background object
make object sphere 99,400,48,48
texture object 99,1
scale object texture 99,6,6
set object cull 99,0
set object light 99,0
rotate object 99,0,0,90
rem add the logo across the bottom
` load image "logo.png", 100000
` sprite 1, 0, screen height() - 60, 100000
endfunction
Dark Physics makes any hot drink go cold.