Skip to content

Commit 45aed1f

Browse files
rekterakathomjohnb432PabstMirror
authored
Advanced Ballistics - Add support for multiple muzzles (#11215)
* Add support for multiple muzzles * Add review suggestions * Apply suggestion from @PabstMirror Co-authored-by: PabstMirror <pabstmirror@gmail.com> --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
1 parent 71a26b9 commit 45aed1f

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

addons/advanced_ballistics/functions/fnc_handleFired.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if (_abort) exitWith {};
6060

6161
// Get Weapon and Ammo Configurations
6262
(_ammo call FUNC(readAmmoDataFromConfig)) params ["_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocityVariationSD"];
63-
(_weapon call FUNC(readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"];
63+
([_weapon, _muzzle] call FUNC(readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"];
6464

6565
private _temperature = nil; // We need the variable in this scope. So we need to init it here.
6666

addons/advanced_ballistics/functions/fnc_readWeaponDataFromConfig.sqf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,31 @@
55
* Reads the weapon class config and updates the config cache
66
*
77
* Arguments:
8-
* weapon - classname <STRING>
8+
* 0: Weapon <STRING>
9+
* 1: Muzzle <STRING> (optional)
910
*
1011
* Return Value:
1112
* 0: _barrelTwist <NUMBER>
1213
* 1: _twistDirection <NUMBER>
1314
* 2: _barrelLength <NUMBER>
1415
*
1516
* Example:
16-
* ["weapon"] call ace_advanced_ballistics_fnc_readWeaponDataFromConfig
17+
* [currentWeapon player, currentMuzzle player] call ace_advanced_ballistics_fnc_readWeaponDataFromConfig
1718
*
1819
* Public: No
1920
*/
2021

2122
params ["_weapon"];
2223

23-
GVAR(weaponData) getOrDefaultCall [_weapon, {
24-
private _weaponConfig = (configFile >> "CfgWeapons" >> _weapon);
24+
private _muzzle = param [1, _weapon];
25+
26+
GVAR(weaponData) getOrDefaultCall [[_weapon, _muzzle], {
27+
// For most weapons muzzle == weapon (config value of "this" for muzzle)
28+
private _weaponConfig = if (_muzzle == _weapon) then {
29+
configFile >> "CfgWeapons" >> _weapon
30+
} else {
31+
configFile >> "CfgWeapons" >> _weapon >> _muzzle
32+
};
2533

2634
private _barrelTwist = 0 max getNumber(_weaponConfig >> "ACE_barrelTwist");
2735
private _twistDirection = parseNumber (_barrelTwist != 0);

addons/scopes/functions/fnc_calculateZeroAngleCorrection.sqf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
* 1: New Zero range <NUMBER>
99
* 2: Bore height <NUMBER>
1010
* 3: Weapon <STRING>
11-
* 4: Ammo <STRING>
12-
* 5: Magazine <STRING>
13-
* 6: Advanced Ballistics enabled? <BOOL>
11+
* 4: Muzzle <STRING>
12+
* 5: Ammo <STRING>
13+
* 6: Magazine <STRING>
14+
* 7: Advanced Ballistics enabled? <BOOL>
1415
*
1516
* Return Value:
1617
* zeroAngleCorrection <NUMBER>
@@ -21,7 +22,7 @@
2122
* Public: No
2223
*/
2324

24-
params ["_oldZeroRange", "_newZeroRange", "_boreHeight"/*in cm*/, "_weapon", "_ammo", "_magazine", "_advancedBallistics"];
25+
params ["_oldZeroRange", "_newZeroRange", "_boreHeight"/*in cm*/, "_weapon", "_muzzle", "_ammo", "_magazine", "_advancedBallistics"];
2526

2627
// When FFV from vehicles currentZeroing will report 0 so just bail
2728
if (_oldZeroRange <= 0) exitWith { 0 };
@@ -46,7 +47,7 @@ GVAR(zeroAngleCorrectionData) getOrDefaultCall [[_oldZeroRange, _newZeroRange, _
4647
private _trueZero = if (_advancedBallistics) then {
4748
// Get Weapon and Ammo Configurations
4849
(_ammo call EFUNC(advanced_ballistics,readAmmoDataFromConfig)) params ["_airFriction", "_caliber", "_bulletLength", "_bulletMass", "_transonicStabilityCoef", "_dragModel", "_ballisticCoefficients", "_velocityBoundaries", "_atmosphereModel", "_ammoTempMuzzleVelocityShifts", "_muzzleVelocityTable", "_barrelLengthTable", "_muzzleVelocityVariationSD"];
49-
(_weapon call EFUNC(advanced_ballistics,readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"];
50+
([_weapon, _muzzle] call EFUNC(advanced_ballistics,readWeaponDataFromConfig)) params ["_barrelTwist", "_twistDirection", "_barrelLength"];
5051

5152
if (missionNamespace getVariable [QEGVAR(advanced_ballistics,barrelLengthInfluenceEnabled), false]) then {
5253
private _barrelVelocityShift = [_barrelLength, _muzzleVelocityTable, _barrelLengthTable, _initSpeed] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift);

addons/scopes/functions/fnc_firedEH.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (GVAR(correctZeroing) || GVAR(simplifiedZeroing)) then {
3333
private _boreHeight = (_unit getVariable [QGVAR(boreHeight), [0,0,0]]) select _weaponIndex;
3434
private _oldZeroRange = currentZeroing _unit;
3535
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
36-
private _zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);
36+
private _zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _muzzle, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);
3737

3838
_zeroing = if (GVAR(simplifiedZeroing)) then {
3939
[0, 0, _zeroCorrection - _baseAngle]

0 commit comments

Comments
 (0)