Skip to content

Commit

Permalink
updated to match current ACE handleDamage function
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdatiger committed Oct 13, 2024
1 parent c107e60 commit 6e03d2f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions addons/armor_modifier_ace/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -17,7 +16,6 @@
*
* Public: No
*/

params ["_args", ["_ignoreAllowDamageACE", false]];
_args params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex", "_instigator", "_hitpoint", "_directHit", "_context"];

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

Expand Down

0 comments on commit 6e03d2f

Please sign in to comment.