fixes unit gather method, ready

This commit is contained in:
2024-01-09 22:16:43 -08:00
parent 12dd0fc83c
commit 7630efeb4d
5 changed files with 82 additions and 147 deletions

View File

@@ -32,9 +32,8 @@ class milsim
class bindEventHandlers { postInit = 1; }; class bindEventHandlers { postInit = 1; };
class bindVehicleActions { postInit = 1; }; class bindVehicleActions { postInit = 1; };
class addClientStatsPFH {}; class addClientStatsPFH {};
class addMedicalOverlayPFH { postInit = 1; }; // nees refactor class addMedicalOverlayPFH { postInit = 1; };
class calculateClientStats {}; class calculateClientStats {};
class medicalTriageState3D {postInit = 1;};
class initVehicleFlags { postInit = 1; }; class initVehicleFlags { postInit = 1; };
class bindEmptyGroupGarbageCleanup { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; };
}; };

View File

@@ -8,7 +8,7 @@ _cpsPFH = [
}, },
"milsim_client_cps_interval" call CBA_settings_fnc_get, "milsim_client_cps_interval" call CBA_settings_fnc_get,
[], [],
{ diag_log text format ["[MILSIM] (client) PFH loaded with interval %1 seconds", "milsim_client_cps_interval" call CBA_settings_fnc_get ], }, { diag_log text format ["[MILSIM] (client) PFH loaded with interval %1 seconds", "milsim_client_cps_interval" call CBA_settings_fnc_get ] },
{ diag_log text format ["[MILSIM] (client) PFH unloaded"] }, { diag_log text format ["[MILSIM] (client) PFH unloaded"] },
{ "milsim_client_cps_enable" call CBA_settings_fnc_get }, { "milsim_client_cps_enable" call CBA_settings_fnc_get },
{ false }, { false },

View File

@@ -1,14 +1,28 @@
// Enable/Disable the script /*
milsim_fnc_addMedicalOverlayPFH
Author: IndigoFox
Description:
Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m)
unconscious players who are not in a vehicle
which indicates their current ACE Triage Card status.
Designed to increase efficiency of CCPs.
*/
// Force setting if CBA doesn't work?
if (isNil "milsim_client_medState3D_enabled") then { if (isNil "milsim_client_medState3D_enabled") then {
milsim_client_medState3D_enabled = true; milsim_client_medState3D_enabled = true;
}; };
if (isNil "milsim_client_medState3D_drawRange") then {
milsim_client_medState3D_drawRange = 10;
};
// List of units to draw icons for // List of units to draw icons for
milsim_client_medState3D_drawTargets = []; milsim_client_medState3D_drawTargets = [];
// Range to draw icons for
milsim_client_medState3D_drawRange = 10;
// ACE Triage colors, for consistency across UIs and functions // ACE Triage colors, for consistency across UIs and functions
// #define TRIAGE_COLOR_NONE 0.5, 0.5, 0.5, 0.1 // #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_MINIMAL 0, 0.5, 0, 0.9
@@ -26,54 +40,54 @@ milsim_client_medState3D_colors = [
]; ];
// Per-frame handler to draw icons // Per-frame handler to draw icons
milsim_client_medState3D_pfh = [ // cleanup
[milsim_client_medState3D_drawTargetsPfh] call CBA_fnc_removePerFrameHandler;
// add pfh
milsim_client_medState3D_pfh = [{
// if disabled, skip processing
if (!milsim_client_medState3D_enabled) exitWith {false};
// if no targets, skip processing
if (count milsim_client_medState3D_drawTargets == 0) exitWith {false};
if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false};
{ {
// if disabled, skip processing // distance within 10 meters
if (!milsim_client_medState3D_enabled) exitWith {}; if (player distance _x > milsim_client_medState3D_drawRange) then {continue};
// check unit not null, not conscious, and not in a vehicle
if (
!(_x getVariable ["ACE_isUnconscious", false]) ||
!isNull (objectParent _x)
) then {continue};
// if no targets, skip processing // color based on triage level
if (count milsim_client_medState3D_drawTargets == 0) exitWith {}; 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;
if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {}; // subroutine to gather nearest 50 units every 5 seconds and store in milsim_client_medState3D_drawTargets
// cleanup
{ [milsim_client_medState3D_drawTargetsPfh] call CBA_fnc_removePerFrameHandler;
// distance within 10 meters // add pfh
if (player distance _x > milsim_client_medState3D_drawRange) then {continue}; milsim_client_medState3D_drawTargetsPfh = [{
// check unit not null, not conscious, and not in a vehicle milsim_client_medState3D_drawTargets = (
if ( (allUnits + allDeadMen) select {
isNull _x || _x isKindOf "CAManBase" &&
!(_x getVariable ["ACE_isUnconscious", false]) || player distance _x < 50 &&
!isNull (objectParent _x) !isNull _x &&
) then {continue}; player isNotEqualTo _x
}
// color based on triage level );
private _color = milsim_client_medState3D_colors select ((_x getVariable ["ace_medical_triageLevel", -1]) -1); }, 5, false] call CBA_fnc_addPerFrameHandler;
// 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;

View File

@@ -1,87 +0,0 @@
/*
milsim_fnc_medicalTriageState3D
Author: IndigoFox
Description:
Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m)
unconscious players who are not in a vehicle
which indicates their current ACE Triage Card status.
Designed to increase efficiency of CCPs.
*/
// Add setting
[
"milsim_client_medState3D_enabled", // variable
"CHECKBOX", // type
["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title
"17th Batallion", // category
true // default value
] call CBA_fnc_addSetting;
// Force setting if CBA doesn't work?
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 (
!(_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;

View File

@@ -109,13 +109,22 @@
//--------------------- //---------------------
[ [
"milsim_client_medState3D_enabled", "milsim_client_medState3D_enabled", // variable
"CHECKBOX", "CHECKBOX", // type
["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title
"Medical", ["17th Battalion", "Medical"], // category
true true // default value
] call CBA_fnc_addSetting; ] call CBA_fnc_addSetting;
[
"milsim_client_medState3D_drawRange", // variable
"LIST", // type
["Range To Draw Icons", "Determines range at which dots are visible"], // title
["17th Battalion", "Medical"], // category
[[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4] // option values, option labels, default index
] call CBA_fnc_addSetting;
diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; diag_log text "[MILSIM] (settings) Custom CBA settings initialized";
nil; nil;