Skip to content

Commit

Permalink
Medical Engine - Optimzie INSTAKILL_ALLOWED macro (acemod#10578)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored Dec 20, 2024
1 parent d28a5bd commit 1bbdff6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .hemtt/lints.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions addons/medical_engine/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand All @@ -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
Expand All @@ -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;
};
Expand Down

0 comments on commit 1bbdff6

Please sign in to comment.