// File: Actions.agc
// Created: 20-04-10

#constant ACTION_GO			0
#constant ACTION_STOP		1
#constant ACTION_PAUSE		2
#constant ACTION_3BACK		3
#constant ACTION_3FORWARD		4
#constant ACTION_SLOW		5

#constant FOREVER			-1
#constant FOLLOW_PATH		999

type tMove
	acc				as integer
	turn				as integer
	time				as float
endtype

type tAction
	name				as string
	nextAction			as integer
	start				as float
	current				as integer
	speed				as float
	move				as tMove[]
endtype

global gActions		as tAction[]

function LoadActions(name as string)
	gActions.load(name)
endfunction

function GetAction(no as integer, vehicle as tVehicle)
	if vehicle.action.name = "slow"
		vehicle = vehicle
	endif
endfunction gActions[no]
	
function GetvehicleById(id as integer)
	i as integer
	v as tVehicle
	
	for i=0 to gVehicles.length
		v = gVehicles[i]
		if v.hit = id
			exitfunction v
		endif
	next
	
	v.hit = -1
	
endfunction v

function GetActionByName(name as string)
	i as integer
	r as integer
	a as tAction	
	
	for i=0 to gActions.length
		a = gActions[i]
		if a.name = name
			exitfunction a
		endif
	next
	
	a.name = "bad"
		
endfunction a

