1- params [" _supType" ];
2- private [" _mode" , " _units" , " _supType" , " _type" , " _static" , " _unit" , " _crew" , " _role" , " _turret" , " _text" ];
3- _units = [];
4-
5- {
6- _units pushback (AIO_HCSelectedUnits select _x );
7- } forEach AIO_HCSelectedUnitsNum;
1+ params [" _units" , " _supType" , " _isHC" ];
2+ private [" _mode" , " _supType" , " _type" , " _static" , " _unit" , " _crew" , " _role" , " _turret" , " _text" ];
83
94if (count _units == 0 ) exitWith {};
105
11- AIO_supportGroups append _units ;
12-
6+ _subUnits = [];
137if (_supType == 0 ) then {
148 _mode = 1 ;
159 {
10+ _unit = _x ;
1611 _back = backpack _x ;
1712 _veh = vehicle _x ;
18- if (getText (configfile >> " CfgVehicles" >> _back >> " faction" ) ! = " Default" && ( _mode ! = 2 )) then {_mode = 1 };
19- if ((_veh isKindOf " Staticweapon" ) || (getText (configfile >> " CfgVehicles" >> typeOf _veh >> " editorSubcategory" ) == " EdSubcat_Artillery" )) then {_mode = 2 };
13+ if (getText (configfile >> " CfgVehicles" >> _back >> " faction" ) ! = " Default" && _back ! = " " ) then {_mode = 1 ; _subUnits pushBack _x };
14+ if ((_veh isKindOf " Staticweapon" ) || (getText (configfile >> " CfgVehicles" >> typeOf _veh >> " editorSubcategory" ) == " EdSubcat_Artillery" )) exitWith {_mode = 2 };
2015 } forEach _units ;
2116};
2217
23- if (isNil " AIO_support_requester" || {isNull AIO_support_requester}) then {
18+ if (isNil " AIO_support_requester" || {! alive AIO_support_requester}) then {
2419 AIO_support_requester = " SupportRequester" createVehicleLocal [0 , 0 , 0 ];
2520 AIO_support_requester setVehicleVarName " AIO_support_requester" ;
2621};
@@ -37,78 +32,111 @@ if (isNil "AIO_support_requester" || {isNull AIO_support_requester}) then {
3732 " Transport"
3833];
3934
35+
36+ _originalGroup = group (_units select 0 );
37+
4038call {
4139 _continue = false ;
42- if (_subType == 0 ) exitWith {
43- {
44- _unit = _x ;
45- if ((vehicle _unit ) isKindOf " Tank" || (vehicle _unit ) isKindOf " staticweapon" ) exitWith {_continue = true };
46- } forEach _units ;
47-
48- if ! (_continue ) then {_unit = _units select 0 };
40+ if (_supType == 0 ) exitWith {
4941
50- if (count _units ! = 2 && _mode == 1 ) exitWith {hintSilent " You need to select 2 members." };
42+ if (count _subUnits < 2 && _mode == 1 ) exitWith {hintSilent " You need to select 2 members." };
5143
5244 _veh = vehicle _unit ;
5345
5446 _crew = fullCrew [vehicle _unit , " " , false ];
5547 {
5648 if (_x select 0 == _unit ) then {_role = _x select 1 ; if (_role == " Turret" ) then {_turret = _x select 3 }};
5749 } forEach _crew ;
58- AIO_support_arty_grp = createGroup (side player );
50+
51+ if (_mode == 1 ) then {
52+ _unit1 = _subUnits select 0 ;
53+ _unit2 = _subUnits select 1 ;
54+
55+ _tempUnit = objNull ;
56+ _originalLeader = leader _originalGroup ;
57+ if (_unit1 == _originalLeader || _unit2 == _originalLeader ) then {
58+ _tempUnit = _originalGroup createUnit [typeOf _unit , [0 ,0 ,1e6 ], [], 0 , " NONE" ];
59+
60+ _originalGroup selectLeader _tempUnit ;
61+ _tempUnit enableSimulation false ;
62+ };
63+
64+ sleep 1 ;
65+
66+ _pos = ASLToAGL (getPosASL _unit1 ) vectorAdd [0 ,0 ,0.5 ];
67+
68+ _target = [_unit1 ] call AIO_fnc_getHideFrom ;
69+
70+ _dir = if (! alive _target ) then {0 } else {_pos getDir (getPosASL _target )};
71+
72+ [_unit1 ,[14 ,_unit2 ,[_pos ,_dir ],objNull ], 0 ] call AIO_fnc_pushToQueue ;
73+ [_unit2 ,[14 ,_unit1 ,[_pos ,_dir ],objNull ], 0 ] call AIO_fnc_pushToQueue ;
74+ [_unit1 , _unit2 ] call AIO_fnc_sync ;
75+
76+ waitUntil {sleep 1 ; ! (_unit1 in AIO_taskedUnits) && ! (_unit2 in AIO_taskedUnits)};
77+
78+ sleep 3 ;
79+
80+ _vehs = _unit1 nearObjects [" staticweapon" , 10 ];
81+ if (alive _tempUnit ) then {deleteVehicle _tempUnit };
82+
83+ if (count _vehs == 0 ) then {
84+ _vehs = _unit2 nearObjects [" staticweapon" , 10 ];
85+ if (count _vehs ! = 0 ) then {_continue = true }
86+ } else {
87+ _continue = true
88+ };
89+
90+ if ! (_continue ) exitWith {};
91+
92+ _veh = _vehs select 0 ;
93+ _role = " Gunner" ;
94+
95+ _originalGroup selectLeader _originalLeader ;
96+ _continue = true ;
97+ } else {
98+ _continue = true
99+ };
100+
101+ if ! (_continue ) exitWith {hintSilent " Cannot create a group with the selected unit(s)" };
102+
103+ AIO_support_arty_grp = createGroup (side _originalGroup );
59104
60105 _units joinSilent AIO_support_arty_grp;
61106
62107 AIO_support_arty_grp selectLeader _unit ;
63108
64- if (isNil " AIO_support_arty" || {isNull AIO_support_arty}) then {
109+ if (isNil " AIO_support_arty" || {! alive AIO_support_arty}) then {
65110 AIO_support_arty = " SupportProvider_Artillery" createVehicleLocal [0 , 0 , 0 ];
66111 AIO_support_arty setVehicleVarName " AIO_support_arty" ;
67112 };
68- if (_mode == 1 ) then {
69- _support_handler = [_units , getPos _unit ] spawn AIO_fnc_assembleStatic ;
70- waitUntil {scriptDone _support_handler };
71- sleep 5 ;
72- _static = _unit nearObjects [" staticweapon" , 10 ];
73- _units = _units - [_unit ];
74- _units joinSilent group player ;
75- _static = _static select 0 ;
76- // _support_handler = [[_unit], _static, 0, false] call AIO_fnc_getIn;
77- _unit assignAsGunner _static ;
78- [_unit ] orderGetIn true ;
79- waitUntil {vehicle _unit ! = _unit || ! alive _unit || ! (_unit in (units AIO_support_arty_grp))};
80- sleep 1 ;
81- _veh = _static ; _role = " Gunner" ;
82- };
83-
84- if (isNil " _role" ) exitWith {hintSilent " Cannot create a group with the selected unit(s)" ; _units joinSilent (group player )};
85113
86114 if (_role == " Turret" ) then {_text = format [" _unit assignAs%1 [_veh, %2]" , _role , _turret ]} else {_text = format [" _unit assignAs%1 _veh" , _role ]};
87115
88116 call compile _text ;
89117 {
90- if ! (_x in (units AIO_support_arty_grp)) then {[_x ] join AIO_support_arty_grp};
118+ if ! (_x in (units AIO_support_arty_grp)) then {[_x ] join AIO_support_arty_grp; _units pushBackUnique _x };
91119 } forEach crew (vehicle _unit );
92120
93- (units AIO_support_arty_grp) orderGetIn true ;
94-
95- AIO_supportGroups append (crew (vehicle _unit ) - [_unit ]);
96-
97121 {
98- if (vehicle _x ! = vehicle _unit ) then {[_x ] joinSilent group player ; AIO_supportGroups = AIO_supportGroups - [_x ]};
99- } forEach (units AIO_support_arty_grp);
122+ if (vehicle _x ! = _veh ) then {[_x ] joinSilent _originalGroup ; _units = _units - [_x ]};
123+ } forEach (( units AIO_support_arty_grp) - [ _unit ] );
100124
101- _unit = (leader AIO_support_arty_grp);
125+ (units AIO_support_arty_grp) orderGetIn true ;
126+
127+ // _unit = (leader AIO_support_arty_grp);
102128
103129 _unit synchronizeObjectsAdd [AIO_support_arty];
104130
105131 player synchronizeObjectsAdd [AIO_support_requester];
106132
107133 [player , AIO_support_requester, AIO_support_arty] call BIS_fnc_addSupportLink ;
134+
135+ if ! (_isHC ) then {AIO_supportGroups append _units };
108136 };
109137
110138
111- if (_subType == 1 ) exitWith {
139+ if (_supType == 1 ) exitWith {
112140
113141 {
114142 _unit = _x ;
@@ -125,44 +153,45 @@ call {
125153 if (_x select 0 == _unit ) then {_role = _x select 1 ; if (_role == " Turret" ) then {_turret = _x select 3 }};
126154 } forEach _crew ;
127155
128- if (isNil " _role" ) exitWith {hintSilent " Cannot create a group with the selected unit(s)" ; _units joinSilent (group player )};
156+ if (isNil " _role" ) exitWith {hintSilent " Cannot create a group with the selected unit(s)" ; _units joinSilent (_originalGroup )};
129157
130158 _landed = [_veh , false ] call AIO_fnc_analyzeHeli ;
131159 if (_landed ) then {
132160 _landPad = createVehicle [" Land_HelipadEmpty_F" , [0 ,0 ,0 ]];
133161 _landPad setPosASL (getPosASL _veh );
134162 };
135163
136- if (isNil " AIO_support_cas_heli" || {isNull AIO_support_cas_heli}) then {
164+ if (isNil " AIO_support_cas_heli" || {! alive AIO_support_cas_heli}) then {
137165 AIO_support_cas_heli = " SupportProvider_CAS_Heli" createVehicleLocal [0 , 0 , 0 ];
138166 AIO_support_cas_heli setVehicleVarName " AIO_support_cas_heli" ;
139167 };
140- AIO_support_cas_heli_grp = createGroup (side player );
168+ AIO_support_cas_heli_grp = createGroup (side _originalGroup );
141169 _units joinSilent AIO_support_cas_heli_grp;
142170 AIO_support_cas_heli_grp selectLeader _unit ;
143171
144172 if (_role == " Turret" ) then {_text = format [" _unit assignAs%1 [_veh, %2]" , _role , _turret ]} else {_text = format [" _unit assignAs%1 _veh" , _role ]};
145173 call compile _text ;
146174 {
147- if ! (_x in (units AIO_support_cas_heli_grp)) then {[_x ] join AIO_support_cas_heli_grp};
175+ if ! (_x in (units AIO_support_cas_heli_grp)) then {[_x ] join AIO_support_cas_heli_grp; _units pushBackUnique _x };
148176 } forEach crew (vehicle _unit );
149177
150- (units AIO_support_cas_heli_grp) orderGetIn true ;
151-
152- AIO_supportGroups append (crew (vehicle _unit ) - [_unit ]);
153178 {
154- if (vehicle _x ! = vehicle _unit ) then {[_x ] joinSilent group player ; AIO_supportGroups = AIO_supportGroups - [_x ]};
179+ if (vehicle _x ! = _veh ) then {[_x ] joinSilent _originalGroup ; _units = _units - [_x ]};
155180 } forEach (units AIO_support_cas_heli_grp);
156181
182+ (units AIO_support_cas_heli_grp) orderGetIn true ;
183+
157184 _unit synchronizeObjectsAdd [AIO_support_cas_heli];
158185
159186 player synchronizeObjectsAdd [AIO_support_requester];
160187
161188 [player , AIO_support_requester, AIO_support_cas_heli] call BIS_fnc_addSupportLink ;
189+
190+ if ! (_isHC ) then {AIO_supportGroups append _units };
162191 };
163192
164193
165- if (_subType == 2 ) exitWith {
194+ if (_supType == 2 ) exitWith {
166195 {
167196 _unit = _x ;
168197 if ((vehicle _unit ) isKindOf " Plane" ) exitWith {_continue = true };
@@ -175,30 +204,35 @@ call {
175204 {
176205 if (_x select 0 == _unit ) then {_role = _x select 1 ; if (_role == " Turret" ) then {_turret = _x select 3 }};
177206 } forEach _crew ;
178- if (isNil " AIO_support_cas_bomb" || {isNull AIO_support_cas_bomb}) then {
207+ if (isNil " AIO_support_cas_bomb" || {! alive AIO_support_cas_bomb}) then {
179208 AIO_support_cas_bomb = " SupportProvider_CAS_Bombing" createVehicleLocal [0 , 0 , 0 ];
180209 AIO_support_cas_bomb setVehicleVarName " AIO_support_cas_bomb" ;
181210 };
182- AIO_support_cas_bomb_grp = createGroup (side player );
211+ AIO_support_cas_bomb_grp = createGroup (side _originalGroup );
183212 _units joinSilent AIO_support_cas_bomb_grp;
184213 AIO_support_cas_bomb_grp selectLeader _unit ;
185214 if (_role == " Turret" ) then {_text = format [" _unit assignAs%1 [_veh, %2]" , _role , _turret ]} else {_text = format [" _unit assignAs%1 _veh" , _role ]};
186215 call compile _text ;
187216 {
188- if ! (_x in (units AIO_support_cas_bomb_grp)) then {[_x ] join AIO_support_cas_bomb_grp};
217+ if ! (_x in (units AIO_support_cas_bomb_grp)) then {[_x ] join AIO_support_cas_bomb_grp; _units pushBackUnique _x };
189218 } forEach crew (vehicle _unit );
190- ( units AIO_support_cas_bomb_grp) orderGetIn true ;
191- AIO_supportGroups append ( crew ( vehicle _unit ) - [ _unit ]);
219+
220+
192221 {
193- if (vehicle _x ! = vehicle _unit ) then {[_x ] joinSilent group player ; AIO_supportGroups = AIO_supportGroups - [_x ]};
222+ if (vehicle _x ! = _veh ) then {[_x ] joinSilent _originalGroup ; _units = _units - [_x ]};
194223 } forEach (units AIO_support_cas_bomb_grp);
224+
225+ (units AIO_support_cas_bomb_grp) orderGetIn true ;
226+
195227 _unit synchronizeObjectsAdd [AIO_support_cas_bomb];
196228 player synchronizeObjectsAdd [AIO_support_requester];
197229 [player , AIO_support_requester, AIO_support_cas_bomb] call BIS_fnc_addSupportLink ;
230+
231+ if ! (_isHC ) then {AIO_supportGroups append _units };
198232 };
199233
200234
201- if (_subType == 3 ) exitWith {
235+ if (_supType == 3 ) exitWith {
202236 {
203237 _unit = _x ;
204238 _veh = vehicle _unit ;
@@ -219,27 +253,32 @@ call {
219253 _landPad setPosASL (getPosASL _veh );
220254 };
221255
222- if (isNil " AIO_support_trans" || {isNull AIO_support_trans}) then {
256+ if (isNil " AIO_support_trans" || {! alive AIO_support_trans}) then {
223257 AIO_support_trans = " SupportProvider_Transport" createVehicleLocal [0 , 0 , 0 ];
224258 AIO_support_trans setVehicleVarName " AIO_support_trans" ;
225259 };
226260
227- AIO_support_trans_grp = createGroup (side player );
261+ AIO_support_trans_grp = createGroup (side _originalGroup );
228262 _units joinSilent AIO_support_trans_grp;
229263 AIO_support_trans_grp selectLeader _unit ;
230264 if (_role == " Turret" ) then {_text = format [" _unit assignAs%1 [_veh, %2]" , _role , _turret ]} else {_text = format [" _unit assignAs%1 _veh" , _role ]};
231265 call compile _text ;
232266 {
233- if ! (_x in (units AIO_support_trans_grp)) then {[_x ] join AIO_support_trans_grp};
267+ if ! (_x in (units AIO_support_trans_grp)) then {[_x ] join AIO_support_trans_grp; _units pushBackUnique _x };
234268 } forEach crew (vehicle _unit );
235- ( units AIO_support_trans_grp) orderGetIn true ;
269+
236270 (crew (vehicle _unit ) - [_unit ]) join AIO_support_trans_grp;
237- AIO_supportGroups append ( crew ( vehicle _unit ) - [ _unit ]);
271+
238272 {
239- if (vehicle _x ! = vehicle _unit ) then {[_x ] joinSilent group player ; AIO_supportGroups = AIO_supportGroups - [_x ]};
273+ if (vehicle _x ! = _veh ) then {[_x ] joinSilent _originalGroup ; _units = _units - [_x ]};
240274 } forEach (units AIO_support_trans_grp);
275+
276+ (units AIO_support_trans_grp) orderGetIn true ;
277+
241278 _unit synchronizeObjectsAdd [AIO_support_trans];
242279 player synchronizeObjectsAdd [AIO_support_requester];
243280 [player , AIO_support_requester, AIO_support_trans] call BIS_fnc_addSupportLink ;
281+
282+ if ! (_isHC ) then {AIO_supportGroups append _units };
244283 };
245284};
0 commit comments