diff --git a/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf b/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf index 43b2e5cf128..e9b5f940f6d 100644 --- a/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf +++ b/addons/advanced_ballistics/functions/fnc_diagnoseWeapons.sqf @@ -65,6 +65,10 @@ for "_i" from 0 to (count _cfgWeapons)-1 do { _WeaponCacheEntry params ["_barrelTwist", "_twistDirection", "_barrelLength"]; private _barrelVelocityShift = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _vanillaInitialSpeed] call FUNC(calculateBarrelLengthVelocityShift); + if (_barrelLength > 0) then { + private _shiftedMV = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, 0] call FUNC(calculateBarrelLengthVelocityShift); + if (_shiftedMV == 0) then { ERROR_2("%1:%2 has length set but invalid mags",_weapon,_magazine)}; + }; private _abInitialSpeed = _vanillaInitialSpeed + _barrelVelocityShift; // -------------------------------------------------- diff --git a/addons/rangecard/functions/fnc_updateRangeCard.sqf b/addons/rangecard/functions/fnc_updateRangeCard.sqf index 76b679accf5..56bc9fb35b1 100644 --- a/addons/rangecard/functions/fnc_updateRangeCard.sqf +++ b/addons/rangecard/functions/fnc_updateRangeCard.sqf @@ -119,7 +119,8 @@ private _useAmmoTemperatureInfluence = ( if (_barrelLength > 0 && _useBarrelLengthInfluence) then { _muzzleVelocity = [_barrelLength, _ammoConfig select 10, _ammoConfig select 11, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift); -} else { +}; +if (_muzzleVelocity == 0) then { private _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "initSpeed"); private _initSpeedCoef = getNumber (configFile >> "CfgWeapons" >> _weaponClass >> "initSpeed"); if (_initSpeedCoef < 0) then { diff --git a/addons/xm157/functions/fnc_ballistics_getData.sqf b/addons/xm157/functions/fnc_ballistics_getData.sqf index f366216e49a..79fae7e632c 100644 --- a/addons/xm157/functions/fnc_ballistics_getData.sqf +++ b/addons/xm157/functions/fnc_ballistics_getData.sqf @@ -41,9 +41,11 @@ if ((_weaponInfo isEqualTo []) && {_magazineClass != ""}) then { ); // Get Muzzle Velocity - private _muzzleVelocity = if (_barrelLength > 0 && _useAB) then { - [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift) - } else { + private _muzzleVelocity = 0; + if (_barrelLength > 0 && _useAB) then { + _muzzleVelocity = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift) + }; + if (_muzzleVelocity == 0) then { private _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "initSpeed"); private _initSpeedCoef = getNumber (configFile >> "CfgWeapons" >> _weaponClass >> "initSpeed"); if (_initSpeedCoef < 0) then { @@ -52,7 +54,7 @@ if ((_weaponInfo isEqualTo []) && {_magazineClass != ""}) then { if (_initSpeedCoef > 0) then { _initSpeed = _initSpeedCoef; }; - _initSpeed + _muzzleVelocity = _initSpeed }; // Scope Base Angle diff --git a/extension/src/ballistics/zero.rs b/extension/src/ballistics/zero.rs index 29b4ab7f18b..e64baa696ac 100644 --- a/extension/src/ballistics/zero.rs +++ b/extension/src/ballistics/zero.rs @@ -39,6 +39,9 @@ pub fn calculate( bore_height: f64, ballistic_model: BallisticModel, ) -> f64 { + if *muzzle_velocity <= 0.0 { + return 0.0; + } let mut zero_angle = 0.0f64; let delta_time = 1.0 / 100.0f64.max(zero_range);