2018-07-30 09:22:14 +00:00
#include "script_component.hpp"
2016-07-15 10:23:47 +00:00
/*
* Author: Glowbal
* Displays the patient information for given unit.
*
* Arguments:
* 0: The Unit <OBJECT>
2016-12-05 20:34:20 +00:00
* 1: Show <NUMBER> (default: 0)
2016-07-15 10:23:47 +00:00
* 2: Selection <NUMBER> (default: 0)
*
2017-06-08 13:31:51 +00:00
* Return Value:
2016-07-15 10:23:47 +00:00
* None
*
2017-06-08 13:31:51 +00:00
* Example:
* [bob, true, 2] call ACE_medical_fnc_displayPatientInformation
*
2016-07-15 10:23:47 +00:00
* Public: No
*/
#define MAX_DISTANCE 10
2016-12-05 20:34:20 +00:00
params ["_target", ["_show", 0], ["_selectionN", 0]];
2016-07-15 10:23:47 +00:00
GVAR(currentSelectedSelectionN) = [0, _selectionN] select (IS_SCALAR(_selectionN));
GVAR(displayPatientInformationTarget) = [ObjNull, _target] select _show;
2016-12-05 20:34:20 +00:00
if (_show == 1) then {
2016-07-15 10:23:47 +00:00
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"];
[{
params ["_args", "_idPFH"];
_args params ["_target", "_selectionN"];
if (GVAR(displayPatientInformationTarget) != _target || GVAR(currentSelectedSelectionN) != _selectionN) exitwith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
2019-03-17 16:58:43 +00:00
if ((ACE_player distance _target > MAX_DISTANCE) && {vehicle _target != vehicle ACE_player}) exitWith {
2016-07-15 10:23:47 +00:00
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
[_idPFH] call CBA_fnc_removePerFrameHandler;
[QEGVAR(common,displayTextStructured), [[ELSTRING(medical,DistanceToFar), [_target] call EFUNC(common,getName)], 1.75, ACE_player], [ACE_player]] call CBA_fnc_targetEvent;
};
disableSerialization;
private _display = uiNamespace getVariable QGVAR(DisplayInformation);
if (isnil "_display") exitwith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
private _allInjuryTexts = [];
private _genericMessages = [];
2018-08-02 08:43:31 +00:00
private _partText = [ELSTRING(medical_gui,Head), ELSTRING(medical_gui,Torso), ELSTRING(medical_gui,Arm_L), ELSTRING(medical_gui,Arm_R), ELSTRING(medical_gui,Leg_L), ELSTRING(medical_gui,Leg_R)] select _selectionN;
2016-07-15 10:23:47 +00:00
_genericMessages pushback [localize _partText, [1, 1, 1, 1]];
2018-05-22 17:06:28 +00:00
if IS_BLEEDING(_target) then {
2018-07-29 21:16:06 +00:00
_genericMessages pushback [LLSTRING(Status_Bleeding), [1, 0.1, 0.1, 1]];
2016-07-15 10:23:47 +00:00
};
2018-07-18 19:38:00 +00:00
2018-07-25 17:42:53 +00:00
// Give a qualitative description of the blood volume lost
switch (GET_HEMORRHAGE(_target)) do {
case 1: {
2018-07-25 10:40:37 +00:00
_genericMessages pushBack [LLSTRING(Lost_Blood1), [1, 0.1, 0.1, 1]];
2018-07-18 19:38:00 +00:00
};
2018-07-25 17:42:53 +00:00
case 2: {
_genericMessages pushBack [LLSTRING(Lost_Blood2), [1, 0.1, 0.1, 1]];
};
case 3: {
_genericMessages pushBack [LLSTRING(Lost_Blood3), [1, 0.1, 0.1, 1]];
};
case 4: {
_genericMessages pushBack [LLSTRING(Lost_Blood4), [1, 0.1, 0.1, 1]];
};
2016-07-15 10:23:47 +00:00
};
2018-07-29 21:43:14 +00:00
if (HAS_TOURNIQUET_APPLIED_ON(_target,_selectionN)) then {
2018-07-29 21:16:06 +00:00
_genericMessages pushback [localize ELSTRING(medical_treatment,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
2016-07-15 10:23:47 +00:00
};
2018-08-11 10:40:06 +00:00
if (GVAR(showPainInMenu) && {[ACE_player, GVAR(painVisualization)] call EFUNC(medical_treatment,isMedic)}) then {
2018-05-08 07:47:03 +00:00
private _painLevel = GET_PAIN_PERCEIVED(_target);
2016-12-14 20:30:28 +00:00
if (_painLevel > 0) then {
2018-07-29 21:16:06 +00:00
private _painText = localize ELSTRING(medical_treatment,Status_Pain);
2016-12-14 20:30:28 +00:00
if (_painLevel < 0.1) then {
2018-07-29 21:16:06 +00:00
_painText = localize ELSTRING(medical_treatment,Status_MildPain);
2016-12-14 20:30:28 +00:00
} else {
if (_painLevel > 0.5) then {
2018-07-29 21:16:06 +00:00
_painText = localize ELSTRING(medical_treatment,Status_SeverePain);
2016-12-14 20:30:28 +00:00
};
2016-12-10 14:24:20 +00:00
};
2016-12-14 20:30:28 +00:00
_genericMessages pushback [_painText, [1, 1, 1, 1]];
2016-12-10 14:24:20 +00:00
};
2016-07-15 10:23:47 +00:00
};
private _totalIvVolume = 0;
{
2017-04-29 18:05:39 +00:00
_x params ["_xVolumeAdded"];
_totalIvVolume = _totalIvVolume + _xVolumeAdded;
} foreach (_target getVariable [QEGVAR(medical,ivBags), []]);
2016-07-15 10:23:47 +00:00
if (_totalIvVolume >= 1) then {
2018-07-29 21:16:06 +00:00
_genericMessages pushback [format[localize ELSTRING(medical_treatment,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
2016-07-15 10:23:47 +00:00
};
2018-07-29 21:43:14 +00:00
private _selectionTourniquet = GET_TOURNIQUETS(_target);
2016-12-05 22:00:02 +00:00
private _selectionBloodLoss = [0, 0, 0, 0, 0, 0];
2016-12-08 10:38:43 +00:00
private _selectionDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
2016-12-05 22:00:02 +00:00
private _allInjuryTexts = [];
2016-07-15 10:23:47 +00:00
{
2016-12-14 17:04:56 +00:00
_x params ["", "_woundClassID", "_bodyPartN", "_amountOf", "_bleeding", "_damage", "_category"];
2016-12-05 22:00:02 +00:00
_selectionBloodLoss set [_bodyPartN, (_selectionBloodLoss select _bodyPartN) + (20 * (_bleeding * _amountOf))];
if (_selectionN == _bodyPartN) then {
2016-07-15 10:23:47 +00:00
// Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this]
2016-12-05 22:00:02 +00:00
if (_amountOf > 0) then {
2016-12-07 20:56:13 +00:00
private _className = (EGVAR(medical_damage,woundsData) select _woundClassID) select 6;
2016-12-14 17:04:56 +00:00
private _postfix = ["Minor", "Medium", "Large"] select _category;
2016-12-07 20:56:13 +00:00
private _woundDescription = localize format [ELSTRING(medical_damage,%1_%2), _className, _postfix];
2016-07-15 10:23:47 +00:00
if (_amountOf >= 1) then {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format["%2x %1", _woundDescription, ceil _amountOf], [1,1,1,1]];
2016-07-15 10:23:47 +00:00
} else {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format["Partial %1", _woundDescription], [1,1,1,1]];
2016-07-15 10:23:47 +00:00
};
2016-12-15 14:01:02 +00:00
} else {
2018-08-11 10:40:06 +00:00
if (!EGVAR(medical_treatment,advancedBandages) || {!EGVAR(medical_treatment,woundReopening)}) then {
2016-12-15 14:01:02 +00:00
private _className = (EGVAR(medical_damage,woundsData) select _woundClassID) select 6;
private _postfix = ["Minor", "Medium", "Large"] select _category;
private _woundDescription = localize format [ELSTRING(medical_damage,%1_%2), _className, _postfix];
if (_amountOf >= 1) then {
_allInjuryTexts pushBack [format ["[B] %2x %1", _woundDescription, ceil _amountOf], [0.7,0.7,0.7,1]];
} else {
_allInjuryTexts pushBack [format ["[B] Partial %1", _woundDescription], [0.7,0.7,0.7,1]];
};
};
2016-07-15 10:23:47 +00:00
};
};
2016-12-05 22:00:02 +00:00
} forEach (_target getVariable [QEGVAR(medical,openWounds), []]);
2016-07-15 10:23:47 +00:00
{
2016-12-14 17:04:56 +00:00
_x params ["", "_woundClassID", "_bodyPartN", "_amountOf", "_bleeding", "_damage", "_category"];
2016-12-05 22:00:02 +00:00
if (_selectionN == _bodyPartN) then {
// Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this]
if (_amountOf > 0) then {
2016-12-07 20:56:13 +00:00
private _className = (EGVAR(medical_damage,woundsData) select _woundClassID) select 6;
2016-12-14 17:04:56 +00:00
private _postfix = ["Minor", "Medium", "Large"] select _category;
2016-12-07 20:56:13 +00:00
private _woundDescription = localize format [ELSTRING(medical_damage,%1_%2), _className, _postfix];
2016-12-05 22:00:02 +00:00
if (_amountOf >= 1) then {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format ["[B] %2x %1", _woundDescription, ceil _amountOf], [0.88,0.7,0.65,1]];
2016-12-05 22:00:02 +00:00
} else {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format ["[B] Partial %1", _woundDescription], [0.88,0.7,0.65,1]];
2016-12-05 22:00:02 +00:00
};
};
2016-07-15 10:23:47 +00:00
};
2016-12-05 22:00:02 +00:00
} forEach (_target getVariable [QEGVAR(medical,bandagedWounds), []]);
{
2016-12-14 17:04:56 +00:00
_x params ["", "_woundClassID", "_bodyPartN", "_amountOf", "_bleeding", "_damage", "_category"];
2016-12-05 22:00:02 +00:00
if (_selectionN == _bodyPartN) then {
2016-07-15 10:23:47 +00:00
// Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this]
if (_amountOf > 0) then {
2016-12-07 20:56:13 +00:00
private _className = (EGVAR(medical_damage,woundsData) select _woundClassID) select 6;
2016-12-14 17:04:56 +00:00
private _postfix = ["Minor", "Medium", "Large"] select _category;
2016-12-07 20:56:13 +00:00
private _woundDescription = localize format [ELSTRING(medical_damage,%1_%2), _className, _postfix];
2016-07-15 10:23:47 +00:00
if (_amountOf >= 1) then {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format ["[S] %2x %1", _woundDescription, ceil _amountOf], [0.7,0.7,0.7,1]];
2016-07-15 10:23:47 +00:00
} else {
2016-12-07 20:56:13 +00:00
_allInjuryTexts pushBack [format ["[S] Partial %1", _woundDescription], [0.7,0.7,0.7,1]];
2016-07-15 10:23:47 +00:00
};
};
};
2016-12-05 22:00:02 +00:00
} forEach (_target getVariable [QEGVAR(medical,stitchedWounds), []]);
2016-07-15 10:23:47 +00:00
// Handle the body image coloring
2016-12-05 22:00:02 +00:00
private _availableSelections = [50, 51, 52, 53, 54, 55];
2016-07-15 10:23:47 +00:00
{
private _red = 1;
private _green = 1;
private _blue = 1;
2016-12-05 22:00:02 +00:00
private _torniquet = _selectionTourniquet select _forEachIndex;
if (_torniquet > 0) then {
2016-12-07 17:28:35 +00:00
_red = 0;
_green = 0;
_blue = 0.8;
2016-12-05 22:00:02 +00:00
} else {
private _bloodLoss = _selectionBloodLoss select _forEachIndex;
if (_bloodLoss > 0) then {
2016-12-07 20:56:13 +00:00
_green = 0 max (0.8 - _bloodLoss);
2016-07-15 10:23:47 +00:00
_blue = _green;
} else {
2016-12-05 22:00:02 +00:00
private _damage = _selectionDamage select _forEachIndex;
2016-12-07 17:28:35 +00:00
if (_damage > 0.1) then {
_blue = 0 max (1 - _damage);
2016-12-07 17:53:04 +00:00
_green = 0.5 max (1 - _damage / 2);
2016-12-07 17:28:35 +00:00
};
2016-07-15 10:23:47 +00:00
};
};
2016-12-05 22:00:02 +00:00
(_display displayCtrl _x) ctrlSetTextColor [_red, _green, _blue, 1.0];
} forEach _availableSelections;
2016-07-15 10:23:47 +00:00
private _lbCtrl = (_display displayCtrl 200);
lbClear _lbCtrl;
{
_x params ["_add", "_color"];
_lbCtrl lbAdd _add;
_lbCtrl lbSetColor [_foreachIndex, _color];
} foreach _genericMessages;
private _amountOfGeneric = count _genericMessages;
{
_x params ["_add", "_color"];
_lbCtrl lbAdd _add;
_lbCtrl lbSetColor [_foreachIndex + _amountOfGeneric, _color];
} foreach _allInjuryTexts;
if (count _allInjuryTexts == 0) then {
2018-07-18 21:19:27 +00:00
_lbCtrl lbAdd (localize ELSTRING(medical_treatment,NoInjuriesBodypart));
2016-07-15 10:23:47 +00:00
};
private _logCtrl = (_display displayCtrl 302);
lbClear _logCtrl;
private _logs = _target getVariable [QGVAR(logFile_Activity), []];
{
_x params ["_message", "_moment", "_type", "_arguments"];
if (isLocalized _message) then {
_message = localize _message;
};
{
if (_x isEqualType "" && {isLocalized _x}) then {
_arguments set [_foreachIndex, localize _x];
};
} foreach _arguments;
_message = format([_message] + _arguments);
_logCtrl lbAdd format["%1 %2", _moment, _message];
} foreach _logs;
2016-12-10 03:27:42 +00:00
private _triageStatus = [_target] call EFUNC(medical_treatment,getTriageStatus);
2016-07-15 10:23:47 +00:00
(_display displayCtrl 303) ctrlSetText (_triageStatus select 0);
(_display displayCtrl 303) ctrlSetBackgroundColor (_triageStatus select 2);
}, 0, [_target, GVAR(currentSelectedSelectionN)]] call CBA_fnc_addPerFrameHandler;
} else {
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
};