Medical - Only stitch wounds on not bleeding body parts (#7044)

* Only stitch wounds on not bleeding body parts
This commit is contained in:
mharis001 2019-09-28 16:48:19 -04:00 committed by SilentSpike
parent f6f82d5ab0
commit ec9e6c088b
8 changed files with 77 additions and 28 deletions

View File

@ -91,7 +91,7 @@ GVAR(dev_watchVariableRunning) = true;
// Wounds:
_return pushBack "------- Wounds: -------";
_return pushBack "------- Open Wounds: -------";
private _wounds = GET_OPEN_WOUNDS(_unit);
{
_x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "_xBleeding", "_xDamage"];

View File

@ -94,6 +94,9 @@
#define DEFAULT_BANDAGE_REOPENING_MIN_DELAY 120
#define DEFAULT_BANDAGE_REOPENING_MAX_DELAY 200
// Time it takes to stitch one wound
#define WOUND_STITCH_TIME 5
#define DEFAULT_TOURNIQUET_VALUES [0,0,0,0,0,0]
#define DEFAULT_FRACTURE_VALUES [0,0,0,0,0,0]

View File

@ -17,7 +17,7 @@
params ["_unit"];
(alive _unit
&& {!IS_UNCONSCIOUS(_unit)}
&& {GET_WOUND_BLEEDING(_unit) == 0}
&& {_unit call FUNC(hasStableVitals)})
alive _unit
&& {!IS_UNCONSCIOUS(_unit)}
&& {GET_WOUND_BLEEDING(_unit) == 0}
&& {_unit call FUNC(hasStableVitals)}

View File

@ -29,6 +29,7 @@ PREP(fullHeal);
PREP(fullHealLocal);
PREP(getBandageTime);
PREP(getHealTime);
PREP(getStitchableWounds);
PREP(getStitchTime);
PREP(getTriageStatus);
PREP(handleBandageOpening);

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Katalam
* Author: Katalam, mharis001
* Checks if the patient can be stitched.
*
* Arguments:
@ -18,4 +18,4 @@
params ["", "_patient"];
!(GET_BANDAGED_WOUNDS(_patient) isEqualTo [])
!(_patient call FUNC(getStitchableWounds) isEqualTo [])

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Calculates the Surgical Kit treatment time based on the amount of bandaged wounds.
* Calculates the Surgical Kit treatment time based on the amount of stitchable wounds.
*
* Arguments:
* 0: Medic (not used) <OBJECT>
@ -16,8 +16,6 @@
* Public: No
*/
#define TIME_PER_WOUND 5
params ["", "_patient"];
count GET_BANDAGED_WOUNDS(_patient) * TIME_PER_WOUND
count (_patient call FUNC(getStitchableWounds)) * WOUND_STITCH_TIME

View File

@ -0,0 +1,33 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Returns a list of all the stitchable wounds that the given unit has.
* A stitchable wound is a bandaged wound on a body part that does not have any bleeding wounds.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Stitchable Wounds <ARRAY>
*
* Example:
* [player] call ace_medical_treatment_fnc_getStitchableWounds
*
* Public: No
*/
params ["_unit"];
private _bleedingBodyParts = GET_OPEN_WOUNDS(_unit) select {
_x params ["", "", "_amountOf", "_bleedingRate"];
_amountOf > 0 && {_bleedingRate > 0}
} apply {
_x select 1
};
GET_BANDAGED_WOUNDS(_unit) select {
_x params ["", "_bodyPartN"];
!(_bodyPartN in _bleedingBodyParts)
}

View File

@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Author: BaerMitUmlaut, mharis001
* Handles the surgical kit treatment by periodically closing bandaged wounds.
*
* Arguments:
@ -22,28 +22,42 @@
params ["_args", "_elapsedTime", "_totalTime"];
_args params ["", "_patient"];
private _stitchableWounds = _patient call FUNC(getStitchableWounds);
// Stop treatment if there are no wounds that can be stitched remaining
if (_stitchableWounds isEqualTo []) exitWith {false};
// Not enough time has elapsed to stitch a wound
if (_totalTime - _elapsedTime > (count _stitchableWounds - 1) * WOUND_STITCH_TIME) exitWith {true};
private _bandagedWounds = GET_BANDAGED_WOUNDS(_patient);
private _stitchedWounds = GET_STITCHED_WOUNDS(_patient);
// Stop treatment if there are no wounds that can be stitched remaining
if (_bandagedWounds isEqualTo []) exitWith { false };
// Remove the first stitchable wound from the bandaged wounds
private _treatedWound = _bandagedWounds deleteAt (_bandagedWounds find (_stitchableWounds select 0));
_treatedWound params ["_treatedID", "_treatedBodyPartN", "_treatedAmountOf"];
// Check if enough time has elapsed to stitch another wound
if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then {
private _treatedWound = _bandagedWounds deleteAt 0;
// Check if we need to add a new stitched wound or increase the amount of an existing one
private _woundIndex = _stitchedWounds findIf {
_x params ["_classID", "_bodyPartN"];
_classID == _treatedID && {_bodyPartN == _treatedBodyPartN}
};
if (_woundIndex == -1) then {
_stitchedWounds pushBack _treatedWound;
_patient setVariable [VAR_BANDAGED_WOUNDS, _bandagedWounds, true];
_patient setVariable [VAR_STITCHED_WOUNDS, _stitchedWounds, true];
TRACE_3("stitched",_treatedWound,count _bandagedWounds,count _stitchedWounds);
} else {
private _wound = _stitchedWounds select _woundIndex;
_wound set [2, (_wound select 2) + _treatedAmountOf];
};
// Check if we fixed limping from this treatment
if ((EGVAR(medical,limping) == 2) && {_patient getVariable [QEGVAR(medical,isLimping), false]}) then {
_treatedWound params ["", "_partN"];
if (_partN > 3) then { // only for LEG wounds
TRACE_3("updating damage effects",_patient,_partN,local _patient);
[QEGVAR(medical_engine,updateDamageEffects), [_patient], _patient] call CBA_fnc_patientEvent;
};
};
_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]} && {_treatedBodyPartN > 3}) then {
TRACE_3("Updating damage effects",_patient,_treatedBodyPartN,local _patient);
[QEGVAR(medical_engine,updateDamageEffects), _patient, _patient] call CBA_fnc_targetEvent;
};
true