Arsenal - Fix incorrect muzzle velocity stat displayed on magazine (#6844)

* Fix incorrect muzzle velocity displayed on magazine

* Apply suggestions from code review

Co-Authored-By: dedmen <dedmen@users.noreply.github.com>

* Remove garbage file

* Script header updates

* Update addons/ballistics/functions/fnc_statTextStatement_magazineMuzzleVelocity.sqf

Co-Authored-By: dedmen <dedmen@users.noreply.github.com>
This commit is contained in:
Dedmen Miller 2019-03-05 17:42:04 +01:00 committed by PabstMirror
parent ca71375259
commit 5ad8b3c6bc
5 changed files with 55 additions and 6 deletions

View File

@ -12,7 +12,7 @@
* muzzle velocity shift - m/s <NUMBER>
*
* Example:
* [[], 5] call ace_advanced_ballistics_fnc_calcilateAmmoTemperatureVelocityShift
* [[], 5] call ace_advanced_ballistics_fnc_calculateAmmoTemperatureVelocityShift
*
* Public: No
*/

View File

@ -53,7 +53,7 @@ class EGVAR(arsenal,stats) {
stats[] = {"initSpeed"};
displayName= CSTRING(statMuzzleVelocity);
showText= 1;
textStatement = QUOTE(params[ARR_2('_stat', '_config')]; private _initSpeed = getNumber (_config >> _stat select 0); format [ARR_3('%1 m/s (%2 ft/s)', _initSpeed, (_initSpeed * 3.28084) toFixed 0)]);
textStatement = QUOTE([ARR_2(_this select 0, _this select 1)] call FUNC(statTextStatement_magazineMuzzleVelocity));
condition = QUOTE(getNumber (_this select 1 >> (_this select 0) select 0) > 0);
tabs[] = {{}, {4}};
};

View File

@ -1 +1,2 @@
PREP(statTextStatement_weaponMuzzleVelocity);
PREP(statTextStatement_magazineMuzzleVelocity);

View File

@ -0,0 +1,48 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Text statement for the magazine ammo muzzle velocity stat.
*
* Arguments:
* 0: Type what it is here <TYPE> (unused)
* 1: Item config path <CONFIG>
*
* Return Value:
* Display text <STRING>
*
* Public: No
*/
params ["", "_config"];
if (EGVAR(arsenal,currentLeftPanel) == 2002) then {
private _primaryMag = primaryWeaponMagazine EGVAR(arsenal,center);
[primaryWeapon EGVAR(arsenal,center), configName _config]
} else {
private _primaryMag = handgunMagazine EGVAR(arsenal,center);
[handgunWeapon EGVAR(arsenal,center), configName _config]
} params ["_weapon", "_magazine"];
if (_magazine isEqualTo "") then {
localize "str_empty";
} else {
private _weaponCfg = configFile >> "CfgWeapons" >> _weapon;
private _ammoCfg = (configFile >> "CfgAmmo" >> (getText (configFile >> "CfgMagazines" >> _magazine >> "ammo")));
private _barrelLength = getNumber (_weaponCfg >> "ACE_barrelLength");
private _muzzleVelocityTable = getArray (_ammoCfg >> "ACE_muzzleVelocities");
private _barrelLengthTable = getArray (_ammoCfg >> "ACE_barrelLengths");
if (_barrelLength != 0 && {count _muzzleVelocityTable > 0} && {count _barrelLengthTable > 0}) then {
private _muzzleVelocity = if (["ace_advanced_ballistics"] call EFUNC(common,isModLoaded)) then {
[_barrelLength, _muzzleVelocityTable, _barrelLengthTable, 0] call EFUNC(advanced_ballistics,calculateBarrelLengthVelocityShift);
} else {
getNumber (_config >> "initSpeed")
};
format ["%1 m/s (%2 ft/s)", _muzzleVelocity toFixed 0, (_muzzleVelocity * 3.28084) toFixed 0]
} else {
localize "str_empty";
};
};

View File

@ -1,14 +1,14 @@
#include "script_component.hpp"
/*
* Author: Alganthe
* Text statement for the weapon muzzle velocity stat
* Text statement for the weapon muzzle velocity stat.
*
* Arguments:
* 0: Not used
* 1: item config path (CONFIG)
* 0: Type what it is here <TYPE> (unused)
* 1: Item config path <CONFIG>
*
* Return Value:
* String to display
* Display text <STRING>
*
* Public: No
*/