Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/medical/dev/watchVariable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
3 changes: 3 additions & 0 deletions addons/medical_engine/script_macros_medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions addons/medical_status/functions/fnc_isInStableCondition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
1 change: 1 addition & 0 deletions addons/medical_treatment/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PREP(fullHeal);
PREP(fullHealLocal);
PREP(getBandageTime);
PREP(getHealTime);
PREP(getStitchableWounds);
PREP(getStitchTime);
PREP(getTriageStatus);
PREP(handleBandageOpening);
Expand Down
4 changes: 2 additions & 2 deletions addons/medical_treatment/functions/fnc_canStitch.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: Katalam
* Author: Katalam, mharis001
* Checks if the patient can be stitched.
*
* Arguments:
Expand All @@ -18,4 +18,4 @@

params ["", "_patient"];

!(GET_BANDAGED_WOUNDS(_patient) isEqualTo [])
!(_patient call FUNC(getStitchableWounds) isEqualTo [])
6 changes: 2 additions & 4 deletions addons/medical_treatment/functions/fnc_getStitchTime.sqf
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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
33 changes: 33 additions & 0 deletions addons/medical_treatment/functions/fnc_getStitchableWounds.sqf
Original file line number Diff line number Diff line change
@@ -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)
}
50 changes: 32 additions & 18 deletions addons/medical_treatment/functions/fnc_surgicalKitProgress.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Author: BaerMitUmlaut, mharis001
* Handles the surgical kit treatment by periodically closing bandaged wounds.
*
* Arguments:
Expand All @@ -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 we need to add a new stitched wound or increase the amount of an existing one
private _woundIndex = _stitchedWounds findIf {
_x params ["_classID", "_bodyPartN"];

// Check if enough time has elapsed to stitch another wound
if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then {
private _treatedWound = _bandagedWounds deleteAt 0;
_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);

// 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;
};
};
} else {
private _wound = _stitchedWounds select _woundIndex;
_wound set [2, (_wound select 2) + _treatedAmountOf];
};

_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