diff --git a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf index 96ee254981..80e1d025a8 100644 --- a/addons/artillerytables/functions/fnc_interactMenuOpened.sqf +++ b/addons/artillerytables/functions/fnc_interactMenuOpened.sqf @@ -65,7 +65,7 @@ TRACE_2("searching for new vehicles",_vehicleAdded,_rangeTablesShown); // Some turrets (MK6) have a neutralX rotation that we need to add to min/max config elevation to get actual limits private _weaponDir = _vehicle weaponDirection _weapon; private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); - private _neutralX = (acos (_turretRot vectorCos _weaponDir)) - (deg _currentElevRad); + private _neutralX = (acos ((_turretRot vectorCos _weaponDir) min 1)) - (deg _currentElevRad); // vectorCos can return values outside of -1..1 _neutralX = (round (_neutralX * 10)) / 10; // minimize floating point errors private _minElev = _neutralX + getNumber (_turretCfg >> "minElev"); private _maxElev = _neutralX + getNumber (_turretCfg >> "maxElev"); diff --git a/addons/artillerytables/functions/fnc_turretPFEH.sqf b/addons/artillerytables/functions/fnc_turretPFEH.sqf index 67f49d5deb..5ebabc85f5 100644 --- a/addons/artillerytables/functions/fnc_turretPFEH.sqf +++ b/addons/artillerytables/functions/fnc_turretPFEH.sqf @@ -70,7 +70,7 @@ if (_useRealWeaponDir) then { if (isNil "_currentTraverseRad") then { _currentTraverseRad = _vehicle animationPhase _turretAnimBody; }; // Get turret roatation around it's z axis, then calc weapon elev in it's projection private _turretRot = [vectorDir _vehicle, vectorUp _vehicle, deg _currentTraverseRad] call FUNC(rotateVector3d); - _realElevation = acos (_turretRot vectorDotProduct _weaponDir) + ((_turretRot call CBA_fnc_vect2polar) select 2); + _realElevation = (acos ((_turretRot vectorCos _weaponDir) min 1)) + ((_turretRot call CBA_fnc_vect2polar) select 2); if (_realElevation > 90) then { _realElevation = 180 - _realElevation; }; // does not flip azimuth! }; };