diff --git a/addons/scopes/functions/fnc_getCurrentZeroRange.sqf b/addons/scopes/functions/fnc_getCurrentZeroRange.sqf index d1bc3b7790d..a62e3d7a022 100644 --- a/addons/scopes/functions/fnc_getCurrentZeroRange.sqf +++ b/addons/scopes/functions/fnc_getCurrentZeroRange.sqf @@ -19,23 +19,40 @@ params ["_unit"]; if (!GVAR(enabled)) exitWith {currentZeroing _unit}; -private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); +private _currentWeapon = currentWeapon _unit; +private _weaponIndex = [_unit, _currentWeapon] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith { currentZeroing _unit }; + if (GVAR(simplifiedZeroing)) exitWith { if !(GVAR(canAdjustElevation) select _weaponIndex) exitWith {currentZeroing _unit}; private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]]; ((_adjustment select _weaponIndex) select 0) }; -private _optic = GVAR(Optics) select _weaponIndex; +private _local = _unit == ACE_Player; + +private _optic = if (_local) then { + GVAR(Optics) select _weaponIndex +} else { + ([_unit] call FUNC(getOptics)) select _weaponIndex +}; private _opticConfig = if (_optic != "") then { (configFile >> "CfgWeapons" >> _optic) } else { - (configFile >> "CfgWeapons" >> (GVAR(Guns) select _weaponIndex)) + if (_local) then { + (configFile >> "CfgWeapons" >> (GVAR(Guns) select _weaponIndex)) + } else { + (configFile >> "CfgWeapons" >> _currentWeapon) + }; }; private _zeroRange = currentZeroing _unit; -if (GVAR(overwriteZeroRange) && {GVAR(canAdjustElevation) select _weaponIndex}) then { +// Revert zeroing to default if overriding is enabled OR the selected sight's magnification is not higher than that of the naked eye, meaning that it is a secondary iron/holo sight +if ( + _local && + (GVAR(canAdjustElevation) select _weaponIndex) && + {GVAR(overwriteZeroRange) || {getNumber (_opticConfig >> "ItemInfo" >> "OpticsModes" >> (_unit getOpticsMode _weaponIndex) >> "opticsZoomMax") > MIN_ZOOM_NAKEDEYE}} +) then { _zeroRange = GVAR(defaultZeroRange); }; if (isNumber (_opticConfig >> "ACE_ScopeZeroRange")) then { diff --git a/addons/scopes/script_component.hpp b/addons/scopes/script_component.hpp index 9e867a9bd28..e7a9edb1587 100644 --- a/addons/scopes/script_component.hpp +++ b/addons/scopes/script_component.hpp @@ -18,6 +18,8 @@ #define DEFAULT_RAIL_BASE_ANGLE 0.0086 // deg +#define MIN_ZOOM_NAKEDEYE 0.2 // Magnification (CfgWeapons opticsZoomMax) that will always be unachievable by the naked eye + // #define DISABLE_DISPERSION #ifdef DEBUG_ENABLED_SCOPES