From 70d73ee8047f160bff59f2d44ea542ad977f4765 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Thu, 30 Jan 2025 01:41:58 -0300 Subject: [PATCH] added functions to handle TCP payloads --- .../main/functions/api/fn_send_drone_cot.sqf | 30 +++++++++ .../main/functions/api/fn_send_group_cots.sqf | 67 +++++++++++++++++++ .../main/functions/api/fn_send_human_cot.sqf | 12 ++++ .../main/functions/api/fn_send_marker_cot.sqf | 12 ++++ .../extract_data/fn_extract_role.sqf | 5 +- 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 addons/main/functions/api/fn_send_drone_cot.sqf create mode 100644 addons/main/functions/api/fn_send_group_cots.sqf create mode 100644 addons/main/functions/api/fn_send_human_cot.sqf create mode 100644 addons/main/functions/api/fn_send_marker_cot.sqf diff --git a/addons/main/functions/api/fn_send_drone_cot.sqf b/addons/main/functions/api/fn_send_drone_cot.sqf new file mode 100644 index 0000000..5cf69a0 --- /dev/null +++ b/addons/main/functions/api/fn_send_drone_cot.sqf @@ -0,0 +1,30 @@ +// function name: armatak_fnc_extract_drone +// function author: Valmo +// function description: Gets the drone information for the CoT Router + +params["_drone"]; + +private _atak_role = "a-f-A"; +private _atak_callsign = getText(configFile >> "CfgVehicles" >> typeOf _drone >> "displayName"); + +switch (side _drone) do { + case "WEST": { + _atak_role = "a-f-A-M-F-Q" + }; + case "EAST": { + _atak_role = "a-h-A-M-F-Q" + }; + case "INDEPENDENT": { + _atak_role = "a-n-A-M-F-Q" + }; + case "CIVILIAN": { + _atak_role = "a-f-A-C" + }; + default { + _atak_role = "a-f-A-M-F-Q" + }; +}; + +_cot = [_drone, _atak_role, _atak_callsign] call armatak_fnc_extract_marker_cot_info; + +"armatak" callExtension ["cot_router:send_marker_cot", [_cot]]; \ No newline at end of file diff --git a/addons/main/functions/api/fn_send_group_cots.sqf b/addons/main/functions/api/fn_send_group_cots.sqf new file mode 100644 index 0000000..7e6f316 --- /dev/null +++ b/addons/main/functions/api/fn_send_group_cots.sqf @@ -0,0 +1,67 @@ +// function name: armatak_fnc_send_group_cots +// function author: Valmo +// function description: handle the cot routing for drones + +params["_group"]; + +{ + _group_colors = missionNamespace getVariable "_group_colors"; + + _group_roles = ["Team Member", "Team Lead", "HQ", "Sniper", "Medic", "Forward Observer", "RTO", "K9"]; + + _group_role = "Team Member"; + + _group_name = ""; + + _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]; + }; + }; + + if (["SpecialOperative", (configFile >> "CfgVehicles" >> typeOf _x >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) then { + _group_role = _group_roles select 5; + }; + + if (_x getUnitTrait "medic") then { + _group_role = _group_roles select 4; + }; + + if ((["jtac", typeOf _x, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 5; + }; + + if (((backpack _x) isKindOf "TFAR_Bag_Base") or (["radio", typeOf _x, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 6; + }; + + if ((["sniper", typeOf _x, false] call BIS_fnc_inString) or (["marksman", (configFile >> "CfgVehicles" >> typeOf _x >> "role") call BIS_fnc_getCfgData, false] call BIS_fnc_inString) or (["sharpshooter", typeOf _x, false] call BIS_fnc_inString)) then { + _group_role = _group_roles select 3; + }; + + if (leader _group == _x) then { + _group_role = _group_roles select 1; + }; + + if (["officer", typeOf _x, false] call BIS_fnc_inString) then { + _group_role = _group_roles select 2; + }; + + [_x, name _x, _group_name, _group_role] call armatak_fnc_send_human_cot; +} forEach (units _group); \ No newline at end of file diff --git a/addons/main/functions/api/fn_send_human_cot.sqf b/addons/main/functions/api/fn_send_human_cot.sqf new file mode 100644 index 0000000..998ef10 --- /dev/null +++ b/addons/main/functions/api/fn_send_human_cot.sqf @@ -0,0 +1,12 @@ +// function name: armatak_fnc_extract_human_cot_info +// function author: Valmo +// function description: Gets the information necessary for generating the Human Cursor Over Time + +params ["_unit", "_callsign", "_group_name", "_group_role"]; + +_unit_position = _unit call armatak_fnc_extract_position; +_uuid = _unit call armatak_fnc_extract_uuid; + +_human_cot = [_uuid, _unit_position select 0, _unit_position select 1, _unit_position select 2, _callsign, _group_name, _group_role, _unit_position select 3, speed player / 3.6]; + +"armatak" callExtension ["cot_router:send_human_cot", [_human_cot]]; \ No newline at end of file diff --git a/addons/main/functions/api/fn_send_marker_cot.sqf b/addons/main/functions/api/fn_send_marker_cot.sqf new file mode 100644 index 0000000..7b9a5b1 --- /dev/null +++ b/addons/main/functions/api/fn_send_marker_cot.sqf @@ -0,0 +1,12 @@ +// function name: armatak_fnc_send_marker_cot +// function author: Valmo +// function description: Gets the information necessary for generating the Marker Cursor Over Time + +params ["_unit", "_type", "_callsign"]; + +_unit_position = _unit call armatak_fnc_extract_position; +_uuid = _unit call armatak_fnc_extract_uuid; + +_marker_cot = [_uuid, _type, _unit_position select 0, _unit_position select 1, _unit_position select 2, _callsign, _unit_position select 3, speed _unit / 3.6]; + +"armatak" callExtension ["cot_router:send_marker_cot", [_marker_cot]]; \ No newline at end of file diff --git a/addons/main/functions/extract_data/fn_extract_role.sqf b/addons/main/functions/extract_data/fn_extract_role.sqf index 9e0a9ef..75efcbf 100644 --- a/addons/main/functions/extract_data/fn_extract_role.sqf +++ b/addons/main/functions/extract_data/fn_extract_role.sqf @@ -24,7 +24,9 @@ switch (side _unit) do { _affiliation = "f"; }; }; + _unit_type = _unit call BIS_fnc_objectType select 1; + switch (_unit_type) do { case "AT": { _type = "G-U-C-F-R"; @@ -63,7 +65,8 @@ switch (_unit_type) do { _type = "G-U-C-I"; }; }; -if (!isNull vehicle _unit) then { + +if (typeOf (vehicle _unit) != typeOf _unit) then { _vehicle_type = (vehicle _unit) call BIS_fnc_objectType select 1; switch (_vehicle_type) do { case "Car": {