From 32d8589733e8dedaf2e682f0e6f2769de02283d5 Mon Sep 17 00:00:00 2001 From: Hizumi <33106048+user4752@users.noreply.github.com> Date: Thu, 4 Jan 2024 01:11:59 -0600 Subject: [PATCH] add medical overlay --- functions/CfgFunctions.hpp | 1 + functions/client/fn_addMedicalOverlayPFH.sqf | 79 ++++++++++++++++++++ functions/settings/fn_addCBASettings.sqf | 11 +++ 3 files changed, 91 insertions(+) create mode 100644 functions/client/fn_addMedicalOverlayPFH.sqf diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 55ba3b7..d2ab5e6 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -32,6 +32,7 @@ class milsim class bindEventHandlers { postInit = 1; }; class bindVehicleActions { postInit = 1; }; class addClientStatsPFH {}; + class addMedicalOverlayPFH { postInit = 1; }; // nees refactor class calculateClientStats {}; class initVehicleFlags { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; }; diff --git a/functions/client/fn_addMedicalOverlayPFH.sqf b/functions/client/fn_addMedicalOverlayPFH.sqf new file mode 100644 index 0000000..6c1f267 --- /dev/null +++ b/functions/client/fn_addMedicalOverlayPFH.sqf @@ -0,0 +1,79 @@ +// Enable/Disable the script +if (isNil "milsim_client_medState3D_enabled") then { + milsim_client_medState3D_enabled = true; +}; + +// List of units to draw icons for +milsim_client_medState3D_drawTargets = []; + +// Range to draw icons for +milsim_client_medState3D_drawRange = 10; + +// ACE Triage colors, for consistency across UIs and functions +// #define TRIAGE_COLOR_NONE 0.5, 0.5, 0.5, 0.1 +// #define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9 +// #define TRIAGE_COLOR_DELAYED 1, 0.84, 0, 0.9 +// #define TRIAGE_COLOR_IMMEDIATE 1, 0, 0, 0.9 +// #define TRIAGE_COLOR_DECEASED 0, 0, 0, 0.9 + +// ACE Triage colors, for consistency across UIs and functions +milsim_client_medState3D_colors = [ + [0, 0.5, 0, 0.9], // TRIAGE_COLOR_MINIMAL + [1, 0.84, 0, 0.9], // TRIAGE_COLOR_DELAYED + [1, 0, 0, 0.9], // TRIAGE_COLOR_IMMEDIATE + [0, 0, 0, 0.9], // TRIAGE_COLOR_DECEASED + [0.5, 0.5, 0.5, 0] // TRIAGE_COLOR_NONE +]; + +// Per-frame handler to draw icons +milsim_client_medState3D_pfh = [ + { + // if disabled, skip processing + if (!milsim_client_medState3D_enabled) exitWith {}; + + // if no targets, skip processing + if (count milsim_client_medState3D_drawTargets == 0) exitWith {}; + + if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {}; + + { + // distance within 10 meters + if (player distance _x > milsim_client_medState3D_drawRange) then {continue}; + // check unit not null, not conscious, and not in a vehicle + if ( + isNull _x || + !(_x getVariable ["ACE_isUnconscious", false]) || + !isNull (objectParent _x) + ) then {continue}; + + // color based on triage level + private _color = milsim_client_medState3D_colors select ((_x getVariable ["ace_medical_triageLevel", -1]) -1); + // draw position, slightly above the prone unit + private _drawPos = (visiblePosition _x) vectorAdd [0, 0, 0.5]; + // draw icon + drawIcon3D [ + "\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture + _color, // color + _drawPos, // position AGL + 1, // width + 1, // height + 0 // angle + // further params optional, omitted + ]; + } forEach milsim_client_medState3D_drawTargets; + }, + 0, + [] +] call CBA_fnc_addPerFrameHandler; + +[ + "Man", + "InitPost", + { + params ["_unit"]; + milsim_client_medState3D_drawTargets pushBack _unit; + }, + true, + [], + true +] call CBA_fnc_addClassEventHandler; \ No newline at end of file diff --git a/functions/settings/fn_addCBASettings.sqf b/functions/settings/fn_addCBASettings.sqf index e1f5321..0ed78f5 100644 --- a/functions/settings/fn_addCBASettings.sqf +++ b/functions/settings/fn_addCBASettings.sqf @@ -104,6 +104,17 @@ } ] call CBA_fnc_addSetting; +//--------------------- +// Medical Overlay +//--------------------- + +[ + "milsim_client_medState3D_enabled", + "CHECKBOX", + ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], + "Medical", + true +] call CBA_fnc_addSetting; diag_log text "[MILSIM] (settings) Custom CBA settings initialized";