Skip to content

Commit

Permalink
Scopes - No Zeroing from Secondary Sights (acemod#10220)
Browse files Browse the repository at this point in the history
Co-authored-by: johnb432 <[email protected]>
  • Loading branch information
mrschick and johnb432 authored Dec 19, 2024
1 parent 1168acb commit ce56d87
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions addons/scopes/functions/fnc_getCurrentZeroRange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions addons/scopes/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce56d87

Please sign in to comment.