Adds settings module for ace_scopes

* Interconnects the rangecard and scopes modules
* Hides the zeroing text when the vanilla zeroing is overwritten
* Makes the scopes module fully compatible with any 3rd party weapon pack without the need for addition compat pbos (though their use is still recommended)
This commit is contained in:
ulteq 2016-11-08 14:47:12 +01:00 committed by ulteq
parent 36c14c5dc4
commit a687c49d2a
18 changed files with 304 additions and 44 deletions

View File

@ -6,10 +6,12 @@ GVAR(RangeCardOpened) = false;
GVAR(controls) = [];
GVAR(zeroRange) = 100;
GVAR(ammoClass) = "B_65x39_Caseless";
GVAR(magazineClass) = "30Rnd_65x39_caseless_mag";
GVAR(weaponClass) = "arifle_MXM_F";
GVAR(zeroRangeCopy) = 100;
GVAR(ammoClassCopy) = "";//"ACE_762x51_Ball_M118LR";
GVAR(magazineClassCopy) = "";//"ACE_20Rnd_762x51_M118LR_Mag";
GVAR(weaponClassCopy) = "";//srifle_DMR_06_olive_F";

View File

@ -6,7 +6,7 @@ class CfgPatches {
units[] = {"ACE_Item_RangeCard"};
weapons[] = {"ACE_RangeCard"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ACE_Advanced_Ballistics"};
requiredAddons[] = {"ACE_Advanced_Ballistics","ace_scopes"};
author = ECSTRING(common,ACETeam);
authors[] = {"Ruthberg"};
url = ECSTRING(main,URL);

View File

@ -23,7 +23,7 @@ if (_this) then {
createDialog "ACE_RangeCard_Dialog";
[GVAR(ammoClassCopy), GVAR(magazineClassCopy), GVAR(weaponClassCopy)] call FUNC(updateRangeCard);
[GVAR(zeroRangeCopy), GVAR(ammoClassCopy), GVAR(magazineClassCopy), GVAR(weaponClassCopy)] call FUNC(updateRangeCard);
};
} else {
if (ACE_player call FUNC(updateClassNames)) then {
@ -31,6 +31,6 @@ if (_this) then {
createDialog "ACE_RangeCard_Dialog";
[GVAR(ammoClass), GVAR(magazineClass), GVAR(weaponClass)] call FUNC(updateRangeCard);
[GVAR(zeroRange), GVAR(ammoClass), GVAR(magazineClass), GVAR(weaponClass)] call FUNC(updateRangeCard);
};
};

View File

@ -37,10 +37,12 @@ if (_weaponClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass)
if (_ammoClass == "") exitWith { (GVAR(ammoClass) != "" && GVAR(magazineClass) != "" && GVAR(weaponClass) != "") };
if (_unit == ACE_player) then {
GVAR(zeroRange) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
GVAR(ammoClass) = _ammoClass;
GVAR(magazineClass) = _magazineClass;
GVAR(weaponClass) = _weaponClass;
} else {
GVAR(zeroRangeCopy) = [_unit] call EFUNC(scopes,getCurrentZeroRange);
GVAR(ammoClassCopy) = _ammoClass;
GVAR(magazineClassCopy) = _magazineClass;
GVAR(weaponClassCopy) = _weaponClass;

View File

@ -3,9 +3,10 @@
* Updates the range card data
*
* Arguments:
* 0: ammo class <STRING>
* 1: magazine class <STRING>
* 2: weapon class <STRING>
* 0: zero range <NUMBER>
* 1: ammo class <STRING>
* 2: magazine class <STRING>
* 3: weapon class <STRING>
*
* Return Value:
* Nothing
@ -20,10 +21,9 @@
disableSerialization;
#define __dsp (uiNamespace getVariable "RangleCard_Display")
private ["_airFriction", "_ammoConfig", "_atmosphereModel", "_barometricPressure", "_barrelLength", "_barrelTwist", "_bc", "_bulletMass", "_boreHeight", "_cacheEntry", "_column", "_control", "_dragModel", "_i", "_muzzleVelocity", "_offset", "_relativeHumidity", "_result", "_row", "_weaponConfig", "_zeroRange", "_initSpeed", "_initSpeedCoef", "_useABConfig"];
_useABConfig = (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]);
private ["_airFriction", "_ammoConfig", "_atmosphereModel", "_barrelLength", "_barrelTwist", "_bc", "_boreHeight", "_cacheEntry", "_column", "_control", "_dragModel", "_i", "_muzzleVelocity", "_offset", "_row", "_weaponConfig", "_initSpeed", "_initSpeedCoef"];
PARAMS_3(_ammoClass,_magazineClass,_weaponClass);
params ["_zeroRange", "_ammoClass", "_magazineClass", "_weaponClass"];
if (_ammoClass == "" || _magazineClass == "" || _weaponClass == "") exitWith {};
@ -105,10 +105,9 @@ if (count (_ammoConfig select 6) > 0) then {
};
_dragModel = _ammoConfig select 5;
_atmosphereModel = _ammoConfig select 8;
_bulletMass = 5;
_boreHeight = 3.81;
_zeroRange = 100;
private _useABConfig = (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]);
if (_bc == 0) then {
_useABConfig = false;
};
@ -147,25 +146,21 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t
lnbAddRow [770300, ["-15°C", " 10°C", " 35°C", "-15°C", " 10°C", " 35°C"]];
};
_barometricPressure = 1013.25;
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
_barometricPressure = 1013.25 * (1 - (0.0065 * EGVAR(common,mapAltitude)) / 288.15) ^ 5.255754495;
};
_relativeHumidity = 0.5;
ctrlSetText [77003, format["%1m ZERO", round(_zeroRange)]];
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
ctrlSetText [770001, format["Drop Tables for B.P.: %1mb; Corrected for MVV at Air/Ammo Temperatures -15-35 °C", round(_barometricPressure * 100) / 100]];
ctrlSetText [77004 , format["B.P.: %1mb", round(_barometricPressure * 100) / 100]];
ctrlSetText [770001, format["Drop Tables for B.P.: %1mb; Corrected for MVV at Air/Ammo Temperatures -15-35 °C", round(EGVAR(scopes,zeroReferenceBarometricPressure) * 100) / 100]];
ctrlSetText [77004 , format["B.P.: %1mb", round(EGVAR(scopes,zeroReferenceBarometricPressure) * 100) / 100]];
} else {
ctrlSetText [770001, ""];
ctrlSetText [77004 , ""];
};
_cacheEntry = missionNamespace getVariable format[QGVAR(%1_%2_%3), _ammoClass, _weaponClass, missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]];
_cacheEntry = missionNamespace getVariable format[QGVAR(%1_%2_%3_%4), _zeroRange, _ammoClass, _weaponClass, missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]];
if (isNil {_cacheEntry}) then {
private _scopeBaseAngle = 0;
{
private _offset = [_scopeBaseAngle, 100, _muzzleVelocity, _airFriction, 1000, _boreHeight, 15, 1013.25, 0.5, _bc, _dragModel, _atmosphereModel, _useABConfig] call EFUNC(scopes,calculateZeroAngle);
private _offset = [_scopeBaseAngle, _zeroRange, _muzzleVelocity, _airFriction, 1000, _boreHeight, EGVAR(scopes,zeroReferenceTemperature), EGVAR(scopes,zeroReferenceBarometricPressure), EGVAR(scopes,zeroReferenceHumidity), _bc, _dragModel, _atmosphereModel, _useABConfig] call EFUNC(scopes,calculateZeroAngle);
_scopeBaseAngle = _scopeBaseAngle + _offset;
if (_offset < 0.01) exitWith {};
} forEach [1, 2, 3];
@ -174,10 +169,10 @@ if (isNil {_cacheEntry}) then {
private _mvShift = [_ammoConfig select 9, _x] call EFUNC(advanced_ballistics,calculateAmmoTemperatureVelocityShift);
private _mv = _muzzleVelocity + _mvShift;
[_scopeBaseAngle,_bulletMass,_boreHeight,_airFriction,_mv,_x,_barometricPressure,_relativeHumidity,1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,_forEachIndex,_useABConfig] call FUNC(calculateSolution);
[_scopeBaseAngle,0,_boreHeight,_airFriction,_mv,_x,EGVAR(scopes,zeroReferenceBarometricPressure),EGVAR(scopes,zeroReferenceHumidity),1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,_forEachIndex,_useABConfig] call FUNC(calculateSolution);
} forEach [-15, -5, 5, 10, 15, 20, 25, 30, 35];
} else {
[_scopeBaseAngle,_bulletMass,_boreHeight,_airFriction,_muzzleVelocity,15,_barometricPressure,_relativeHumidity,1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,4,_useABConfig] call FUNC(calculateSolution);
[_scopeBaseAngle,0,_boreHeight,_airFriction,_muzzleVelocity,15,EGVAR(scopes,zeroReferenceBarometricPressure),EGVAR(scopes,zeroReferenceHumidity),1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,4,_useABConfig] call FUNC(calculateSolution);
};
for "_i" from 0 to 9 do {
@ -195,7 +190,7 @@ if (isNil {_cacheEntry}) then {
};
};
missionNamespace setVariable [format[QGVAR(%1_%2_%3), _ammoClass, _weaponClass, missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]], [GVAR(rangeCardDataElevation), GVAR(rangeCardDataWindage), GVAR(rangeCardDataLead), GVAR(rangeCardDataMVs), GVAR(lastValidRow)]];
missionNamespace setVariable [format[QGVAR(%1_%2_%3_%4), _zeroRange, _ammoClass, _weaponClass, missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]], [GVAR(rangeCardDataElevation), GVAR(rangeCardDataWindage), GVAR(rangeCardDataLead), GVAR(rangeCardDataMVs), GVAR(lastValidRow)]];
} else {
GVAR(rangeCardDataElevation) = _cacheEntry select 0;
GVAR(rangeCardDataWindage) = _cacheEntry select 1;

View File

@ -0,0 +1,48 @@
class ACE_Settings {
class GVAR(enabled) {
typeName = "BOOL";
value = 1;
displayName = CSTRING(enabled_displayName);
description = CSTRING(enabled_description);
};
// ACE_ScopeAdjust_Vertical and ACE_ScopeAdjust_Horizontal will be populated with default values instead of [0,0]
class GVAR(forceUseOfAdjustmentTurrets) {
typeName = "BOOL";
value = 0;
displayName = CSTRING(forceUseOfAdjustmentTurrets_displayName);
description = CSTRING(forceUseOfAdjustmentTurrets_description);
};
// Only affects scopes with elevation adjustment turrets (ACE_ScopeAdjust_Vertical != [0,0])
class GVAR(defaultZeroRange) {
typeName = "SCALAR";
value = 100;
displayName = CSTRING(defaultZeroRange_displayName);
description = CSTRING(defaultZeroRange_description);
};
// Only relevant when advanced ballistics is enabled
class GVAR(zeroReferenceTemperature) {
typeName = "SCALAR";
value = 15;
displayName = CSTRING(zeroReferenceTemperature_displayName);
description = CSTRING(zeroReferenceTemperature_description);
};
class GVAR(zeroReferenceBarometricPressure) {
typeName = "SCALAR";
value = 1013.25;
displayName = CSTRING(zeroReferenceBarometricPressure_displayName);
description = CSTRING(zeroReferenceBarometricPressure_description);
};
class GVAR(zeroReferenceHumidity) {
typeName = "SCALAR";
value = 0.5;
displayName = CSTRING(zeroReferenceHumidity_displayName);
description = CSTRING(zeroReferenceHumidity_description);
};
class GVAR(deduceBarometricPressureFromTerrainAltitude) {
typeName = "BOOL";
value = 0;
displayName = CSTRING(deduceBarometricPressureFromTerrainAltitude_displayName);
description = CSTRING(deduceBarometricPressureFromTerrainAltitude_description);
};
};

View File

@ -16,4 +16,63 @@ class CfgVehicles {
};
};
};
class ACE_Module;
class GVAR(ModuleSettings): ACE_Module {
scope = 2;
displayName = CSTRING(DisplayName);
//icon = ""; // needs an icon
category = "ACE";
function = QUOTE(DFUNC(initModuleSettings));
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
author = ECSTRING(common,ACETeam);
class Arguments {
class enabled {
displayName = CSTRING(enabled_DisplayName);
description = CSTRING(enabled_Description);
typeName = "BOOL";
defaultValue = 1;
};
class forceUseOfAdjustmentTurrets {
displayName = CSTRING(forceUseOfAdjustmentTurrets_DisplayName);
description = CSTRING(forceUseOfAdjustmentTurrets_Description);
typeName = "BOOL";
defaultValue = 0;
};
class defaultZeroRange {
displayName = CSTRING(defaultZeroRange_DisplayName);
description = CSTRING(defaultZeroRange_Description);
typeName = "NUMBER";
defaultValue = 100;
};
class zeroReferenceTemperature {
displayName = CSTRING(zeroReferenceTemperature_DisplayName);
description = CSTRING(zeroReferenceTemperature_Description);
typeName = "NUMBER";
defaultValue = 15;
};
class zeroReferenceBarometricPressure {
displayName = CSTRING(zeroReferenceBarometricPressure_DisplayName);
description = CSTRING(zeroReferenceBarometricPressure_Description);
typeName = "NUMBER";
defaultValue = 1013.25;
};
class zeroReferenceHumidity {
displayName = CSTRING(zeroReferenceHumidity_DisplayName);
description = CSTRING(zeroReferenceHumidity_Description);
typeName = "NUMBER";
defaultValue = 0.5;
};
class deduceBarometricPressureFromTerrainAltitude {
displayName = CSTRING(deduceBarometricPressureFromTerrainAltitude_DisplayName);
description = CSTRING(deduceBarometricPressureFromTerrainAltitude_Description);
typeName = "BOOL";
defaultValue = 0;
};
};
class ModuleDescription {
description = CSTRING(Description);
};
};
};

View File

@ -56,6 +56,8 @@ class CfgWeapons {
class optic_NVS : ItemCore {
ACE_ScopeHeightAboveRail = 4.2;
ACE_ScopeAdjust_Vertical[] = {0, 0};
ACE_ScopeAdjust_Horizontal[] = {0, 0};
};
class optic_TWS : ItemCore {

View File

@ -6,6 +6,8 @@ PREP(calculateZeroAngle);
PREP(calculateZeroAngleCorrection);
PREP(canAdjustZero);
PREP(firedEH);
PREP(getCurrentZeroRange);
PREP(getOptics);
PREP(initModuleSettings);
PREP(inventoryCheck);
PREP(showZeroing);

View File

@ -10,6 +10,9 @@
if (!hasInterface) exitWith {};
GVAR(Optics) = ["", "", ""];
GVAR(canAdjustElevation) = [false, false, false];
GVAR(canAdjustWindage) = [false, false, false];
GVAR(scopeAdjust) = [[[0,0],0,[0,0],0], [[0,0],0,[0,0],0], [[0,0],0,[0,0],0]];
// Check inventory when it changes
["loadout", FUNC(inventoryCheck)] call CBA_fnc_addPlayerEventHandler;

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = { "ace_common" };
author = ECSTRING(common,ACETeam);
authors[] = {"KoffeinFlummi", "esteldunedain"};
authors[] = {"KoffeinFlummi", "esteldunedain", "Ruthberg"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
@ -19,3 +19,4 @@ class CfgPatches {
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "RscTitles.hpp"
#include "ACE_Settings.hpp"

View File

@ -23,6 +23,7 @@ params ["_unit", "_turretAndDirection", "_majorStep"];
if (!(_unit isKindOf "Man")) exitWith {false};
if (currentMuzzle _unit != currentWeapon _unit) exitWith {false};
if (!GVAR(enabled)) exitWith {false};
_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
if (_weaponIndex < 0) exitWith {false};
@ -32,20 +33,14 @@ if (isNil "_adjustment") then {
_adjustment = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; // [Windage, Elevation, Zero]
};
_optic = GVAR(Optics) select _weaponIndex;
_opticConfig = configFile >> "CfgWeapons" >> _optic;
_verticalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_VerticalIncrement");
_horizontalIncrement = getNumber (_opticConfig >> "ACE_ScopeAdjust_HorizontalIncrement");
_maxVertical = getArray (_opticConfig >> "ACE_ScopeAdjust_Vertical");
_maxHorizontal = getArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal");
if ((count _maxHorizontal < 2) || (count _maxVertical < 2)) exitWith {false};
if ((_verticalIncrement == 0) && (_turretAndDirection in [ELEVATION_UP, ELEVATION_DOWN])) exitWith {false};
if ((_horizontalIncrement == 0) && (_turretAndDirection in [WINDAGE_UP, WINDAGE_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};
_zeroing = _adjustment select _weaponIndex;
_zeroing params ["_elevation", "_windage", "_zero"];
(GVAR(scopeAdjust) select _weaponIndex) params ["_maxVertical", "_verticalIncrement", "_maxHorizontal", "_horizontalIncrement"];
switch (_turretAndDirection) do {
case ELEVATION_UP: { _elevation = _elevation + _verticalIncrement };
case ELEVATION_DOWN: { _elevation = _elevation - _verticalIncrement };

View File

@ -47,11 +47,6 @@ private _vanillaZero = 0; // in degrees
if (_offset < 0.01) exitWith {};
} forEach [1, 2, 3];
// Standard atmosphere (optionally overwrite with ace setting)
private _temperature = 15;
private _barometricPressure = 1013.25;
private _relativeHumidity = 0.5;
if (_advancedBallistics) then {
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,barrelLengthInfluenceEnabled), false]) then {
private _barrelVelocityShift = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _initSpeed] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift);
@ -60,8 +55,8 @@ if (_advancedBallistics) then {
};
private _zeroAngle = 0; // in degrees
{
private _offset = [_zeroAngle, _newZeroRange, _initSpeed, _airFriction, 1000, _boreHeight, _temperature, _barometricPressure, _relativeHumidity, _ballisticCoefficients select 0, _dragModel, _atmosphereModel, _advancedBallistics] call FUNC(calculateZeroAngle);
{
private _offset = [_zeroAngle, _newZeroRange, _initSpeed, _airFriction, 1000, _boreHeight, GVAR(zeroReferenceTemperature), GVAR(zeroReferenceBarometricPressure), GVAR(zeroReferenceHumidity), _ballisticCoefficients select 0, _dragModel, _atmosphereModel, _advancedBallistics] call FUNC(calculateZeroAngle);
_zeroAngle = _zeroAngle + _offset;
if (_offset < 0.01) exitWith {};
} forEach [1, 2, 3];

View File

@ -1,5 +1,5 @@
/*
* Author: KoffeinFlummi, esteldunedain
* Author: KoffeinFlummi, esteldunedain, Ruthberg
* Adjusts the flight path of the bullet according to the zeroing. Called from the unified fired EH only for local and non-local players on foot.
*
* Arguments:
@ -60,7 +60,7 @@ if (_ammo isKindOf "BulletBase") then {
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
private _boreHeight = _railHeightAboveBore + _scopeHeightAboveRail;
private _oldZeroRange = currentZeroing _unit;
private _newZeroRange = _oldZeroRange; // Change this if you want to overwrite the discreteDistance[] setting
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
private _zeroCorrection = missionNamespace getVariable format[QGVAR(%1_%2_%3_%4_%5_%6_%7), _oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics];
if (isNil "_zeroCorrection") then {
_zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);

View File

@ -0,0 +1,35 @@
/*
* Author: Ruthberg
* Gets the zero range of the currently used optic
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* current zero range
*
* Example:
* _unit call ace_scopes_fnc_getCurrentZeroRange
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
if (_weaponIndex < 0) exitWith { 0 };
private _optic = GVAR(Optics) select _weaponIndex;
private _opticConfig = configFile >> "CfgWeapons" >> _optic;
private _opticType = getNumber(_opticConfig >> "ItemInfo" >> "opticType");
private _zeroRange = currentZeroing _unit;
if (_opticType == 2 && {(GVAR(canAdjustElevation) select _weaponIndex) || GVAR(forceUseOfAdjustmentTurrets)}) then {
_zeroRange = GVAR(defaultZeroRange);
};
if (isNumber (_opticConfig >> "ACE_ScopeZeroRange")) then {
_zeroRange = getNumber(_opticConfig >> "ACE_ScopeZeroRange");
};
_zeroRange

View File

@ -0,0 +1,36 @@
/*
* Author: Glowbal, Ruthberg
* Module for adjusting the scopes settings
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_logic","_units", "_activated"];
if !(_activated) exitWith {};
[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(forceUseOfAdjustmentTurrets), "forceUseOfAdjustmentTurrets"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(defaultZeroRange), "defaultZeroRange"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(zeroReferenceTemperature), "zeroReferenceTemperature"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(zeroReferenceBarometricPressure), "zeroReferenceBarometricPressure"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(zeroReferenceHumidity), "zeroReferenceHumidity"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(deduceBarometricPressureFromTerrainAltitude), "deduceBarometricPressureFromTerrainAltitude"] call EFUNC(common,readSettingFromModule);
GVAR(defaultZeroRange) = 0 max GVAR(defaultZeroRange) min 1000;
GVAR(zeroReferenceTemperature) = -55 max GVAR(zeroReferenceTemperature) max 55;
GVAR(zeroReferenceBarometricPressure) = 0 max GVAR(zeroReferenceBarometricPressure) min 1013.25;
GVAR(zeroReferenceHumidity) = 0 max GVAR(zeroReferenceHumidity) min 1.0;
if (GVAR(deduceBarometricPressureFromTerrainAltitude)) then {
GVAR(zeroReferenceBarometricPressure) = 1013.25 * (1 - (0.0065 * EGVAR(common,mapAltitude)) / 288.15) ^ 5.255754495;
};

View File

@ -1,5 +1,5 @@
/*
* Author: KoffeinFlummi, Commy2
* Author: KoffeinFlummi, Commy2, Ruthberg
* Check if weapon optics changed and reset zeroing if needed
*
* Arguments:
@ -34,6 +34,43 @@ private _newOptics = [_player] call FUNC(getOptics);
_adjustment set [_forEachIndex, [0, 0, 0]];
[ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
};
private _opticConfig = configFile >> "CfgWeapons" >> (_newOptics select _forEachIndex);
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 = [];
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Vertical")) then {
_maxVertical = getArray (_opticConfig >> "ACE_ScopeAdjust_Vertical");
};
private _maxHorizontal = [];
if (isArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal")) then {
_maxHorizontal = getArray (_opticConfig >> "ACE_ScopeAdjust_Horizontal");
};
if (GVAR(forceUseOfAdjustmentTurrets)) 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 [1, _verticalIncrement];
(GVAR(scopeAdjust) select _forEachIndex) set [2, _maxHorizontal];
(GVAR(scopeAdjust) select _forEachIndex) set [3, _horizontalIncrement];
GVAR(canAdjustElevation) set [_forEachIndex, (_verticalIncrement > 0) && !(_maxVertical isEqualTo [0, 0])];
GVAR(canAdjustWindage) set [_forEachIndex, (_horizontalIncrement > 0) && !(_maxHorizontal isEqualTo [0, 0])];
// Does not work reliably
//private _hideVanillaZeroing = (getNumber(_opticConfig >> "ItemInfo" >> "opticType") == 2 && (GVAR(canAdjustElevation) select _forEachIndex)) || {isNumber (_opticConfig >> "ACE_ScopeZeroRange")};
//private _result = ["zeroing", !_hideVanillaZeroing, false] call EFUNC(ui,setAdvancedElement);
};
} forEach GVAR(Optics);

View File

@ -1,6 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Scopes">
<Key ID="STR_ACE_Scopes_DisplayName">
<English>Scopes</English>
</Key>
<Key ID="STR_ACE_Scopes_enabled_displayName">
<English>Enable ACE Scope adjustment</English>
</Key>
<Key ID="STR_ACE_Scopes_enabled_description">
<English>Enable adjustmet turrets on high powered scopes</English>
</Key>
<Key ID="STR_ACE_Scopes_forceUseOfAdjustmentTurrets_displayName">
<English>Force adjustment turrets</English>
</Key>
<Key ID="STR_ACE_Scopes_forceUseOfAdjustmentTurrets_description">
<English>Force usage of adjustmet turrets on high powered scopes</English>
</Key>
<Key ID="STR_ACE_Scopes_defaultZeroRange_displayName">
<English>Default zero distance</English>
</Key>
<Key ID="STR_ACE_Scopes_defaultZeroRange_description">
<English>High power scopes will be zeroed at this distance</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceTemperature_displayName">
<English>Reference temperature</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceTemperature_description">
<English>Temperature at which the scope was zeroed</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceBarometricPressure_displayName">
<English>Reference barometric pressure</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceBarometricPressure_description">
<English>Barometric pressure at which the scope was zeroed</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceHumidity_displayName">
<English>Reference humidity</English>
</Key>
<Key ID="STR_ACE_Scopes_zeroReferenceHumidity_description">
<English>Humidity at which the scope was zeroed</English>
</Key>
<Key ID="STR_ACE_Scopes_deduceBarometricPressureFromTerrainAltitude_displayName">
<English>Deduce pressure from altitude</English>
</Key>
<Key ID="STR_ACE_Scopes_deduceBarometricPressureFromTerrainAltitude_description">
<English>Deduce the barometric pressure from the terrain altitude</English>
</Key>
<Key ID="STR_ACE_Scopes_AdjustUpMinor">
<English>Minor adjustment up</English>
<Polish>Zerowanie powoli w górę</Polish>
@ -118,5 +163,8 @@
<Czech>Vynulovat korekci</Czech>
<Japanese>ゼロインを調節</Japanese>
</Key>
<Key ID="STR_ACE_Scopes_Description">
<English>This module adds windage and elevation adjustment turrets on high power rifle scopes.</English>
</Key>
</Package>
</Project>