From a684e874fb9b90f116ad074690e90e1de554dc87 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:16:55 -0300 Subject: [PATCH] Medical Engine - Exit early if incoming damage is 0 (#9733) --- addons/medical_engine/functions/fnc_handleDamage.sqf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/medical_engine/functions/fnc_handleDamage.sqf b/addons/medical_engine/functions/fnc_handleDamage.sqf index 8db9950a86..35d23e46ea 100644 --- a/addons/medical_engine/functions/fnc_handleDamage.sqf +++ b/addons/medical_engine/functions/fnc_handleDamage.sqf @@ -32,6 +32,11 @@ if (_hitPoint isEqualTo "") then { if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) exitWith {_oldDamage}; private _newDamage = _damage - _oldDamage; + +// Happens occasionally for vehiclehit events (see line 80 onwards) +// Just exit early to save some frametime +if (_newDamage == 0) exitWith {_oldDamage}; + // Get scaled armor value of hitpoint and calculate damage before armor // We scale using passThrough to handle explosive-resistant armor properly (#9063) // We need realDamage to determine which limb was hit correctly