From fc99d07f7c27fea36185dd9ccb30d2b0e53e10b4 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 16 May 2015 12:11:45 +0200 Subject: [PATCH] fixes #1155 --- addons/medical/functions/fnc_handleDamage.sqf | 53 +++++++------------ 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/addons/medical/functions/fnc_handleDamage.sqf b/addons/medical/functions/fnc_handleDamage.sqf index 1d8c821d1f6..73849dabb2d 100644 --- a/addons/medical/functions/fnc_handleDamage.sqf +++ b/addons/medical/functions/fnc_handleDamage.sqf @@ -41,22 +41,6 @@ if (_selection in GVAR(SELECTIONS)) then { }; if !(_unit getVariable [QGVAR(allowDamage), true]) exitWith {_damageOld}; -// Figure out whether to prevent death before handling damage -if (diag_frameno > (_unit getVariable [QGVAR(frameNo), -3]) + 2) then { - _unit setVariable [QGVAR(frameNo), diag_frameno]; - _unit setVariable [QGVAR(wasUnconscious), _unit getVariable ["ACE_isUnconscious", false]]; - - _preventDeath = _unit getVariable [QGVAR(preventInstaDeath), GVAR(preventInstaDeath)]; - if (_unit getVariable ["ACE_isUnconscious", false]) then { - _preventDeath = _unit getVariable [QGVAR(enableRevive), GVAR(enableRevive)]; - if !([_unit] call EFUNC(common,isPlayer)) then { - _preventDeath = _preventDeath - 1; - }; - _preventDeath = _preventDeath > 0; - }; - _unit setVariable [QGVAR(preventDeath), _preventDeath]; -}; - // Get return damage _damageReturn = _damage; if (GVAR(level) < 2) then { @@ -97,30 +81,33 @@ if (GVAR(level) < 2) then { }; [_unit] call FUNC(addToInjuredCollection); -// Prevent death if necessary -if (_unit getVariable QGVAR(preventDeath)) then { - if (_selection in ["", "head", "body"]) then { - _damageReturn = _damageReturn min 0.89; - }; - // Move the unit out of the vehicle if necessary - if (vehicle _unit != _unit and damage (vehicle _unit) == 1) then { +if (_unit getVariable [QGVAR(preventInstaDeath), GVAR(preventInstaDeath)]) exitWith { + if (vehicle _unit != _unit and {damage (vehicle _unit) >= 1}) then { [_unit] call EFUNC(common,unloadPerson); - if (_unit getVariable QGVAR(wasUnconscious)) then { + }; + + if (_damageReturn >= 0.9 && {_selection in ["", "head", "body"]}) exitWith { + systemChat format["Lethal damage %1 ", _unit]; + if (_unit getvariable ["ACE_isUnconscious", false]) exitwith { [_unit] call FUNC(setDead); - } else { - [_unit, true] call FUNC(setUnconscious); + 0.89 }; + [{ + [_this select 0, true] call FUNC(setUnconscious); + }, [_unit]] call EFUNC(common,execNextFrame); + 0.89 }; + _damageReturn min 0.89; +}; - // Temporarily disable all damage to prevent stuff like - // being killed during the animation etc. - if (!_wasUnconscious and (_unit getVariable ["ACE_isUnconscious", false])) then { - _unit setVariable [QGVAR(allowDamage), false]; - [{ - _this setVariable [QGVAR(allowDamage), true]; - }, _unit, 0.7, 0] call EFUNC(common,waitAndExecute); +if (((_unit getVariable [QGVAR(enableRevive), GVAR(enableRevive)]) > 0) && {_damageReturn >= 0.9} && {_selection in ["", "head", "body"]}) exitWith { + if (vehicle _unit != _unit and {damage (vehicle _unit) >= 1}) then { + [_unit] call EFUNC(common,unloadPerson); }; + [_unit] call FUNC(setDead); + + 0.89 }; _damageReturn