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] - Added ZEN module for creating loadout lockers mid-mission. #155

Merged
merged 6 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
27 changes: 14 additions & 13 deletions components/gearScript/fn_createLoadoutLocker.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,20 @@ if (IS_PLAYER) then

_locker setVariable ["f_var_isLoadoutLocker", true];

if (isServer) then

_bagType = switch (_gearVariant) do
{
_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 createVehicle [0,0,0];
_lockerBag attachTo [_locker, [0,0,1]];
_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]];
1 change: 1 addition & 0 deletions components/gearScript/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class gearScriptRadios
class gearScript_zen
{
file = "components\gearScript\zen";
class zen_createLoadoutLocker{};
class zen_createSupplyCrate{};
class zen_createSupplyCrate_followUpDialog{};
class zen_createSupplyCrate_performAction{};
Expand Down
45 changes: 45 additions & 0 deletions components/gearScript/zen/fn_zen_createLoadoutLocker.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "../macros.hpp"

CLIENT_ONLY;

params ["_position", "_unit"];

if ((!isNull _unit) and {_unit isKindOf "CAManBase"}) exitWith
{
["Cannot use this module on units. Try on ground, vehicles or containers."] call zen_common_fnc_showMessage;
};
Copy link
Collaborator

@Cre8or Cre8or Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the function is called on, say, an object (e.g. by placing the Zeus module on a vehicle)? This condition won't catch that, so the function continues to run, causing the dialog to pop up. Not critical, but... odd? Is this intended?


private _createLocker =
{
params ["_dialogValues", "_args"];
_dialogValues params ["_chosenFaction"];
_args params ["_position", "_unit"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_unit is not referenced inside _createLocker. Continuing from my comment above: if executed on a vehicle, the dialog shows up. Zeus confirms their options and confirms the dialog, causing _createLocker to run. Next thing they know, a locker is spawned inside of the vehicle - and ArmA™ ensues.

Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with cre here, the fact that the locker always seems to be spawned even though the exitWith statement would suggest the user its usable on vics and containers seems contradictory


private _lockerModel = ["Metal_Locker_F", "Land_OfficeCabinet_02_F"] select (isNull (configFile >> "CfgVehicles" >> "Metal_Locker_F"));
private _locker = _lockerModel createVehicle [0,0,0];
_locker setPosASL _position;

[_locker, _chosenFaction] remoteExec ["f_fnc_createLoadoutLocker", 0, _locker];
};

private _potentialSides =
[
["BLUFOR", "blu_f"],
["OPFOR", "opf_f"],
["INDFOR", "ind_f"],
["Civilian", "civ_f"],
["Guerrilla", "blu_g_f"]
];

private _sidesInUse = _potentialSides select { CRATE_REGISTRY_DYNAMIC(toLower (_x # 0)) isNotEqualTo [] };

[
"Choose Gearscript Side",
[
["LIST", "Choose gearscript side", [_sidesInUse apply {_x#1}, _sidesInUse apply {_x#0}, 0, (count _sidesInUse)]]
],
_createLocker,
{},
_this

] call zen_dialog_fnc_create;
10 changes: 9 additions & 1 deletion components/gearScript/zen_modules.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
call
{
private _category = "[CAFE3] Logistics";

[
"[CAFE3] Logistics",
_category,
"Create / refill supply crate",
f_fnc_zen_createSupplyCrate

] call zen_custom_modules_fnc_register;

[
_category,
"Create Loadout Locker",
f_fnc_zen_createLoadoutLocker

] call zen_custom_modules_fnc_register;
};