mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1441 from acemod/rangeCardFixes
Improved error handling when AB is enabled with incomplete configs
This commit is contained in:
commit
08b779956d
@ -24,7 +24,9 @@
|
|||||||
* 18: Stability factor <NUMBER>
|
* 18: Stability factor <NUMBER>
|
||||||
* 19: Twist Direction <NUMBER>
|
* 19: Twist Direction <NUMBER>
|
||||||
* 20: Latitude <NUMBER>
|
* 20: Latitude <NUMBER>
|
||||||
* 21: Range Card Slot <NUMBER>
|
* 21: Direction of Fire <NUMBER>
|
||||||
|
* 22: Range Card Slot <NUMBER>
|
||||||
|
* 23: Use advanced ballistics config? <BOOL>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* 0: Elevation (MOA) <NUMBER>
|
* 0: Elevation (MOA) <NUMBER>
|
||||||
@ -44,7 +46,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_scopeBaseAngle", "_bulletMass", "_boreHeight", "_airFriction", "_muzzleVelocity", "_temperature", "_barometricPressure", "_relativeHumidity", "_simSteps", "_windSpeed1", "_windSpeed2", "_windDirection", "_inclinationAngle", "_targetSpeed", "_targetRange", "_drag", "_bc", "_dragModel", "_atmosphereModel", "_storeRangeCardData", "_stabilityFactor", "_twistDirection", "_latitude", "_directionOfFire", "_rangeCardSlot"];
|
private ["_scopeBaseAngle", "_bulletMass", "_boreHeight", "_airFriction", "_muzzleVelocity", "_temperature", "_barometricPressure", "_relativeHumidity", "_simSteps", "_windSpeed1", "_windSpeed2", "_windDirection", "_inclinationAngle", "_targetSpeed", "_targetRange", "_drag", "_bc", "_dragModel", "_atmosphereModel", "_storeRangeCardData", "_stabilityFactor", "_twistDirection", "_latitude", "_directionOfFire", "_rangeCardSlot", "_useABConfig"];
|
||||||
_scopeBaseAngle = _this select 0;
|
_scopeBaseAngle = _this select 0;
|
||||||
_bulletMass = _this select 1;
|
_bulletMass = _this select 1;
|
||||||
_boreHeight = _this select 2;
|
_boreHeight = _this select 2;
|
||||||
@ -69,6 +71,7 @@ _twistDirection = _this select 19;
|
|||||||
_latitude = _this select 20;
|
_latitude = _this select 20;
|
||||||
_directionOfFire = _this select 21;
|
_directionOfFire = _this select 21;
|
||||||
_rangeCardSlot = _this select 22;
|
_rangeCardSlot = _this select 22;
|
||||||
|
_useABConfig = _this select 23;
|
||||||
|
|
||||||
if (_storeRangeCardData) then {
|
if (_storeRangeCardData) then {
|
||||||
GVAR(rangeCardDataMVs) set [_rangeCardSlot, format[" %1", round(_muzzleVelocity)]];
|
GVAR(rangeCardDataMVs) set [_rangeCardSlot, format[" %1", round(_muzzleVelocity)]];
|
||||||
@ -109,10 +112,17 @@ private ["_wind1", "_wind2", "_windDrift"];
|
|||||||
_wind1 = [cos(270 - _windDirection * 30) * _windSpeed1, sin(270 - _windDirection * 30) * _windSpeed1, 0];
|
_wind1 = [cos(270 - _windDirection * 30) * _windSpeed1, sin(270 - _windDirection * 30) * _windSpeed1, 0];
|
||||||
_wind2 = [cos(270 - _windDirection * 30) * _windSpeed2, sin(270 - _windDirection * 30) * _windSpeed2, 0];
|
_wind2 = [cos(270 - _windDirection * 30) * _windSpeed2, sin(270 - _windDirection * 30) * _windSpeed2, 0];
|
||||||
_windDrift = 0;
|
_windDrift = 0;
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (_useABConfig) then {
|
||||||
_bc = [_bc, _temperature, _barometricPressure, _relativeHumidity, _atmosphereModel] call EFUNC(advanced_ballistics,calculateAtmosphericCorrection);
|
_bc = [_bc, _temperature, _barometricPressure, _relativeHumidity, _atmosphereModel] call EFUNC(advanced_ballistics,calculateAtmosphericCorrection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private ["_airFrictionCoef", "_airDensity"];
|
||||||
|
_airFrictionCoef = 1;
|
||||||
|
if (!_useABConfig && (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false])) then {
|
||||||
|
_airDensity = [_temperature, _barometricPressure, _relativeHumidity] call EFUNC(weather,calculateAirDensity);
|
||||||
|
_airFrictionCoef = _airDensity / 1.22498;
|
||||||
|
};
|
||||||
|
|
||||||
private ["_speedTotal", "_stepsTotal", "_speedAverage"];
|
private ["_speedTotal", "_stepsTotal", "_speedAverage"];
|
||||||
_speedTotal = 0;
|
_speedTotal = 0;
|
||||||
_stepsTotal = 0;
|
_stepsTotal = 0;
|
||||||
@ -139,7 +149,7 @@ while {_TOF < 6 && (_bulletPos select 1) < _targetRange} do {
|
|||||||
_trueVelocity = _bulletVelocity vectorDiff _wind1;
|
_trueVelocity = _bulletVelocity vectorDiff _wind1;
|
||||||
_trueSpeed = vectorMagnitude _trueVelocity;
|
_trueSpeed = vectorMagnitude _trueVelocity;
|
||||||
|
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (_useABConfig) then {
|
||||||
_drag = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,extensionAvailable), false]) then {
|
_drag = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,extensionAvailable), false]) then {
|
||||||
parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3", _dragModel, _bc, _trueSpeed]))
|
parseNumber(("ace_advanced_ballistics" callExtension format["retard:%1:%2:%3", _dragModel, _bc, _trueSpeed]))
|
||||||
} else {
|
} else {
|
||||||
@ -147,7 +157,7 @@ while {_TOF < 6 && (_bulletPos select 1) < _targetRange} do {
|
|||||||
};
|
};
|
||||||
_bulletAccel = (vectorNormalized _trueVelocity) vectorMultiply (-1 * _drag);
|
_bulletAccel = (vectorNormalized _trueVelocity) vectorMultiply (-1 * _drag);
|
||||||
} else {
|
} else {
|
||||||
_bulletAccel = _trueVelocity vectorMultiply (_trueSpeed * _airFriction);
|
_bulletAccel = _trueVelocity vectorMultiply (_trueSpeed * _airFriction * _airFrictionCoef);
|
||||||
};
|
};
|
||||||
|
|
||||||
_bulletAccel = _bulletAccel vectorAdd _gravity;
|
_bulletAccel = _bulletAccel vectorAdd _gravity;
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
disableSerialization;
|
disableSerialization;
|
||||||
#define __dsp (uiNamespace getVariable "RangleCard_Display")
|
#define __dsp (uiNamespace getVariable "RangleCard_Display")
|
||||||
|
|
||||||
private ["_airFriction", "_ammoConfig", "_atmosphereModel", "_barometricPressure", "_barrelLength", "_barrelTwist", "_bc", "_boreHeight", "_cacheEntry", "_column", "_control", "_dragModel", "_i", "_muzzleVelocity", "_mv", "_mvShift", "_offset", "_relativeHumidity", "_result", "_row", "_scopeBaseAngle", "_weaponConfig", "_zeroRange", "_initSpeed", "_initSpeedCoef"];
|
private ["_airFriction", "_ammoConfig", "_atmosphereModel", "_barometricPressure", "_barrelLength", "_barrelTwist", "_bc", "_bulletMass", "_boreHeight", "_cacheEntry", "_column", "_control", "_dragModel", "_i", "_muzzleVelocity", "_mv", "_mvShift", "_offset", "_relativeHumidity", "_result", "_row", "_scopeBaseAngle", "_weaponConfig", "_zeroRange", "_initSpeed", "_initSpeedCoef", "_useABConfig"];
|
||||||
|
_useABConfig = (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]);
|
||||||
|
|
||||||
PARAMS_3(_ammoClass,_magazineClass,_weaponClass);
|
PARAMS_3(_ammoClass,_magazineClass,_weaponClass);
|
||||||
|
|
||||||
@ -80,14 +81,6 @@ lnbClear 770200;
|
|||||||
lnbClear 770300;
|
lnbClear 770300;
|
||||||
lnbClear 770400;
|
lnbClear 770400;
|
||||||
|
|
||||||
lnbAddRow [770100, ["4mps Wind(MRADs)", "1mps LEAD(MRADs)"]];
|
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
|
||||||
lnbAddRow [770100, ["Air/Ammo Temp", "Air/Ammo Temp"]];
|
|
||||||
|
|
||||||
lnbAddRow [770200, ["-15°C", " -5°C", " 5°C", " 10°C", " 15°C", " 20°C", " 25°C", " 30°C", " 35°C"]];
|
|
||||||
lnbAddRow [770300, ["-15°C", " 10°C", " 35°C", "-15°C", " 10°C", " 35°C"]];
|
|
||||||
};
|
|
||||||
|
|
||||||
GVAR(rangeCardDataElevation) = [[], [], [], [], [], [], [], [], []];
|
GVAR(rangeCardDataElevation) = [[], [], [], [], [], [], [], [], []];
|
||||||
GVAR(rangeCardDataWindage) = [[], [], [], [], [], [], [], [], []];
|
GVAR(rangeCardDataWindage) = [[], [], [], [], [], [], [], [], []];
|
||||||
GVAR(rangeCardDataLead) = [[], [], [], [], [], [], [], [], []];
|
GVAR(rangeCardDataLead) = [[], [], [], [], [], [], [], [], []];
|
||||||
@ -105,7 +98,22 @@ _airFriction = _ammoConfig select 0;
|
|||||||
_barrelTwist = _weaponConfig select 0;
|
_barrelTwist = _weaponConfig select 0;
|
||||||
_barrelLength = _weaponConfig select 2;
|
_barrelLength = _weaponConfig select 2;
|
||||||
_muzzleVelocity = 0;
|
_muzzleVelocity = 0;
|
||||||
if (_barrelLength > 0 && missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
|
||||||
|
_bc = 0;
|
||||||
|
if (count (_ammoConfig select 6) > 0) then {
|
||||||
|
_bc = (_ammoConfig select 6) select 0;
|
||||||
|
};
|
||||||
|
_dragModel = _ammoConfig select 5;
|
||||||
|
_atmosphereModel = _ammoConfig select 8;
|
||||||
|
_bulletMass = 5;
|
||||||
|
_boreHeight = 3.81;
|
||||||
|
_zeroRange = 100;
|
||||||
|
|
||||||
|
if (_bc == 0) then {
|
||||||
|
_useABConfig = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_barrelLength > 0 && _useABConfig) then {
|
||||||
_muzzleVelocity = [_barrelLength, _ammoConfig select 10, _ammoConfig select 11, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift);
|
_muzzleVelocity = [_barrelLength, _ammoConfig select 10, _ammoConfig select 11, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift);
|
||||||
} else {
|
} else {
|
||||||
_initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "initSpeed");
|
_initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "initSpeed");
|
||||||
@ -119,7 +127,7 @@ if (_barrelLength > 0 && missionNamespace getVariable [QEGVAR(advanced_ballistic
|
|||||||
_muzzleVelocity = _initSpeed;
|
_muzzleVelocity = _initSpeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (_useABConfig) then {
|
||||||
ctrlSetText [770000, format["%1'' - %2 gr (%3)", round((_ammoConfig select 1) * 39.3700787) / 1000, round((_ammoConfig select 3) * 15.4323584), _ammoClass]];
|
ctrlSetText [770000, format["%1'' - %2 gr (%3)", round((_ammoConfig select 1) * 39.3700787) / 1000, round((_ammoConfig select 3) * 15.4323584), _ammoClass]];
|
||||||
if (_barrelLength > 0 && _barrelTwist > 0) then {
|
if (_barrelLength > 0 && _barrelTwist > 0) then {
|
||||||
ctrlSetText [770002, format["Barrel: %1'' 1:%2'' twist", round(_barrelLength * 0.0393700787), round(_barrelTwist * 0.0393700787)]];
|
ctrlSetText [770002, format["Barrel: %1'' 1:%2'' twist", round(_barrelLength * 0.0393700787), round(_barrelTwist * 0.0393700787)]];
|
||||||
@ -128,14 +136,16 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
ctrlSetText [770000, getText (configFile >> "CfgMagazines" >> _magazineClass >> "displayNameShort")];
|
ctrlSetText [770000, getText (configFile >> "CfgMagazines" >> _magazineClass >> "displayNameShort")];
|
||||||
ctrlSetText [770002, ""];
|
ctrlSetText [770002, getText (configFile >> "CfgWeapons" >> _weaponClass >> "displayName")];
|
||||||
};
|
};
|
||||||
|
|
||||||
_bc = (_ammoConfig select 6) select 0;
|
lnbAddRow [770100, ["4mps Wind(MRADs)", "1mps LEAD(MRADs)"]];
|
||||||
_dragModel = _ammoConfig select 5;
|
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||||
_atmosphereModel = _ammoConfig select 8;
|
lnbAddRow [770100, ["Air/Ammo Temp", "Air/Ammo Temp"]];
|
||||||
_boreHeight = 3.81;
|
|
||||||
_zeroRange = 100;
|
lnbAddRow [770200, ["-15°C", " -5°C", " 5°C", " 10°C", " 15°C", " 20°C", " 25°C", " 30°C", " 35°C"]];
|
||||||
|
lnbAddRow [770300, ["-15°C", " 10°C", " 35°C", "-15°C", " 10°C", " 35°C"]];
|
||||||
|
};
|
||||||
|
|
||||||
_barometricPressure = 1013.25;
|
_barometricPressure = 1013.25;
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||||
@ -147,27 +157,23 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t
|
|||||||
ctrlSetText [770001, format["Drop Tables for B.P.: %1mb; Corrected for MVV at Air/Ammo Temperatures -15-35 °C", round(_barometricPressure * 100) / 100]];
|
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 [77004 , format["B.P.: %1mb", round(_barometricPressure * 100) / 100]];
|
||||||
} else {
|
} else {
|
||||||
ctrlSetText [770001, getText (configFile >> "CfgWeapons" >> _weaponClass >> "displayName")];
|
ctrlSetText [770001, ""];
|
||||||
ctrlSetText [77004 , ""];
|
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), _ammoClass, _weaponClass, missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]];
|
||||||
if (isNil {_cacheEntry}) then {
|
if (isNil {_cacheEntry}) then {
|
||||||
|
_result = [0, 0, _boreHeight, _airFriction, _muzzleVelocity, 15, 1013.25, 0.5, 1000, [0, 0], 0, 0, 0, _zeroRange, _bc, _dragModel, _atmosphereModel, false, 1.5, 0, 0, 0, 0, _useABConfig] call FUNC(calculateSolution);
|
||||||
|
_scopeBaseAngle = (_result select 0) / 60;
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
||||||
{
|
{
|
||||||
_mvShift = [_ammoConfig select 9, _x] call EFUNC(advanced_ballistics,calculateAmmoTemperatureVelocityShift);
|
_mvShift = [_ammoConfig select 9, _x] call EFUNC(advanced_ballistics,calculateAmmoTemperatureVelocityShift);
|
||||||
_mv = _muzzleVelocity + _mvShift;
|
_mv = _muzzleVelocity + _mvShift;
|
||||||
|
|
||||||
_result = [0, 0, _boreHeight, _airFriction, _mv, _x, 1013.25, 0.5, 1000, [0, 0], 0, 0, 0, _zeroRange, _bc, _dragModel, _atmosphereModel, false, 1.5, 0, 0, 0] call FUNC(calculateSolution);
|
[_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 = (_result select 0) / 60;
|
|
||||||
|
|
||||||
[_scopeBaseAngle,27,_boreHeight,_airFriction,_mv,_x,_barometricPressure,_relativeHumidity,1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,_forEachIndex] call FUNC(calculateSolution);
|
|
||||||
} forEach [-15, -5, 5, 10, 15, 20, 25, 30, 35];
|
} forEach [-15, -5, 5, 10, 15, 20, 25, 30, 35];
|
||||||
} else {
|
} else {
|
||||||
_result = [0, 0, _boreHeight, _airFriction, _muzzleVelocity, _x, 1013.25, 0.5, 1000, [0, 0], 0, 0, 0, _zeroRange, _bc, _dragModel, _atmosphereModel, false, 1.5, 0, 0, 0] call FUNC(calculateSolution);
|
[_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,3,_useABConfig] call FUNC(calculateSolution);
|
||||||
_scopeBaseAngle = (_result select 0) / 60;
|
|
||||||
|
|
||||||
[_scopeBaseAngle,27,_boreHeight,_airFriction,_muzzleVelocity,_x,_barometricPressure,_relativeHumidity,1000,[4,0],3,0,1,GVAR(rangeCardEndRange),_bc,_dragModel,_atmosphereModel,true,1.5,1,46,23,3] call FUNC(calculateSolution);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for "_i" from 0 to 9 do {
|
for "_i" from 0 to 9 do {
|
||||||
@ -234,7 +240,7 @@ for "_column" from 0 to 8 do {
|
|||||||
};
|
};
|
||||||
} forEach [0, 3, 8];
|
} forEach [0, 3, 8];
|
||||||
|
|
||||||
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
if (_useABConfig) then {
|
||||||
ctrlSetText [770020, "For best results keep ammunition at ambient air temperature. Tables calculated for the above listed barrel"];
|
ctrlSetText [770020, "For best results keep ammunition at ambient air temperature. Tables calculated for the above listed barrel"];
|
||||||
ctrlSetText [770021, "and load with optic mounted 1.5'' above line of bore."];
|
ctrlSetText [770021, "and load with optic mounted 1.5'' above line of bore."];
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user