From 816d5343045100fc06dbd6681373c068d1a29720 Mon Sep 17 00:00:00 2001 From: James Woods Date: Sun, 20 Feb 2022 14:07:35 +0000 Subject: [PATCH 1/2] Add vehicle explosion handling --- .../functions/fnc_handleDamage.sqf | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/addons/medical_engine/functions/fnc_handleDamage.sqf b/addons/medical_engine/functions/fnc_handleDamage.sqf index 1b3bb238a11..afc12585059 100644 --- a/addons/medical_engine/functions/fnc_handleDamage.sqf +++ b/addons/medical_engine/functions/fnc_handleDamage.sqf @@ -67,6 +67,34 @@ if ( 0 }; +// Being inside an exploding vehicle doesn't trigger for each hitpoint +// It seems to fire twice with ammo type "FuelExplosion" or "FuelExplosionBig" +if ( + _hitPoint isEqualTo "#structural" && + {_ammo isKindOf "FuelExplosion"} && + {_vehicle != _unit} && + {_damage == 1} +) exitwith { + // triggers twice, so do half damage each time. not very important as it's basically always lethal + private _hit = GET_NUMBER(configFile >> "CfgAmmo" >> _ammo >> "indirectHit", 10)/2; + private _uniform = uniform _unit; + if (_uniform isEqualTo "") then { + _uniform = getText (configOf _unit >> "nakedUniform"); + }; + private _uniformClass = GET_STRING(configFile >> "CfgWeapons" >> _uniform >> "ItemInfo" >> "uniformClass", "U_BasicBody"); + private _damages = []; + { + private _armor = [_unit, _x] call FUNC(getHitpointArmor); + // would be nice to move this into getHitpointArmor + private _shielding = GET_NUMBER(configFile >> "CfgVehicles" >> _uniformClass >> "Hitpoints" >> _x >> "explosionShielding", 1); + _damages pushBack [_hit*_shielding/_armor, ALL_BODY_PARTS select _forEachIndex, _hit*_shielding] + } forEach ALL_HITPOINTS; + TRACE_6("Vehicle explosion",_unit,_shooter,_instigator,_damage,_newDamage,_damages); + [QEGVAR(medical,woundReceived), [_unit, _damages, _unit, _ammo]] call CBA_fnc_localEvent; + + 0 +}; + // This hitpoint is set to trigger last, evaluate all the stored damage values // to determine where wounds are applied if (_hitPoint isEqualTo "ace_hdbracket") exitWith { From 93bb7cd0dacb28d4e00a0e197a4a91c6cee2f122 Mon Sep 17 00:00:00 2001 From: James Woods Date: Fri, 10 Jun 2022 14:31:15 +0100 Subject: [PATCH 2/2] Missing semicolon --- addons/medical_engine/functions/fnc_handleDamage.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical_engine/functions/fnc_handleDamage.sqf b/addons/medical_engine/functions/fnc_handleDamage.sqf index afc12585059..68798d38dad 100644 --- a/addons/medical_engine/functions/fnc_handleDamage.sqf +++ b/addons/medical_engine/functions/fnc_handleDamage.sqf @@ -87,7 +87,7 @@ if ( private _armor = [_unit, _x] call FUNC(getHitpointArmor); // would be nice to move this into getHitpointArmor private _shielding = GET_NUMBER(configFile >> "CfgVehicles" >> _uniformClass >> "Hitpoints" >> _x >> "explosionShielding", 1); - _damages pushBack [_hit*_shielding/_armor, ALL_BODY_PARTS select _forEachIndex, _hit*_shielding] + _damages pushBack [_hit*_shielding/_armor, ALL_BODY_PARTS select _forEachIndex, _hit*_shielding]; } forEach ALL_HITPOINTS; TRACE_6("Vehicle explosion",_unit,_shooter,_instigator,_damage,_newDamage,_damages); [QEGVAR(medical,woundReceived), [_unit, _damages, _unit, _ammo]] call CBA_fnc_localEvent;