
; Create enemy unit



_built = (BUILT select 2)
_dir = getDir _built

_dista = 90 + (random 25)
_distb = 90 + (random 10)

		? _this == "attackbuilding" : _dista=-50

_x = (getPos _built select 0) + _distb * (sin(_dir)) + _dista * (cos(_dir))
_y = (getPos _built select 1) + _distb * (cos(_dir)) - _dista * (sin(_dir))
_z = 0

	_class = "WW4dune_linf_"
	if (MYSIDEVAR == East) then {_class=_class+"Atreides"} else {_class=_class+"Harkonnen"}
	
	_group = BLUEspawn
	? MYSIDEVAR == West : _group = REDspawn
	
	_class createUnit [[_x,_y,_z],  _group, "ENEMIES=ENEMIES+[this]", 1, "PRIVATE"] 
	_newGuy = ENEMIES select (count ENEMIES - 1)
	
	
	~0.5
	
	_newGuy setUnitPos "UP"
	_newGuy setSpeedMode "FULL"
	_newGuy setSkill 1
	_newGuy allowFleeing 0 
	_newGuy setCombatMode "BLUE"
	_newGuy setBehaviour "AWARE"
	_newGuy addeventhandler ["killed", {playSound "scream"}]

	_newGuy exec "Unit\Blood.sqs"
	_newGuy exec "Unit\Magazines.sqs"
	_newGuy addEventHandler ["fired", {_this exec "bullet.sqs"}]
	

~0.5
[_newGuy] join grpnull
_dista = 0 + (random 20)
_distb = 18 + 0

_x = (getPos _built select 0) + _distb * (sin(_dir)) + _dista * (cos(_dir))
_y = (getPos _built select 1) + _distb * (cos(_dir)) - _dista * (sin(_dir))
_z = 0
_newGuy move [_x,_y,_z]

_logic = "logic" camCreate [0,0,0]
_logic setPos [_x,_y,_z]


;Drop ["cl_water","","Billboard",1,5,[0,0,0],[0,0,0.02],0,1.2,1.1,0,[1.2,0,0],[[0.8,0.8,0,1]],[0,1,0],1,0.8,"","",_logic]


	_script = "Enemy\" + _this + ".sqs"
	;player globalchat format ["%1",_script]
	[_newGuy,_x,_y] exec _script


	
	
	@!alive _newGuy
	ENEMIES = ENEMIES - [_newGuy]