Skip to content

Commit

Permalink
Fixed item tag being able to add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom committed Apr 19, 2024
1 parent bce49ef commit a72dc63
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 32 deletions.
60 changes: 50 additions & 10 deletions cScripts/CfgEquipmentTags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,51 @@ class CfgEquipmentTags {
class_rhs_weap_m4a1[] = {
"rhs_weap_m4a1_carryhandle",
"rhs_weap_m4a1_carryhandle_mstock",
"rhs_weap_m4a1",
"rhs_weap_m4a1_mstock",
"rhs_weap_m4a1_d",
"rhs_weap_m4a1_d_mstock",
"rhs_weap_m4a1_wd",
"rhs_weap_m4a1_wd_mstock",

"rhs_weap_m4a1_blockII",
"rhs_weap_m4a1_blockII_KAC",
"rhs_weap_m4a1_blockII_bk",
"rhs_weap_m4a1_blockII_M203_bk",
"rhs_weap_m4a1_blockII_KAC_bk",
"rhs_weap_m4a1_blockII_d",
"rhs_weap_m4a1_blockII_M203_d",
"rhs_weap_m4a1_blockII_KAC_d",
"rhs_weap_m4a1_blockII_KAC",
"rhs_weap_m4a1_blockII_wd",
"rhs_weap_m4a1_blockII_KAC_wd",
"rhs_weap_m4a1",
"rhs_weap_m4a1_d",
"rhs_weap_m4a1_mstock",
"rhs_weap_m4a1_wd",
"rhs_weap_m4a1_wd_mstock"
};

"equ_magazines_basic_stanag",
"equ_scopes_basic"
class_rhs_weap_m4a1_m203[] = {
"rhs_weap_m4a1_carryhandle_m203",
"rhs_weap_m4a1_carryhandle_m203S",
"rhs_weap_m4a1_blockII_M203",
"rhs_weap_m4a1_blockII_M203_wd",
"rhs_weap_m4a1_m203s_d",
"rhs_weap_m4a1_d_mstock",
"rhs_weap_m4a1_m203",
"rhs_weap_m4a1_m203s",
"rhs_weap_m4a1_m320",
"rhs_weap_m4a1_m203s_wd"
};

class_rhs_weap_m249[] = {
"rhs_weap_m249",
"rhs_weap_m249_pip",
"rhs_weap_m249_light_L",
"rhs_weap_m249_pip_L_para",
"rhs_weap_m249_pip_L",
"rhs_weap_m249_pip_ris",
"rhs_weap_m249_light_S",
"rhs_weap_m249_pip_S_para",
"rhs_weap_m249_pip_S",
"equ_magazines_basic_box"
};
class_rhs_weap_m249_pip[] = {"class_rhs_weap_m249"};
class_rhs_weap_m249_pip_L[] = {"class_rhs_weap_m249"};
class_rhs_weap_m249_pip_S[] = {"class_rhs_weap_m249"};

coll_weapons_sidearms[] = {"class_UK3CB_P320_BLK"};
class_UK3CB_P320_BLK[] = {
Expand All @@ -52,6 +78,20 @@ class CfgEquipmentTags {
};

// Magazines
equ_magazines_basic_box[] = {
"rhsusf_200Rnd_556x45_mixed_soft_pouch",
"rhsusf_200Rnd_556x45_mixed_soft_pouch_coyote",
"rhsusf_200Rnd_556x45_mixed_soft_pouch_ucp",
"rhsusf_200Rnd_556x45_soft_pouch",
"rhsusf_200Rnd_556x45_soft_pouch_coyote",
"rhsusf_200Rnd_556x45_soft_pouch_ucp",
"rhsusf_100Rnd_556x45_soft_pouch",
"rhsusf_100Rnd_556x45_soft_pouch_coyote",
"rhsusf_100Rnd_556x45_soft_pouch_ucp",
"rhsusf_100Rnd_556x45_mixed_soft_pouch",
"rhsusf_100Rnd_556x45_mixed_soft_pouch_coyote",
"rhsusf_100Rnd_556x45_mixed_soft_pouch_ucp"
};
equ_magazines_basic_stanag[] = {
"rhs_mag_30Rnd_556x45_M855A1_Stanag",
"rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Red"
Expand Down
14 changes: 8 additions & 6 deletions cScripts/functions/arsenal/fn_arsenal_getWhitelist.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,21 @@ private _weaponSystemItems = [];
private _handgunWeapon = if (!isNil{_loadout#2#0}) then {_loadout#2#0} else {""};
private _launcherWeapon = if (!isNil{_loadout#1#0}) then {_loadout#1#0} else {""};

LOG_5("DEBUG","(%1: %2), [%3, %4, %5]",_weaponTagName,_classWeaponName,_primaryWeapon,_handgunWeapon,_launcherWeapon);
diag_log format["DEBUG %1",_primaryWeapon isKindof [_classWeaponName, configFile >> 'CfgWeapons']];

if (_primaryWeapon isKindof [_classWeaponName, configFile >> 'CfgWeapons']) then {
_weaponSystemItems append ([_weaponTagName] call EGVAR(gear,getTagItems));
LOG_1("DEBUG","Adding %1 weapon system",_weaponTagName);
_weaponSystemItems append ([_weaponTagName] call EFUNC(gear,getTagItems));
continue
};
if (_handgunWeapon isKindof [_classWeaponName, configFile >> 'CfgWeapons']) then {
_weaponSystemItems append ([_weaponTagName] call EGVAR(gear,getTagItems));
_weaponSystemItems append ([_weaponTagName] call EFUNC(gear,getTagItems));
continue
};
if (_launcherWeapon isKindof [_classWeaponName, configFile >> 'CfgWeapons']) then {
_weaponSystemItems append ([_weaponTagName] call EGVAR(gear,getTagItems));
_weaponSystemItems append ([_weaponTagName] call EFUNC(gear,getTagItems));
continue
};
} forEach _allEquipmentTags;
diag_log format ["cScripts DEBUG: Weapon System: %1", _weaponSystemItems];

private _whitelist = _loadoutSpecificItems + _commonSideItems + _companyItems + _companyPlatoonItems + _weaponSystemItems;

Expand Down
28 changes: 12 additions & 16 deletions cScripts/functions/gear/fn_gear_getTagItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,35 @@
params [["_tag","",[""]]];

if (_tag isEqualTo "") exitWith {[]};
INFO_1("EquipmentTag","Adding '%1' to whitelist", _tag);

private _fn_getTagItemsList = {
params [["_tag","",[]]];
private _equipmentTag = getArray (missionConfigFile >> "CfgEquipmentTags" >> _tag);
_equipmentTag;
};

EGVAR(gear,arsenalWhitelistAddedTags) append [_tag];

private _equipmentTagObjects = [_tag] call _fn_getTagItemsList;
private _tagItemList = [_tag] call _fn_getTagItemsList;
INFO_1("EquipmentTag","Tag List: %1", _tagItemList);

private _itemList = [];
{
INFO_1("EquipmentTag","Checking and adding item %1", _x);
//FIXME: remove this check when we are stable
if (_forEachIndex > 100) then {
ERROR("EquipmentTag","Infinet loop detected stopping loop!");
break;
};
if (_x in EGVAR(gear,arsenalWhitelistAddedTags)) then { continue; };

LOG_1("DEBUG_TAG","Adding item: %1",_x);

if ([_x] call EFUNC(gear,isTag)) then {
// if items already obtained continue
_equipmentTagObjects append [_x];
EGVAR(gear,arsenalWhitelistAddedTags) append [_x];
continue;
LOG_1("DEBUG_TAG","Item: %1 is tag",_x);
_tagItemList append ([_x] call _fn_getTagItemsList);
continue
};
if (_x in _itemList) exitWith {continue};
if ([_x] call FUNC(checkItemValidity)) then {
_itemList append [_x];
continue;
if (_x in _itemList) exitWith {
WARNING_1("EquipmentTag","Item '%1' is item already in itemlist.",_x);
continue
};
} forEach _equipmentTagObjects;
_itemList append [_x];
} forEach _tagItemList;

_itemList;

0 comments on commit a72dc63

Please sign in to comment.