2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-02-27 19:31:07 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2016-02-27 20:12:50 +00:00
|
|
|
* Get the caliber of the ammo in a magazine and return its parameters.
|
2016-02-27 19:31:07 +00:00
|
|
|
*
|
2016-06-06 18:42:20 +00:00
|
|
|
* Arguments:
|
2016-02-27 19:31:07 +00:00
|
|
|
* 0: Magazine Classname <STRING>
|
|
|
|
*
|
2016-06-06 18:42:20 +00:00
|
|
|
* Return Value:
|
2016-02-27 19:31:07 +00:00
|
|
|
* 0: Caliber information <ARRAY>
|
|
|
|
* 0: Rounded caliber <NUMBER>
|
|
|
|
* 1: Caliber index <NUMBER>
|
|
|
|
*
|
|
|
|
* Example:
|
2016-02-27 20:05:19 +00:00
|
|
|
* ["500Rnd_127x99_mag_Tracer_Red"] call ace_rearm_fnc_getCaliber
|
2016-02-27 19:31:07 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2016-05-12 12:55:40 +00:00
|
|
|
params [
|
2017-09-29 19:53:25 +00:00
|
|
|
["_magazineClass", ""]
|
2016-05-12 12:55:40 +00:00
|
|
|
];
|
2016-02-27 19:31:07 +00:00
|
|
|
|
|
|
|
if (_magazineClass isEqualTo "") exitWith {[8, 2]};
|
|
|
|
|
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
|
|
|
|
private _tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
|
|
|
|
private _cal = 8;
|
|
|
|
if (_tmpCal > 0) then {
|
|
|
|
_cal = _tmpCal;
|
|
|
|
} else {
|
|
|
|
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(caliber));
|
|
|
|
if (_tmpCal > 0) then {
|
|
|
|
_cal = _tmpCal;
|
|
|
|
} else {
|
2019-01-31 00:31:01 +00:00
|
|
|
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, configName inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
2016-02-27 19:31:07 +00:00
|
|
|
if (_ammo isKindOf "BulletBase") then {
|
|
|
|
_cal = 8;
|
|
|
|
} else {
|
|
|
|
_cal = 100;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
_cal = round _cal;
|
|
|
|
private _idx = REARM_CALIBERS find _cal;
|
|
|
|
if (_idx == -1 ) then {
|
|
|
|
_idx = 2;
|
|
|
|
};
|
|
|
|
|
|
|
|
[_cal, _idx]
|