waitUntil {((player distance getMarkerPos "Task_7") <= 100)};


/*
	File: "sts_unitspawn.sqf";
	Author: Phantom
	visit: http://www.24th-sts.eu
			
	e.g.
	[[position,number of units,radius] execvm "sts_unitspawn";
	
	sts_unitspawn = compile preprocessFile "sts_unitspawn.sqf"; // call from init.sqf
	[[position,number of units,radius] call sts_unitspawn;
	
	terms of use: feel free to use and modify
*/

if (!isServer) exitWith {};

private ["_pos","_num","_unitpool","_unitspawn","_grp","_type","_behaviourpool","_behaviour"];

_pos = _this select 0;
_num = _this select 1;
_rad = _this select 2;

_unitpool =
[
	"rhs_vdv_at",
	"rhs_vdv_efreitor",
	"rhs_vdv_grenadier_rpg",
	"rhs_vdv_aa",
	"rhs_vdv_maschinegunner",
	"rhs_vdv_arifleman",
	"rhs_vdv_medic",
	"rhs_vdv_rifleman",
	"rhs_vdv_grenadier",
	"rhs_vdv_marksman"
];

for "_unitspawn" from 1 to _num do
{
	_grp = creategroup east;
	_type = _unitpool call bis_fnc_selectRandom;
	_unit = _grp createUnit [_type, _pos, [], 0, "private"];
	[_unit,2 + floor(random 3)] call sts_unitskill;
	[_unit,_pos,_rad] call cba_fnc_taskPatrol;
	//_behaviourpool = ["careless","safe","aware","combat"];
	_behaviourpool = ["careless","safe","aware"];
	_behaviour = _behaviourpool call bis_fnc_selectRandom;
	_unit setBehaviour _behaviour;
	_unit setspeedmode "limited";
	{_x addmpeventhandler ["mpkilled", {_this execvm "scripts\deletebody.sqf"}]} forEach units _grp;
};
