From dbf5aedae95caa4c1c0ab8cda356ba8970e434a3 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 29 Sep 2024 02:39:47 +0200 Subject: [PATCH] Vehicle Damage - Improve finding engine selection (#10340) Co-authored-by: PabstMirror --- addons/cookoff/functions/fnc_cookOffLocal.sqf | 2 +- addons/cookoff/functions/fnc_cookOffServer.sqf | 2 +- addons/cookoff/functions/fnc_engineFireLocal.sqf | 6 +++++- .../vehicle_damage/functions/fnc_handleCookoff.sqf | 13 ++++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/addons/cookoff/functions/fnc_cookOffLocal.sqf b/addons/cookoff/functions/fnc_cookOffLocal.sqf index 39f8fe12a11..4c61a4e5a63 100644 --- a/addons/cookoff/functions/fnc_cookOffLocal.sqf +++ b/addons/cookoff/functions/fnc_cookOffLocal.sqf @@ -7,7 +7,7 @@ * 0: Vehicle * 1: Spawn fire jet * 2: Spawn fire ring - * 3: What selection fire will originate from + * 3: What selection fire will originate from * 4: Cookoff intensity value * 5: Start time * 6: Duration of effect (max 20 seconds) diff --git a/addons/cookoff/functions/fnc_cookOffServer.sqf b/addons/cookoff/functions/fnc_cookOffServer.sqf index 3e37eb92827..d1e5347be5e 100644 --- a/addons/cookoff/functions/fnc_cookOffServer.sqf +++ b/addons/cookoff/functions/fnc_cookOffServer.sqf @@ -12,7 +12,7 @@ * 4: Delay between smoke and fire enabled (default: true) * 5: Ammo detonation chance (default: 0) * 6: Detonate after cook-off (default: false) - * 7: Selection for fire source (default: "") + * 7: Selection for fire source (default: "") * 8: Can spawn fire ring (default: true) * 9: Can spawn fire jet (default: true) * 10: Maximum intensity (default: MAX_COOKOFF_INTENSITY) diff --git a/addons/cookoff/functions/fnc_engineFireLocal.sqf b/addons/cookoff/functions/fnc_engineFireLocal.sqf index afd6827d6b1..5960a518ce7 100644 --- a/addons/cookoff/functions/fnc_engineFireLocal.sqf +++ b/addons/cookoff/functions/fnc_engineFireLocal.sqf @@ -27,7 +27,11 @@ if (hasInterface) then { private _hitPoints = getAllHitPointsDamage _vehicle; // Get hitpoint for engine - private _index = (_hitPoints select 0) findIf {_x == "hitengine"}; + private _index = if (_hitPoints isNotEqualTo []) then { + (_hitPoints select 0) findIf {_x == "hitengine"} + } else { + -1 + }; // Get corresponding selection private _position = if (_index != -1) then { diff --git a/addons/vehicle_damage/functions/fnc_handleCookoff.sqf b/addons/vehicle_damage/functions/fnc_handleCookoff.sqf index b4556447909..4b84e9a76e9 100644 --- a/addons/vehicle_damage/functions/fnc_handleCookoff.sqf +++ b/addons/vehicle_damage/functions/fnc_handleCookoff.sqf @@ -58,8 +58,19 @@ private _detonateAfterCookoff = (_fireDetonateChance / 4) > random 1; private _sourceHitpoint = ""; +// Passed to the selectionPosition command in cookoff if (_hitPart == "engine") then { - _sourceHitpoint = ["hit_engine_point", "HitPoints"]; + private _hitPoints = getAllHitPointsDamage _vehicle; + + if (_hitPoints isEqualTo []) exitWith {}; + + // Get hitpoint for engine + private _index = (_hitPoints select 0) findIf {_x == "hitengine"}; + + if (_index == -1) exitWith {}; + + // Get corresponding selection + _sourceHitpoint = [(_hitPoints select 1) select _index, "HitPoints", "AveragePoint"]; }; [QEGVAR(cookOff,cookOffServer), [_vehicle, _intensity, _source, _instigator, _delaySmoke, _fireDetonateChance, _detonateAfterCookoff, _sourceHitpoint, _canRing, _canJet]] call CBA_fnc_serverEvent;