From db0b266e9e4c03dba0946160aded3d550c9bd56f Mon Sep 17 00:00:00 2001 From: Marcel de Vries Date: Sat, 24 Sep 2016 16:07:56 +0200 Subject: [PATCH] Move bits from fnc_combatSupport to fnc_artillery --- addons/sup_artillery/fnc_artillery.sqf | 32 +++++++++++++++ .../sup_combatsupport/fnc_combatSupport.sqf | 40 +------------------ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/addons/sup_artillery/fnc_artillery.sqf b/addons/sup_artillery/fnc_artillery.sqf index 8709d9f66..16892080c 100644 --- a/addons/sup_artillery/fnc_artillery.sqf +++ b/addons/sup_artillery/fnc_artillery.sqf @@ -234,6 +234,7 @@ switch (_operation) do { private _side = _type call ALIVE_fnc_classSide; private _group = createGroup _side; + private _vehicles = []; for "_i" from 0 to 2 do { // TODO: Spawn vehicles in proper fancy formation (see CfgFormations) @@ -242,11 +243,41 @@ switch (_operation) do { _vehicle setDir (getDir _logic); _vehicle lock true; [_vehicle, _group] call BIS_fnc_spawnCrew; + _vehicles pushBack _vehicle; }; _group setVariable ["logic", _logic]; _logic setVariable ["group", _group]; + // Set available rounds + private _rounds = [ + ["HE", parseNumber (_artyLogic getVariable ["artillery_he", "30"])], + ["ILLUM", parseNumber (_artyLogic getVariable ["artillery_illum", "30"])], + ["SMOKE", parseNumber (_artyLogic getVariable ["artillery_smoke", "30"])], + ["SADARM", parseNumber (_artyLogic getVariable ["artillery_guided", "30"])], + ["CLUSTER", parseNumber (_artyLogic getVariable ["artillery_cluster", "30"])], + ["LASER", parseNumber (_artyLogic getVariable ["artillery_lg", "30"])], + ["MINE", parseNumber (_artyLogic getVariable ["artillery_mine", "30"])], + ["AT MINE", parseNumber (_artyLogic getVariable ["artillery_atmine", "30"])], + ["ROCKETS", parseNumber (_artyLogic getVariable ["artillery_rockets", "16"])] + ]; + + private _roundsAvailable = []; + private _roundsUnit = (typeOf (_vehicles select 0)) call ALIVE_fnc_getArtyRounds; + + { + if ((_x select 0) in _roundsUnit) then { + _roundsAvailable pushBack _x; + }; + } forEach _rounds; + + // Assign artillery group to the NEO_radio scripts + leader _group setVariable ["NEO_radioArtyBatteryRounds", _roundsAvailable, true]; + private _a = NEO_radioLogic getVariable format ["NEO_radioArtyArray_%1", _side]; + _a set [count _a, [leader _group, _group, _callsign, _vehicles, _roundsAvailable]]; + NEO_radioLogic setVariable [format ["NEO_radioArtyArray_%1", _side], _a, true]; + + // Start state machine if it hasn't already if (isNil "ALIVE_sup_artillery_stateMachine") then { ALIVE_sup_artillery_stateMachine_list = []; ALIVE_sup_artillery_stateMachine = [ @@ -254,6 +285,7 @@ switch (_operation) do { ] call CBA_statemachine_fnc_createFromConfig; }; + // Add artillery group to state machine ALIVE_sup_artillery_stateMachine_list pushBack _logic; _result = _group; diff --git a/addons/sup_combatsupport/fnc_combatSupport.sqf b/addons/sup_combatsupport/fnc_combatSupport.sqf index 8c9b29efe..c25220d66 100644 --- a/addons/sup_combatsupport/fnc_combatSupport.sqf +++ b/addons/sup_combatsupport/fnc_combatSupport.sqf @@ -673,48 +673,12 @@ switch(_operation) do { NEO_radioLogic setVariable [format ["NEO_radioArtyArray_%1", _side], _a, true]; //} forEach SUP_ARTYARRAYS; - } forEach []; + } forEach []; // TODO: Delete entire block once arty fixes are done :-) - // TODO: Move most of the code below to ALIVE_fnc_artillery for "_i" from 0 to ((count synchronizedObjects _logic)-1) do { if (typeOf ((synchronizedObjects _logic) select _i) == "ALiVE_sup_artillery") then { private _artyLogic = (synchronizedObjects _logic) select _i; - private _group = [_artyLogic, "spawn"] call ALIVE_fnc_artillery; - private _vehicles = []; - - { - if (vehicle _x != _x && {!(vehicle _x in _vehicles)}) then { - _vehicles pushBack (vehicle _x); - }; - } forEach (units _group); - - private _callsign = _artyLogic getVariable ["artillery_callsign","FOX ONE"]; - - private _rounds = [ - ["HE", parseNumber (_artyLogic getVariable ["artillery_he", "30"])], - ["ILLUM", parseNumber (_artyLogic getVariable ["artillery_illum", "30"])], - ["SMOKE", parseNumber (_artyLogic getVariable ["artillery_smoke", "30"])], - ["SADARM", parseNumber (_artyLogic getVariable ["artillery_guided", "30"])], - ["CLUSTER", parseNumber (_artyLogic getVariable ["artillery_cluster", "30"])], - ["LASER", parseNumber (_artyLogic getVariable ["artillery_lg", "30"])], - ["MINE", parseNumber (_artyLogic getVariable ["artillery_mine", "30"])], - ["AT MINE", parseNumber (_artyLogic getVariable ["artillery_atmine", "30"])], - ["ROCKETS", parseNumber (_artyLogic getVariable ["artillery_rockets", "16"])] - ]; - - private _roundsAvailable = []; - private _roundsUnit = (typeOf (_vehicles select 0)) call ALIVE_fnc_getArtyRounds; - - { - if ((_x select 0) in _roundsUnit) then { - _roundsAvailable pushBack _x; - }; - } forEach _rounds; - - leader _group setVariable ["NEO_radioArtyBatteryRounds", _roundsAvailable, true]; - private _a = NEO_radioLogic getVariable format ["NEO_radioArtyArray_%1", side _group]; - _a set [count _a, [leader _group, _group, _callsign, _vehicles, _roundsAvailable]]; - NEO_radioLogic setVariable [format ["NEO_radioArtyArray_%1", side _group], _a, true]; + [_artyLogic, "spawn"] call ALIVE_fnc_artillery; }; };