/* Author: Djeeberjr Description: Set up a C-RAM defence system Parameter(s): 0: OBJECT - The C-RAM. must be "B_AAA_System_01_F" 1: NUMBER - the radius Returns: Script Handle - for the main loop */ params ["_self","_radius"]; {_self removeWeapon _x} forEach weapons _self; _self addWeapon "Gatling_30mm_Plane_CAS_01_F"; _self addMagazine "1000Rnd_Gatling_30mm_Plane_CAS_01_F"; _self disableAI "TARGET"; _self disableAI "AUTOTARGET"; //start loop (see https://forums.bohemia.net/forums/topic/215598-release-c-ram-script/) _handle = [_self,_radius,_guns] spawn { params ["_self","_radius","_guns"]; _incoming = []; _isEngaging = false; while {true} do { sleep 1; _incoming = _incoming + ((getPos _self) nearObjects ["MissileBase",_radius]); _incoming = _incoming + ((getPos _self) nearObjects ["RocketBase",_radius]); _incoming = _incoming + ((getPos _self) nearObjects ["ShellBase",_radius]); if(count _incoming > 0)then{ if(not _isEngaging)then{ _self say3D ["DLib_idf",1000]; }; _incomingRound = _incoming select 0; _isEngaging = true; _fromTarget = _incomingRound getDir _self; _targetDir = direction _incomingRound; _roundChanche = 100; //Start shooting while {alive _incomingRound && (getPosATL _incomingRound select 2) > 50}do{ _target = "Land_HelipadEmpty_F" createVehicle [0,0,0]; _leadPrediction = (((_self distance _incomingRound) / 4032) * (speed _incomingRound)) / (_self distance _incomingRound); _zeroing = ((_self distance _incomingRound) / 100) * 8; _target attachTo [_incomingRound,[0,_leadPrediction,_zeroing]]; _self doWatch _target; if(alive _incomingRound)then{ if(_roundChanche == 100)then{ sleep 2; }; _self fire "Gatling_30mm_Plane_CAS_01_F"; }; sleep 0.5; deleteVehicle _target; if(alive _incomingRound)then{ _roundChanche = _roundChanche - random[0,25,100]; if(_roundChanche <= 0)then{ "helicopterexplosmall" createVehicle getPos _incomingRound; deleteVehicle _incomingRound; }; }; }; _incoming deleteAt 0; }else{ if(_isEngaging)then{ _isEngaging = false; //No more targets }; }; }; }; _handle;