Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scopes - No Zeroing from Secondary Sights #10220

Merged
merged 15 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions addons/scopes/functions/fnc_getCurrentZeroRange.sqf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self to clean this up eventually (save CfgWeapons lookup, parentheses)

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}}
mrschick marked this conversation as resolved.
Show resolved Hide resolved
) 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
Loading