From e817e13cfd24e79108369778209b1c8c3699ea99 Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 14 Dec 2016 21:02:24 +0100 Subject: [PATCH] Only call 'handleIncapacitation' when it makes sense * Minor injuries should not trigger incapacitation --- addons/medical_damage/functions/fnc_woundsHandler.sqf | 6 ++++++ addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 07952a713f..340aa54499 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -40,6 +40,7 @@ call compile _extensionOutput; // todo: Make the pain and bleeding calculations part of the extension again private _painLevel = 0; +private _critialDamage = false; private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; { _x params ["", "_woundClassIDToAdd", "_bodyPartNToAdd", "", "_bleeding"]; @@ -63,6 +64,9 @@ private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0, private _pain = ((GVAR(woundsData) select _woundClassIDToAdd) select 3) * _painfullness; _painLevel = _painLevel max _pain; + if (_bodyPartNToAdd == 0 || {_bodyPartNToAdd == 1 && {_damage > PENETRATION_THRESHOLD}}) then { + _critialDamage = true; + }; #ifdef DEBUG_MODE_FULL systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; #endif @@ -107,6 +111,8 @@ _unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; // Only update if new wounds have been created if (count _woundsCreated > 0) then { _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; +}; +if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { [_unit] call EFUNC(medical,handleIncapacitation); }; diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 97959f017d..da9dfc37bd 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -73,6 +73,7 @@ private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []]; private _woundID = _unit getVariable [QGVAR(lastUniqueWoundID), 1]; private _painLevel = 0; +private _critialDamage = false; private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; private _woundsCreated = []; { @@ -111,6 +112,9 @@ private _woundsCreated = []; private _pain = _injuryPain * _painfullness; _painLevel = _painLevel max _pain; + if (_bodyPartNToAdd == 0 || {_bodyPartNToAdd == 1 && {_damage > PENETRATION_THRESHOLD}}) then { + _critialDamage = true; + }; #ifdef DEBUG_MODE_FULL systemChat format["%1, damage: %2, peneration: %3, bleeding: %4, pain: %5", _bodyPart, round(_damage * 100) / 100, _damage > PENETRATION_THRESHOLD, round(_bleeding * 1000) / 1000, round(_pain * 1000) / 1000]; #endif @@ -163,6 +167,8 @@ _unit setVariable [QEGVAR(medical,bodyPartDamage), _bodyPartDamage, true]; // Only update if new wounds have been created if (count _woundsCreated > 0) then { _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; +}; +if (_critialDamage || {_painLevel > PAIN_UNCONSCIOUS}) then { [_unit] call EFUNC(medical,handleIncapacitation); };