From 0d3e103de199989549d18a4598982a766b6de33b Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 11 Feb 2015 20:59:41 +0100 Subject: [PATCH] fcs work around for weaponDirection with commander turrets --- addons/fcs/functions/fnc_keyDown.sqf | 10 +++++++++- addons/fcs/functions/fnc_keyUp.sqf | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/addons/fcs/functions/fnc_keyDown.sqf b/addons/fcs/functions/fnc_keyDown.sqf index 4cfcf7c57a..5a3febf6ea 100644 --- a/addons/fcs/functions/fnc_keyDown.sqf +++ b/addons/fcs/functions/fnc_keyDown.sqf @@ -28,7 +28,15 @@ if (_distance == 0) then { _distance = [5, 5000, 0] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision }; -_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); +_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets + +if (_turret isEqualTo ([typeOf _vehicle] call EFUNC(common,getTurretCommander))) then { + _weaponDirection = eyeDirection _vehicle; +}; + +if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turrets + _weaponDirection = [1,0,0]; +}; GVAR(Position) = [ (getPos _vehicle select 0) + _distance * (_weaponDirection select 0), diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index 78a622331f..96e85714fd 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -21,7 +21,7 @@ _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call E _distance = call FUNC(getRange); -_magazines = magazines _vehicle; +_magazines = _vehicle magazinesTurret _turret; if (_distance == 0) then { _distance = [ @@ -33,7 +33,16 @@ if (_distance == 0) then { private ["_weaponDirection", "_angleTarget"]; -_weaponDirection = _vehicle weaponDirection currentWeapon _vehicle; +_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets + +if (_turret isEqualTo ([typeOf _vehicle] call EFUNC(common,getTurretCommander))) then { + _weaponDirection = eyeDirection _vehicle; +}; + +if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turrets + _weaponDirection = [1,0,0]; +}; + _angleTarget = asin (_weaponDirection select 2); if (count _this > 2) then {