From b2aece723d3385e7a1d106c115ff284fecb7fb0c Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Mon, 19 Mar 2018 08:20:11 +0100 Subject: [PATCH 1/6] Add Func --- addons/common/fnc_getUniquePlayerItems.sqf | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 addons/common/fnc_getUniquePlayerItems.sqf diff --git a/addons/common/fnc_getUniquePlayerItems.sqf b/addons/common/fnc_getUniquePlayerItems.sqf new file mode 100644 index 000000000..df44b69da --- /dev/null +++ b/addons/common/fnc_getUniquePlayerItems.sqf @@ -0,0 +1,44 @@ +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_getUniquePlayerItems + +Description: + A function used to retrieve a unique list of items in the units inventory + +Parameters: + _unit - Unit to retrieve the items from + _weaponItems - Include weapons, attachments, loaded magazines (Default: false) + _backpack - Include items in backpack (Default: true) + _vest - Include items in vest (Default: true) + _uniform - Include items in uniform (Default: true) + +Example: + (begin example) + _allItems = [player, true, false] call CBA_fnc_getUniquePlayerItems + (end) + +Returns: + Array of item classnames + +Author: + Dedmen +---------------------------------------------------------------------------- */ +#include "script_component.hpp" +SCRIPT(getUniquePlayerItems); + +params [["_unit", objNull, [objNull]], ["_weaponItems", true, [true]], ["_backpack", true, [true]], ["_vest", true, [true]], ["_uniform", true, [true]]]; + +private _allItems = (assignedItems _unit); +if (_uniform) then {_allItems append ((getItemCargo (uniformContainer _unit)) select 0);}; +if (_vest) then {_allItems append ((getItemCargo (vestContainer _unit)) select 0);}; +if (_backpack) then {_allItems append ((getItemCargo (backpackContainer _unit)) select 0);}; + +if (_weaponItems) then { + _allItems append (primaryWeaponItems _unit); + _allItems append (secondaryWeaponItems _unit); + _allItems append (handgunItems _unit); + _allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, + primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit + ]; +}; + +_allItems arrayIntersect _allItems //Remove duplicates From b5c810622b403ab50ef4acc96f7b9edabd6226b2 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Mon, 19 Mar 2018 13:30:47 +0100 Subject: [PATCH 2/6] Rename, Indent, CfgFunctions --- addons/common/CfgFunctions.hpp | 1 + addons/common/fnc_getUniquePlayerItems.sqf | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/common/CfgFunctions.hpp b/addons/common/CfgFunctions.hpp index 2ac70f691..e0b709266 100644 --- a/addons/common/CfgFunctions.hpp +++ b/addons/common/CfgFunctions.hpp @@ -65,6 +65,7 @@ class CfgFunctions { PATHTO_FNC(removeWeapon); PATHTO_FNC(removeMagazine); PATHTO_FNC(removeItem); + PATHTO_FNC(unitItemsUnique); PATHTO_FNC(weaponComponents); PATHTO_FNC(dropWeapon); PATHTO_FNC(dropMagazine); diff --git a/addons/common/fnc_getUniquePlayerItems.sqf b/addons/common/fnc_getUniquePlayerItems.sqf index df44b69da..85a6388dc 100644 --- a/addons/common/fnc_getUniquePlayerItems.sqf +++ b/addons/common/fnc_getUniquePlayerItems.sqf @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Function: CBA_fnc_getUniquePlayerItems +Function: CBA_fnc_unitItemsUnique Description: A function used to retrieve a unique list of items in the units inventory @@ -13,7 +13,7 @@ Parameters: Example: (begin example) - _allItems = [player, true, false] call CBA_fnc_getUniquePlayerItems + _allItems = [player, true, false] call CBA_fnc_unitItemsUnique (end) Returns: @@ -23,7 +23,7 @@ Author: Dedmen ---------------------------------------------------------------------------- */ #include "script_component.hpp" -SCRIPT(getUniquePlayerItems); +SCRIPT(unitItemsUnique); params [["_unit", objNull, [objNull]], ["_weaponItems", true, [true]], ["_backpack", true, [true]], ["_vest", true, [true]], ["_uniform", true, [true]]]; @@ -36,7 +36,8 @@ if (_weaponItems) then { _allItems append (primaryWeaponItems _unit); _allItems append (secondaryWeaponItems _unit); _allItems append (handgunItems _unit); - _allItems append [ primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, + _allItems append [ + primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit ]; }; From 19d94314c3425e1273da52514a11ea7ce77f4f20 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Wed, 21 Mar 2018 08:12:41 +0100 Subject: [PATCH 3/6] Rename, indent --- addons/common/CfgFunctions.hpp | 2 +- ...UniquePlayerItems.sqf => fnc_uniqueUnitItems.sqf} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename addons/common/{fnc_getUniquePlayerItems.sqf => fnc_uniqueUnitItems.sqf} (80%) diff --git a/addons/common/CfgFunctions.hpp b/addons/common/CfgFunctions.hpp index e0b709266..d6ad244bd 100644 --- a/addons/common/CfgFunctions.hpp +++ b/addons/common/CfgFunctions.hpp @@ -65,7 +65,7 @@ class CfgFunctions { PATHTO_FNC(removeWeapon); PATHTO_FNC(removeMagazine); PATHTO_FNC(removeItem); - PATHTO_FNC(unitItemsUnique); + PATHTO_FNC(uniqueUnitItems); PATHTO_FNC(weaponComponents); PATHTO_FNC(dropWeapon); PATHTO_FNC(dropMagazine); diff --git a/addons/common/fnc_getUniquePlayerItems.sqf b/addons/common/fnc_uniqueUnitItems.sqf similarity index 80% rename from addons/common/fnc_getUniquePlayerItems.sqf rename to addons/common/fnc_uniqueUnitItems.sqf index 85a6388dc..7dc6fbdbe 100644 --- a/addons/common/fnc_getUniquePlayerItems.sqf +++ b/addons/common/fnc_uniqueUnitItems.sqf @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- -Function: CBA_fnc_unitItemsUnique +Function: CBA_fnc_uniqueUnitItems Description: A function used to retrieve a unique list of items in the units inventory @@ -13,7 +13,7 @@ Parameters: Example: (begin example) - _allItems = [player, true, false] call CBA_fnc_unitItemsUnique + _allItems = [player, true, false] call CBA_fnc_uniqueUnitItems (end) Returns: @@ -23,7 +23,7 @@ Author: Dedmen ---------------------------------------------------------------------------- */ #include "script_component.hpp" -SCRIPT(unitItemsUnique); +SCRIPT(uniqueUnitItems); params [["_unit", objNull, [objNull]], ["_weaponItems", true, [true]], ["_backpack", true, [true]], ["_vest", true, [true]], ["_uniform", true, [true]]]; @@ -37,9 +37,9 @@ if (_weaponItems) then { _allItems append (secondaryWeaponItems _unit); _allItems append (handgunItems _unit); _allItems append [ - primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, - primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit - ]; + primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, + primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit + ]; }; _allItems arrayIntersect _allItems //Remove duplicates From 5808da8d9a05320756e1f58d042f3d0aefc16cc9 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Wed, 21 Mar 2018 08:14:40 +0100 Subject: [PATCH 4/6] Description --- addons/common/fnc_uniqueUnitItems.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_uniqueUnitItems.sqf b/addons/common/fnc_uniqueUnitItems.sqf index 7dc6fbdbe..687bec6fe 100644 --- a/addons/common/fnc_uniqueUnitItems.sqf +++ b/addons/common/fnc_uniqueUnitItems.sqf @@ -2,7 +2,7 @@ Function: CBA_fnc_uniqueUnitItems Description: - A function used to retrieve a unique list of items in the units inventory + Retrievs a unique list of items in the units inventory. Parameters: _unit - Unit to retrieve the items from From a79f59ff310b3096d0e29131f071b6f6d87fd48c Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sat, 14 Apr 2018 21:50:51 +0200 Subject: [PATCH 5/6] add binoc magazine --- addons/common/fnc_uniqueUnitItems.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/common/fnc_uniqueUnitItems.sqf b/addons/common/fnc_uniqueUnitItems.sqf index 687bec6fe..b2e23915c 100644 --- a/addons/common/fnc_uniqueUnitItems.sqf +++ b/addons/common/fnc_uniqueUnitItems.sqf @@ -40,6 +40,7 @@ if (_weaponItems) then { primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit ]; + _allItems pushBack (_unit call CBA_fnc_binocularMagazine); }; _allItems arrayIntersect _allItems //Remove duplicates From e0bdb1aaf008cebdb43a58ab1251b635980df8e4 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sun, 15 Apr 2018 01:00:11 +0200 Subject: [PATCH 6/6] ARRAYS --- addons/common/fnc_uniqueUnitItems.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/common/fnc_uniqueUnitItems.sqf b/addons/common/fnc_uniqueUnitItems.sqf index b2e23915c..d4ba7a139 100644 --- a/addons/common/fnc_uniqueUnitItems.sqf +++ b/addons/common/fnc_uniqueUnitItems.sqf @@ -36,9 +36,11 @@ if (_weaponItems) then { _allItems append (primaryWeaponItems _unit); _allItems append (secondaryWeaponItems _unit); _allItems append (handgunItems _unit); + _allItems append (primaryWeaponMagazine _unit); + _allItems append (secondaryWeaponMagazine _unit); + _allItems append (handgunMagazine _unit); _allItems append [ - primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, - primaryWeaponMagazine _unit, secondaryWeaponMagazine _unit, handgunMagazine _unit + primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit ]; _allItems pushBack (_unit call CBA_fnc_binocularMagazine); };