Skip to content

Commit

Permalink
[Feature] - Add ACE actions to loadout lockers (#174)
Browse files Browse the repository at this point in the history
* 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

* Restrict function recompiling

- Disable function recompiling outside of 3DEN preview (mission-defined functions are not final when recompiling is enabled)
  • Loading branch information
Cre8or authored Aug 3, 2023
1 parent 47009a5 commit 11b3f0a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 42 deletions.
118 changes: 76 additions & 42 deletions components/gearScript/fn_createLoadoutLocker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 ["<t color='#999999'>Take loadout:</t> <t color='#ff8800'>%1</t>", _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 ["<t color='#999999'>Take loadout:</t> <t color='#ff8800'>%1</t>", _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]);
}
];
6 changes: 6 additions & 0 deletions components/gearScript/zen/fn_zen_createLoadoutLocker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions description.ext
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ loadScreen = "ca_logo_large.jpg";


enableDebugConsole = 1;
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"
Expand Down

0 comments on commit 11b3f0a

Please sign in to comment.