Skip to content

Commit ce56d87

Browse files
mrschickjohnb432
andauthored
Scopes - No Zeroing from Secondary Sights (#10220)
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
1 parent 1168acb commit ce56d87

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

addons/scopes/functions/fnc_getCurrentZeroRange.sqf

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,40 @@ params ["_unit"];
1919

2020
if (!GVAR(enabled)) exitWith {currentZeroing _unit};
2121

22-
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
22+
private _currentWeapon = currentWeapon _unit;
23+
private _weaponIndex = [_unit, _currentWeapon] call EFUNC(common,getWeaponIndex);
2324
if (_weaponIndex < 0) exitWith { currentZeroing _unit };
25+
2426
if (GVAR(simplifiedZeroing)) exitWith {
2527
if !(GVAR(canAdjustElevation) select _weaponIndex) exitWith {currentZeroing _unit};
2628
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
2729
((_adjustment select _weaponIndex) select 0)
2830
};
2931

30-
private _optic = GVAR(Optics) select _weaponIndex;
32+
private _local = _unit == ACE_Player;
33+
34+
private _optic = if (_local) then {
35+
GVAR(Optics) select _weaponIndex
36+
} else {
37+
([_unit] call FUNC(getOptics)) select _weaponIndex
38+
};
3139
private _opticConfig = if (_optic != "") then {
3240
(configFile >> "CfgWeapons" >> _optic)
3341
} else {
34-
(configFile >> "CfgWeapons" >> (GVAR(Guns) select _weaponIndex))
42+
if (_local) then {
43+
(configFile >> "CfgWeapons" >> (GVAR(Guns) select _weaponIndex))
44+
} else {
45+
(configFile >> "CfgWeapons" >> _currentWeapon)
46+
};
3547
};
3648

3749
private _zeroRange = currentZeroing _unit;
38-
if (GVAR(overwriteZeroRange) && {GVAR(canAdjustElevation) select _weaponIndex}) then {
50+
// 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
51+
if (
52+
_local &&
53+
(GVAR(canAdjustElevation) select _weaponIndex) &&
54+
{GVAR(overwriteZeroRange) || {getNumber (_opticConfig >> "ItemInfo" >> "OpticsModes" >> (_unit getOpticsMode _weaponIndex) >> "opticsZoomMax") > MIN_ZOOM_NAKEDEYE}}
55+
) then {
3956
_zeroRange = GVAR(defaultZeroRange);
4057
};
4158
if (isNumber (_opticConfig >> "ACE_ScopeZeroRange")) then {

addons/scopes/script_component.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#define DEFAULT_RAIL_BASE_ANGLE 0.0086 // deg
2020

21+
#define MIN_ZOOM_NAKEDEYE 0.2 // Magnification (CfgWeapons opticsZoomMax) that will always be unachievable by the naked eye
22+
2123
// #define DISABLE_DISPERSION
2224

2325
#ifdef DEBUG_ENABLED_SCOPES

0 commit comments

Comments
 (0)