From 1990a11061f82e34d9bf83a6ddee088ecd0cce8d Mon Sep 17 00:00:00 2001 From: AndreasBrostrom Date: Sun, 7 Apr 2024 10:11:37 +0200 Subject: [PATCH] Updated the whitelist system with tags --- cScripts/CfgEquipmentTags.hpp | 27 +++++++++ cScripts/CfgFunctions.hpp | 2 + .../gear/fn_gear_getLoadoutCompany.sqf | 24 ++++++++ .../functions/gear/fn_gear_getTagItems.sqf | 3 +- cScripts/functions/gear/fn_gear_getTags.sqf | 2 +- .../systems/fn_getArsenalWhitelist.sqf | 57 ++++++++++--------- description.ext | 1 + 7 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 cScripts/CfgEquipmentTags.hpp create mode 100644 cScripts/functions/gear/fn_gear_getLoadoutCompany.sqf diff --git a/cScripts/CfgEquipmentTags.hpp b/cScripts/CfgEquipmentTags.hpp new file mode 100644 index 000000000..102ec3453 --- /dev/null +++ b/cScripts/CfgEquipmentTags.hpp @@ -0,0 +1,27 @@ +class CfgEquipmentTags { + Common[] = {"G_Aviator"}; + + CommonBlufor[] = {"G_Aviator"}; + + CommonBluforCompanyAlpha[] = {"ace_banana"}; + CommonBluforCompanyBravo[] = {"ace_banana"}; + CommonBluforCompanyCharlie[] = {"ace_banana"}; + + + equ_specialized_radio[] = {""}; + equ_signal_equipment[] = {""}; + + medical_equipment_level_0[] = {""}; + medical_equipment_level_1[] = {""}; + medical_equipment_level_2[] = {""}; + medical_equipment_level_3[] = {""}; + + weapon_system_launchers[] = {""}; + + weapon_system_m4a1[] = {""}; + weapon_system_glock[] = {""}; + + // used for expanding the weapon systems + weapon_system_rifle_expanded[] = {"weapon_system_m4a1"}; + weapon_system_pistol_expanded[] = {"weapon_system_glock"}; +}; diff --git a/cScripts/CfgFunctions.hpp b/cScripts/CfgFunctions.hpp index 5794f37d3..41a25a015 100644 --- a/cScripts/CfgFunctions.hpp +++ b/cScripts/CfgFunctions.hpp @@ -226,6 +226,8 @@ class cScripts { class gear_applyFunctions {}; class gear_selectLoadout {}; class gear_getSideConfig {}; + + class gear_getLoadoutCompany {}; class gear_setupRadios {}; diff --git a/cScripts/functions/gear/fn_gear_getLoadoutCompany.sqf b/cScripts/functions/gear/fn_gear_getLoadoutCompany.sqf new file mode 100644 index 000000000..48867c537 --- /dev/null +++ b/cScripts/functions/gear/fn_gear_getLoadoutCompany.sqf @@ -0,0 +1,24 @@ +#include "..\script_component.hpp"; +/* + * Author: SGT.Brostrom.A + * This function return your company + * + * Arguments: + * None + * + * Return Value: + * CompanyName + * + * Example: + * call cScripts_fnc_player_getLoadoutCompany; + * + * Public: No + */ + +//FIXME: Mabe not have afterall? +params [["_loadout","",[]]]; + +private _config = missionConfigFile >> "CfgLoadouts" >> _loadout; +private _company = getArray (_config >> "company"); + +_company; diff --git a/cScripts/functions/gear/fn_gear_getTagItems.sqf b/cScripts/functions/gear/fn_gear_getTagItems.sqf index dd8c4178d..36f7dd47c 100644 --- a/cScripts/functions/gear/fn_gear_getTagItems.sqf +++ b/cScripts/functions/gear/fn_gear_getTagItems.sqf @@ -10,7 +10,8 @@ * Tags * * Example: - * call cScripts_fnc_gear_getTagItems + * ["CommonDefault"] call cScripts_fnc_gear_getTagItems + * ["CommonBluforCompanyAlpha"] call cScripts_fnc_gear_getTagItems * */ diff --git a/cScripts/functions/gear/fn_gear_getTags.sqf b/cScripts/functions/gear/fn_gear_getTags.sqf index 8835a63ae..c3ddf4919 100644 --- a/cScripts/functions/gear/fn_gear_getTags.sqf +++ b/cScripts/functions/gear/fn_gear_getTags.sqf @@ -10,7 +10,7 @@ * Tags * * Example: - * call cScripts_fnc_gear_getTags + * [typeOf player] call cScripts_fnc_gear_getTags * */ diff --git a/cScripts/functions/systems/fn_getArsenalWhitelist.sqf b/cScripts/functions/systems/fn_getArsenalWhitelist.sqf index dfb894e21..3c8b9f25c 100644 --- a/cScripts/functions/systems/fn_getArsenalWhitelist.sqf +++ b/cScripts/functions/systems/fn_getArsenalWhitelist.sqf @@ -19,46 +19,47 @@ if !(isClass (missionConfigFile >> "CfgLoadouts" >> _classname)) exitWith { []; }; +// Loadout Items private _loadout = parseSimpleArray getText (missionConfigFile >> "CfgLoadouts" >> _classname >> "loadout"); private _unitItems = str _loadout splitString "[]," joinString ","; _unitItems = parseSimpleArray ("[" + _unitItems + "]"); _unitItems = _unitItems arrayIntersect _unitItems select {_x isEqualType "" && {_x != ""}}; +// Global Items +private _anySideCommon = ["Common"] FUNC(getGetItems); + +// Side Items +private _side = [side group player] call EFUNC(gear,getSideConfig); +private _commonGear = switch (_side) do { + case "CommonBlufor": { ["CommonBlufor"] FUNC(getGetItems); }; + case "CommonOpfor": { ["CommonOpfor"] FUNC(getGetItems); }; + case "CommonIndependant": { ["CommonIndependant"] FUNC(getGetItems); }; + case "CommonCivilian": { ["CommonCivilian"] FUNC(getGetItems); }; + default { ["CommonDefault"] FUNC(getGetItems); }; +}; -private _commonGear = GET_CONTAINER_KEYS("arsenal_common"); - - +// Side Company Items private _company = call EFUNC(player,getCompany); -private _companyItems = switch (_company) do { - case "alpha": {GET_CONTAINER_KEYS("alpha_company");}; - case "bravo": {GET_CONTAINER_KEYS("bravo_company");}; - case "charlie": {GET_CONTAINER_KEYS("charlie_company");}; - default {GET_CONTAINER_KEYS("arsenal_company_fallback");}; +private _titleCompany = [_company] call CBA_fnc_capitalize; +private _companyItems = switch (_side) do { + case "CommonBlufor": { ["CommonBluforCompany"+_titleCompany] FUNC(getGetItems); }; + case "CommonOpfor": { ["CommonOpforCompany"+_titleCompany] FUNC(getGetItems); }; + case "CommonIndependant": { ["CommonIndependantCompany"+_titleCompany] FUNC(getGetItems); }; + case "CommonCivilian": { ["CommonCivilianCompany"+_titleCompany] FUNC(getGetItems); }; + default { ["CommonDefaultCompany"+_titleCompany] FUNC(getGetItems); }; }; - +// Equipmnet Tag Items private _tagItems = []; +private _equipmentTags = call EGVAR(gear,getLoadoutTags); { - private _tag = switch (_x) do { - case "role_officer": {GET_CONTAINER_KEYS("arsenal_role_officer");}; - case "role_squadleader": {GET_CONTAINER_KEYS("arsenal_role_squadleader");}; - case "role_fireteamleader": {GET_CONTAINER_KEYS("arsenal_role_fireteamleader");}; - case "role_weapons": {GET_CONTAINER_KEYS("arsenal_role_weapons");}; - case "role_pilot"; - case "role_rotarypilot": {GET_CONTAINER_KEYS("arsenal_role_rotarypilot");}; - case "role_rotarycrew": {GET_CONTAINER_KEYS("arsenal_role_pilotcrew");}; - case "role_pilotfighter": {GET_CONTAINER_KEYS("arsenal_role_pilotfighter");}; - case "role_pilottransport": {GET_CONTAINER_KEYS("arsenal_role_pilottransport");}; - - case "tag_cls": {GET_CONTAINER_KEYS("arsenal_tag_cls");}; - case "tag_medic": {GET_CONTAINER_KEYS("arsenal_tag_medic");}; - case "tag_doctor": {GET_CONTAINER_KEYS("arsenal_tag_doctor");}; - default {[]}; - }; - _tagItems append _x; -} forEach [player] call EFUNC(gear,getLoadoutRole) ; + private _items = [_x] call EGVAR(gear,getTagItems); + _tagItemsList append _items; +} forEach _equipmentTags; +// Weapon System Items +// FIXME: Make the system generalized and auto configured private _primaryWeapon = if (!isNil{_loadout#0#0}) then {_loadout#0#0} else {""}; private _primarySpecific = switch (true) do { case (_primaryWeapon isKindof ['rhs_weap_mk18_m320', configFile >> 'CfgWeapons'] @@ -97,6 +98,6 @@ private _launcherSpecific = switch (true) do { default {[]}; }; -private _whitelist = _commonGear + _unitItems + _companyItems + _tagItems + _primarySpecific + _handgunSpecific + _launcherSpecific; +private _whitelist = _unitItems + _anySideCommon + _commonGear + _companyItems + _primarySpecific + _handgunSpecific + _launcherSpecific; _whitelist diff --git a/description.ext b/description.ext index 6de5b007c..870c5043b 100644 --- a/description.ext +++ b/description.ext @@ -71,5 +71,6 @@ class CfgFunctions { #include "cScripts\CfgFunctions.hpp" }; #include "cScripts\CfgLoadouts.hpp" +#include "cScripts\CfgEquipmentTags.hpp" /* OTHER */