Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - Add ACE actions to loadout lockers #174

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 1; // Enables using BIS_fnc_recompile from 3DEN preview

// CAFE - Debug variable, needs to exist pre-init.
#include "startup\configuration\internals\debug.sqf"
Expand Down