// Puts enemy soldiers into the capture state.
_unit = _this select 0;
_grp = group _unit;

debuglog format ["submit.sqf calling capture on _unit = %1", _unit];
//hint "submit calling capture";
//hint format ["submit.sqf calling capture on _unit = %1", _unit];

sleep 5;

_tag = _unit addaction [localize "STR_M04xt10","scripts\capture.sqf",0,1, true, true,""]; // "Capture"

if (isServer) then
{
	removeallweapons _unit;
	removeheadgear _unit;
	removebackpack _unit;
	removevest _unit;
//	removeuniform _unit;
	removeallassigneditems _unit;

	_unit setBehaviour "Careless";
	_unit allowFleeing 0;
	commandStop _unit;
	_unit switchmove "amovpercmstpsnonwnondnon";
	_unit disableAI "AUTOTARGET";
	
	_type = typeOf _unit;

	if (_type in EGG_EVO_enemyOff) then
	{	
		_unit addEventHandler ["killed", {EGG_EVO_sot = format["%1",(_this select 1)];EGG_EVO_sor = EGG_EVO_offpen;EGG_EVO_sop = (_this select 1);publicVariable "EGG_EVO_sop";publicVariable "EGG_EVO_sot";publicVariable "EGG_EVO_sor";(_this select 0) removealleventhandlers "killed"}];
	} else {
		_unit addEventHandler ["killed", {EGG_EVO_sot = format["%1",(_this select 1)];EGG_EVO_sor = EGG_EVO_powpen;EGG_EVO_sop = (_this select 1);publicVariable "EGG_EVO_sop";publicVariable "EGG_EVO_sot";publicVariable "EGG_EVO_sor";(_this select 0) removealleventhandlers "killed"}];
	};
};

WaitUntil {not (alive _unit) or animationState _unit == "AmovPercMstpSsurWnonDnon"};
_unit removeaction _tag;
//bringing back capture to POW_CAMP in capture script
