Skip to content

Commit

Permalink
Move bits from fnc_combatSupport to fnc_artillery
Browse files Browse the repository at this point in the history
  • Loading branch information
marceldev89 committed Oct 21, 2016
1 parent 617aa2c commit fcd8149
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 38 deletions.
32 changes: 32 additions & 0 deletions addons/sup_artillery/fnc_artillery.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -242,18 +243,49 @@ 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 = [
configFile >> "ArtilleryStateMachine"
] call CBA_statemachine_fnc_createFromConfig;
};

// Add artillery group to state machine
ALIVE_sup_artillery_stateMachine_list pushBack _logic;

_result = _group;
Expand Down
40 changes: 2 additions & 38 deletions addons/sup_combatsupport/fnc_combatSupport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};

Expand Down

0 comments on commit fcd8149

Please sign in to comment.