Skip to content

Commit

Permalink
Medical & Vehicle Damage - Only detect end key if dmg is exactly 1 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored Oct 13, 2024
1 parent a177034 commit d2b60a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions addons/medical_engine/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), t
// Killing units via End key is an edge case (#10375)
// This didn't matter pre-Arma 3 2.18 but now this goes through the event handler
// 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
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
Expand Down
10 changes: 5 additions & 5 deletions addons/vehicle_damage/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ TRACE_9("handleDamage",_vehicle,_selection,_newDamage,_source,_projectile,_hitIn

if (!local _vehicle) exitWith {};

// Killing units via End key is an edge case (#10375)
// This didn't matter pre-Arma 3 2.18 but now this goes through the event handler
// 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
if (_context == 0 && {_newDamage >= 1 && _projectile == "" && isNull _source && isNull _instigator}) exitWith {_newDamage};

private _currentDamage = if (_selection != "") then {
_vehicle getHitIndex _hitIndex
} else {
damage _vehicle
};

// Killing units via End key is an edge case (#10375)
// This didn't matter pre-Arma 3 2.18 but now this goes through the event handler
// 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
if (_context == 0 && {(abs (_newDamage - _currentDamage - 1)) < 0.001 && _projectile == "" && isNull _source && isNull _instigator}) exitWith {_newDamage};

if !(_projectile in ["ace_ammoExplosion", "ACE_ammoExplosionLarge"]) then {
// If an invalid hit, don't process it
if (_newDamage <= 0 || {"#light" in _hitPoint}) exitWith {};
Expand Down

0 comments on commit d2b60a5

Please sign in to comment.