diff --git a/addons/medical/dev/watchVariable.sqf b/addons/medical/dev/watchVariable.sqf index 7684c1a17d9..7c27acbac8d 100644 --- a/addons/medical/dev/watchVariable.sqf +++ b/addons/medical/dev/watchVariable.sqf @@ -59,7 +59,7 @@ GVAR(dev_watchVariableRunning) = true; _return pushBack format [" - [Pain: %1] [Suppress: %2]", _pain toFixed 3, _painSuppress toFixed 3]; // Damage: - private _damage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; + private _damage = GET_BODYPART_DAMAGE(_unit); private _limping = ["", "[ Limping ]"] select (_unit getVariable [QEGVAR(medical,isLimping), false]); _return pushBack format ["BodyPartDamage: [H: %1] [B: %2]", (_damage select 0) toFixed 2, (_damage select 1) toFixed 2]; _return pushBack format ["[LA:%1] [RA: %2] [LL:%3] [RL: %4]", (_damage select 2) toFixed 2, (_damage select 3) toFixed 2, (_damage select 4) toFixed 2, (_damage select 5) toFixed 2]; diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 2ffe8d77322..7d71888eb08 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -54,14 +54,14 @@ if (!isNull _instigator) then { }; #ifdef DEBUG_TESTRESULTS -private _startDmg = +(_unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]); +private _startDmg = +GET_BODYPART_DAMAGE(_unit); private _startPain = GET_PAIN(_unit); #endif [QEGVAR(medical,woundReceived), [_unit, [[_damageToAdd, _bodyPart, _damageToAdd]], _instigator, _typeOfDamage]] call CBA_fnc_localEvent; #ifdef DEBUG_TESTRESULTS -private _endDmg = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; +private _endDmg = GET_BODYPART_DAMAGE(_unit); private _endPain = GET_PAIN(_unit); private _typeOfDamageAdj = _typeOfDamage call EFUNC(medical_damage,getTypeOfDamage); private _config = configFile >> "ACE_Medical_Injuries" >> "damageTypes" >> _typeOfDamageAdj; diff --git a/addons/medical/functions/fnc_deserializeState.sqf b/addons/medical/functions/fnc_deserializeState.sqf index 6fbb00985db..8416599bec5 100644 --- a/addons/medical/functions/fnc_deserializeState.sqf +++ b/addons/medical/functions/fnc_deserializeState.sqf @@ -97,7 +97,7 @@ private _state = [_json] call CBA_fnc_parseJSON; [QEGVAR(medical,ivBags), nil], [QEGVAR(medical,triageLevel), 0], [QEGVAR(medical,triageCard), []], - [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]] + [VAR_BODYPART_DAMAGE, DEFAULT_BODYPART_DAMAGE_VALUES] // Offset needs to be converted // [VAR_MEDICATIONS, []] ]; diff --git a/addons/medical/functions/fnc_serializeState.sqf b/addons/medical/functions/fnc_serializeState.sqf index 67783e85d94..b12cf781cd3 100644 --- a/addons/medical/functions/fnc_serializeState.sqf +++ b/addons/medical/functions/fnc_serializeState.sqf @@ -44,7 +44,7 @@ private _state = [] call CBA_fnc_createNamespace; [QEGVAR(medical,ivBags), nil], [QEGVAR(medical,triageLevel), 0], [QEGVAR(medical,triageCard), []], - [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]] + [VAR_BODYPART_DAMAGE, DEFAULT_BODYPART_DAMAGE_VALUES] // Time needs to be converted // [VAR_MEDICATIONS, []] ]; diff --git a/addons/medical_damage/functions/fnc_handleIncapacitation.sqf b/addons/medical_damage/functions/fnc_handleIncapacitation.sqf index 391d69c08bf..be9e80db8a0 100644 --- a/addons/medical_damage/functions/fnc_handleIncapacitation.sqf +++ b/addons/medical_damage/functions/fnc_handleIncapacitation.sqf @@ -18,7 +18,7 @@ params ["_unit"]; private _painLevel = GET_PAIN_PERCEIVED(_unit); -private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; +private _bodyPartDamage = GET_BODYPART_DAMAGE(_unit); _bodyPartDamage params ["_headDamage", "_bodyDamage"]; diff --git a/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf b/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf index 270e77b2513..402018353aa 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf @@ -35,7 +35,7 @@ private _createdWounds = false; private _updateDamageEffects = false; private _painLevel = 0; private _criticalDamage = false; -private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; +private _bodyPartDamage = GET_BODYPART_DAMAGE(_unit); private _bodyPartVisParams = [_unit, false, false, false, false]; // params array for EFUNC(medical_engine,updateBodyPartVisuals); // process wounds separately for each body part hit @@ -197,7 +197,7 @@ if (_updateDamageEffects) then { if (_createdWounds) then { _unit setVariable [VAR_OPEN_WOUNDS, _openWounds, true]; - _unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; + _unit setVariable [VAR_BODYPART_DAMAGE, _bodyPartDamage, true]; _bodyPartVisParams call EFUNC(medical_engine,updateBodyPartVisuals); diff --git a/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf b/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf index a4403ffa7d5..219b46d5894 100644 --- a/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf +++ b/addons/medical_engine/functions/fnc_updateBodyPartVisuals.sqf @@ -22,7 +22,7 @@ params ["_unit", "_updateHead", "_updateBody", "_updateArms", "_updateLegs"]; TRACE_5("updateBodyPartVisuals",_unit,_updateHead,_updateBody,_updateArms,_updateLegs); -private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; +private _bodyPartDamage = GET_BODYPART_DAMAGE(_unit); if (_updateHead) then { [_unit, "head", (_bodyPartDamage select 0) > VISUAL_BODY_DAMAGE_THRESHOLD] call FUNC(damageBodyPart); diff --git a/addons/medical_engine/script_macros_medical.hpp b/addons/medical_engine/script_macros_medical.hpp index 167765c5767..20a9a689209 100644 --- a/addons/medical_engine/script_macros_medical.hpp +++ b/addons/medical_engine/script_macros_medical.hpp @@ -134,6 +134,8 @@ #define DEFAULT_FRACTURE_VALUES [0,0,0,0,0,0] +#define DEFAULT_BODYPART_DAMAGE_VALUES [0,0,0,0,0,0] + // Triage colors, for consistency across UIs and functions #define TRIAGE_COLOR_NONE 0, 0, 0, 0.9 #define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9 @@ -168,6 +170,7 @@ #define VAR_OPEN_WOUNDS QEGVAR(medical,openWounds) #define VAR_BANDAGED_WOUNDS QEGVAR(medical,bandagedWounds) #define VAR_STITCHED_WOUNDS QEGVAR(medical,stitchedWounds) +#define VAR_BODYPART_DAMAGE QEGVAR(medical,bodyPartDamage) // These variables track gradual adjustments (from medication, etc.) #define VAR_MEDICATIONS QEGVAR(medical,medications) // These variables track the current state of status values above @@ -197,6 +200,7 @@ #define GET_BANDAGED_WOUNDS(unit) (unit getVariable [VAR_BANDAGED_WOUNDS, createHashMap]) #define GET_STITCHED_WOUNDS(unit) (unit getVariable [VAR_STITCHED_WOUNDS, createHashMap]) #define GET_DAMAGE_THRESHOLD(unit) (unit getVariable [QEGVAR(medical,damageThreshold), [EGVAR(medical,AIDamageThreshold),EGVAR(medical,playerDamageThreshold)] select (isPlayer unit)]) +#define GET_BODYPART_DAMAGE(unit) (unit getVariable [VAR_BODYPART_DAMAGE, DEFAULT_BODYPART_DAMAGE_VALUES]) // The following function calls are defined here just for consistency #define GET_BLOOD_LOSS(unit) ([unit] call EFUNC(medical_status,getBloodLoss)) diff --git a/addons/medical_gui/functions/fnc_updateBodyImage.sqf b/addons/medical_gui/functions/fnc_updateBodyImage.sqf index 25204e4b6ac..e197ef96a4e 100644 --- a/addons/medical_gui/functions/fnc_updateBodyImage.sqf +++ b/addons/medical_gui/functions/fnc_updateBodyImage.sqf @@ -22,7 +22,7 @@ params ["_ctrlGroup", "_target", "_selectionN"]; // Get tourniquets, damage, and blood loss for target private _tourniquets = GET_TOURNIQUETS(_target); private _fractures = GET_FRACTURES(_target); -private _bodyPartDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0, 0, 0, 0, 0, 0]]; +private _bodyPartDamage = GET_BODYPART_DAMAGE(_target); private _damageThreshold = GET_DAMAGE_THRESHOLD(_target); private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0]; diff --git a/addons/medical_gui/functions/fnc_updateInjuryList.sqf b/addons/medical_gui/functions/fnc_updateInjuryList.sqf index c9c9694a445..8cd5ef2fb4a 100644 --- a/addons/medical_gui/functions/fnc_updateInjuryList.sqf +++ b/addons/medical_gui/functions/fnc_updateInjuryList.sqf @@ -163,7 +163,7 @@ _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; + private _bodyPartDamage = GET_BODYPART_DAMAGE(_target) select _selectionN; if (_bodyPartDamage > 0) then { private _damageThreshold = GET_DAMAGE_THRESHOLD(_target); switch (true) do { diff --git a/addons/medical_status/functions/fnc_initUnit.sqf b/addons/medical_status/functions/fnc_initUnit.sqf index 278163d90b9..f1e5c1a4df3 100644 --- a/addons/medical_status/functions/fnc_initUnit.sqf +++ b/addons/medical_status/functions/fnc_initUnit.sqf @@ -70,7 +70,7 @@ if (_isRespawn) then { _unit setVariable [QEGVAR(medical,triageCard), [], true]; // Damage storage - _unit setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true]; + _unit setVariable [VAR_BODYPART_DAMAGE, DEFAULT_BODYPART_DAMAGE_VALUES, true]; // Medication _unit setVariable [VAR_MEDICATIONS, [], true]; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index d7165b59705..b0ebf325e76 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -1,6 +1,7 @@ PREP(addLoadPatientActions); PREP(addToLog); PREP(addToTriageCard); +PREP(addTrauma); PREP(bandage); PREP(bandageLocal); PREP(bodyCleanupLoop); @@ -58,6 +59,7 @@ PREP(scanMedicalItems); PREP(setTriageStatus); PREP(splint); PREP(splintLocal); +PREP(stitchWound); PREP(surgicalKitProgress); PREP(surgicalKitStart); PREP(tourniquet); diff --git a/addons/medical_treatment/functions/fnc_addTrauma.sqf b/addons/medical_treatment/functions/fnc_addTrauma.sqf new file mode 100644 index 00000000000..dab6f1d929c --- /dev/null +++ b/addons/medical_treatment/functions/fnc_addTrauma.sqf @@ -0,0 +1,43 @@ +#include "..\script_component.hpp" +/* + * Author: LinkIsGrim + * Add trauma to a body part. + * + * Arguments: + * 0: Patient + * 1: Body Part + * 2: Amount of trauma to add, negative to remove + * + * Return Value: + * None + * + * Example: + * [player, "head", -5] call ace_medical_treatment_fnc_addTrauma + * + * Public: No + */ + +params ["_unit", "_bodyPart", "_trauma"]; + +private _partIndex = ALL_BODY_PARTS find _bodyPart; +private _bodyPartDamage = GET_BODYPART_DAMAGE(_unit); +private _newDam = (_bodyPartDamage select _partIndex) + _trauma; + +// Prevent obscenely small damage from lack of floating precision +if (_trauma < 0 && _newDam < 0.05) then { + _bodyPartDamage set [_partIndex, 0]; +} else { + _bodyPartDamage set [_partIndex, _newDam]; +}; + +// Update body part visuals +switch (_bodyPart) do { + case "head": { [_unit, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; + case "body": { [_unit, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; + case "leftarm"; + case "rightarm": { [_unit, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; + default { [_unit, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); }; +}; + +TRACE_2("trauma - added damage",_trauma,_newDam); +_unit setVariable [VAR_BODYPART_DAMAGE, _bodyPartDamage, true]; diff --git a/addons/medical_treatment/functions/fnc_bandageLocal.sqf b/addons/medical_treatment/functions/fnc_bandageLocal.sqf index 2c59540fd12..74dce0bc40c 100644 --- a/addons/medical_treatment/functions/fnc_bandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_bandageLocal.sqf @@ -72,27 +72,8 @@ if ( }; if (GVAR(clearTrauma) == 2) then { - TRACE_2("clearTrauma - clearing trauma after bandage",_bodyPart,_openWounds); - private _partIndex = ALL_BODY_PARTS find _bodyPart; - private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; - private _newDam = (_bodyPartDamage select _partIndex) - _treatedDamage; - - // Prevent obscenely small damage from lack of floating precision - if (_newDam < 0.05) then { - _bodyPartDamage set [_partIndex, 0]; - } else { - _bodyPartDamage set [_partIndex, _newDam]; - }; - _patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; - TRACE_2("clearTrauma - healed damage",_partIndex,_treatedDamage); - - switch (_bodyPart) do { - case "head": { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case "body": { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case "leftarm"; - case "rightarm": { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); }; - }; + TRACE_2("trauma - clearing trauma after bandage",_bodyPart,_woundsOnPart); + [_patient, _bodyPart, -_treatedDamage] call FUNC(addTrauma); }; // Reset treatment condition cache for nearby players if we stopped all bleeding diff --git a/addons/medical_treatment/functions/fnc_fullHealLocal.sqf b/addons/medical_treatment/functions/fnc_fullHealLocal.sqf index 3d14380c776..059f33c01f2 100644 --- a/addons/medical_treatment/functions/fnc_fullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_fullHealLocal.sqf @@ -73,7 +73,7 @@ _patient setVariable [VAR_OXYGEN_DEMAND, 0, true]; _patient setVariable [QEGVAR(medical,ivBags), nil, true]; // Damage storage -_patient setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true]; +_patient setVariable [VAR_BODYPART_DAMAGE, DEFAULT_BODYPART_DAMAGE_VALUES, true]; // wakeup needs to be done after achieving stable vitals, but before manually reseting unconc var if IS_UNCONSCIOUS(_patient) then { diff --git a/addons/medical_treatment/functions/fnc_getHealTime.sqf b/addons/medical_treatment/functions/fnc_getHealTime.sqf index 74c2bb26d87..4e173579e21 100644 --- a/addons/medical_treatment/functions/fnc_getHealTime.sqf +++ b/addons/medical_treatment/functions/fnc_getHealTime.sqf @@ -24,6 +24,6 @@ private _bodyPartDamage = 0; { _bodyPartDamage = _bodyPartDamage + _x; -} forEach (_patient getVariable [QEGVAR(medical,bodyPartDamage), []]); +} forEach GET_BODYPART_DAMAGE(_patient); 10 max (((_bodyPartDamage * DAMAGE_SCALING_FACTOR) min 180) * GVAR(timeCoefficientPAK)) diff --git a/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf b/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf index b90198f0eb6..1d6a1228035 100644 --- a/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf +++ b/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf @@ -98,7 +98,7 @@ if (random 1 <= _reopeningChance * GVAR(woundReopenChance)) then { _injury params ["_classID"]; private _selectedInjury = _woundsOnPart select _injuryIndex; - _selectedInjury params ["_selClassID", "_selAmmount"]; + _selectedInjury params ["_selClassID", "_selAmount", "", "_selDamage"]; if (_selClassID == _classID) then { // matching the IDs private _bandagedWounds = GET_BANDAGED_WOUNDS(_target); private _exist = false; @@ -113,7 +113,7 @@ if (random 1 <= _reopeningChance * GVAR(woundReopenChance)) then { if (_exist) then { TRACE_2("Reopening Wound",_bandagedWounds,_openWounds); - _selectedInjury set [1, _selAmmount + _impact]; + _selectedInjury set [1, _selAmount + _impact]; _target setVariable [VAR_BANDAGED_WOUNDS, _bandagedWounds, true]; _target setVariable [VAR_OPEN_WOUNDS, _openWounds, true]; @@ -123,20 +123,7 @@ if (random 1 <= _reopeningChance * GVAR(woundReopenChance)) then { // Re-add trauma and damage visuals if (GVAR(clearTrauma) == 2) then { - private _injuryDamage = (_selectedInjury select 4) * _impact; - private _bodyPartDamage = _target getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; - private _newDam = (_bodyPartDamage select _partIndex) + _injuryDamage; - _bodyPartDamage set [_partIndex, _newDam]; - - _target setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; - - switch (_partIndex) do { - case 0: { [_target, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case 1: { [_target, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case 2; - case 3: { [_target, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - default { [_target, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); }; - }; + [_target, _part, _selDamage * _impact] call FUNC(addTrauma); }; // Check if we gained limping from this wound re-opening diff --git a/addons/medical_treatment/functions/fnc_stitchWound.sqf b/addons/medical_treatment/functions/fnc_stitchWound.sqf new file mode 100644 index 00000000000..c9e7d0aac18 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_stitchWound.sqf @@ -0,0 +1,75 @@ +#include "..\script_component.hpp" +/* + * Author: BaerMitUmlaut, mharis001, LinkIsGrim + * Stitches a wound (either the first or a specific wound) from a body part. + * + * Arguments: + * 0: Patient + * 1: Body Part + * 2: Wound Array, will close first wound on body part if empty (default: []) + * + * Return Value: + * Wound was stitched + * + * Example: + * [player, "head"] call ace_medical_treatment_fnc_stitchWound + * + * Public: No + */ + +params ["_patient", "_bodyPart", ["_treatedWound", []]]; + +private _bandagedWounds = GET_BANDAGED_WOUNDS(_patient); +private _bandagedWoundsOnPart = _bandagedWounds getOrDefault [_bodyPart, []]; + +// Get the first stitchable wound from bandaged wounds, or make sure the passed wound exists +private _bandagedIndex = (count _bandagedWoundsOnPart) - 1; +if (_treatedWound isEqualTo []) then { + _treatedWound = _bandagedWoundsOnPart param [_bandagedIndex, _treatedWound]; +} else { + _bandagedIndex = _bandagedWoundsOnPart find _treatedWound; +}; + +// Wound doesn't exist or there are no bandaged wounds to stitch +if (_bandagedIndex == -1) exitWith {false}; + +// Remove the wound from bandagedWounds +_bandagedWoundsOnPart deleteAt _bandagedIndex; + +_treatedWound params ["_treatedID", "_treatedAmountOf", "", "_treatedDamageOf"]; + +// Check if we need to add a new stitched wound or increase the amount of an existing one +private _stitchedWounds = GET_STITCHED_WOUNDS(_patient); +private _stitchedWoundsOnPart = _stitchedWounds getOrDefault [_bodyPart, [], true]; + +private _stitchedIndex = _stitchedWoundsOnPart findIf { + _x params ["_classID"]; + _classID == _treatedID +}; + +if (_stitchedIndex == -1) then { + _stitchedWoundsOnPart pushBack _treatedWound; +} else { + private _wound = _stitchedWoundsOnPart select _stitchedIndex; + _wound set [1, (_wound select 1) + _treatedAmountOf]; +}; + +if (GVAR(clearTrauma) == 1) then { + TRACE_2("trauma - clearing trauma after stitching",_bodyPart,_treatedWound); + [_patient, _bodyPart, -(_treatedDamageOf * _treatedAmountOf)] call FUNC(addTrauma); +}; + +_patient setVariable [VAR_BANDAGED_WOUNDS, _bandagedWounds, true]; +_patient setVariable [VAR_STITCHED_WOUNDS, _stitchedWounds, true]; + +// Check if we fixed limping by stitching this wound (only for leg wounds) +if ( + EGVAR(medical,limping) == 2 + && {_patient getVariable [QEGVAR(medical,isLimping), false]} + && {_bodyPart in ["leftleg", "rightleg"]} +) then { + TRACE_3("Updating damage effects",_patient,_bodyPart,local _patient); + [QEGVAR(medical_engine,updateDamageEffects), _patient, _patient] call CBA_fnc_targetEvent; +}; + +true // return diff --git a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf index 477c8101f5d..a70a0d57b48 100644 --- a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf +++ b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf @@ -5,7 +5,7 @@ * * Arguments: * 0: Arguments - * 0: Medic (not used) + * 0: Medic * 1: Patient * 2: Body Part * 1: Elapsed Time @@ -32,54 +32,12 @@ if (_bandagedWoundsOnPart isEqualTo []) exitWith {false}; // Not enough time has elapsed to stitch a wound if (_totalTime - _elapsedTime > ([_patient, _patient, _bodyPart] call FUNC(getStitchTime)) - GVAR(woundStitchTime)) exitWith {true}; -// Remove the first stitchable wound from the bandaged wounds -private _treatedWound = _bandagedWoundsOnPart deleteAt (count _bandagedWoundsOnPart - 1); -_treatedWound params ["_treatedID", "_treatedAmountOf", "", "_treatedDamageOf"]; +// Stitch the first possible wound on the body part +private _stitched = [_patient, _bodyPart] call FUNC(stitchWound); -// Check if we need to add a new stitched wound or increase the amount of an existing one -private _stitchedWounds = GET_STITCHED_WOUNDS(_patient); -private _stitchedWoundsOnPart = _stitchedWounds getOrDefault [_bodyPart, [], true]; - -private _woundIndex = _stitchedWoundsOnPart findIf { - _x params ["_classID"]; - _classID == _treatedID -}; - -if (_woundIndex == -1) then { - _stitchedWoundsOnPart pushBack _treatedWound; -} else { - private _wound = _stitchedWoundsOnPart select _woundIndex; - _wound set [1, (_wound select 1) + _treatedAmountOf]; -}; - -if (GVAR(clearTrauma) == 1) then { - private _partIndex = ALL_BODY_PARTS find _bodyPart; - TRACE_2("clearTrauma - clearing trauma after stitching",_bodyPart,_treatedWound); - private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), []]; - _bodyPartDamage set [_partIndex, (_bodyPartDamage select _partIndex) - (_treatedDamageOf * _treatedAmountOf)]; - _patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; - TRACE_2("clearTrauma - healed damage",_bodyPart,_treatedDamageOf); - - switch (_bodyPart) do { - case "head": { [_patient, true, false, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case "body": { [_patient, false, true, false, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - case "leftarm"; - case "rightarm": { [_patient, false, false, true, false] call EFUNC(medical_engine,updateBodyPartVisuals); }; - default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); }; - }; -}; - -_patient setVariable [VAR_BANDAGED_WOUNDS, _bandagedWounds, true]; -_patient setVariable [VAR_STITCHED_WOUNDS, _stitchedWounds, true]; - -// Check if we fixed limping by stitching this wound (only for leg wounds) -if ( - EGVAR(medical,limping) == 2 - && {_patient getVariable [QEGVAR(medical,isLimping), false]} - && {_bodyPart in ["leftleg", "rightleg"]} -) then { - TRACE_3("Updating damage effects",_patient,_bodyPart,local _patient); - [QEGVAR(medical_engine,updateDamageEffects), _patient, _patient] call CBA_fnc_targetEvent; +if (!_stitched) exitWith { + ERROR_1("failed to stitch wound on unit - %1",_patient); + false }; // Consume a suture for the next wound if one exists, stop stitching if none are left