forked from acemod/ACE3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfnc_updateInjuryList.sqf
More file actions
257 lines (227 loc) · 8.65 KB
/
fnc_updateInjuryList.sqf
File metadata and controls
257 lines (227 loc) · 8.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#include "..\script_component.hpp"
/*
* Author: mharis001
* Updates injury list for given body part for the target.
*
* Arguments:
* 0: Injury list <CONTROL>
* 1: Target <OBJECT>
* 2: Body part, -1 to only show overall health info <NUMBER>
*
* Return Value:
* None
*
* Example:
* [_ctrlInjuries, _target, 0] call ace_medical_gui_fnc_updateInjuryList
*
* Public: No
*/
params ["_ctrl", "_target", "_selectionN"];
private _entries = [];
private _nonissueColor = [1, 1, 1, 0.33];
// Indicate if unit is bleeding at all
if (IS_BLEEDING(_target)) then {
// Give a qualitative description of the rate of bleeding
private _cardiacOutput = [_target] call EFUNC(medical_status,getCardiacOutput);
private _bleedRate = GET_BLOOD_LOSS(_target);
private _bleedRateKO = BLOOD_LOSS_KNOCK_OUT_THRESHOLD * (_cardiacOutput max 0.05);
// Use nonzero minimum cardiac output to prevent all bleeding showing as massive during cardiac arrest
switch (true) do {
case (_bleedRate < _bleedRateKO * BLEED_RATE_SLOW): {
_entries pushBack [localize LSTRING(Bleed_Rate1), [1, 1, 0, 1]];
};
case (_bleedRate < _bleedRateKO * BLEED_RATE_MODERATE): {
_entries pushBack [localize LSTRING(Bleed_Rate2), [1, 0.67, 0, 1]];
};
case (_bleedRate < _bleedRateKO * BLEED_RATE_SEVERE): {
_entries pushBack [localize LSTRING(Bleed_Rate3), [1, 0.33, 0, 1]];
};
default {
_entries pushBack [localize LSTRING(Bleed_Rate4), [1, 0, 0, 1]];
};
};
} else {
_entries pushBack [localize LSTRING(Status_Nobleeding), _nonissueColor];
};
if (GVAR(showBloodlossEntry)) then {
// Give a qualitative description of the blood volume lost
switch (GET_HEMORRHAGE(_target)) do {
case 0: {
_entries pushBack [localize LSTRING(Lost_Blood0), _nonissueColor];
};
case 1: {
_entries pushBack [localize LSTRING(Lost_Blood1), [1, 1, 0, 1]];
};
case 2: {
_entries pushBack [localize LSTRING(Lost_Blood2), [1, 0.67, 0, 1]];
};
case 3: {
_entries pushBack [localize LSTRING(Lost_Blood3), [1, 0.33, 0, 1]];
};
case 4: {
_entries pushBack [localize LSTRING(Lost_Blood4), [1, 0, 0, 1]];
};
};
};
// Show receiving IV volume remaining
private _totalIvVolume = 0;
private _saline = 0;
private _blood = 0;
private _plasma = 0;
{
_x params ["_volumeRemaining", "_type"];
switch (_type) do {
case "Saline": {
_saline = _saline + _volumeRemaining;
};
case "Blood": {
_blood = _blood + _volumeRemaining;
};
case "Plasma": {
_plasma = _plasma + _volumeRemaining;
};
};
_totalIvVolume = _totalIvVolume + _volumeRemaining;
} forEach (_target getVariable [QEGVAR(medical,ivBags), []]);
if (_totalIvVolume > 0) then {
if (_saline > 0) then {
_entries pushBack [format [localize ELSTRING(medical_treatment,receivingSalineIvVolume), floor _saline], [1, 1, 1, 1]];
};
if (_blood > 0) then {
_entries pushBack [format [localize ELSTRING(medical_treatment,receivingBloodIvVolume), floor _blood], [1, 1, 1, 1]];
};
if (_plasma > 0) then {
_entries pushBack [format [localize ELSTRING(medical_treatment,receivingPlasmaIvVolume), floor _plasma], [1, 1, 1, 1]];
};
} else {
_entries pushBack [localize ELSTRING(medical_treatment,Status_NoIv), _nonissueColor];
};
// Indicate the amount of pain the unit is in
if (_target call EFUNC(common,isAwake)) then {
private _pain = GET_PAIN_PERCEIVED(_target);
if (_pain > 0) then {
private _painText = switch (true) do {
case (_pain > PAIN_UNCONSCIOUS): {
ELSTRING(medical_treatment,Status_SeverePain);
};
case (_pain > (PAIN_UNCONSCIOUS / 5)): {
ELSTRING(medical_treatment,Status_Pain);
};
default {
ELSTRING(medical_treatment,Status_MildPain);
};
};
_entries pushBack [localize _painText, [1, 1, 1, 1]];
} else {
_entries pushBack [localize ELSTRING(medical_treatment,Status_NoPain), _nonissueColor];
};
};
// Skip the rest as they're body part specific
if (_selectionN == -1) exitWith {
// Add all entries to injury list
lbClear _ctrl;
{
_x params ["_text", "_color"];
_ctrl lbSetColor [_ctrl lbAdd _text, _color];
} forEach _entries;
_ctrl lbSetCurSel -1;
};
_entries pushBack ["", [1, 1, 1, 1]];
// Add selected body part name
private _bodyPartName = [
LSTRING(Head),
LSTRING(Torso),
LSTRING(LeftArm),
LSTRING(RightArm),
LSTRING(LeftLeg),
LSTRING(RightLeg)
] select _selectionN;
_entries pushBack [localize _bodyPartName, [1, 1, 1, 1]];
// Damage taken tooltip
if (GVAR(showDamageEntry)) then {
private _bodyPartDamage = (_target getVariable [QEGVAR(medical,bodyPartDamage), [0, 0, 0, 0, 0, 0]]) select _selectionN;
if (_bodyPartDamage > 0) then {
private _damageThreshold = GET_DAMAGE_THRESHOLD(_target);
switch (true) do {
case (_selectionN > 3): { // legs: index 4 & 5
_damageThreshold = LIMPING_DAMAGE_THRESHOLD * 4;
};
case (_selectionN > 1): { // arms: index 2 & 3
_damageThreshold = FRACTURE_DAMAGE_THRESHOLD * 4;
};
case (_selectionN == 0): { // head: index 0
_damageThreshold = _damageThreshold * 1.25;
};
default { // torso: index 1
_damageThreshold = _damageThreshold * 1.5;
};
};
_bodyPartDamage = (_bodyPartDamage / _damageThreshold) min 1;
switch (true) do {
case (_bodyPartDamage isEqualTo 1): {
_entries pushBack [localize LSTRING(traumaSustained4), [_bodyPartDamage] call FUNC(damageToRGBA)];
};
case (_bodyPartDamage >= 0.75): {
_entries pushBack [localize LSTRING(traumaSustained3), [_bodyPartDamage] call FUNC(damageToRGBA)];
};
case (_bodyPartDamage >= 0.5): {
_entries pushBack [localize LSTRING(traumaSustained2), [_bodyPartDamage] call FUNC(damageToRGBA)];
};
case (_bodyPartDamage >= 0.25): {
_entries pushBack [localize LSTRING(traumaSustained1), [_bodyPartDamage] call FUNC(damageToRGBA)];
};
};
};
};
// Indicate if a tourniquet is applied
if (HAS_TOURNIQUET_APPLIED_ON(_target,_selectionN)) then {
_entries pushBack [localize LSTRING(Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
};
// Indicate current body part fracture status
switch (GET_FRACTURES(_target) select _selectionN) do {
case 1: {
_entries pushBack [localize LSTRING(Status_Fractured), [1, 0, 0, 1]];
};
case -1: {
if (EGVAR(medical,fractures) in [2, 3]) then { // Ignore if the splint has no effect
_entries pushBack [localize LSTRING(Status_SplintApplied), [0.2, 0.2, 1, 1]];
};
};
};
// Add entries for open, bandaged, and stitched wounds
private _woundEntries = [];
private _fnc_processWounds = {
params ["_wounds", "_format", "_color"];
{
_x params ["_woundClassID", "_amountOf"];
if (_amountOf > 0) then {
private _classIndex = _woundClassID / 10;
private _category = _woundClassID % 10;
private _className = EGVAR(medical_damage,woundClassNames) select _classIndex;
private _suffix = ["Minor", "Medium", "Large"] select _category;
private _woundName = localize format [ELSTRING(medical_damage,%1_%2), _className, _suffix];
private _woundDescription = if (_amountOf >= 1) then {
format ["%1x %2", ceil _amountOf, _woundName]
} else {
format [localize LSTRING(PartialX), _woundName]
};
_woundEntries pushBack [format [_format, _woundDescription], _color];
};
} forEach (_wounds getOrDefault [ALL_BODY_PARTS select _selectionN, []]);
};
[GET_OPEN_WOUNDS(_target), "%1", [1, 1, 1, 1]] call _fnc_processWounds;
[GET_BANDAGED_WOUNDS(_target), "[B] %1", [0.88, 0.7, 0.65, 1]] call _fnc_processWounds;
[GET_STITCHED_WOUNDS(_target), "[S] %1", [0.7, 0.7, 0.7, 1]] call _fnc_processWounds;
// Handle no wound entries
if (_woundEntries isEqualTo []) then {
_entries pushBack [localize ELSTRING(medical_treatment,NoInjuriesBodypart), _nonissueColor];
} else {
_entries append _woundEntries;
};
// Add all entries to injury list
lbClear _ctrl;
{
_x params ["_text", "_color"];
_ctrl lbSetColor [_ctrl lbAdd _text, _color];
} forEach _entries;
_ctrl lbSetCurSel -1;