Minor code clean up (#6474)

* Minor code clean up
* refactor(medical): shorten some code
* refactor(medical): use macros for tourniquets
* refactor(medical): pull cache expiry values into script_macros_medical
This commit is contained in:
Thomas Kooi 2018-07-29 23:43:14 +02:00 committed by SilentSpike
parent 9e26833b94
commit 36f2c5fcc9
29 changed files with 70 additions and 71 deletions

View File

@ -70,7 +70,7 @@
// Tourniquets: // Tourniquets:
_return pushBack "------- Tourniquets: -------"; _return pushBack "------- Tourniquets: -------";
private _tourniquets = _unit getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_unit);
private _occludedMedications = _unit getVariable [QEGVAR(medical,occludedMedications), []]; private _occludedMedications = _unit getVariable [QEGVAR(medical,occludedMedications), []];
{ {
private _tPartNum = _forEachIndex; private _tPartNum = _forEachIndex;

View File

@ -78,6 +78,11 @@
#define BANDAGE_TIME_MOD_MEDIC -2 #define BANDAGE_TIME_MOD_MEDIC -2
#define BANDAGE_TIME_MOD_SELF 4 #define BANDAGE_TIME_MOD_SELF 4
#define DEFAULT_BANDAGE_REOPENING_CHANCE 0.1
#define DEFAULT_BANDAGE_REOPENING_MIN_DELAY 120
#define DEFAULT_BANDAGE_REOPENING_MAX_DELAY 200
#define DEFAULT_TOURNIQUET_VALUES [0,0,0,0,0,0]
// - Unit Variables ---------------------------------------------------- // - Unit Variables ----------------------------------------------------
// These variables get stored in object space and used across components // These variables get stored in object space and used across components
@ -98,6 +103,7 @@
#define VAR_HEMORRHAGE QEGVAR(medical,hemorrhage) #define VAR_HEMORRHAGE QEGVAR(medical,hemorrhage)
#define VAR_IN_PAIN QEGVAR(medical,inPain) #define VAR_IN_PAIN QEGVAR(medical,inPain)
#define VAR_IS_BLEEDING QEGVAR(medical,isBleeding) #define VAR_IS_BLEEDING QEGVAR(medical,isBleeding)
#define VAR_TOURNIQUET QEGVAR(medical,tourniquets)
// - Unit Functions --------------------------------------------------- // - Unit Functions ---------------------------------------------------
@ -108,6 +114,7 @@
#define GET_HEMORRHAGE(unit) (unit getVariable [VAR_HEMORRHAGE,0]) #define GET_HEMORRHAGE(unit) (unit getVariable [VAR_HEMORRHAGE,0])
#define GET_PAIN(unit) (unit getVariable [VAR_PAIN,0]) #define GET_PAIN(unit) (unit getVariable [VAR_PAIN,0])
#define GET_PAIN_SUPPRESS(unit) (unit getVariable [VAR_PAIN_SUPP,0]) #define GET_PAIN_SUPPRESS(unit) (unit getVariable [VAR_PAIN_SUPP,0])
#define GET_TOURNIQUETS(unit) (unit getVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES])
#define IN_CRDC_ARRST(unit) (unit getVariable [VAR_CRDC_ARRST,false]) #define IN_CRDC_ARRST(unit) (unit getVariable [VAR_CRDC_ARRST,false])
#define IS_BLEEDING(unit) (unit getVariable [VAR_IS_BLEEDING,false]) #define IS_BLEEDING(unit) (unit getVariable [VAR_IS_BLEEDING,false])
#define IS_IN_PAIN(unit) (unit getVariable [VAR_IN_PAIN,false]) #define IS_IN_PAIN(unit) (unit getVariable [VAR_IN_PAIN,false])
@ -119,3 +126,9 @@
// Derivative unit values commonly used // Derivative unit values commonly used
#define GET_PAIN_PERCEIVED(unit) (0 max (GET_PAIN(unit) - GET_PAIN_SUPPRESS(unit)) min 1) #define GET_PAIN_PERCEIVED(unit) (0 max (GET_PAIN(unit) - GET_PAIN_SUPPRESS(unit)) min 1)
#define HAS_TOURNIQUET_APPLIED_ON(unit,index) ((GET_TOURNIQUETS(unit) select index) > 0)
// Cache expiry values, in seconds
#define IN_MEDICAL_FACILITY_CACHE_EXPIRY 1
#define CAN_TREAT_CONDITION_CACHE_EXPIRY 2

View File

@ -72,7 +72,7 @@ if (_show == 1) then {
}; };
}; };
if (((_target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]) select _selectionN) > 0) then { if (HAS_TOURNIQUET_APPLIED_ON(_target,_selectionN)) then {
_genericMessages pushback [localize ELSTRING(medical_treatment,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]]; _genericMessages pushback [localize ELSTRING(medical_treatment,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
}; };
if (EGVAR(medical,showPainInMenu) && {[ACE_player, EGVAR(medical,medicSetting_PainVisualization)] call EFUNC(medical_treatment,isMedic)}) then { if (EGVAR(medical,showPainInMenu) && {[ACE_player, EGVAR(medical,medicSetting_PainVisualization)] call EFUNC(medical_treatment,isMedic)}) then {
@ -100,7 +100,7 @@ if (_show == 1) then {
_genericMessages pushback [format[localize ELSTRING(medical_treatment,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; _genericMessages pushback [format[localize ELSTRING(medical_treatment,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
}; };
private _selectionTourniquet = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _selectionTourniquet = GET_TOURNIQUETS(_target);
private _selectionBloodLoss = [0, 0, 0, 0, 0, 0]; private _selectionBloodLoss = [0, 0, 0, 0, 0, 0];
private _selectionDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; private _selectionDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _allInjuryTexts = []; private _allInjuryTexts = [];

View File

@ -29,7 +29,7 @@ private _bloodLossOnBodyPart = 0;
}; };
} forEach (_target getvariable [QEGVAR(medical,openWounds), []]); } forEach (_target getvariable [QEGVAR(medical,openWounds), []]);
private _hasTourniquet = ((_target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]) select _partIndex) > 0; private _hasTourniquet = HAS_TOURNIQUET_APPLIED_ON(_target,_partIndex);
switch (true) do { switch (true) do {
case (_bloodLossOnBodyPart >= 0.15): { case (_bloodLossOnBodyPart >= 0.15): {

View File

@ -47,7 +47,7 @@ switch (GET_HEMORRHAGE(_target)) do {
}; };
}; };
if (((_target getVariable [QEGVAR(medical,tourniquets), [0, 0, 0, 0, 0, 0]]) select _selectionN) > 0) then { if (HAS_TOURNIQUET_APPLIED_ON(_target,_selectionN)) then {
_genericMessages pushBack [localize ELSTRING(medical_treatment,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]]; _genericMessages pushBack [localize ELSTRING(medical_treatment,Status_Tourniquet_Applied), [0.77, 0.51, 0.08, 1]];
}; };
@ -77,7 +77,7 @@ if (_totalIvVolume >= 1) then {
_genericMessages pushBack [format [localize ELSTRING(medical_treatment,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; _genericMessages pushBack [format [localize ELSTRING(medical_treatment,receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
}; };
private _selectionTourniquet = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _selectionTourniquet = GET_TOURNIQUETS(_target);
private _selectionBloodLoss = [0, 0, 0, 0, 0, 0]; private _selectionBloodLoss = [0, 0, 0, 0, 0, 0];
private _selectionDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; private _selectionDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
private _allInjuryTexts = []; private _allInjuryTexts = [];

View File

@ -17,7 +17,7 @@
params ["_unit"]; params ["_unit"];
private _tourniquets = _unit getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_unit);
private _bodyPartBleeding = [0,0,0,0,0,0]; private _bodyPartBleeding = [0,0,0,0,0,0];
{ {
_x params ["", "", "_bodyPart", "_amountOf", "_bleeeding"]; _x params ["", "", "_bodyPart", "_amountOf", "_bleeeding"];

View File

@ -24,7 +24,7 @@ private _bloodVolumeChange = -_deltaT * GET_BLOOD_LOSS(_unit);
if (!isNil {_unit getVariable QEGVAR(medical,ivBags)}) then { if (!isNil {_unit getVariable QEGVAR(medical,ivBags)}) then {
private _bloodBags = _unit getVariable [QEGVAR(medical,ivBags), []]; private _bloodBags = _unit getVariable [QEGVAR(medical,ivBags), []];
private _tourniquets = _unit getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_unit);
_bloodBags = _bloodBags apply { _bloodBags = _bloodBags apply {
_x params ["_bagVolumeRemaining", "_type", "_bodyPart"]; _x params ["_bagVolumeRemaining", "_type", "_bodyPart"];

View File

@ -48,7 +48,7 @@ _unit setVariable [QEGVAR(medical,isLimping), false, true];
_unit setVariable [VAR_UNCON, false, true]; _unit setVariable [VAR_UNCON, false, true];
// - Treatments --------------------------------------------------------------- // - Treatments ---------------------------------------------------------------
_unit setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; _unit setVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES, true];
_unit setVariable [QEGVAR(medical,occludedMedications), nil, true]; //Delayed Medications (from tourniquets) _unit setVariable [QEGVAR(medical,occludedMedications), nil, true]; //Delayed Medications (from tourniquets)
_unit setVariable [QEGVAR(medical,ivBags), nil, true]; _unit setVariable [QEGVAR(medical,ivBags), nil, true];

View File

@ -19,6 +19,5 @@ params ["_target"];
private _owner = _target getVariable [QEGVAR(common,owner), objNull]; private _owner = _target getVariable [QEGVAR(common,owner), objNull];
if (isNull _owner) exitWith {false}; !(isNull _owner)
&& {(_owner getVariable [QEGVAR(dragging,carriedObject), objNull]) == _target}
(_owner getVariable [QEGVAR(dragging,carriedObject), objNull]) == _target

View File

@ -19,6 +19,5 @@ params ["_target"];
private _owner = _target getVariable [QEGVAR(common,owner), objNull]; private _owner = _target getVariable [QEGVAR(common,owner), objNull];
if (isNull _owner) exitWith {false}; !(isNull _owner)
&& {(_owner getVariable [QEGVAR(dragging,draggedObject), objNull]) == _target}
(_owner getVariable [QEGVAR(dragging,draggedObject), objNull]) == _target

View File

@ -18,9 +18,7 @@
params ["_unit"]; params ["_unit"];
if (!alive _unit) exitWith { false }; (alive _unit
if IS_UNCONSCIOUS(_unit) exitWith { false }; && {!IS_UNCONSCIOUS(_unit)}
if (GET_BLOOD_LOSS(_unit) > 0) exitWith { false }; && {GET_BLOOD_LOSS(_unit) == 0}
if (!(_unit call FUNC(hasStableVitals))) exitWith { false }; && {_unit call FUNC(hasStableVitals)})
true

View File

@ -21,12 +21,9 @@ params ["_caller", "_target"];
private _accessLevel = _target getVariable [QGVAR(allowSharedEquipmentAccess), -1]; private _accessLevel = _target getVariable [QGVAR(allowSharedEquipmentAccess), -1];
private _return = false; switch (_accessLevel) do {
case 0: { true };
if (_accessLevel >= 0) then { case 1: { side _target == side _caller };
if (_accessLevel == 0) exitWith { _return = true; }; case 2: { group _target == group _caller };
if (_accessLevel == 1) exitWith { _return = (side _target == side _caller); }; default { false };
if (_accessLevel == 2) exitWith { _return = (group _target == group _caller); };
}; };
_return;

View File

@ -19,8 +19,7 @@
#include "script_component.hpp" #include "script_component.hpp"
#define MAX_DURATION_CACHE 2
params ["", "_target", "_selection", "_classname"]; params ["", "_target", "_selection", "_classname"];
// parameters, function, namespace, uid // parameters, function, namespace, uid
[_this, DFUNC(canTreat), _target, format [QGVAR(canTreat_%1_%2), _selection, _classname], MAX_DURATION_CACHE, QEGVAR(interact_menu,clearConditionCaches)] call EFUNC(common,cachedCall); [_this, DFUNC(canTreat), _target, format [QGVAR(canTreat_%1_%2), _selection, _classname], CAN_TREAT_CONDITION_CACHE_EXPIRY, QEGVAR(interact_menu,clearConditionCaches)] call EFUNC(common,cachedCall);

View File

@ -25,10 +25,9 @@ private _category = _injury select 6;
private _postfix = ["Minor", "Medium", "Large"] select _category; private _postfix = ["Minor", "Medium", "Large"] select _category;
private _className = format ["%1%2", EGVAR(medical_damage,woundClassNames) select _classID, _postfix]; private _className = format ["%1%2", EGVAR(medical_damage,woundClassNames) select _classID, _postfix];
// default, just in case.. private _reopeningChance = DEFAULT_BANDAGE_REOPENING_CHANCE;
private _reopeningChance = 0.1; private _reopeningMinDelay = DEFAULT_BANDAGE_REOPENING_MIN_DELAY;
private _reopeningMinDelay = 120; private _reopeningMaxDelay = DEFAULT_BANDAGE_REOPENING_MAX_DELAY;
private _reopeningMaxDelay = 200;
// Get the default values for the used bandage // Get the default values for the used bandage
private _config = configFile >> QUOTE(ADDON) >> "Bandaging"; private _config = configFile >> QUOTE(ADDON) >> "Bandaging";

View File

@ -31,14 +31,14 @@ if ([_medic, _item] call EFUNC(common,hasItem)) exitWith {
true true
}; };
private _return = false; private _hasItem = false;
if (vehicle _medic != _medic && {vehicle _medic call FUNC(isMedicalVehicle)}) then { if (vehicle _medic != _medic && {vehicle _medic call FUNC(isMedicalVehicle)}) then {
{ {
if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {[_x, _item] call EFUNC(common,hasItem)}) exitWith { if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {[_x, _item] call EFUNC(common,hasItem)}) exitWith {
_return = true; _hasItem = true;
}; };
} forEach crew vehicle _medic; } forEach crew vehicle _medic;
}; };
_return _hasItem

View File

@ -20,6 +20,4 @@ params ["_target", "_bodyPart"];
private _index = ALL_BODY_PARTS find toLower _bodyPart; private _index = ALL_BODY_PARTS find toLower _bodyPart;
if (_index < 0) exitWith { false }; _index >= 0 && {HAS_TOURNIQUET_APPLIED_ON(_target,_index)}
((_target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]) select _index) > 0

View File

@ -23,6 +23,7 @@ private _treatTime = 0;
{ {
_totalDamage = _totalDamage + _x; _totalDamage = _totalDamage + _x;
} forEach (_unit getVariable [QEGVAR(medical,bodyPartDamage), []]); } forEach (_unit getVariable [QEGVAR(medical,bodyPartDamage), []]);
if (EGVAR(medical,PAKTime) > 0) then { if (EGVAR(medical,PAKTime) > 0) then {
_treatTime = EGVAR(medical,PAKTime); _treatTime = EGVAR(medical,PAKTime);
} else { } else {

View File

@ -48,6 +48,7 @@ private _objects = (lineIntersectsWith [_unit modelToWorldVisual [0, 0, (_eyePos
_isInBuilding = true; _isInBuilding = true;
}; };
} forEach _objects; } forEach _objects;
if (!_isInBuilding) then { if (!_isInBuilding) then {
_objects = _unit nearObjects 7.5; _objects = _unit nearObjects 7.5;
{ {
@ -57,7 +58,6 @@ if (!_isInBuilding) then {
} forEach _objects; } forEach _objects;
}; };
//Save the results (with a 1 second expiry) _unit setVariable [QGVAR(cacheInFacility), [CBA_missionTime + IN_MEDICAL_FACILITY_CACHE_EXPIRY, _isInBuilding]];
_unit setVariable [QGVAR(cacheInFacility), [CBA_missionTime + 1, _isInBuilding]];
_isInBuilding; _isInBuilding;

View File

@ -21,4 +21,4 @@ private _vehicle = vehicle _unit;
if (_unit == _vehicle) exitWith {false}; if (_unit == _vehicle) exitWith {false};
if (_unit in [driver _vehicle, gunner _vehicle, commander _vehicle]) exitWith {false}; if (_unit in [driver _vehicle, gunner _vehicle, commander _vehicle]) exitWith {false};
[_vehicle] call FUNC(isMedicalVehicle) [_vehicle] call FUNC(isMedicalVehicle);

View File

@ -28,4 +28,4 @@ if (([_unit] call FUNC(isInMedicalVehicle)) || {[_unit] call FUNC(isInMedicalFac
_class = _class + 1; //boost by one: untrained becomes medic, medic becomes doctor _class = _class + 1; //boost by one: untrained becomes medic, medic becomes doctor
}; };
_class >= _medicN min EGVAR(medical,medicSetting) _class >= _medicN min EGVAR(medical,medicSetting);

View File

@ -23,10 +23,4 @@ params ["_caller", "_target", "_bodyPart", "_className", "_items"];
[QGVAR(treatmentBandageLocal), [_target, _className, _bodyPart], _target] call CBA_fnc_targetEvent; [QGVAR(treatmentBandageLocal), [_target, _className, _bodyPart], _target] call CBA_fnc_targetEvent;
/*{
if (_x != "") then {
[_target, _x] call FUNC(addToTriageCard);
};
} forEach _items;*/
true true

View File

@ -18,6 +18,9 @@
params ["_caller", "_target"]; params ["_caller", "_target"];
[QGVAR(treatmentFullHealLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; [QGVAR(treatmentFullHealLocal), [_target], _target] call CBA_fnc_targetEvent;
[_target, "activity", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[_target, "activity_view", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message
true true

View File

@ -3,8 +3,7 @@
* Handles full heal of a patient. * Handles full heal of a patient.
* *
* Arguments: * Arguments:
* 0: The medic <OBJECT> * 0: The patient <OBJECT>
* 1: The patient <OBJECT>
* *
* Return Value: * Return Value:
* Succesful treatment started <BOOL> * Succesful treatment started <BOOL>
@ -13,7 +12,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_caller", "_target"]; params ["_target"];
if (!alive _target) exitWith {}; if (!alive _target) exitWith {};
@ -21,7 +20,7 @@ _unit setVariable [VAR_PAIN, 0, true];
_unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true]; _unit setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
// tourniquets // tourniquets
_target setVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0], true]; _target setVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES, true];
_target setVariable [QGVAR(occludedMedications), nil, true]; _target setVariable [QGVAR(occludedMedications), nil, true];
// wounds and injuries // wounds and injuries
@ -71,6 +70,3 @@ _target setVariable [QEGVAR(medical,triageCard), [], true];
_target setDamage 0; _target setDamage 0;
[QEGVAR(medical,FullHeal), _target] call CBA_fnc_localEvent; [QEGVAR(medical,FullHeal), _target] call CBA_fnc_localEvent;
[_target, "activity", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[_target, "activity_view", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message

View File

@ -30,7 +30,7 @@ if (!EGVAR(medical,advancedMedication)) exitWith {
}; };
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for", _target); TRACE_1("Running treatmentMedicationLocal with Advanced configuration for", _target);
private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_target);
if (_tourniquets select _partIndex > 0) exitWith { if (_tourniquets select _partIndex > 0) exitWith {
TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets); TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets);

View File

@ -21,7 +21,7 @@ if (count _items == 0) exitWith {false};
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_target);
if (_tourniquets select _partIndex > 0) exitWith { if (_tourniquets select _partIndex > 0) exitWith {
private _output = "There is already a tourniquet on this body part!"; // TODO localization private _output = "There is already a tourniquet on this body part!"; // TODO localization

View File

@ -19,8 +19,8 @@ params ["_target", "_tourniquetItem", "_bodyPart"];
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
// Place a tourniquet on the bodypart // Place a tourniquet on the bodypart
private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_target);
_tourniquets set [_partIndex, CBA_missionTime]; _tourniquets set [_partIndex, CBA_missionTime];
_target setVariable [QEGVAR(medical,tourniquets), _tourniquets, true]; _target setVariable [VAR_TOURNIQUET, _tourniquets, true];

View File

@ -19,7 +19,7 @@ TRACE_3("params",_caller,_target,_bodyPart);
// grab the required data // grab the required data
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_target);
// Check if there is a tourniquet on this bodypart // Check if there is a tourniquet on this bodypart
if (_tourniquets select _partIndex == 0) exitWith { if (_tourniquets select _partIndex == 0) exitWith {
@ -28,7 +28,7 @@ if (_tourniquets select _partIndex == 0) exitWith {
// Removing the tourniquet // Removing the tourniquet
_tourniquets set [_partIndex, 0]; _tourniquets set [_partIndex, 0];
_target setVariable [QEGVAR(medical,tourniquets), _tourniquets, true]; _target setVariable [VAR_TOURNIQUET, _tourniquets, true];
// Adding the tourniquet item to the caller // Adding the tourniquet item to the caller
[_caller, "ACE_tourniquet", true] call CBA_fnc_addItem; [_caller, "ACE_tourniquet", true] call CBA_fnc_addItem;

View File

@ -18,6 +18,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
#define HAS_USED_ITEM(itemUsedInfo) (itemUsedInfo select 0)
#define GET_ITEM_USED_BY(itemUsedInfo) (itemUsedInfo select 1)
params ["_medic", "_patient", "_items"]; params ["_medic", "_patient", "_items"];
private _itemsUsedBy = []; private _itemsUsedBy = [];
@ -28,8 +31,8 @@ private _itemsUsedBy = [];
{ {
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem); private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitWith { if (HAS_USED_ITEM(_itemUsedInfo)) exitWith {
_itemsUsedBy pushBack [_itemUsedInfo select 1, _x]; _itemsUsedBy pushBack [GET_ITEM_USED_BY(_itemUsedInfo), _x];
}; };
} forEach _x; } forEach _x;
}; };
@ -38,8 +41,8 @@ private _itemsUsedBy = [];
if (_x isEqualType "") then { if (_x isEqualType "") then {
private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem); private _itemUsedInfo = [_medic, _patient, _x] call FUNC(useItem);
if (_itemUsedInfo select 0) exitWith { if (HAS_USED_ITEM(_itemUsedInfo)) exitWith {
_itemsUsedBy pushBack [_itemUsedInfo select 1, _x]; _itemsUsedBy pushBack [GET_ITEM_USED_BY(_itemUsedInfo), _x];
}; };
}; };
} forEach _items; } forEach _items;

View File

@ -70,7 +70,7 @@ if !(_inPain isEqualTo IS_IN_PAIN(_unit)) then {
// Handle pain due tourniquets, that have been applied more than 120 s ago // Handle pain due tourniquets, that have been applied more than 120 s ago
private _tourniquetPain = 0; private _tourniquetPain = 0;
private _tourniquets = _unit getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; private _tourniquets = GET_TOURNIQUETS(_unit);
{ {
if (_x > 0 && {CBA_missionTime - _x > 120}) then { if (_x > 0 && {CBA_missionTime - _x > 120}) then {
_tourniquetPain = _tourniquetPain max (CBA_missionTime - _x - 120) * 0.001; _tourniquetPain = _tourniquetPain max (CBA_missionTime - _x - 120) * 0.001;
@ -89,7 +89,7 @@ _bloodPressure params ["_bloodPressureL", "_bloodPressureH"];
private _cardiacOutput = [_unit] call EFUNC(medical_status,getCardiacOutput); private _cardiacOutput = [_unit] call EFUNC(medical_status,getCardiacOutput);
// Most lethal events need to be checked first here // Statements are ordered by most lethal first.
switch (true) do { switch (true) do {
case (_bloodVolume < BLOOD_VOLUME_FATAL): { case (_bloodVolume < BLOOD_VOLUME_FATAL): {
TRACE_3("BloodVolume Fatal",_unit,BLOOD_VOLUME_FATAL,_bloodVolume); TRACE_3("BloodVolume Fatal",_unit,BLOOD_VOLUME_FATAL,_bloodVolume);