diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 82be8c81af..be64563857 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -30,7 +30,6 @@ PREP(fullHeal); PREP(fullHealLocal); PREP(getBandageTime); PREP(getHealTime); -PREP(getStitchableWounds); PREP(getStitchTime); PREP(getTriageStatus); PREP(handleBandageOpening); diff --git a/addons/medical_treatment/functions/fnc_canStitch.sqf b/addons/medical_treatment/functions/fnc_canStitch.sqf index 08dd3dd70d..efe240f423 100644 --- a/addons/medical_treatment/functions/fnc_canStitch.sqf +++ b/addons/medical_treatment/functions/fnc_canStitch.sqf @@ -1,23 +1,31 @@ #include "script_component.hpp" /* * Author: Katalam, mharis001, Brett Mayson - * Checks if the patient can be stitched. + * Checks if the patient's body part can be stitched. * * Arguments: * 0: Medic * 1: Patient + * 2: Body Part * * ReturnValue: * Can Stitch * * Example: - * [player, cursorTarget] call ace_medical_treatment_fnc_canStitch + * [player, cursorTarget, "head"] call ace_medical_treatment_fnc_canStitch * * Public: No */ -params ["_medic", "_patient"]; +params ["_medic", "_patient", "_bodyPart"]; if ((GVAR(consumeSurgicalKit) == 2) && {!([_medic, _patient, ["ACE_suture"]] call FUNC(hasItem))}) exitWith {false}; -count (_patient call FUNC(getStitchableWounds)) > 0 +private _isBleeding = false; +{ + _x params ["", "_amountOf", "_bleedingRate"]; + _isBleeding = _amountOf > 0 && {_bleedingRate > 0}; + if (_isBleeding) then {break}; +} forEach (GET_OPEN_WOUNDS(_patient) get _bodyPart); + +(!_isBleeding && {(GET_BANDAGED_WOUNDS(_patient) getOrDefault [_bodyPart, []]) isNotEqualTo []}) // return diff --git a/addons/medical_treatment/functions/fnc_getStitchTime.sqf b/addons/medical_treatment/functions/fnc_getStitchTime.sqf index 3d965eed78..1bb6ac6ab5 100644 --- a/addons/medical_treatment/functions/fnc_getStitchTime.sqf +++ b/addons/medical_treatment/functions/fnc_getStitchTime.sqf @@ -6,23 +6,17 @@ * Arguments: * 0: Medic (not used) * 1: Patient + * 2: Body Part * * Return Value: * Treatment Time * * Example: - * [player, cursorObject] call ace_medical_treatment_fnc_getStitchTime + * [player, cursorObject, "head"] call ace_medical_treatment_fnc_getStitchTime * * Public: No */ -params ["", "_patient"]; +params ["", "_patient", "_bodyPart"]; - -private _stitchableTotal = 0; - -{ - _stitchableTotal = _stitchableTotal + count _y; -} forEach (_patient call FUNC(getStitchableWounds)); - -_stitchableTotal * GVAR(woundStitchTime) +count (GET_BANDAGED_WOUNDS(_patient) getOrDefault [_bodyPart, []]) * GVAR(woundStitchTime) diff --git a/addons/medical_treatment/functions/fnc_getStitchableWounds.sqf b/addons/medical_treatment/functions/fnc_getStitchableWounds.sqf deleted file mode 100644 index e06e12ffa1..0000000000 --- a/addons/medical_treatment/functions/fnc_getStitchableWounds.sqf +++ /dev/null @@ -1,42 +0,0 @@ -#include "script_component.hpp" -/* - * Author: kymckay - * Returns a hashmap of the stitchable wounds that the given unit has on each body part. - * A stitchable wound is a bandaged wound on a body part that does not have any bleeding wounds. - * - * Arguments: - * 0: Unit - * - * Return Value: - * Stitchable Wounds - * - * Example: - * [player] call ace_medical_treatment_fnc_getStitchableWounds - * - * Public: No - */ - -params ["_unit"]; - -// First determine which body parts have a bleeding wound -private _bleedingBodyParts = createHashMap; -{ - private _isBleeding = _y findIf { - _x params ["", "_amountOf", "_bleedingRate"]; - _amountOf > 0 && {_bleedingRate > 0} - } != -1; - - if (_isBleeding) then { - _bleedingBodyParts set [_x, true]; - }; -} forEach GET_OPEN_WOUNDS(_unit); - -// Any bandaged wound on a body part not bleeding is stitchable -private _stitchableWounds = createHashMap; -{ - if (!(_x in _bleedingBodyParts) && {_y isNotEqualTo []}) then { - _stitchableWounds set [_x, _y]; - }; -} forEach GET_BANDAGED_WOUNDS(_unit); - -_stitchableWounds diff --git a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf index ee16205099..8fc4832f8f 100644 --- a/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf +++ b/addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf @@ -7,6 +7,7 @@ * 0: Arguments * 0: Medic (not used) * 1: Patient + * 2: Body Part * 1: Elapsed Time * 2: Total Time * @@ -20,35 +21,34 @@ */ params ["_args", "_elapsedTime", "_totalTime"]; -_args params ["_medic", "_patient"]; - -private _stitchableWounds = _patient call FUNC(getStitchableWounds); - -// Stop treatment if there are no wounds that can be stitched remaining -if (_stitchableWounds isEqualTo createHashMap) exitWith {false}; - -// Not enough time has elapsed to stitch a wound -if (_totalTime - _elapsedTime > ([_patient, _patient] call FUNC(getStitchTime)) - GVAR(woundStitchTime)) exitWith {true}; +_args params ["_medic", "_patient", "_bodyPart"]; private _bandagedWounds = GET_BANDAGED_WOUNDS(_patient); -private _stitchedWounds = GET_STITCHED_WOUNDS(_patient); +private _bandagedWoundsOnPart = _bandagedWounds get _bodyPart; + +// Stop treatment if there are no wounds that can be stitched remaining +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 _bodyPart = (keys _stitchableWounds) select 0; -private _bandagedWoundsOnPart = _bandagedWounds get _bodyPart; private _treatedWound = _bandagedWoundsOnPart deleteAt (count _bandagedWoundsOnPart - 1); _treatedWound params ["_treatedID", "_treatedAmountOf", "", "_treatedDamageOf"]; // Check if we need to add a new stitched wound or increase the amount of an existing one -private _woundIndex = (_stitchedWounds getOrDefault [_bodyPart, []]) findIf { +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 { - (_stitchedWounds getOrDefault [_bodyPart, [], true]) pushBack _treatedWound; + _stitchedWoundsOnPart pushBack _treatedWound; } else { - private _wound = (_stitchedWounds get _bodyPart) select _woundIndex; + private _wound = _stitchedWoundsOnPart select _woundIndex; _wound set [1, (_wound select 1) + _treatedAmountOf]; }; @@ -76,7 +76,7 @@ _patient setVariable [VAR_STITCHED_WOUNDS, _stitchedWounds, true]; if ( EGVAR(medical,limping) == 2 && {_patient getVariable [QEGVAR(medical,isLimping), false]} - && {_bodyPart isEqualTo "leftleg" || _bodyPart isEqualTo "rightleg"} + && {_bodyPart in ["leftleg", "rightleg"]} ) then { TRACE_3("Updating damage effects",_patient,_bodyPart,local _patient); [QEGVAR(medical_engine,updateDamageEffects), _patient, _patient] call CBA_fnc_targetEvent; @@ -85,7 +85,7 @@ if ( // Consume a suture for the next wound if one exists, stop stitching if none are left if (GVAR(consumeSurgicalKit) == 2) then { // Don't consume a suture if there are no more wounds to stitch - if (count (values _stitchableWounds) isEqualTo 1) exitWith {false}; + if (_bandagedWoundsOnPart isEqualTo []) exitWith {false}; ([_medic, _patient, ["ACE_suture"]] call FUNC(useItem)) params ["_user"]; !isNull _user } else {