Scopes - Adds simplified zeroing subsystem (#5787)

* Client side setting to choose the preferred zeroing method
* Replicates the behaviour of the vanilla zeroing system
This commit is contained in:
ulteq 2017-11-29 11:38:19 +01:00 committed by GitHub
parent eab909e60e
commit 09c3187c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 121 additions and 65 deletions

View File

@ -78,4 +78,12 @@ class ACE_Settings {
displayName = CSTRING(useLegacyUI_displayName); displayName = CSTRING(useLegacyUI_displayName);
description = CSTRING(useLegacyUI_description); description = CSTRING(useLegacyUI_description);
}; };
class GVAR(simplifiedZeroing) {
category = CSTRING(DisplayName);
typeName = "BOOL";
value = 0;
displayName = CSTRING(simplifiedZeroing_displayName);
description = CSTRING(simplifiedZeroing_description);
};
}; };

View File

@ -92,6 +92,12 @@ class CfgVehicles {
typeName = "BOOL"; typeName = "BOOL";
defaultValue = 0; defaultValue = 0;
}; };
class simplifiedZeroing {
displayName = CSTRING(simplifiedZeroing_displayName);
description = CSTRING(simplifiedZeroing_description);
typeName = "BOOL";
defaultValue = 0;
};
}; };
class ModuleDescription { class ModuleDescription {
description = CSTRING(Description); description = CSTRING(Description);

View File

@ -26,11 +26,10 @@ if (!GVAR(enabled)) exitWith {false};
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
if (_weaponIndex < 0) exitWith {false}; if (_weaponIndex < 0) exitWith {false};
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
if (!(GVAR(canAdjustElevation) select _weaponIndex) && (_turretAndDirection in [ELEVATION_UP, ELEVATION_DOWN])) exitWith {false}; if (!(GVAR(canAdjustElevation) select _weaponIndex) && (_turretAndDirection in [ELEVATION_UP, ELEVATION_DOWN])) exitWith {false};
if (!(GVAR(canAdjustWindage) select _weaponIndex) && (_turretAndDirection in [WINDAGE_UP, WINDAGE_DOWN])) exitWith {false}; if (!(GVAR(canAdjustWindage) select _weaponIndex) && (_turretAndDirection in [WINDAGE_UP, WINDAGE_DOWN])) exitWith {false};
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
private _zeroing = _adjustment select _weaponIndex; private _zeroing = _adjustment select _weaponIndex;
_zeroing params ["_elevation", "_windage", "_zero"]; _zeroing params ["_elevation", "_windage", "_zero"];

View File

@ -33,14 +33,16 @@ playSound selectRandom ["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_
// slightly rotate the player if looking through optic // slightly rotate the player if looking through optic
if (cameraView == "GUNNER") then { if (cameraView == "GUNNER") then {
// Convert adjustmentDifference from mils to degrees if (!GVAR(simplifiedZeroing)) then {
_adjustmentDifference = _adjustmentDifference apply {MRAD_TO_DEG(_x)}; // Convert adjustmentDifference from mils to degrees
_adjustmentDifference params ["_elevationDifference", "_windageDifference"]; _adjustmentDifference = _adjustmentDifference apply {MRAD_TO_DEG(_x)};
private _pitchBankYaw = [_unit] call EFUNC(common,getPitchBankYaw); _adjustmentDifference params ["_elevationDifference", "_windageDifference"];
_pitchBankYaw params ["_pitch", "_bank", "_yaw"]; private _pitchBankYaw = [_unit] call EFUNC(common,getPitchBankYaw);
_pitch = _pitch + _elevationDifference; _pitchBankYaw params ["_pitch", "_bank", "_yaw"];
_yaw = _yaw + _windageDifference; _pitch = _pitch + _elevationDifference;
[_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw); _yaw = _yaw + _windageDifference;
[_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw);
};
} else { } else {
[] call FUNC(showZeroing); [] call FUNC(showZeroing);
}; };

View File

@ -19,6 +19,7 @@ params ["_unit"];
if (cameraView == "GUNNER") exitWith {false}; if (cameraView == "GUNNER") exitWith {false};
if (vehicle _unit != _unit) exitWith {false}; if (vehicle _unit != _unit) exitWith {false};
if (GVAR(simplifiedZeroing)) exitWith {false};
if (!(missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false])) exitWith {false}; if (!(missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false])) exitWith {false};
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);

View File

@ -30,7 +30,7 @@ TRACE_1("Adjusting With",_zeroing);
// Convert zeroing from mils to degrees // Convert zeroing from mils to degrees
_zeroing = _zeroing vectorMultiply MRAD_TO_DEG(1); _zeroing = _zeroing vectorMultiply MRAD_TO_DEG(1);
if (GVAR(correctZeroing)) then { if (GVAR(correctZeroing) || GVAR(simplifiedZeroing)) then {
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]; private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
private _baseAngle = GVAR(baseAngle) select _weaponIndex; private _baseAngle = GVAR(baseAngle) select _weaponIndex;
private _boreHeight = GVAR(boreHeight) select _weaponIndex; private _boreHeight = GVAR(boreHeight) select _weaponIndex;
@ -40,7 +40,11 @@ if (GVAR(correctZeroing)) then {
if (isNil "_zeroCorrection") then { if (isNil "_zeroCorrection") then {
_zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection); _zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);
}; };
_zeroing = _zeroing vectorAdd [0, 0, _zeroCorrection - _baseAngle]; if (GVAR(simplifiedZeroing)) then {
_zeroing = [0, 0, _zeroCorrection - _baseAngle];
} else {
_zeroing = _zeroing vectorAdd [0, 0, _zeroCorrection - _baseAngle];
};
#ifdef DISABLE_DISPERSION #ifdef DISABLE_DISPERSION
_projectile setVelocity (_unit weaponDirection currentWeapon _unit) vectorMultiply (vectorMagnitude (velocity _projectile)); _projectile setVelocity (_unit weaponDirection currentWeapon _unit) vectorMultiply (vectorMagnitude (velocity _projectile));
#endif #endif

View File

@ -21,6 +21,10 @@ if (!GVAR(enabled)) exitWith { currentZeroing _unit };
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
if (_weaponIndex < 0) exitWith { currentZeroing _unit }; if (_weaponIndex < 0) exitWith { currentZeroing _unit };
if (GVAR(simplifiedZeroing)) exitWith {
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 _optic = GVAR(Optics) select _weaponIndex;
private _opticConfig = if (_optic != "") then { private _opticConfig = if (_optic != "") then {

View File

@ -30,7 +30,6 @@ if !(_activated) exitWith {};
[_logic, QGVAR(zeroReferenceBarometricPressure), "zeroReferenceBarometricPressure"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(zeroReferenceBarometricPressure), "zeroReferenceBarometricPressure"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(zeroReferenceHumidity), "zeroReferenceHumidity"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(zeroReferenceHumidity), "zeroReferenceHumidity"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(deduceBarometricPressureFromTerrainAltitude), "deduceBarometricPressureFromTerrainAltitude"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(deduceBarometricPressureFromTerrainAltitude), "deduceBarometricPressureFromTerrainAltitude"] call EFUNC(common,readSettingFromModule);
GVAR(defaultZeroRange) = 0 max GVAR(defaultZeroRange) min 1000; GVAR(defaultZeroRange) = 0 max GVAR(defaultZeroRange) min 1000;
GVAR(zeroReferenceTemperature) = -55 max GVAR(zeroReferenceTemperature) min 55; GVAR(zeroReferenceTemperature) = -55 max GVAR(zeroReferenceTemperature) min 55;
GVAR(zeroReferenceBarometricPressure) = 0 max GVAR(zeroReferenceBarometricPressure) min 1013.25; GVAR(zeroReferenceBarometricPressure) = 0 max GVAR(zeroReferenceBarometricPressure) min 1013.25;

View File

@ -25,32 +25,50 @@ private _newOptics = [_player] call FUNC(getOptics);
if (_newOptics select _forEachIndex != _x) then { if (_newOptics select _forEachIndex != _x) then {
private _opticConfig = configFile >> "CfgWeapons" >> (_newOptics select _forEachIndex); private _opticConfig = configFile >> "CfgWeapons" >> (_newOptics select _forEachIndex);
private _opticType = getNumber(_opticConfig >> "ItemInfo" >> "opticType"); private _opticType = getNumber(_opticConfig >> "ItemInfo" >> "opticType");
private _verticalIncrement = -1;
if (isNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement")) then {
_verticalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement");
};
private _horizontalIncrement = -1;
if (isNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement")) then {
_horizontalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
};
private _maxVertical = []; private _maxVertical = [];
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Vertical")) then { private _verticalIncrement = -1;
_maxVertical = getArray (_opticConfig >> "ACE_ScopeAdjust_Vertical");
};
private _maxHorizontal = []; private _maxHorizontal = [];
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal")) then { private _horizontalIncrement = -1;
_maxHorizontal = getArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal"); if (GVAR(simplifiedZeroing)) then {
}; private _maxDistanceZoomMax = 300;
if (GVAR(forceUseOfAdjustmentTurrets) && _opticType == 2) then { private _maxDiscreteDistanceSize = 0;
if (_maxVertical isEqualTo []) then { _maxVertical = [-4, 30]; }; {
if (_maxHorizontal isEqualTo []) then { _maxHorizontal = [-6, 6]; }; _maxDistanceZoomMax = _maxDistanceZoomMax max (getNumber ( _x >> "distanceZoomMax"));
if (_verticalIncrement == -1) then { _verticalIncrement = 0.1; }; _maxDiscreteDistanceSize = _maxDiscreteDistanceSize max (count getArray (_x >> "discreteDistance"));
if (_horizontalIncrement == -1) then { _horizontalIncrement = 0.1; }; } forEach ("isArray (_x >> 'discreteDistance')" configClasses (_opticConfig >> "ItemInfo" >> "OpticsModes"));
if (_maxDiscreteDistanceSize < 2 && {getNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement") != 0}) then {
_maxVertical = [50, _maxDistanceZoomMax];
_verticalIncrement = 50;
} else {
_maxVertical = [0, 0];
_verticalIncrement = 0;
};
_maxHorizontal = [0, 0];
_horizontalIncrement = 0;
} else { } else {
if (_maxVertical isEqualTo []) then { _maxVertical = [0, 0]; }; if (isNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement")) then {
if (_maxHorizontal isEqualTo []) then { _maxHorizontal = [0, 0]; }; _verticalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement");
if (_verticalIncrement == -1) then { _verticalIncrement = 0; }; };
if (_horizontalIncrement == -1) then { _horizontalIncrement = 0; }; if (isNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement")) then {
_horizontalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
};
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Vertical")) then {
_maxVertical = getArray (_opticConfig >> "ACE_ScopeAdjust_Vertical");
};
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal")) then {
_maxHorizontal = getArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal");
};
if (GVAR(forceUseOfAdjustmentTurrets) && _opticType == 2) then {
if (_maxVertical isEqualTo []) then { _maxVertical = [-4, 30]; };
if (_maxHorizontal isEqualTo []) then { _maxHorizontal = [-6, 6]; };
if (_verticalIncrement == -1) then { _verticalIncrement = 0.1; };
if (_horizontalIncrement == -1) then { _horizontalIncrement = 0.1; };
} else {
if (_maxVertical isEqualTo []) then { _maxVertical = [0, 0]; };
if (_maxHorizontal isEqualTo []) then { _maxHorizontal = [0, 0]; };
if (_verticalIncrement == -1) then { _verticalIncrement = 0; };
if (_horizontalIncrement == -1) then { _horizontalIncrement = 0; };
};
}; };
(GVAR(scopeAdjust) select _forEachIndex) set [0, _maxVertical]; (GVAR(scopeAdjust) select _forEachIndex) set [0, _maxVertical];
(GVAR(scopeAdjust) select _forEachIndex) set [1, _verticalIncrement]; (GVAR(scopeAdjust) select _forEachIndex) set [1, _verticalIncrement];
@ -70,20 +88,21 @@ private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapo
if ((_newOptics select _x) == "") then { if ((_newOptics select _x) == "") then {
// Check if the weapon comes with an integrated optic // Check if the weapon comes with an integrated optic
private _weaponConfig = configFile >> "CfgWeapons" >> (_newGuns select _x); private _weaponConfig = configFile >> "CfgWeapons" >> (_newGuns select _x);
private _verticalIncrement = 0;
if (isNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement")) then {
_verticalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement");
};
private _horizontalIncrement = 0;
if (isNumber (_weaponConfig >> "ACE_ScopeAdjust_HorizontalIncrement")) then {
_horizontalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
};
private _maxVertical = [0, 0]; private _maxVertical = [0, 0];
if (isArray (_weaponConfig >> "ACE_ScopeAdjust_Vertical")) then { private _verticalIncrement = 0;
_maxVertical = getArray (_weaponConfig >> "ACE_ScopeAdjust_Vertical");
};
private _maxHorizontal = [0, 0]; private _maxHorizontal = [0, 0];
if (isArray (_weaponConfig >> "ACE_ScopeAdjust_Horizontal")) then { private _horizontalIncrement = 0;
if (GVAR(simplifiedZeroing)) then {
private _maxZeroing = 300 max (getNumber (_weaponConfig >> "maxZeroing"));
private _maxDiscreteDistanceSize = count getArray (configFile >> "CfgWeapons" >> (_newGuns select _x) >> "discreteDistance");
if (_maxDiscreteDistanceSize < 2 && {getNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement") != 0}) then {
_maxVertical = [50, _maxZeroing];
_verticalIncrement = 50;
};
} else {
_verticalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_VerticalIncrement");
_horizontalIncrement = getNumber (_weaponConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
_maxVertical = getArray (_weaponConfig >> "ACE_ScopeAdjust_Vertical");
_maxHorizontal = getArray (_weaponConfig >> "ACE_ScopeAdjust_Horizontal"); _maxHorizontal = getArray (_weaponConfig >> "ACE_ScopeAdjust_Horizontal");
}; };
TRACE_5("",_newGuns select _x,_verticalIncrement,_horizontalIncrement,_maxVertical,_maxHorizontal); TRACE_5("",_newGuns select _x,_verticalIncrement,_horizontalIncrement,_maxVertical,_maxHorizontal);
@ -101,8 +120,9 @@ private _newGuns = [primaryWeapon _player, secondaryWeapon _player, handgunWeapo
if (!(_persistentZero isEqualType 0) || {_persistentZero < _minElevation || _persistentZero > _maxElevation}) then { if (!(_persistentZero isEqualType 0) || {_persistentZero < _minElevation || _persistentZero > _maxElevation}) then {
_persistentZero = 0; _persistentZero = 0;
}; };
if (!((_adjustment select _forEachIndex) isEqualTo [0, 0, _persistentZero])) then { private _defaultElevation = [0, 300] select GVAR(simplifiedZeroing);
_adjustment set [_forEachIndex, [0, 0, _persistentZero]]; if (!((_adjustment select _forEachIndex) isEqualTo [_defaultElevation, 0, _persistentZero])) then {
_adjustment set [_forEachIndex, [_defaultElevation, 0, _persistentZero]];
_updateAdjustment = true; _updateAdjustment = true;
}; };
} }

View File

@ -35,26 +35,31 @@ private _zeroing = _adjustment select _weaponIndex;
_zeroing params ["_elevation", "_windage"]; _zeroing params ["_elevation", "_windage"];
private _vertical = _display displayCtrl 12; private _vertical = _display displayCtrl 12;
private _horizontal = _display displayCtrl 13; private _horizontal = _display displayCtrl 13;
if (GVAR(useLegacyUI)) then { if (GVAR(simplifiedZeroing)) then {
_vertical ctrlSetText (str _elevation); _vertical ctrlSetText format["%1 m", round(_elevation)];
_horizontal ctrlSetText (str _windage); _horizontal ctrlSetText "";
} else { } else {
if (_elevation == 0) then { if (GVAR(useLegacyUI)) then {
_vertical ctrlSetText "0"; _vertical ctrlSetText (str _elevation);
_horizontal ctrlSetText (str _windage);
} else { } else {
if (_elevation > 0) then { if (_elevation == 0) then {
_vertical ctrlSetText (str _elevation); _vertical ctrlSetText "0";
} else { } else {
_vertical ctrlSetText format[localize LSTRING(DisplayAdjustmentDown), abs(_elevation)]; if (_elevation > 0) then {
_vertical ctrlSetText (str _elevation);
} else {
_vertical ctrlSetText format[localize LSTRING(DisplayAdjustmentDown), abs(_elevation)];
};
}; };
}; if (_windage == 0) then {
if (_windage == 0) then { _horizontal ctrlSetText "0";
_horizontal ctrlSetText "0";
} else {
if (_windage > 0) then {
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentRight), abs(_windage)];
} else { } else {
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentLeft), abs(_windage)]; if (_windage > 0) then {
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentRight), abs(_windage)];
} else {
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentLeft), abs(_windage)];
};
}; };
}; };
}; };

View File

@ -224,6 +224,14 @@
<Chinese>使用帶著標籤的數字顯示歸零遠近與風偏程度</Chinese> <Chinese>使用帶著標籤的數字顯示歸零遠近與風偏程度</Chinese>
<Chinesesimp>使用带着标签的数字显示归零远近与风偏程度</Chinesesimp> <Chinesesimp>使用带着标签的数字显示归零远近与风偏程度</Chinesesimp>
</Key> </Key>
<Key ID="STR_ACE_Scopes_simplifiedZeroing_displayName">
<English>Simplified zeroing</English>
<German>Vereinfachte Nullung</German>
</Key>
<Key ID="STR_ACE_Scopes_simplifiedZeroing_description">
<English>Replicates the vanilla zeroing system for riflescopes.</English>
<German>Repliziert das Vanilla-Zeroing-System für Zielfernrohre.</German>
</Key>
<Key ID="STR_ACE_Scopes_AdjustUpMinor"> <Key ID="STR_ACE_Scopes_AdjustUpMinor">
<English>Minor adjustment up</English> <English>Minor adjustment up</English>
<German>Kleine Korrektur hoch</German> <German>Kleine Korrektur hoch</German>