@@ -19,34 +19,55 @@ params ["_unit"];
1919private _chestpack = [_unit ] call FUNC(chestpack);
2020private _chestpackLoadout = [_unit ] call FUNC(chestpackLoadout);
2121private _chestpackVariables = [_unit ] call FUNC(chestpackVariables);
22+ private _chestpackAcreRadios = [_unit ] call FUNC(chestpackAcreRadios);
2223
2324private _shouldSwitchNVGs = currentVisionMode _unit ! = 0 ;
2425
2526// make sure the player has a chestpack and no backpack
2627if ((_chestpack isEqualTo " " ) or (backpack _unit isNotEqualTo " " )) exitWith {};
2728
28- // add items
29- private _loadout = getUnitLoadout _unit ;
30- _loadout set [5 , [_chestpack , _chestpackLoadout ]];
31- _unit setUnitLoadout _loadout ;
29+ private _acreEnabled = [_unit ] call FUNC(acreIsInitialized);
30+ private _preRadios = [];
31+ if (_acreEnabled && {! (_chestpackAcreRadios isEqualTo [])}) then {
32+ _preRadios = [_unit ] call acre_api_fnc_getAllRadios ;
33+ };
34+
35+ if (_acreEnabled ) then {
36+ // Avoid setUnitLoadout when ACRE is running to prevent full radio re-init.
37+ _unit addBackpackGlobal _chestpack ;
38+ private _backpack = backpackContainer _unit ;
39+ [_backpack , _chestpackLoadout ] call FUNC(setBackpackLoadout);
40+ } else {
41+ // add items
42+ private _loadout = getUnitLoadout _unit ;
43+ _loadout set [5 , [_chestpack , _chestpackLoadout ]];
44+ _unit setUnitLoadout _loadout ;
45+ };
3246
3347if (GVAR(isACEAXLoaded)) then {
3448 [_unit , [_unit ] call aceax_gearinfo_fnc_getTextureOptions ] call aceax_gearinfo_fnc_setTextureOptions ;
3549};
3650
37- if (_shouldSwitchNVGs ) then {
51+ if (! _acreEnabled && { _shouldSwitchNVGs } ) then {
3852 _unit action [" NVGoggles" , _unit ];
3953};
4054// prefilled versions of backpacks (ammo bearer, engineer, explosives, medic, repair, etc)
4155// can be emptied and placed in unit's backpack
4256// they must each be emptied when added
4357// safe since game inventory won't let players add non-empty backpacks into their backpack
44- [QGVAR(clearCargoBackpacks), [backpackContainer _unit ]] call CBA_fnc_globalEvent ;
58+ if (! _acreEnabled ) then {
59+ [QGVAR(clearCargoBackpacks), [backpackContainer _unit ]] call CBA_fnc_globalEvent ;
60+ };
4561
4662// add variables
4763private _backpack = backpackContainer _unit ;
4864{
4965 _backpack setVariable [(_x select 0 ), (_x select 1 ), true ];
5066} forEach _chestpackVariables ;
5167
68+ // Restore ACRE radio settings for radios that were inside the pack when it was moved to chest.
69+ if (_acreEnabled && {! (_chestpackAcreRadios isEqualTo [])}) then {
70+ [_unit , _preRadios , _chestpackAcreRadios ] call FUNC(acreRestoreRadioStates);
71+ };
72+
5273[_unit ] call FUNC(removeChestpack);
0 commit comments