2015-03-01 15:04:53 +00:00
/*
* Author: Glowbal
* Displays the patient information for given unit.
*
* Arguments:
* 0: The Unit <OBJECT>
2015-08-22 14:25:10 +00:00
* 1: Show <BOOL> (default: true)
* 2: Selection <NUMBER> (default: 0)
2015-03-01 15:04:53 +00:00
*
* ReturnValue:
2015-08-22 14:25:10 +00:00
* None
2015-03-01 15:04:53 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2015-08-09 07:14:42 +00:00
#define MAX_DISTANCE 10
2015-03-01 15:04:53 +00:00
2015-04-17 03:04:27 +00:00
// Exit for basic medical
if (GVAR(level) < 2) exitWith {};
2015-08-26 08:04:51 +00:00
private ["_amountOfGeneric", "_bandagedwounds", "_logCtrl", "_part", "_partText", "_pointDamage", "_severity", "_total", "_totalIvVolume", "_triageStatus", "_type"];
params ["_target", ["_show", true], ["_selectionN", 0]];
2015-03-01 15:04:53 +00:00
2015-08-29 13:29:02 +00:00
GVAR(currentSelectedSelectionN) = [0, _selectionN] select (IS_SCALAR(_selectionN));
GVAR(displayPatientInformationTarget) = [ObjNull, _target] select _show;
2015-03-01 15:04:53 +00:00
2015-04-01 18:03:44 +00:00
if (USE_WOUND_EVENT_SYNC) then {
[_target, ACE_player] call FUNC(requestWoundSync);
};
2015-03-22 16:04:42 +00:00
2015-03-01 15:04:53 +00:00
if (_show) then {
2015-03-07 12:57:36 +00:00
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"];
[{
private ["_target", "_display", "_alphaLevel", "_damaged", "_availableSelections", "_openWounds", "_selectionBloodLoss", "_red", "_green", "_blue", "_alphaLevel", "_allInjuryTexts", "_lbCtrl", "_genericMessages"];
2015-08-22 14:25:10 +00:00
params ["_args", "_idPFH"];
_args params ["_target", "_selectionN"];
2015-04-06 17:43:27 +00:00
if (GVAR(displayPatientInformationTarget) != _target || GVAR(currentSelectedSelectionN) != _selectionN) exitwith {
2015-08-22 14:25:10 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-03-07 12:57:36 +00:00
};
2015-08-09 07:14:42 +00:00
if (ACE_player distance _target > MAX_DISTANCE) exitwith {
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
2015-08-22 14:25:10 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-08-09 07:14:42 +00:00
["displayTextStructured", [ACE_player], [[LSTRING(DistanceToFar), [_target] call EFUNC(common,getName)], 1.75, ACE_player]] call EFUNC(common,targetEvent);
};
2015-03-07 12:57:36 +00:00
disableSerialization;
2015-11-30 16:53:57 +00:00
_display = uiNamespace getVariable QGVAR(DisplayInformation);
2015-03-07 12:57:36 +00:00
if (isnil "_display") exitwith {
2015-08-22 14:25:10 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-03-07 12:57:36 +00:00
};
_allInjuryTexts = [];
_genericMessages = [];
2015-04-03 18:26:24 +00:00
2015-11-06 07:05:25 +00:00
if (GVAR(level) >= 2 && {([_unit] call FUNC(hasMedicalEnabled))}) then {
2015-06-05 03:51:40 +00:00
_partText = [LSTRING(Head), LSTRING(Torso), LSTRING(LeftArm) ,LSTRING(RightArm) ,LSTRING(LeftLeg), LSTRING(RightLeg)] select _selectionN;
2015-04-08 05:39:16 +00:00
_genericMessages pushback [localize _partText, [1, 1, 1, 1]];
};
2015-04-03 18:26:24 +00:00
2015-11-30 16:53:57 +00:00
if (_target getVariable[QGVAR(isBleeding), false]) then {
2015-05-28 19:59:04 +00:00
_genericMessages pushback [localize LSTRING(Status_Bleeding), [1, 0.1, 0.1, 1]];
2015-03-07 12:57:36 +00:00
};
2015-11-30 16:53:57 +00:00
if (_target getVariable[QGVAR(hasLostBlood), 0] > 1) then {
2015-05-28 19:59:04 +00:00
_genericMessages pushback [localize LSTRING(Status_Lost_Blood), [1, 0.1, 0.1, 1]];
2015-03-07 12:57:36 +00:00
};
2015-11-30 16:53:57 +00:00
if (((_target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select _selectionN) > 0) then {
2015-05-28 19:59:04 +00:00
_genericMessages pushback [localize LSTRING(Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
2015-03-07 12:57:36 +00:00
};
2015-11-30 16:53:57 +00:00
if (_target getVariable[QGVAR(hasPain), false]) then {
2015-05-28 19:59:04 +00:00
_genericMessages pushback [localize LSTRING(Status_Pain), [1, 1, 1, 1]];
2015-03-09 21:23:37 +00:00
};
2015-03-07 12:57:36 +00:00
2015-04-05 18:11:54 +00:00
_totalIvVolume = 0;
{
private "_value";
2015-11-30 16:53:57 +00:00
_value = _target getVariable _x;
2015-04-05 18:11:54 +00:00
if !(isnil "_value") then {
2015-11-30 16:53:57 +00:00
_totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]);
2015-04-05 18:11:54 +00:00
};
2015-08-22 14:25:10 +00:00
} foreach GVAR(IVBags);
2015-04-05 18:11:54 +00:00
if (_totalIvVolume >= 1) then {
2015-05-28 19:59:04 +00:00
_genericMessages pushback [format[localize LSTRING(receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
2015-04-05 18:11:54 +00:00
};
2015-04-07 18:19:32 +00:00
_damaged = [false, false, false, false, false, false];
2015-03-07 12:57:36 +00:00
_selectionBloodLoss = [0,0,0,0,0,0];
2015-11-06 07:05:25 +00:00
if (GVAR(level) >= 2 && {([_target] call FUNC(hasMedicalEnabled))}) then {
2015-11-30 16:53:57 +00:00
_openWounds = _target getVariable [QGVAR(openWounds), []];
2015-03-07 12:57:36 +00:00
private "_amountOf";
{
2015-08-22 14:25:10 +00:00
_x params ["", "_x1", "_selectionX", "_amountOf", "_x4"];
2015-03-07 12:57:36 +00:00
// Find how much this bodypart is bleeding
2015-04-07 18:19:32 +00:00
if (_amountOf > 0) then {
2015-08-22 14:25:10 +00:00
_damaged set[_selectionX, true];
_selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
2015-04-07 18:19:32 +00:00
2015-08-22 14:25:10 +00:00
if (_selectionN == _selectionX) then {
2015-03-07 12:57:36 +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 >= 1) then {
// TODO localization
2015-08-22 14:25:10 +00:00
_allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6, _amountOf], [1,1,1,1]];
2015-03-07 12:57:36 +00:00
} else {
// TODO localization
2015-08-22 14:25:10 +00:00
_allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6], [1,1,1,1]];
2015-03-07 12:57:36 +00:00
};
};
};
2015-08-22 14:25:10 +00:00
} foreach _openWounds;
2015-04-05 17:26:33 +00:00
2015-11-30 16:53:57 +00:00
_bandagedwounds = _target getVariable [QGVAR(bandagedWounds), []];
2015-04-05 17:26:33 +00:00
{
2015-08-22 14:25:10 +00:00
_x params ["", "", "_selectionX", "_amountOf", "_x4"];
2015-04-05 17:26:33 +00:00
// Find how much this bodypart is bleeding
2015-08-22 14:25:10 +00:00
if !(_damaged select _selectionX) then {
_selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
2015-04-07 18:19:32 +00:00
};
2015-08-22 14:25:10 +00:00
if (_selectionN == _selectionX) then {
2015-04-05 17:26:33 +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 {
if (_amountOf >= 1) then {
// TODO localization
2015-04-07 18:19:32 +00:00
_allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [0.88,0.7,0.65,1]];
2015-04-05 17:26:33 +00:00
} else {
// TODO localization
2015-04-07 18:19:32 +00:00
_allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]];
2015-04-05 17:26:33 +00:00
};
};
};
2015-08-22 14:25:10 +00:00
} foreach _bandagedwounds;
2015-03-07 12:57:36 +00:00
} else {
2015-04-07 18:19:32 +00:00
_damaged = [true, true, true, true, true, true];
2015-03-12 06:34:29 +00:00
{
2015-11-21 17:11:13 +00:00
private _hitPoint = [_target, _x, true] call FUNC(translateSelections);
_selectionBloodLoss set [_forEachIndex, _target getHitPointDamage _hitPoint];
if (_target getHitPointDamage _hitPoint > 0 && {_forEachIndex == _selectionN}) then {
_pointDamage = _target getHitPointDamage _hitPoint;
2015-04-14 18:40:17 +00:00
_severity = switch (true) do {
2015-05-28 19:59:04 +00:00
case (_pointDamage > 0.5): {localize LSTRING(HeavilyWounded)};
case (_pointDamage > 0.1): {localize LSTRING(LightlyWounded)};
default {localize LSTRING(VeryLightlyWounded)};
2015-04-14 18:40:17 +00:00
};
_part = localize ([
2015-05-28 19:59:04 +00:00
LSTRING(Head),
LSTRING(Torso),
LSTRING(LeftArm),
LSTRING(RightArm),
LSTRING(LeftLeg),
LSTRING(RightLeg)
2015-04-14 18:40:17 +00:00
] select _forEachIndex);
_allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]];
2015-03-19 20:31:56 +00:00
};
2015-11-21 17:11:13 +00:00
} forEach GVAR(SELECTIONS);
2015-03-07 12:57:36 +00:00
};
// Handle the body image coloring
2015-04-07 18:19:32 +00:00
2015-03-07 12:57:36 +00:00
_availableSelections = [50,51,52,53,54,55];
{
2015-08-22 14:25:10 +00:00
private ["_red", "_green", "_blue", "_total"];
2015-03-07 12:57:36 +00:00
_total = _x;
_red = 1;
_green = 1;
_blue = 1;
2015-04-07 18:19:32 +00:00
if (_total > 0) then {
if (_damaged select _forEachIndex) then {
_green = (0.9 - _total) max 0;
_blue = _green;
} else {
_green = (0.9 - _total) max 0;
_red = _green;
//_blue = _green;
2015-03-07 12:57:36 +00:00
};
};
(_display displayCtrl (_availableSelections select _foreachIndex)) ctrlSetTextColor [_red, _green, _blue, 1.0];
2015-08-22 14:25:10 +00:00
} foreach _selectionBloodLoss;
2015-03-07 12:57:36 +00:00
_lbCtrl = (_display displayCtrl 200);
lbClear _lbCtrl;
{
2015-08-22 14:25:10 +00:00
_x params ["_add", "_color"];
_lbCtrl lbAdd _add;
_lbCtrl lbSetColor [_foreachIndex, _color];
} foreach _genericMessages;
2015-04-07 18:19:32 +00:00
_amountOfGeneric = count _genericMessages;
2015-03-07 12:57:36 +00:00
{
2015-08-22 14:25:10 +00:00
_x params ["_add", "_color"];
_lbCtrl lbAdd _add;
_lbCtrl lbSetColor [_foreachIndex + _amountOfGeneric, _color];
} foreach _allInjuryTexts;
2015-04-03 18:26:24 +00:00
if (count _allInjuryTexts == 0) then {
2015-05-28 19:59:04 +00:00
_lbCtrl lbAdd (localize LSTRING(NoInjuriesBodypart));
2015-03-07 12:57:36 +00:00
};
_logCtrl = (_display displayCtrl 302);
lbClear _logCtrl;
2015-04-30 06:17:26 +00:00
private ["_logs", "_message", "_moment", "_arguments", "_lbCtrl"];
2015-11-30 16:53:57 +00:00
_logs = _target getVariable [QGVAR(logFile_Activity), []];
2015-03-07 12:57:36 +00:00
{
2015-04-03 19:03:22 +00:00
// [_message,_moment,_type, _arguments]
2015-08-26 08:04:51 +00:00
_x params ["_message", "_moment", "_type", "_arguments"];
2015-04-03 19:03:22 +00:00
if (isLocalized _message) then {
_message = localize _message;
};
2015-03-07 12:57:36 +00:00
{
2015-11-20 17:40:31 +00:00
if (_x isEqualType "" && {isLocalized _x}) then {
2015-04-03 19:03:22 +00:00
_arguments set [_foreachIndex, localize _x];
2015-03-07 12:57:36 +00:00
};
2015-08-22 14:25:10 +00:00
} foreach _arguments;
2015-04-03 19:03:22 +00:00
_message = format([_message] + _arguments);
_logCtrl lbAdd format["%1 %2", _moment, _message];
2015-08-22 14:25:10 +00:00
} foreach _logs;
2015-03-07 12:57:36 +00:00
_triageStatus = [_target] call FUNC(getTriageStatus);
(_display displayCtrl 303) ctrlSetText (_triageStatus select 0);
(_display displayCtrl 303) ctrlSetBackgroundColor (_triageStatus select 2);
2015-04-06 17:43:27 +00:00
}, 0, [_target, GVAR(currentSelectedSelectionN)]] call CBA_fnc_addPerFrameHandler;
2015-03-01 15:04:53 +00:00
} else {
2015-03-07 12:57:36 +00:00
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
2015-03-12 06:34:29 +00:00
};