/* ---------------------------------------------------------------------------------------------------- Function: GKB_fnc_randomAAFire Author: Gekkibi Terms for copying, distribution and modification: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) http://creativecommons.org/licenses/by-nc-sa/3.0/ Description: Defined AA-batteries shoots coherently to a randomly selected position. Parameters: 1st Objects in Array AA-units 2nd Arrays in array From what coordinate to other coordinate should they shoot 3rd Number Delay between targets 4th Code When true new targets are calculated Returns: Nil Example: [ [GKB_aa1, GKB_aa2, GKB_aa3], [[2000, 10000], [0, 0], [500, 600]], 20 + random 100, {GKB_e_obj < 3 && GKB_w_obj < 3} ] spawn GKB_fnc_randomAAFire; ---------------------------------------------------------------------------------------------------- */ if (isServer) then { private ["_positionArray", "_runCondition", "_sleepTime", "_unitArray"]; _unitArray = _this select 0; _positionArray = _this select 1; _sleepTime = _this select 2; _runCondition = _this select 3; while _runCondition do { private ["_direction"]; { if (! alive gunner _x) then { _unitArray = _unitArray - [_x]; }; } forEach _unitArray; if (count _unitArray == 0) exitWith {}; _direction = [ (_positionArray select 0 select 0) - random ((_positionArray select 0 select 0) - (_positionArray select 0 select 1)), (_positionArray select 1 select 0) - random ((_positionArray select 1 select 0) - (_positionArray select 1 select 1)), (_positionArray select 2 select 0) - random ((_positionArray select 2 select 0) - (_positionArray select 2 select 1)) ]; { if (alive gunner _x && isNull assignedTarget _x) then { [_x, _direction] spawn { private ["_direction", "_unit"]; _unit = _this select 0; _direction = _this select 1; _unit doWatch _direction; sleep 2; for "_x" from 1 to 1 + ceil random 5 do { sleep random 2; for "_x" from 1 to 5 do { if (! isNull assignedTarget _unit) exitWith {}; _unit fire currentWeapon _unit; sleep 0.3; }; if (! isNull assignedTarget _unit) exitWith {}; _unit doWatch _direction; }; if (isNull assignedTarget _unit) then { _unit doWatch objNull; } else { _unit doWatch assignedTarget _unit; }; _unit setVehicleAmmo 1; }; }; } forEach _unitArray; sleep _sleepTime; }; };