From 1bbdff6dbd20010fd02d2be491ec64c8e8f667a1 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 20 Dec 2024 07:58:04 -0600 Subject: [PATCH] Medical Engine - Optimzie `INSTAKILL_ALLOWED` macro (#10578) --- .hemtt/lints.toml | 3 +++ addons/medical_engine/functions/fnc_handleDamage.sqf | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.hemtt/lints.toml b/.hemtt/lints.toml index f77ab4358b1..1faf5157242 100644 --- a/.hemtt/lints.toml +++ b/.hemtt/lints.toml @@ -1,3 +1,6 @@ +[config.file_type] +options.allow_no_extension = true + [sqf.banned_commands] options.ignore = [ "addPublicVariableEventHandler", # Alt syntax is broken, we are using main syntax diff --git a/addons/medical_engine/functions/fnc_handleDamage.sqf b/addons/medical_engine/functions/fnc_handleDamage.sqf index 7a037bd979e..a338efcf009 100644 --- a/addons/medical_engine/functions/fnc_handleDamage.sqf +++ b/addons/medical_engine/functions/fnc_handleDamage.sqf @@ -14,7 +14,7 @@ * Public: No */ -#define INSTAKILL_BLOCKED(unit) (unit isEqualTo (unit getVariable [QGVAR(blockInstaKill), objNull])) +#define INSTAKILL_ALLOWED(unit) (unit isNotEqualTo (unit getVariable [QGVAR(blockInstaKill), objNull])) params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex", "_instigator", "_hitpoint", "_directHit", "_context"]; @@ -40,7 +40,7 @@ if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), t // TODO: Structural fire damage >= 1 in a single damage event could still be caught here and we don't want that, but we haven't found a better way to catch this, fire damage should be small most of the time anyway // Also triggers for catastrophic vehicle explosions which would kill crew outright, check for blocking private _newDamage = _damage - _oldDamage; -if (_structuralDamage && {(abs (_newDamage - 1)) < 0.001 && _ammo == "" && isNull _shooter && isNull _instigator} && {!INSTAKILL_BLOCKED(_unit)}) exitWith { +if (_structuralDamage && {(abs (_newDamage - 1)) < 0.001 && _ammo == "" && isNull _shooter && isNull _instigator} && {INSTAKILL_ALLOWED(_unit)}) exitWith { TRACE_1("unit killed by curator or engine",_unit); _damage @@ -52,7 +52,7 @@ if (_structuralDamage && {(abs (_newDamage - 1)) < 0.001 && _ammo == "" && isNul if (_context != 2 && {_context == 4 || _newDamage == 0}) exitWith { TRACE_4("Skipping engine bleeding or zero damage, blocking insta kills until next frame",_ammo,_newDamage,_directHit,_context); - if (!INSTAKILL_BLOCKED(_unit)) then { + if (INSTAKILL_ALLOWED(_unit)) then { _unit setVariable [QGVAR(blockInstaKill), _unit]; [{_this setVariable [QGVAR(blockInstaKill), nil]}, _unit] call CBA_fnc_execNextFrame; };