From 4efacebf469ac5ce526189f8b9abd9a7f17ba854 Mon Sep 17 00:00:00 2001 From: Cre8or Date: Wed, 12 Jul 2023 21:04:30 +0200 Subject: [PATCH 1/2] ACE actions, QoL improvements - Added ACE actions to loadout lockers - Ensure loadout lockers are automatically registered as Zeus editable objects - Fixed loadout locker bags not getting deleted alongside their locker --- .../gearScript/fn_createLoadoutLocker.sqf | 118 +++++++++++------- .../zen/fn_zen_createLoadoutLocker.sqf | 6 + description.ext | 1 + 3 files changed, 83 insertions(+), 42 deletions(-) diff --git a/components/gearScript/fn_createLoadoutLocker.sqf b/components/gearScript/fn_createLoadoutLocker.sqf index d70caf1..7647c88 100644 --- a/components/gearScript/fn_createLoadoutLocker.sqf +++ b/components/gearScript/fn_createLoadoutLocker.sqf @@ -15,58 +15,92 @@ if (_gearVariant isEqualTo "") exitWith {}; if (IS_PLAYER) then { - _registry = LOADOUT_REGISTRY_DYNAMIC(_gearVariant); - - if (_registry isEqualTo []) exitWith {}; - - _codeTemplate = "['%1', (_this select 1), '%2'] call f_fnc_assignGear;"; - - { - _xCaps = toUpper _x; - - if !(_xCaps isEqualTo "DEFAULT") then - { - _condition = "!(_this getVariable ['f_var_assignGear_running', false])"; - - if (_xCaps isEqualTo "ZEUS") then - { - _condition = "!((_this getVariable ['f_var_assignGear_running', false]) or {!(_this getVariable ['f_var_isZeus', false])})"; - }; - - _locker addAction - [ - format ["Take loadout: %1", _xCaps], - format [_codeTemplate, _x, _faction], - nil, - 1.5, - false, - true, - "", - _condition, - 5 - ]; - }; - - } forEach _registry; + _registry = LOADOUT_REGISTRY_DYNAMIC(_gearVariant); + + if (_registry isEqualTo []) exitWith {}; + + _codeTemplate = "['%1', (_this select 1), '%2'] call f_fnc_assignGear;"; + + // Add the base ACE3 category + [ + _locker, + 0, + [], + [ + "cafe3_takeLoadout", + "Take Loadout", + "", + {}, + {true} + ] call ace_interact_menu_fnc_createAction + ] call ace_interact_menu_fnc_addActionToObject; + + { + _xCaps = toUpper _x; + + if !(_xCaps isEqualTo "DEFAULT") then + { + _condition = "!(_this getVariable ['f_var_assignGear_running', false])"; + + if (_xCaps isEqualTo "ZEUS") then + { + _condition = "!((_this getVariable ['f_var_assignGear_running', false]) or {!(_this getVariable ['f_var_isZeus', false])})"; + }; + + _locker addAction + [ + format ["Take loadout: %1", _xCaps], + format [_codeTemplate, _x, _faction], + nil, + 1.5, + false, + true, + "", + _condition, + 5 + ]; + + [ + _locker, + 0, + ["cafe3_takeLoadout"], + [ + format ["cafe3_takeLoadout_%1", _xCaps], + _xCaps, + "", + compile format ["_this = [_target, _player];" + _codeTemplate, _x, _faction], + compile ("_this = _player;" + _condition) + ] call ace_interact_menu_fnc_createAction + ] call ace_interact_menu_fnc_addActionToObject; + }; + + } forEach _registry; }; _locker setVariable ["f_var_isLoadoutLocker", true]; - _bagType = switch (_gearVariant) do { - case ("blufor"): {"Land_TentSolar_01_folded_bluewhite_F"}; - case ("opfor"): {"Land_TentSolar_01_folded_redwhite_F"}; - case ("indfor"): {"Land_TentSolar_01_folded_olive_F"}; - case ("guerrilla"): {"Land_TentSolar_01_folded_olive_F"}; - case ("civilian"): {"Land_TentSolar_01_folded_sand_F"}; - default {"RoadCone_L_F"}; + case "blufor": {"Land_TentSolar_01_folded_bluewhite_F"}; + case "opfor": {"Land_TentSolar_01_folded_redwhite_F"}; + case "indfor": {"Land_TentSolar_01_folded_olive_F"}; + case "guerrilla": {"Land_TentSolar_01_folded_olive_F"}; + case "civilian": {"Land_TentSolar_01_folded_sand_F"}; + default {"RoadCone_L_F"}; }; -_lockerBag = _bagType createVehicleLocal [0,0,0]; - +private _lockerBag = _bagType createVehicleLocal [0,0,0]; private _lockerHeightTop = (0 boundingBoxReal _locker) # 1 # 2; private _bagHeightBottom = (0 boundingBoxReal _lockerBag) # 0 # 2; _lockerBag attachTo [_locker, [0,0,_lockerHeightTop - _bagHeightBottom]]; +_locker setVariable ["f_var_lockerBag", _lockerBag, false]; + +_locker addEventHandler ["Deleted", + { + params ["_locker"]; + + deleteVehicle (_locker getVariable ["f_var_lockerBag", objNull]); + } +]; diff --git a/components/gearScript/zen/fn_zen_createLoadoutLocker.sqf b/components/gearScript/zen/fn_zen_createLoadoutLocker.sqf index 08a89da..7bcf535 100644 --- a/components/gearScript/zen/fn_zen_createLoadoutLocker.sqf +++ b/components/gearScript/zen/fn_zen_createLoadoutLocker.sqf @@ -21,6 +21,12 @@ private _createLocker = private _lockerModel = ["Metal_Locker_F", "Land_OfficeCabinet_02_F"] select (isNull (configFile >> "CfgVehicles" >> "Metal_Locker_F")); _locker = _lockerModel createVehicle [0,0,0]; _locker setPosASL _position; + + { + if (!isNull getAssignedCuratorUnit _x) then { + [_x, [[_locker], false]] remoteExecCall ["addCuratorEditableObjects", 2, false]; + }; + } forEach allCurators; }; // In case picked object becomes a locker while zeus is in the side selection menu. diff --git a/description.ext b/description.ext index 0bdbfc9..d738b77 100644 --- a/description.ext +++ b/description.ext @@ -38,6 +38,7 @@ loadScreen = "ca_logo_large.jpg"; enableDebugConsole = 1; +allowFunctionsRecompile = 1; // Enables using BIS_fnc_recompile from 3DEN preview // CAFE - Debug variable, needs to exist pre-init. #include "startup\configuration\internals\debug.sqf" From e6d53114b1e116dc2c6f94ec692d94f2a726a001 Mon Sep 17 00:00:00 2001 From: Cre8or Date: Thu, 3 Aug 2023 19:05:37 +0200 Subject: [PATCH 2/2] Restrict function recompiling - Disable function recompiling outside of 3DEN preview (mission-defined functions are not final when recompiling is enabled) --- description.ext | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/description.ext b/description.ext index d738b77..d55ed2d 100644 --- a/description.ext +++ b/description.ext @@ -38,7 +38,7 @@ loadScreen = "ca_logo_large.jpg"; enableDebugConsole = 1; -allowFunctionsRecompile = 1; // Enables using BIS_fnc_recompile from 3DEN preview +allowFunctionsRecompile = __EVAL(is3DENPreview); // Enables using BIS_fnc_recompile from 3DEN preview // CAFE - Debug variable, needs to exist pre-init. #include "startup\configuration\internals\debug.sqf"