From f6a3a6cab2d4b24407aaeb8e2f347d2e826669e3 Mon Sep 17 00:00:00 2001 From: AndreasBrostrom Date: Sat, 6 Apr 2024 20:24:41 +0200 Subject: [PATCH 1/3] Added equipment tag functions --- cScripts/CfgFunctions.hpp | 5 +++ .../functions/gear/fn_gear_getTagItems.sqf | 45 +++++++++++++++++++ cScripts/functions/gear/fn_gear_getTags.sqf | 22 +++++++++ cScripts/functions/gear/fn_gear_isTag.sqf | 30 +++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 cScripts/functions/gear/fn_gear_getTagItems.sqf create mode 100644 cScripts/functions/gear/fn_gear_getTags.sqf create mode 100644 cScripts/functions/gear/fn_gear_isTag.sqf diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index 75b0e02aa..5506bcc07 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -235,6 +235,11 @@ class cScripts { class gear_removeLoadout {}; class gear_hasSavedLoadout {}; + // equipmentTags + class gear_getTagItems {}; + class gear_getTags {}; + class gear_isTag {}; + // other class gear_getLoadoutRole {}; class gear_getLoadoutName {}; diff --git a/cScripts/functions/gear/fn_gear_getTagItems.sqf b/cScripts/functions/gear/fn_gear_getTagItems.sqf new file mode 100644 index 000000000..150631266 --- /dev/null +++ b/cScripts/functions/gear/fn_gear_getTagItems.sqf @@ -0,0 +1,45 @@ +#include "..\script_component.hpp" +/* + * Author: CPL.Brostrom.A + * This function return given equipment tag items. + * + * Arguments: + * 0: Loadout + * + * Return Value: + * Tags + * + * Example: + * call cScripts_fnc_gear_getTagItems + * + */ + +params [["_tag","",[""]]]; + +if (_tag isEqualTo "") exitWith {[]}; + +private _fn_getTagItemsList = { + params [["_tag","",[]]]; + private _equipmentTag = getArray (missionConfigFile >> "CfgEquipmentTags" >> _tag); + _equipmentTag +} + +private _equipmentTagObjects = [_tag] call _fn_getTagItemsList; + +private _itemList = []; +{ + if (call EFUNC(gear,isTag)) then { + _equipmentTagObjects append [_x]; + continue + }; + if ([_x] call FUNC(checkItemValidity)) then { + _itemList append [_x]; + continue + }; + if (count _equipmentTagObjects >= 100) then { + SHOW_CHAT_WARNING_1("equipmentTag", "Infinit loop suspected for %1 exiting item list creation!", _tag); + break; + } +} forEach _equipmentTagObjects; + +_equipmentTag; \ No newline at end of file diff --git a/cScripts/functions/gear/fn_gear_getTags.sqf b/cScripts/functions/gear/fn_gear_getTags.sqf new file mode 100644 index 000000000..8835a63ae --- /dev/null +++ b/cScripts/functions/gear/fn_gear_getTags.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +/* + * Author: CPL.Brostrom.A + * This function return your equipmetTags + * + * Arguments: + * 0: Loadout + * + * Return Value: + * Tags + * + * Example: + * call cScripts_fnc_gear_getTags + * + */ + +params [["_loadout","",[]]]; + +private _config = missionConfigFile >> "CfgLoadouts" >> _loadout; +private _tags = getArray (_config >> "equipmentTags"); + +_tags; \ No newline at end of file diff --git a/cScripts/functions/gear/fn_gear_isTag.sqf b/cScripts/functions/gear/fn_gear_isTag.sqf new file mode 100644 index 000000000..2cc987a4a --- /dev/null +++ b/cScripts/functions/gear/fn_gear_isTag.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" +/* + * Author: CPL.Brostrom.A + * This function return true or false if the tag is a equipmentTag or not + * + * Arguments: + * 0: Tag + * + * Return Value: + * True/False + * + * Example: + * call cScripts_fnc_gear_isTag + * + */ + +params [["_item","",[]]]; + +private _cfgMagazines = getText (configFile >> 'CfgMagazines' >> _item >> 'displayName'); +private _cfgWeapons = getText (configFile >> 'CfgWeapons' >> _item >> 'displayName'); +private _cfgVehicles = getText (configFile >> 'CfgVehicles' >> _item >> 'displayName'); +private _cfgEquipmentTags = isArray (missionConfigFile >> "CfgEquipmentTags" >> _item); + +if (_cfgMagazines != "") exitWith {false}; +if (_cfgWeapons != "") exitWith {false}; +if (_cfgVehicles != "") exitWith {false}; + +if (_cfgEquipmentTags) exitWith {true}; + +false \ No newline at end of file From 5583f49934255bb7fb44652ec206ac9d36fa9980 Mon Sep 17 00:00:00 2001 From: AndreasBrostrom Date: Sat, 6 Apr 2024 20:29:00 +0200 Subject: [PATCH 2/3] Added ; --- cScripts/functions/gear/fn_gear_getTagItems.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cScripts/functions/gear/fn_gear_getTagItems.sqf b/cScripts/functions/gear/fn_gear_getTagItems.sqf index 150631266..759f15572 100644 --- a/cScripts/functions/gear/fn_gear_getTagItems.sqf +++ b/cScripts/functions/gear/fn_gear_getTagItems.sqf @@ -21,7 +21,7 @@ if (_tag isEqualTo "") exitWith {[]}; private _fn_getTagItemsList = { params [["_tag","",[]]]; private _equipmentTag = getArray (missionConfigFile >> "CfgEquipmentTags" >> _tag); - _equipmentTag + _equipmentTag; } private _equipmentTagObjects = [_tag] call _fn_getTagItemsList; @@ -30,11 +30,11 @@ private _itemList = []; { if (call EFUNC(gear,isTag)) then { _equipmentTagObjects append [_x]; - continue + continue; }; if ([_x] call FUNC(checkItemValidity)) then { _itemList append [_x]; - continue + continue; }; if (count _equipmentTagObjects >= 100) then { SHOW_CHAT_WARNING_1("equipmentTag", "Infinit loop suspected for %1 exiting item list creation!", _tag); From dd1561959c832f51eeab983242e229b4dd17ebc1 Mon Sep 17 00:00:00 2001 From: AndreasBrostrom Date: Sat, 6 Apr 2024 23:26:09 +0200 Subject: [PATCH 3/3] Added missing ; --- cScripts/functions/gear/fn_gear_getTagItems.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cScripts/functions/gear/fn_gear_getTagItems.sqf b/cScripts/functions/gear/fn_gear_getTagItems.sqf index 759f15572..dd8c4178d 100644 --- a/cScripts/functions/gear/fn_gear_getTagItems.sqf +++ b/cScripts/functions/gear/fn_gear_getTagItems.sqf @@ -22,7 +22,7 @@ private _fn_getTagItemsList = { params [["_tag","",[]]]; private _equipmentTag = getArray (missionConfigFile >> "CfgEquipmentTags" >> _tag); _equipmentTag; -} +}; private _equipmentTagObjects = [_tag] call _fn_getTagItemsList;