PRIVATE ["_unit","_zeit","_rakete","_x","_y","_z","_entfernung","Basisflugfaktor","_Flugzeit","_zielrakete","_vel","_rand1","_rn","_m"];

_rakete = nearestObject [vehicle (_this select 0), _this select 4];
_unit= vehicle (_this select 0);

_Basisflugfaktor=100;
_Rakettetyp= "R_MLRS";

_zeit=time;	
_entfernung=_unit distance [x,y,0];
_Flugzeit=(_entfernung/_Basisflugfaktor)+(z*10);
_y=y;
_x=x;
Vehicle Player Vehiclechat format ["Flugzeit :%1 Sec Entfernung :%2 M",round _Flugzeit,round _entfernung];
while {Alive _rakete} do
	 	{
		if ((_zeit+2.8) <= time) then
		{
		_rakete setpos [0,0,0];
		};	
		sleep 0.1;		
		};
if ((_zeit+2.7) <= time) then
		{
		deleteVehicle _rakete;
		waitUntil {sleep 0.1;((_Flugzeit+_zeit)<=time)};
		Vehicle player Vehiclechat "Einschlag";
		_m=0;
		_rand1=0+random 1;
		_rn = (_rand1 + 0.5) - ((_rand1 + 0.5) Mod 1);
		if (_rn == 1) then {_m=-1;};
		if (_rn == 0) then {_m=1;};
		_xs=(_x+random(50*_m));
		_ys=(_y+random(50*_m));
		Player sidechat format ["X :%1 Y :%2",_xs,_ys];
		if ((typeof _rakete) == _Rakettetyp) then
			{	
			_zielrakete="ARTY_R_227mm_HE" createVehicle [_xs,_ys,500];
			}
		else
			{
			_zielrakete="ARTY_Sh_81_HE" createVehicle [_xs,_ys,500];
			};
		}
else
		{
		Vehicle Player Vehiclechat "Kontakt zur Rakete verloren";
		};