From efbff8cc231db1d30bc2aeaf3fca2e8ac8dbdeaf Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Sat, 6 Feb 2016 16:49:53 -0300 Subject: [PATCH] Pass the turret path too --- addons/common/functions/fnc_firedEH.sqf | 18 +++++++++++++++++- addons/fcs/functions/fnc_firedEH.sqf | 2 -- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/common/functions/fnc_firedEH.sqf b/addons/common/functions/fnc_firedEH.sqf index 5e6e5bb833..ce16b6dc2c 100644 --- a/addons/common/functions/fnc_firedEH.sqf +++ b/addons/common/functions/fnc_firedEH.sqf @@ -36,7 +36,23 @@ if (_unit isKindOf "CAManBase") then { }; } else { // The unit is a vehicle - private _gunner = [_unit, _weapon] call EFUNC(common,getGunner); + + // Get the gunner and turret path. + // Code based on FUNC(getGunner), extracted for efficency. + private _gunner = objNull; + private _turret = []; + { + if (_weapon in (_unit weaponsTurret _x)) exitWith { + _gunner = _unit turretUnit _x; + _turret = _x; + }; + false + } count allTurrets [_unit, true]; + // Ensure that at least the pilot is returned if there is no gunner + if (isManualFire _unit && {isNull _gunner}) then { + _gunner = driver _unit; + }; + if (_gunner == ACE_player) then { ["firedPlayerVehicle", this] call FUNC(localEvent); } else { diff --git a/addons/fcs/functions/fnc_firedEH.sqf b/addons/fcs/functions/fnc_firedEH.sqf index 4c101b9292..29149eb19b 100644 --- a/addons/fcs/functions/fnc_firedEH.sqf +++ b/addons/fcs/functions/fnc_firedEH.sqf @@ -12,8 +12,6 @@ */ #include "script_component.hpp" -private _turret = _gunner call EFUNC(common,getTurretIndex); - private _FCSMagazines = _vehicle getVariable [format ["%1_%2", QGVAR(Magazines), _turret], []]; private _FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret];