-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arsenal - Reuse current inventory containers when importing invalid l…
…oadouts (#10364) Co-authored-by: Jouni Järvinen <[email protected]> Co-authored-by: Grim <[email protected]>
- Loading branch information
1 parent
03d3b80
commit c82b51f
Showing
9 changed files
with
105 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "..\script_component.hpp" | ||
#include "..\defines.hpp" | ||
/* | ||
* Author: Alganthe, johnb43, mrschick | ||
* Checks the current loadout of the given unit for inventory containers (uniform/vest/backpack) filled beyond their max load, removing excess items if present. | ||
* | ||
* Arguments: | ||
* 0: Unit to check for overfill <OBJECT> | ||
* 1: Which container to check. If unit, will go through all containers starting from uniform <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", ["_container", objNull]]; | ||
|
||
if (isNull _container || _container isEqualTo _unit) then { | ||
_container = [uniformContainer _unit, vestContainer _unit, backpackContainer _unit]; | ||
} else { | ||
_container = [_container]; | ||
}; | ||
|
||
{ | ||
private _currentContainer = _x; | ||
{ | ||
_currentContainer addItemCargoGlobal [_x, -1]; | ||
|
||
if (load _currentContainer <= 1) then { | ||
break; | ||
}; | ||
} forEachReversed (itemCargo _currentContainer); | ||
} forEach (_container select {load _x > 1}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "..\script_component.hpp" | ||
#include "..\defines.hpp" | ||
/* | ||
* Author: mrschick | ||
* Attempts to recover a loadout with invalid containers by substituting them for the currently worn containers. | ||
* It is meant to be passed a loadout modified by `[loadout, true] call ace_arsenal_fnc_verifyLoadout`, nested in the format: `[[_loadout, _extendedInfo], _nullItemsList, _unavailableItemsList, _missingExtendedInfo]` | ||
* | ||
* Arguments: | ||
* 0: Unit from which to get valid (worn) containers <OBJECT> | ||
* 1: Verified loadout to insert valid containers into <ARRAY> | ||
* | ||
* Return Value: | ||
* Copy of the passed loadout, with recovered containers <ARRAY> | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", "_loadout"]; | ||
|
||
// Work on a copy of the original array | ||
private _loadoutData = +_loadout; | ||
|
||
{ | ||
_x params ["_containerIdx", "_wornContainer"]; | ||
|
||
// Only modify the loadout if it has a filled invalid container to be recovered | ||
if ( | ||
(_loadoutData#0#0#_containerIdx isNotEqualTo []) && | ||
{_loadoutData#0#0#_containerIdx#0 == ""} | ||
) then { | ||
// Replace loadout container with worn one, if present | ||
if (_wornContainer == "") then { | ||
(_loadoutData#0#0) set [_containerIdx, []]; | ||
} else { | ||
(_loadoutData#0#0#_containerIdx) set [0, _wornContainer]; | ||
}; | ||
}; | ||
} forEach [ | ||
[3, uniform _unit], | ||
[4, vest _unit], | ||
[5, backpack _unit] | ||
]; | ||
|
||
_loadoutData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters