--project->F map script file

--global variables
outbuffer={};
runtime=0;
oldruntime=0;
pi=3.1416;

--operation types
OPTYPE=
{
	NEWUNIT=0,
	UPDATEUNIT=1,
	UPDATEGROUP=2,
	NEWGEFFECT=3,
	USEPANEL=4,
	UPDATEPANEL=5,
	UPDATEWIDGET=6,
	CREATEPANEL=7,
	CREATEWIDGET=8,
	UPDATECAMERA=9,
	UPDATEMAPMODEL=10,
	DEBUG=11,
	AIGOTO=12,
	AIGOBYWAYPOINT=13,
	GAMECONTROL=14,
	LOADTEXTURE=15,
	NEWBULLET=16
}

--widget types
WIDGETTYPE=
{
	BUTTON=0,
 	CHECKBOX=1,
  	RADIOBOX=2,
   	SCROLLBAR=3,
    	STATIC=4,
     	POPLIST=5,
      	PROGRESSBAR=6,
       	LIST=7
}

--color themes
COLORTHEME=
{
	GREY=0,
	BLUE=1,
	FLATBLUE=2,
	ORANGE=3,
	FLATORANGE=4,
	TRANSPARENT=5
}

--game Control Commands
GAMECONTROL=
{
	PAUSE=0,
	RESUME=1,
	BLOCKINPUT=2,
	ALLOWINPUT=3,
	WIN=4,
	LOSE=5
}

--camera types
CAMERATYPE=
{
	FOLLOWPLAYER=1,
	SIDEPLAYER=2,
	FOLLOWTARGET=3,
	FREECAMERA=0
}

--create a new unit with given properties
function newUnit(name,group,unit,team,x,y,z,a)
	return {operation=OPTYPE.NEWUNIT,name=name,group=group,unit=unit,team=team,x=x,y=y,z=z,a=a};
end;

--update existing unit properties by name
function updateUnit(name)
	return {operation=OPTYPE.UPDATEUNIT,name=name};
end;

--update existing unit properties by group name
function updateGroup(group)
	return {operation=OPTYPE.UPDATEGROUP,group=group};
end;

--create a new graphic effect with given properties
function newGEffect(effect,x,y,z,dx,dy,dz)
	return {operation=OPTYPE.NEWGEFFECT,effect=effect,x=x,y=y,z=z,dx=dx,dy=dy,dz=dz};
end;

--enable a panel for later use
function usePanel(name,use)
	return {operation=OPTYPE.USEPANEL,name=name,use=use};
end;

--create a new panel with given properties
function createPanel(name,x,y,z,w,h,caption)
	return {operation=OPTYPE.CREATEPANEL,name=name,x=x,y=y,z=z,w=w,h=h,caption=caption};
end;

--create a new new widget on a given panel
--the properties has to be manually set, according to the type of the widget
function createWidget(widget,name,panel,x,y,z,w,h)
	return {operation=OPTYPE.CREATEWIDGET,widget=widget,name=name,panel=panel,x=x,y=y,z=z,w=w,h=h};
end;

--set the position and direction of the camera
function updateCamera()
	return {operation=OPTYPE.UPDATECAMERA};
end;

--set the position and direction of a map model, according to its index
function updateMapModel(model)
	return {operation=OPTYPE.UPDATEMAPMODEL,model=model};
end;

--send debug infomation to console
function debug(text)
	return {operation=OPTYPE.DEBUG,text=text};
end;

--make units goto the given position by shotest route
function aiGoto(unit,group,x,y)
	return {operation=OPTYPE.AIGOTO,unit=unit,group=group,x=x,y=y};
end;

--make units goto the given position, through given waypoints
function aiGoByWaypoint(unit,group,x,y,waypoint)
	return {operation=OPTYPE.AIGOBYWAYPOINT,unit=unit,group=group,x=x,y=y,waypoint=waypoint};
end;

--set game status
function gameControl(control)
	return {operation=OPTYPE.GAMECONTROL,control=control};	
end;

--load a texture for UI usage
function loadTexture(texname)
	return {operation=OPTYPE.LOADTEXTURE,texname=texname};
end;

--create a new bullet with given properties
function newBullet(bullet,source,target,x,y,z,a,b,dx,dy,dz)
	return {operation=OPTYPE.NEWBULLET,bullet=bullet,source=source,target=target,x=x,y=y,z=z,a=a,b=b,dx=dx,dy=dy,dz=dz};
end;

--push the element into output buffer
function pushBuffer(elem)
	outbuffer[outbuffer.size] = elem;
	outbuffer.size = outbuffer.size + 1;
end;

--empty the output buffer
function emptyBuffer()
	outbuffer = {size=0};
end;

--[USER CODE]
