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..dd8c4178d --- /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