From 6e03d2f3b0f2604670955ee7b359ff02f925dfb1 Mon Sep 17 00:00:00 2001 From: lambdatiger Date: Sat, 12 Oct 2024 22:25:51 -0500 Subject: [PATCH 1/2] updated to match current ACE handleDamage function --- .../functions/fnc_handleDamage.sqf | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf b/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf index 980f65784..788f94a8c 100644 --- a/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf +++ b/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf @@ -1,7 +1,6 @@ #include "..\script_component.hpp" - /* - * Author: commy2, kymckay, modified by johnb43 & Lambda.Tiger + * Author: commy2, kymckay, LinkIsGrim modified by johnb43 & Lambda.Tiger * Original: * HandleDamage EH where wound events are raised based on incoming damage. * Be aware that for each source of damage, the EH can fire multiple times (once for each hitpoint). @@ -17,7 +16,6 @@ * * Public: No */ - params ["_args", ["_ignoreAllowDamageACE", false]]; _args params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex", "_instigator", "_hitpoint", "_directHit", "_context"]; @@ -28,7 +26,7 @@ if !(local _unit) exitWith {nil}; private _oldDamage = 0; private _structuralDamage = _context == 0; -if (_hitPoint isEqualTo "") then { +if (_structuralDamage) then { _hitPoint = "#structural"; _oldDamage = damage _unit; } else { @@ -38,6 +36,9 @@ if (_hitPoint isEqualTo "") then { // Damage can be disabled with old variable or via sqf command allowDamage if !(isDamageAllowed _unit && {_unit getVariable ["ace_medical_allowDamage", true] || _ignoreAllowDamageACE}) exitWith {_oldDamage}; +// Killing units via End key is an edge case (#10375) +if (_structuralDamage && {_damage == 1 && _ammo == "" && isNull _shooter && isNull _instigator}) exitWith {_damage}; + private _newDamage = _damage - _oldDamage; // _newDamage == 0 happens occasionally for vehiclehit events (see line 80 onwards), just exit early to save some frametime @@ -206,7 +207,11 @@ if (_context == 2) then { if (_environmentDamage) then { // Any collision with terrain/vehicle/object has a shooter // Check this first because burning can happen at any velocity - if !(isNull _shooter) then { + if (isNull _shooter) then { + // Anything else is almost guaranteed to be fire damage + _ammo = "fire"; + TRACE_5("Fire Damage",_unit,_shooter,_instigator,_damage,_allDamages); + } else { /* If shooter != unit then they hit unit, otherwise it could be: - Unit hitting anything at speed @@ -221,10 +226,6 @@ if (_context == 2) then { _ammo = "collision"; TRACE_5("Collision",_unit,_shooter,_instigator,_damage,_allDamages); }; - } else { - // Anything else is almost guaranteed to be fire damage - _ammo = "fire"; - TRACE_5("Fire Damage",_unit,_shooter,_instigator,_damage,_allDamages); }; }; From 80d3ce97fac35b26fd08d2e0ffbc57045f50f44f Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 14 Oct 2024 23:57:27 -0500 Subject: [PATCH 2/2] update to ace pr10416 (new dmg exactly 1) --- addons/armor_modifier_ace/functions/fnc_handleDamage.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf b/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf index 788f94a8c..9b70c0d0e 100644 --- a/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf +++ b/addons/armor_modifier_ace/functions/fnc_handleDamage.sqf @@ -37,9 +37,9 @@ if (_structuralDamage) then { if !(isDamageAllowed _unit && {_unit getVariable ["ace_medical_allowDamage", true] || _ignoreAllowDamageACE}) exitWith {_oldDamage}; // Killing units via End key is an edge case (#10375) -if (_structuralDamage && {_damage == 1 && _ammo == "" && isNull _shooter && isNull _instigator}) exitWith {_damage}; - private _newDamage = _damage - _oldDamage; +if (_structuralDamage && {(abs (_newDamage - 1)) < 0.001 && _ammo == "" && isNull _shooter && isNull _instigator}) exitWith {_damage}; + // _newDamage == 0 happens occasionally for vehiclehit events (see line 80 onwards), just exit early to save some frametime // context 4 is engine "bleeding". For us, it's just a duplicate event for #structural which we can ignore without any issues