From 0191bb77acbfdfda4c2c964f45adc0d473c9286b Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Thu, 30 Jan 2025 15:36:22 -0300 Subject: [PATCH] added group information gathering functions --- .../extract_data/fn_extract_group_color.sqf | 25 ++++++++++++++ .../extract_data/fn_extract_group_role.sqf | 34 +++++++++++++++++++ .../extract_data/fn_extract_human_role.sqf | 1 - .../extract_data/fn_extract_role.sqf | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 addons/main/functions/extract_data/fn_extract_group_color.sqf create mode 100644 addons/main/functions/extract_data/fn_extract_group_role.sqf delete mode 100644 addons/main/functions/extract_data/fn_extract_human_role.sqf diff --git a/addons/main/functions/extract_data/fn_extract_group_color.sqf b/addons/main/functions/extract_data/fn_extract_group_color.sqf new file mode 100644 index 0000000..03e0348 --- /dev/null +++ b/addons/main/functions/extract_data/fn_extract_group_color.sqf @@ -0,0 +1,25 @@ +params["_group"]; + +_group_name = _group getVariable "_atak_group_name"; + +if (isNil "_group_name") then { + _group_colors = missionNamespace getVariable "_group_colors"; + _group_name = selectRandom _group_colors; + + if (count _group_colors > 0) then { + _randomIndex = floor (random (count _group_colors)); + + _selectedColor = _group_colors select _randomIndex; + + _group_colors deleteAt _randomIndex; + + _group_name = _selectedColor; + _group setVariable ["_atak_group_name", _group_name]; + missionNamespace setVariable ["_group_colors", _group_colors] + } else { + _group_name = "Red"; + _group setVariable ["_atak_group_name", _group_name]; + }; +}; + +_group_name \ No newline at end of file diff --git a/addons/main/functions/extract_data/fn_extract_group_role.sqf b/addons/main/functions/extract_data/fn_extract_group_role.sqf new file mode 100644 index 0000000..bc4546b --- /dev/null +++ b/addons/main/functions/extract_data/fn_extract_group_role.sqf @@ -0,0 +1,34 @@ +params["_unit"]; + +_group_roles = ["Team Member", "Team Lead", "HQ", "Sniper", "Medic", "Forward Observer", "RTO", "K9"]; +_group_role = "Team Member"; + +if (["SpecialOperative", (configFile >> "CfgVehicles" >> typeOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) then { + _group_role = _group_roles select 5; +}; + +if (_unit getUnitTrait "medic") then { + _group_role = _group_roles select 4; +}; + +if ((["jtac", typeOf _unit, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 5; +}; + +if (((backpack _unit) isKindOf "TFAR_Bag_Base") or (["radio", typeOf _unit, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 6; +}; + +if ((["sniper", typeOf _unit, false] call BIS_fnc_inString) or (["marksman", (configFile >> "CfgVehicles" >> typeOf _unit >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) or (["sharpshooter", typeOf _unit, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 3; +}; + +if (leader _group == _unit) then { + _group_role = _group_roles select 1; +}; + +if (["officer", typeOf _unit, false] call BIS_fnc_inString) then { + _group_role = _group_roles select 2; +}; + +_group_role \ No newline at end of file diff --git a/addons/main/functions/extract_data/fn_extract_human_role.sqf b/addons/main/functions/extract_data/fn_extract_human_role.sqf deleted file mode 100644 index 6e8f797..0000000 --- a/addons/main/functions/extract_data/fn_extract_human_role.sqf +++ /dev/null @@ -1 +0,0 @@ -params["_unit"]; diff --git a/addons/main/functions/extract_data/fn_extract_role.sqf b/addons/main/functions/extract_data/fn_extract_role.sqf index 75efcbf..1f3a152 100644 --- a/addons/main/functions/extract_data/fn_extract_role.sqf +++ b/addons/main/functions/extract_data/fn_extract_role.sqf @@ -7,6 +7,7 @@ params["_unit"]; private _affiliation = "f"; private _type = "G"; private _role = "a-f-G-U-C-I"; + switch (side _unit) do { case "WEST": { _affiliation = "f";