;****************************************
;carsAI.bb
;
;23 November 2004
;
;author : Christopher Turek
;
;
;this file of functions sets up the cars for the street scene and then animates them into AI patterns.
;
;
;
;

Global policeC, hearseC, uscarC, whitecarC, taxiC, redC




;function to setup the cars in the before the game begins
Function setUpCars()

policeC = LoadMesh("policecar.3DS")
policeTex = LoadTexture("policeCa.bmp")
EntityTexture policeC, policeTex
EntityType policeC, POLICE
ScaleEntity policeC, .5, .5, .5
EntityRadius policeC, .2
PositionEntity policeC, 4, -3, 60
RotateEntity policeC,0, -90,0
EntityOrder policeC, 0


hearseC = LoadMesh("yellowcar.3DS")
hearseTex = LoadTexture("smallCaY.bmp")
EntityTexture hearseC, hearseTex
EntityType hearseC, HEARSE
EntityRadius hearseC, .2
ScaleEntity hearseC,.5,.5,.5
PositionEntity hearseC,4,-3,-84
RotateEntity hearseC,0,-90,0
EntityOrder hearseC, 0

uscarC = LoadMesh("uscar.3DS")
uscarTex = LoadTexture("uscar.bmp")
EntityTexture uscarC, uscarTex
EntityType uscarC, USCAR
EntityRadius uscarC, .2
ScaleEntity uscarC,.5,.5,.5
PositionEntity uscarC,4,-3,-87
RotateEntity uscarC,0,-90,0
EntityOrder uscarC, 0


whitecarC = LoadMesh("whitecar.3DS")
whitecarTex = LoadTexture("smallCaW.bmp")
EntityTexture whitecarC, whitecarTex
EntityType whitecarC, WHITECAR
EntityRadius whitecarC, .2
ScaleEntity whitecarC,.5,.5,.5
PositionEntity whitecarC, -135, -3, 194
EntityOrder whitecarC, 0

taxiC = LoadMesh("taxi.3DS")
taxiTex = LoadTexture("taxi.bmp")
EntityTexture taxiC, taxiTex
EntityType taxiC, TAXI
EntityRadius taxiC, .2
ScaleEntity taxiC,.5,.5,.5
PositionEntity taxiC,-137, -3, 194
EntityOrder taxiC, 0

redC = LoadMesh("redcar.3DS")
redCTex = LoadTexture("smallCaR.bmp")
EntityTexture redC, redCTex
EntityType redC, RED
EntityRadius redC, .2
ScaleEntity redC,.5,.5,.5
PositionEntity redC,-139, -3, -225
RotateEntity redC,0,-180,0
EntityOrder redC, 0




End Function



;ai for the cars to drive up and down the streets
Function moveAICars()



;police car AI
	If policeFlag = 0 Then
	
		If Not(EntityX#(policeC) < -272) Then

			PositionEntity policeC, EntityX#(policeC) -.2, EntityY#(policeC) , EntityZ#(policeC)
	
		Else
		
			PositionEntity policeC, 4, -3, 60
		
		EndIf
	
	Else
	
		RotateEntity policeC, 180, 0, 0
		
		
	EndIf
	
		
		
;hearse AI
	If hearseFlag = 0 Then
	
		If Not(EntityX#(hearseC) < -272) Then

			PositionEntity hearseC, EntityX#(hearseC) -.2, EntityY#(hearseC) , EntityZ#(hearseC)
	
		Else
		
			PositionEntity hearseC, 4,-3,-84
		
		EndIf
	
	Else
	
		RotateEntity hearseC, 180, 0, 0
		
		
	EndIf
	
	
	
;uscar AI
	If uscarFlag = 0 Then
	
		If Not(EntityX#(uscarC) < -272) Then

			PositionEntity uscarC, EntityX#(uscarC) -.5, EntityY#(uscarC) , EntityZ#(uscarC)
	
		Else
		
			PositionEntity uscarC, 4,-3,-87
		
		EndIf
	
	Else
	
		RotateEntity uscarC, 180, 0, 0
		
		
	EndIf
	
	
;whitecar AI
	If whitecarFlag = 0 Then
	
		If Not(EntityZ#(whitecarC) < -225) Then

			PositionEntity whitecarC, EntityX#(whitecarC), EntityY#(whitecarC) , EntityZ#(whitecarC) -.5
	
		Else
		
			PositionEntity whitecarC, -135, -3, 194
		
		EndIf
	
	Else
	
		RotateEntity whitecarC, 180, 0, 0
		
		
	EndIf	


;taxi AI
	If taxiFlag = 0 Then
	
		If Not(EntityZ#(taxiC) < -225) Then

			PositionEntity taxiC, EntityX#(taxiC), EntityY#(taxiC) , EntityZ#(taxiC) -.2
	
		Else
		
			PositionEntity taxiC,-137, -3, 194
		
		EndIf
	
	Else
	
		RotateEntity taxiC, 180, 0, 0
		
		
	EndIf
	
	
;redCar AI
	If redFlag = 0 Then
	
		If EntityZ#(redC) < 194 Then

			PositionEntity redC, EntityX#(redC), EntityY#(redC) , EntityZ#(redC) +.2
	
		Else
		
			PositionEntity redC,-139, -3, -225
		
		EndIf
	
	Else
	
		RotateEntity redC, 180, 0, 0
		
		
	EndIf
	
	
	
	
	

End Function