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

Add ability to define vehicle loadouts to be stored in crates #544

Merged
merged 21 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d176a4e
Added supply box stacking
lambdatiger Sep 7, 2024
cb2ba49
Added option to allow crates weight to not impede movement
lambdatiger Sep 7, 2024
8613741
Initial commit, requires PR539 before further anything
lambdatiger Sep 8, 2024
7355e05
Added marking actions and updated some syntax
lambdatiger Sep 10, 2024
9234f6f
changed up how a few things are ordered to avoid repeat code
lambdatiger Sep 10, 2024
3eac360
syntaxFixes
lambdatiger Sep 10, 2024
55991db
Merge branch 'boxes-n-boxes' into vehicleBoxes
lambdatiger Sep 10, 2024
f704915
Bad glow stick variable name and marker broadcasting
lambdatiger Sep 10, 2024
65e70ec
Merge branch 'boxes-n-boxes' into vehicleBoxes
lambdatiger Sep 10, 2024
3d639ef
missed a FUNC
lambdatiger Sep 10, 2024
f59990d
and one more
lambdatiger Sep 10, 2024
4e323a6
updating authorship
lambdatiger Sep 11, 2024
d695aec
fixed author
lambdatiger Sep 11, 2024
373210d
added ability to set vehicle space to allow for more boxes
lambdatiger Sep 11, 2024
5da6194
Fixed box spawn point and added option to increase vehicle ace cargo …
lambdatiger Sep 11, 2024
0505bae
Merge remote-tracking branch 'upstream/master' into vehicleBoxes
lambdatiger Sep 20, 2024
5fea95d
Revert "Merge remote-tracking branch 'upstream/master' into vehicleBo…
lambdatiger Sep 20, 2024
cfba64b
Merge remote-tracking branch 'upstream/master' into vehicleBoxes
lambdatiger Sep 20, 2024
cef81d6
move cleanup to not run twice
lambdatiger Sep 20, 2024
b0e4c71
alphabetized PREP
lambdatiger Sep 20, 2024
8c92083
Fixed example function name
lambdatiger Sep 20, 2024
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
7 changes: 4 additions & 3 deletions addons/assignGear/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ TRACE_1("",QUOTE(ADDON));
PREP(addItemsToContainer);
PREP(addSupplyBoxActions);
PREP(assignGearMan);
PREP(assignGearSupplyBox);
PREP(assignGearPotatoBox);
PREP(assignGearVehicle);
PREP(assignGearSupplyBox);
PREP(assignGearVehicle_asBoxes);
PREP(cleanPrefix);
PREP(assignGearVehicle);
PREP(changeableOptics_getChildren);
PREP(changeableOptics_setOptic);
PREP(cleanPrefix);
PREP(getContainerInfo);
PREP(getDisposableInfo); // temp?? for cba change to disposable hash maps
PREP(getLinkedIndex);
Expand All @@ -18,4 +18,5 @@ PREP(getWeaponArray);
PREP(isOpticMagnified);
PREP(requestPlayerGear);
PREP(setBoxContentsFromConfig);
PREP(setContainerContentsFromConfig);
PREP(setWeaponAttachment);
2 changes: 1 addition & 1 deletion addons/assignGear/functions/fnc_assignGearSupplyBox.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (_subBoxes isNotEqualTo []) then {
private _subBox = createVehicle [_subBoxType, [0, 0, 0], [], 0, "CAN_COLLIDE"];
[_subBox, _x, ["%1", "%1 " + str _i] select (_boxCount > 1)] call FUNC(setBoxContentsFromConfig);
[_subBox, 1] call ACEFUNC(cargo,setSize);
if !([_subBox, _theBox, true] call ace_cargo_fnc_loadItem) exitWith {
if !([_subBox, _theBox, true] call ACEFUNC(cargo,loadItem)) exitWith {
diag_log formatText [
"[POTATO-assignGear] - Failed to create %1 %2 supply box(es) for %3 - out of space ",
_subBoxType,
Expand Down
100 changes: 49 additions & 51 deletions addons/assignGear/functions/fnc_assignGearVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/*
* Author: PabstMirror
* Applies a loadout to a vehicle
* Edited by Bailed to add option 2
* Edited by Lambda.Tier to add option 3 and move some common code to functions
*
* Arguments:
* 0: Vehicle <OBJECT>
Expand All @@ -27,7 +29,7 @@ TRACE_2("",GVAR(setVehicleLoadouts),_loadout);
//Leave default gear when "F_Gear" is "Default" or GVAR(setVehicleLoadouts) is 0
if ((GVAR(setVehicleLoadouts) == 0) || {_loadout == "Default"}) exitWith {
if (GVAR(alwaysAddToolkits)) then { _theVehicle addItemCargoGlobal ["Toolkit", 1]; };
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
_theVehicle addItemCargoGlobal ["ACE_rope15", 1]; // note: this rope is probably too short to fastrope with, so don't add to air
};
};
Expand All @@ -40,7 +42,7 @@ if ((GVAR(setVehicleLoadouts) == -1) || {_loadout == "Empty"}) exitWith {
clearBackpackCargoGlobal _theVehicle;
//Add a Toolkit
if (GVAR(alwaysAddToolkits)) then { _theVehicle addItemCargoGlobal ["Toolkit", 1]; };
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
_theVehicle addItemCargoGlobal ["ACE_rope15", 1];
};
};
Expand Down Expand Up @@ -74,58 +76,54 @@ if (!isClass _path) exitWith {
diag_log text format ["[POTATO-assignGear] - No loadout found for %1 (typeOf %2) (kindOf %3) (defaultLoadout: %4)", _theVehicle, typeOf _theVehicle, _loadout, _defaultLoadout];
};

//Clean out starting inventory (even if there is no class)
clearWeaponCargoGlobal _theVehicle;
clearMagazineCargoGlobal _theVehicle;
clearItemCargoGlobal _theVehicle;
clearBackpackCargoGlobal _theVehicle;
//Add a Toolkit
if (GVAR(alwaysAddToolkits)) then { _theVehicle addItemCargoGlobal ["Toolkit", 1]; };
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
_theVehicle addItemCargoGlobal ["ACE_rope15", 1];
};

private _transportMagazines = getArray(_path >> "TransportMagazines");
private _transportItems = getArray(_path >> "TransportItems");
private _transportWeapons = getArray(_path >> "TransportWeapons");
private _transportBackpacks = getArray(_path >> "TransportBackpacks");

switch (GVAR(setVehicleLoadouts)) do {
case 1: { // ammo in vehicle inventory
// transportMagazines
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theVehicle addMagazineCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportMagazines; // count used here for speed, make sure nil is above this line

// transportItems
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theVehicle addItemCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportItems; // count used here for speed, make sure nil is above this line

// transportWeapons
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
private _disposableName = [cba_disposable_LoadedLaunchers, _classname, "get", ""] call FUNC(getDisposableInfo);
if (_disposableName != "") then {
TRACE_2("cba_disposable_LoadedLaunchers replace",_classname,_disposableName);
_classname = _disposableName;
};
_theVehicle addWeaponCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportWeapons; // count used here for speed, make sure nil is above this line

// transportBackpacks
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theVehicle addBackpackCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportBackpacks; // count used here for speed, make sure nil is above this line
[_theVehicle, _path] call FUNC(setContainerContentsFromConfig);
};
case 2: { // ammo in boxes in vehicle
[_theVehicle, _path, _transportMagazines, _transportItems, _transportWeapons, _transportBackpacks] call FUNC(assignGearVehicle_asBoxes);
clearWeaponCargoGlobal _theVehicle;
clearMagazineCargoGlobal _theVehicle;
clearItemCargoGlobal _theVehicle;
clearBackpackCargoGlobal _theVehicle;
[_theVehicle, _path,
getArray(_path >> "TransportMagazines"),
getArray(_path >> "TransportItems"),
getArray(_path >> "TransportWeapons"),
getArray(_path >> "TransportBackpacks")] call FUNC(assignGearVehicle_asBoxes);
};
case 3: { // ammo in boxes in vehicle from config
clearWeaponCargoGlobal _theVehicle;
clearMagazineCargoGlobal _theVehicle;
clearItemCargoGlobal _theVehicle;
clearBackpackCargoGlobal _theVehicle;
private _boxes = "true" configClasses _path;
private _vehicleSpace = getNumber (_path >> "minVehicleBoxSpace");
if (_vehicleSpace > 0) then {
private _currentVehicleSpace = _theVehicle getVariable [
QACEGVAR(cargo,hasCargo),
getNumber (configOf _theVehicle >> QACEGVAR(cargo,space))
];
[_theVehicle, _vehicleSpace max _currentVehicleSpace] call ACEFUNC(cargo,setSpace);
};
{
private _boxType = configName _x;
private _boxCount = (getNumber (_x >> "boxCount")) max 1;
for "_i" from 1 to _boxCount do {
private _box = createVehicle [_boxType, [0, 0, 0], [], 0, "CAN_COLLIDE"];
[_box, _x, ["%1", "%1 " + str _i] select (_boxCount > 1)] call FUNC(setBoxContentsFromConfig);
[_box, 1] call ACEFUNC(cargo,setSize);
if !([_box, _theVehicle, true] call ACEFUNC(cargo,loadItem)) exitWith {
lambdatiger marked this conversation as resolved.
Show resolved Hide resolved
diag_log text format ["[POTATO-assignGear] - Failed to create %1 supply box(es) for %2 - out of space ", _boxType, typeOf _theVehicle];
deleteVehicle _box;
};
_box setVariable [QGVAR(initialized), true];
};
} forEach _boxes;
};
};

//Add a Toolkit
if (GVAR(alwaysAddToolkits)) then { _theVehicle addItemCargoGlobal ["Toolkit", 1]; };
if (GVAR(alwaysAddLandRopes) && {(_theVehicle isKindOf "Car") || {_theVehicle isKindOf "Tank"}}) then {
_theVehicle addItemCargoGlobal ["ACE_rope15", 1];
};
52 changes: 6 additions & 46 deletions addons/assignGear/functions/fnc_setBoxContentsFromConfig.sqf
Original file line number Diff line number Diff line change
@@ -1,73 +1,33 @@
#include "script_component.hpp"
/*
* Author: Bailey
* Author: Lambda.Tiger
* Fills box with gear from a config
* Edited by Lambda.Tiger to add box names
*
* Arguments:
* 0: Box <OBJECT>
* 1: missionConfigFile path for the box's loadout <STRING>
* 1: Config path for the box's loadout <STRING>
* 2: Optional format string for box name, must contain "%1" <STRING>
*
* Return Value:
* None
*
* Example:
* [cursorObject, missionConfigFile >> "CfgLoadouts" >> "SupplyBoxes" >> (typeOf cursorObject)] call potato_assignGear_fnc_setBoxContentsFromConfig
* [cursorObject, missionConfigFile >> "CfgLoadouts" >> "SupplyBoxes" >> (typeOf cursorObject), missionConfigFile >> "CfgLoadouts" >> "SupplyBox" >> (typeOf cursorObject)] call potato_assignGear_fnc_setBoxContentsFromConfig
*
* Public: No
*/

params ["_theBox", "_path", ["_nameFormatString", "%1", [""]]];

clearWeaponCargoGlobal _theBox;
clearMagazineCargoGlobal _theBox;
clearItemCargoGlobal _theBox;
clearBackpackCargoGlobal _theBox;

private _transportMagazines = getArray(_path >> "TransportMagazines");
private _transportItems = getArray(_path >> "TransportItems");
private _transportWeapons = getArray(_path >> "TransportWeapons");
private _transportBackpacks = getArray(_path >> "TransportBackpacks");

// transportMagazines
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theBox addMagazineCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportMagazines; // count used here for speed, make sure nil is above this line

// transportItems
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theBox addItemCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportItems; // count used here for speed, make sure nil is above this line

// transportWeapons
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
private _disposableName = [cba_disposable_LoadedLaunchers, _classname, "get", ""] call FUNC(getDisposableInfo);
if (_disposableName != "") then {
_classname = _disposableName;
};
_theBox addWeaponCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportWeapons; // count used here for speed, make sure nil is above this line

// transportBackpacks
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theBox addBackpackCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportBackpacks; // count used here for speed, make sure nil is above this line
[_theBox, _path] call FUNC(setContainerContentsFromConfig);

private _boxName = getText (_path >> "boxCustomName");
if (_boxName isNotEqualTo "") then {
_theBox setVariable [QACEGVAR(cargo,customName), format [_nameFormatString, _boxName], true];
_theBox setVariable [QACEGVAR(cargo,customName), format [_nameFormatString, _boxName], true];
};

private _overrideCarryWeight = 1 == (getNumber (_path >> "forceAllowCarry"));
private _overrideDragWeight = 1 == (getNumber (_path >> "forceAllowDrag"));
_theBox setVariable [QACEGVAR(cargo,ignoreWeightCarry), _overrideCarryWeight, true];
_theBox setVariable [QACEGVAR(cargo,ignoreWeightDrag), _overrideCarryWeight || _overrideDragWeight, true];
_theBox setVariable [QACEGVAR(cargo,ignoreWeightDrag), _overrideCarryWeight || _overrideDragWeight, true];
61 changes: 61 additions & 0 deletions addons/assignGear/functions/fnc_setContainerContentsFromConfig.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "script_component.hpp"
/*
* Author: Pabst
* Fills box with gear from a config
*
* Arguments:
* 0: The container to be filled such as a vehicle or supply box <OBJECT>
* 1: Config path for the box's loadout <STRING>
*
* Return Value:
* None
*
* Example:
* [cursorObject, missionConfigFile >> "CfgLoadouts" >> "SupplyBox" >> (typeOf cursorObject)] call potato_assignGear_fnc_setContainerContentsFromConfig
*
* Public: No
*/

params ["_theContainer", "_path"];

clearWeaponCargoGlobal _theContainer;
clearMagazineCargoGlobal _theContainer;
clearItemCargoGlobal _theContainer;
clearBackpackCargoGlobal _theContainer;

private _transportMagazines = getArray(_path >> "TransportMagazines");
private _transportItems = getArray(_path >> "TransportItems");
private _transportWeapons = getArray(_path >> "TransportWeapons");
private _transportBackpacks = getArray(_path >> "TransportBackpacks");

// transportMagazines
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theContainer addMagazineCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportMagazines; // count used here for speed, make sure nil is above this line

// transportItems
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theContainer addItemCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportItems; // count used here for speed, make sure nil is above this line

// transportWeapons
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
private _disposableName = [cba_disposable_LoadedLaunchers, _classname, "get", ""] call FUNC(getDisposableInfo);
if (_disposableName != "") then {
_classname = _disposableName;
};
_theContainer addWeaponCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportWeapons; // count used here for speed, make sure nil is above this line

// transportBackpacks
{
(_x splitString ":") params ["_classname", ["_amount", "1", [""]]];
_theContainer addBackpackCargoGlobal [_classname, parseNumber _amount];
nil
} count _transportBackpacks; // count used here for speed, make sure nil is above this line