diff --git a/addons/advanced_ballistics/functions/fnc_handleFired.sqf b/addons/advanced_ballistics/functions/fnc_handleFired.sqf index fcfc9a2c7aa..7b59e3229e6 100644 --- a/addons/advanced_ballistics/functions/fnc_handleFired.sqf +++ b/addons/advanced_ballistics/functions/fnc_handleFired.sqf @@ -60,7 +60,7 @@ if (_abort) exitWith {}; // Get Weapon and Ammo Configurations (_ammo call FUNC(readAmmoDataFromConfig)) params ["_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocityVariationSD"]; -(_weapon call FUNC(readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"]; +([_weapon, _muzzle] call FUNC(readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"]; private _temperature = nil; // We need the variable in this scope. So we need to init it here. diff --git a/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf b/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf index 10a366f00ac..9ea28a9a818 100644 --- a/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf +++ b/addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf @@ -5,7 +5,8 @@ * Reads the weapon class config and updates the config cache * * Arguments: - * weapon - classname + * 0: Weapon + * 1: Muzzle (optional) * * Return Value: * 0: _barrelTwist @@ -13,15 +14,22 @@ * 2: _barrelLength * * Example: - * ["weapon"] call ace_advanced_ballistics_fnc_readWeaponDataFromConfig + * [currentWeapon player, currentMuzzle player] call ace_advanced_ballistics_fnc_readWeaponDataFromConfig * * Public: No */ params ["_weapon"]; -GVAR(weaponData) getOrDefaultCall [_weapon, { - private _weaponConfig = (configFile >> "CfgWeapons" >> _weapon); +private _muzzle = param [1, _weapon]; + +GVAR(weaponData) getOrDefaultCall [[_weapon, _muzzle], { + // For most weapons muzzle == weapon (config value of "this" for muzzle) + private _weaponConfig = if (_muzzle == _weapon) then { + configFile >> "CfgWeapons" >> _weapon + } else { + configFile >> "CfgWeapons" >> _weapon >> _muzzle + }; private _barrelTwist = 0 max getNumber(_weaponConfig >> "ACE_barrelTwist"); private _twistDirection = parseNumber (_barrelTwist != 0); diff --git a/addons/scopes/functions/fnc_calculateZeroAngleCorrection.sqf b/addons/scopes/functions/fnc_calculateZeroAngleCorrection.sqf index d90aa97390e..56168326654 100644 --- a/addons/scopes/functions/fnc_calculateZeroAngleCorrection.sqf +++ b/addons/scopes/functions/fnc_calculateZeroAngleCorrection.sqf @@ -8,9 +8,10 @@ * 1: New Zero range * 2: Bore height * 3: Weapon - * 4: Ammo - * 5: Magazine - * 6: Advanced Ballistics enabled? + * 4: Muzzle + * 5: Ammo + * 6: Magazine + * 7: Advanced Ballistics enabled? * * Return Value: * zeroAngleCorrection @@ -21,7 +22,7 @@ * Public: No */ -params ["_oldZeroRange", "_newZeroRange", "_boreHeight"/*in cm*/, "_weapon", "_ammo", "_magazine", "_advancedBallistics"]; +params ["_oldZeroRange", "_newZeroRange", "_boreHeight"/*in cm*/, "_weapon", "_muzzle", "_ammo", "_magazine", "_advancedBallistics"]; // When FFV from vehicles currentZeroing will report 0 so just bail if (_oldZeroRange <= 0) exitWith { 0 }; @@ -46,7 +47,7 @@ GVAR(zeroAngleCorrectionData) getOrDefaultCall [[_oldZeroRange, _newZeroRange, _ private _trueZero = if (_advancedBallistics) then { // Get Weapon and Ammo Configurations (_ammo call EFUNC(advanced_ballistics,readAmmoDataFromConfig)) params ["_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocityVariationSD"]; - (_weapon call EFUNC(advanced_ballistics,readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"]; + ([_weapon, _muzzle] call EFUNC(advanced_ballistics,readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"]; if (missionNamespace getVariable [QEGVAR(advanced_ballistics,barrelLengthInfluenceEnabled), false]) then { private _barrelVelocityShift = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _initSpeed] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift); diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index 7345d261ca2..cade0fe7244 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -33,7 +33,7 @@ if (GVAR(correctZeroing) || GVAR(simplifiedZeroing)) then { private _boreHeight = (_unit getVariable [QGVAR(boreHeight), [0,0,0]]) select _weaponIndex; private _oldZeroRange = currentZeroing _unit; private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange); - private _zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection); + private _zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _muzzle, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection); _zeroing = if (GVAR(simplifiedZeroing)) then { [0, 0, _zeroCorrection - _baseAngle]