2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-06-03 15:31:46 +00:00
|
|
|
/*
|
2019-09-28 20:48:19 +00:00
|
|
|
* Author: BaerMitUmlaut, mharis001
|
2019-06-03 15:31:46 +00:00
|
|
|
* Handles the surgical kit treatment by periodically closing bandaged wounds.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Arguments <ARRAY>
|
|
|
|
* 0: Medic (not used) <OBJECT>
|
|
|
|
* 1: Patient <OBJECT>
|
2023-06-27 22:43:45 +00:00
|
|
|
* 2: Body Part <STRING>
|
2019-06-03 15:31:46 +00:00
|
|
|
* 1: Elapsed Time <NUMBER>
|
|
|
|
* 2: Total Time <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Continue Treatment <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [[objNull, player], 5, 10] call ace_medical_treatment_fnc_surgicalKitProgress
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_args", "_elapsedTime", "_totalTime"];
|
2023-06-27 22:43:45 +00:00
|
|
|
_args params ["_medic", "_patient", "_bodyPart"];
|
2019-06-03 15:31:46 +00:00
|
|
|
|
2023-06-27 22:43:45 +00:00
|
|
|
private _bandagedWounds = GET_BANDAGED_WOUNDS(_patient);
|
|
|
|
private _bandagedWoundsOnPart = _bandagedWounds get _bodyPart;
|
2019-09-28 20:48:19 +00:00
|
|
|
|
|
|
|
// Stop treatment if there are no wounds that can be stitched remaining
|
2023-06-27 22:43:45 +00:00
|
|
|
if (_bandagedWoundsOnPart isEqualTo []) exitWith {false};
|
2019-09-28 20:48:19 +00:00
|
|
|
|
|
|
|
// Not enough time has elapsed to stitch a wound
|
2023-06-27 22:43:45 +00:00
|
|
|
if (_totalTime - _elapsedTime > ([_patient, _patient, _bodyPart] call FUNC(getStitchTime)) - GVAR(woundStitchTime)) exitWith {true};
|
2019-06-03 15:31:46 +00:00
|
|
|
|
2019-09-28 20:48:19 +00:00
|
|
|
// Remove the first stitchable wound from the bandaged wounds
|
2023-06-24 05:11:56 +00:00
|
|
|
private _treatedWound = _bandagedWoundsOnPart deleteAt (count _bandagedWoundsOnPart - 1);
|
|
|
|
_treatedWound params ["_treatedID", "_treatedAmountOf", "", "_treatedDamageOf"];
|
2019-09-28 20:48:19 +00:00
|
|
|
|
|
|
|
// Check if we need to add a new stitched wound or increase the amount of an existing one
|
2023-06-27 22:43:45 +00:00
|
|
|
private _stitchedWounds = GET_STITCHED_WOUNDS(_patient);
|
|
|
|
private _stitchedWoundsOnPart = _stitchedWounds getOrDefault [_bodyPart, [], true];
|
|
|
|
|
|
|
|
private _woundIndex = _stitchedWoundsOnPart findIf {
|
2023-06-24 05:11:56 +00:00
|
|
|
_x params ["_classID"];
|
|
|
|
_classID == _treatedID
|
2019-09-28 20:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_woundIndex == -1) then {
|
2023-06-27 22:43:45 +00:00
|
|
|
_stitchedWoundsOnPart pushBack _treatedWound;
|
2019-09-28 20:48:19 +00:00
|
|
|
} else {
|
2023-06-27 22:43:45 +00:00
|
|
|
private _wound = _stitchedWoundsOnPart select _woundIndex;
|
2023-06-24 05:11:56 +00:00
|
|
|
_wound set [1, (_wound select 1) + _treatedAmountOf];
|
2019-09-28 20:48:19 +00:00
|
|
|
};
|
|
|
|
|
2021-10-12 08:08:10 +00:00
|
|
|
if (GVAR(clearTrauma) == 1) then {
|
2023-06-24 05:11:56 +00:00
|
|
|
private _partIndex = ALL_BODY_PARTS find _bodyPart;
|
|
|
|
TRACE_2("clearTrauma - clearing trauma after stitching",_bodyPart,_treatedWound);
|
2021-10-12 08:08:10 +00:00
|
|
|
private _bodyPartDamage = _patient getVariable [QEGVAR(medical,bodyPartDamage), []];
|
2023-09-23 16:59:10 +00:00
|
|
|
_bodyPartDamage set [_partIndex, (_bodyPartDamage select _partIndex) - (_treatedDamageOf * _treatedAmountOf)];
|
2021-10-12 08:08:10 +00:00
|
|
|
_patient setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true];
|
2023-06-24 05:11:56 +00:00
|
|
|
TRACE_2("clearTrauma - healed damage",_bodyPart,_treatedDamageOf);
|
2021-10-12 08:08:10 +00:00
|
|
|
|
2023-06-24 05:11:56 +00:00
|
|
|
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); };
|
2021-10-12 08:08:10 +00:00
|
|
|
default { [_patient, false, false, false, true] call EFUNC(medical_engine,updateBodyPartVisuals); };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-09-28 20:48:19 +00:00
|
|
|
_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)
|
2023-06-24 05:11:56 +00:00
|
|
|
if (
|
|
|
|
EGVAR(medical,limping) == 2
|
|
|
|
&& {_patient getVariable [QEGVAR(medical,isLimping), false]}
|
2023-06-27 22:43:45 +00:00
|
|
|
&& {_bodyPart in ["leftleg", "rightleg"]}
|
2023-06-24 05:11:56 +00:00
|
|
|
) then {
|
|
|
|
TRACE_3("Updating damage effects",_patient,_bodyPart,local _patient);
|
2019-09-28 20:48:19 +00:00
|
|
|
[QEGVAR(medical_engine,updateDamageEffects), _patient, _patient] call CBA_fnc_targetEvent;
|
2019-06-03 15:31:46 +00:00
|
|
|
};
|
|
|
|
|
2023-03-06 20:17:01 +00:00
|
|
|
// Consume a suture for the next wound if one exists, stop stitching if none are left
|
2023-07-07 05:19:45 +00:00
|
|
|
if (GVAR(consumeSurgicalKit) == 2 && {_bandagedWoundsOnPart isNotEqualTo []}) then {
|
2023-03-06 20:17:01 +00:00
|
|
|
([_medic, _patient, ["ACE_suture"]] call FUNC(useItem)) params ["_user"];
|
|
|
|
!isNull _user
|
|
|
|
} else {
|
|
|
|
true
|
|
|
|
}
|