client/addons/medical/functions/fnc_moveInventory.sqf
Jacob Schmidt d474b3676a
All checks were successful
Build / Build (push) Successful in 28s
Refactor: Standardize function descriptions and variable handling
This commit refactors several client-side functions to improve code consistency and readability.

- Standardizes function descriptions by removing redundant "Function: forge_client..." prefixes and "[Description]" sections, focusing on concise descriptions of the function's purpose.
- Updates variable handling in arsenal functions to use GVAR and EGVARS for default values, improving consistency and reducing code duplication.
- Removes the bank init function as it is no longer needed.
- Adds a done variable to the preinit file.
2025-05-25 11:30:26 -05:00

82 lines
2.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: IDSolutions
* Moves the unit's inventory to the body bag
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Body Bag <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, bodyBag] call forge_client_medical_fnc_moveInventory;
*
* Public: Yes
*/
params ["_unit", "_bodyBag"];
private _items = [];
private _weapons = [];
private _backpack = backpack _unit;
private _nearHolders = _bodyBag nearObjects ["WeaponHolderSimulated", 3];
_items pushBack (headgear _unit);
_items pushBack (uniform _unit);
_items append (uniformItems _unit);
_items pushBack (vest _unit);
_items append (vestItems _unit);
_items append (backpackItems _unit);
_weapons pushBack (primaryWeapon _unit);
_items append (primaryWeaponItems _unit);
_items append (primaryWeaponMagazine _unit);
_weapons pushBack (secondaryWeapon _unit);
_items append (secondaryWeaponItems _unit);
_items append (secondaryWeaponMagazine _unit);
_weapons pushBack (handgunWeapon _unit);
_items append (handgunItems _unit);
_items append (handgunMagazine _unit);
_weapons append (_unit getVariable [QGVAR(droppedWeapons), []]);
_items append (_unit getVariable [QGVAR(droppedItems), []]);
_items append (assignedItems _unit);
_items pushBack (_unit call CFUNC(binocularMagazine));
if !((goggles _unit ) in (_unit getVariable [QGVAR(droppedItems), []])) then {
_items pushBack (goggles _unit);
};
_items = _items select {_x != ""};
_weapons = _weapons select {_x != ""};
{ _bodyBag addItemCargoGlobal [_x, 1] } forEach _items;
{
private _weaponNonPresent = [_x] call CFUNC(getNonPresetClass);
if (_weaponNonPresent == "") then {
_weaponNonPresent = _x;
};
_bodyBag addWeaponCargoGlobal [_weaponNonPresent, 1];
} forEach _weapons;
if (_backpack != "") then {
private _backpackNonPresent = [_backpack, "CfgVehicles"] call CFUNC(getNonPresetClass);
if (_backpackNonPresent == "") then {
_backpackNonPresent = _backpack;
};
_bodyBag addBackpackCargoGlobal [_backpackNonPresent, 1];
};
{
private _holderWeapons = ((getWeaponCargo _x) select 0) select { _x in _weapons };
if (_holderWeapons isNotEqualTo []) then {
deleteVehicle _x;
};
} forEach _nearHolders;