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

[Improve] Fix PAK Stitch Exploit Pending ACE PR Merge #128

Merged
merged 9 commits into from
Oct 16, 2022
10 changes: 10 additions & 0 deletions components/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class ace_medical_feedback
};
};


class ace_medical_status
{
class overrides
{
file = "components\medical";
class isInStableCondition{};
}
};

class ace_gunbag
{
class overrides
Expand Down
39 changes: 39 additions & 0 deletions components/medical/fn_isInStableCondition.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


params ["_unit"];

// Hard-coding variables that would otherwise be in CBA and/or I can't seem to retrieve (defaultBloodVolume. These should be safe to hard-code.
private _minHeartRatePAK = 40;
private _minBloodPAK = 0.85;
private _defaultBloodVolume = 6;


// If the unit is dead, unconscious, bleeding, or below minimum heart rate, we cannot PAK.
if (!alive _unit
|| {(_unit getVariable ["ACE_isUnconscious", false])}
|| {(_unit getVariable ["ace_medical_woundBleeding", 0]) > 0}
|| {(_unit getVariable ["ace_medical_heartRate", 0]) < _minHeartRatePAK}
) exitWith {false};

// If they have insufficient blood, we cannot PAK.
private _requiredBloodVolume = _defaultBloodVolume * (_minBloodPAK / 100);
if ((_unit getVariable ["ace_medical_bloodVolume", 0]) < _requiredBloodVolume) exitWith {false};

// Unit must not have fractures
private _fractures = _unit getVariable ["ace_medical_fractures", []];
if ((_fractures findIf {_x isEqualTo 1}) != -1) exitWith {false};
Bubbus marked this conversation as resolved.
Show resolved Hide resolved

// Unit must not be in pain
if (_unit getVariable ["ace_medical_inPain", false]) exitWith {false};


// If there are any bandaged wounds, they have not been stitched.
private _hasUnstitchedWounds = (_unit getVariable ["ace_medical_bandagedWounds", []]) isNotEqualTo [];

// If there are any bandageable wounds that are open, there are open wounds. _x select 3 > 0 Discards any non-bleeding wounds, such as bruises.
private _hasOpenWounds = (_unit getVariable ["ace_medical_openWounds", []] findIf {(_x select 2 > 0) and (_x select 3 > 0)} ) != -1;

if (_hasOpenWounds or _hasUnstitchedWounds) exitWith {false};


true