diff --git a/addons/fcs/functions/fnc_keyDown.sqf b/addons/fcs/functions/fnc_keyDown.sqf index 5e2fabccc9..24e4a7611d 100644 --- a/addons/fcs/functions/fnc_keyDown.sqf +++ b/addons/fcs/functions/fnc_keyDown.sqf @@ -19,7 +19,8 @@ _turret = _this select 1; _distance = call FUNC(getRange); -if !(!GVAR(enabled) && [] call FUNC(canUseFCS)) exitWith {}; +if (GVAR(Enabled)) exitWith {}; +if !([] call FUNC(canUseFCS)) exitWith {}; GVAR(Enabled) = true; GVAR(Time) = time; diff --git a/addons/fcs/functions/fnc_keyUp.sqf b/addons/fcs/functions/fnc_keyUp.sqf index 1e5878f0b5..b893262e88 100644 --- a/addons/fcs/functions/fnc_keyUp.sqf +++ b/addons/fcs/functions/fnc_keyUp.sqf @@ -19,18 +19,22 @@ _turret = _this select 1; _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); -_distance = call FUNC(getRange); +_distance = 0; +if (count _this > 2) then { + _distance = _this select 2; +} else { + _distance = call FUNC(getRange); + if (_distance == 0) then { + _distance = [ + getNumber (_turretConfig >> QGVAR(DistanceInterval)), + getNumber (_turretConfig >> QGVAR(MaxDistance)), + getNumber (_turretConfig >> QGVAR(MinDistance)) + ] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision + }; +}; _magazines = _vehicle magazinesTurret _turret; -if (_distance == 0) then { - _distance = [ - getNumber (_turretConfig >> QGVAR(DistanceInterval)), - getNumber (_turretConfig >> QGVAR(MaxDistance)), - getNumber (_turretConfig >> QGVAR(MinDistance)) - ] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision -}; - private ["_weaponDirection", "_angleTarget"]; _weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets @@ -45,10 +49,6 @@ if (_weaponDirection isEqualTo [0,0,0]) then { // dummy value for non main turr _angleTarget = asin (_weaponDirection select 2); -if (count _this > 2) then { - _distance = _this select 2; -}; - if (!(isNil QGVAR(backgroundCalculation)) and {!(scriptDone GVAR(backgroundCalculation))}) then { terminate GVAR(backgroundCalculation); };