remstart
Dark AI Tutorial
By Steve Vink for The Game Creators Ltd
remend

` The debug switch allows us to show waypoints manually.
` The automatic debug visibility is not appropriate,
` because of the different landscape heights
#constant cDEBUG 1

` To store the positions of objects and entities efficiently,
` we will use a user defined type to hold the 3 coordinates.
Type tPos
	x as float
	y as float
	z as float
endtype


` Waypoint positions will be stored in an array for future reference
dim gWaypoints() as tPos

	` Basic Setup
	SYNC ON: SYNC RATE 60
	autocam off
	AI start
	
	` *********************************************************************
	` Make the scene using advanced terrain and some scenery
	makeTerrain()
	
	
	` *********************************************************************
	` Add waypoints to the map, to mark out the relevant paths
	createWaypoints()
	
	
	` *********************************************************************
	` Add random waypoints across the map as intermediate points
	for x = 50 to 1500 step 100
		for z = 50 to 1500 step 100
			x# = x + (rnd(20) - 10) : z# = z + (rnd(20) - 10)
			AI add waypoint 0, x#, z#
			if cDEBUG
				obj = freeObj(100)
				make object cone obj, 5
				color object obj, rgb(128,255,255)
				position object obj, x#,get terrain ground height(1,x#,z#),z#
			endif
		next z
	next x
	
	AI update waypoint visibility 0, 120
	
	
	` *********************************************************************
	` Make a character
	makeCharacter()
	
	` Create a path from Start to End, and assign to our character
	AI make path between points 10, 0,gWaypoints(0).x,gWaypoints(0).z,gWaypoints(1).x,gWaypoints(1).z,300
	AI entity assign patrol path cCHARACTER, 10
	
	` *************************************************
	` Main Loop
	
	do
		
		AI Update
		` Position the character
		posChar(50)

		set camera to follow object position x(50), object position y(50), object position z(50), object angle y(50), 30, 15,50,0
		position camera camera position x(), get terrain ground height(1,camera position x(),camera position z()) + 5,camera position z()
		point camera object position x(50), object position y(50), object position z(50)
		update terrain
		sync
		
	loop
	
	end
	
	
	
	
	
	
	

		 