Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added equipment tag functions #1169

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
45 changes: 45 additions & 0 deletions cScripts/functions/gear/fn_gear_getTagItems.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "..\script_component.hpp"
/*
* Author: CPL.Brostrom.A
* This function return given equipment tag items.
*
* Arguments:
* 0: Loadout <STRING>
*
* Return Value:
* Tags <ARRAY>
*
* 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;
22 changes: 22 additions & 0 deletions cScripts/functions/gear/fn_gear_getTags.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "..\script_component.hpp"
/*
* Author: CPL.Brostrom.A
* This function return your equipmetTags
*
* Arguments:
* 0: Loadout <STRING>
*
* Return Value:
* Tags <ARRAY>
*
* Example:
* call cScripts_fnc_gear_getTags
*
*/

params [["_loadout","",[]]];

private _config = missionConfigFile >> "CfgLoadouts" >> _loadout;
private _tags = getArray (_config >> "equipmentTags");

_tags;
30 changes: 30 additions & 0 deletions cScripts/functions/gear/fn_gear_isTag.sqf
Original file line number Diff line number Diff line change
@@ -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 <STRING>
*
* Return Value:
* True/False <BOOLEAN>
*
* 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