Skip to content

Commit

Permalink
Updated the whitelist system with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBrostrom committed Apr 7, 2024
1 parent 865d07c commit 1990a11
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 30 deletions.
27 changes: 27 additions & 0 deletions cScripts/CfgEquipmentTags.hpp
Original file line number Diff line number Diff line change
@@ -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"};
};
2 changes: 2 additions & 0 deletions cScripts/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ class cScripts {
class gear_applyFunctions {};
class gear_selectLoadout {};
class gear_getSideConfig {};

class gear_getLoadoutCompany {};

class gear_setupRadios {};

Expand Down
24 changes: 24 additions & 0 deletions cScripts/functions/gear/fn_gear_getLoadoutCompany.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\script_component.hpp";
/*
* Author: SGT.Brostrom.A
* This function return your company
*
* Arguments:
* None
*
* Return Value:
* CompanyName <STRING>
*
* 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;
3 changes: 2 additions & 1 deletion cScripts/functions/gear/fn_gear_getTagItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* Tags <ARRAY>
*
* Example:
* call cScripts_fnc_gear_getTagItems
* ["CommonDefault"] call cScripts_fnc_gear_getTagItems
* ["CommonBluforCompanyAlpha"] call cScripts_fnc_gear_getTagItems
*
*/

Expand Down
2 changes: 1 addition & 1 deletion cScripts/functions/gear/fn_gear_getTags.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Tags <ARRAY>
*
* Example:
* call cScripts_fnc_gear_getTags
* [typeOf player] call cScripts_fnc_gear_getTags
*
*/

Expand Down
57 changes: 29 additions & 28 deletions cScripts/functions/systems/fn_getArsenalWhitelist.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions description.ext
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ class CfgFunctions {
#include "cScripts\CfgFunctions.hpp"
};
#include "cScripts\CfgLoadouts.hpp"
#include "cScripts\CfgEquipmentTags.hpp"

/* OTHER */

0 comments on commit 1990a11

Please sign in to comment.