2015-08-15 16:43:13 +00:00
|
|
|
/*
|
|
|
|
* Author: GitHawk
|
2015-08-18 00:32:10 +00:00
|
|
|
* Starts progress bar for rearming a vehicle.
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-18 00:32:10 +00:00
|
|
|
* 0: Unit <OBJECT>
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, vehicle] call ace_rearm_fnc_rearm
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
private ["_magazineClass", "_ammo", "_tmpCal", "_cal", "_idx", "_needRearmMags", "_magazineDisplayName"];
|
2015-08-18 01:37:02 +00:00
|
|
|
params ["_unit"];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
_magazineClass = _unit getVariable QGVAR(carriedMagazine);
|
|
|
|
if (isNil "_magazineClass") exitWith {false};
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
_ammo = getText (configFile >> "CfgMagazines" >> _magazineClass >> "ammo");
|
2015-08-15 16:43:13 +00:00
|
|
|
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ace_caliber");
|
|
|
|
_cal = 8;
|
|
|
|
if (_tmpCal > 0) then {
|
|
|
|
_cal = _tmpCal;
|
|
|
|
} else {
|
2015-08-15 17:00:28 +00:00
|
|
|
_tmpCal = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(caliber));
|
2015-08-15 16:43:13 +00:00
|
|
|
if (_tmpCal > 0) then {
|
|
|
|
_cal = _tmpCal;
|
|
|
|
} else {
|
2015-08-18 00:32:10 +00:00
|
|
|
diag_log format ["[ACE] ERROR: Undefined Ammo [%1 : %2]", _ammo, inheritsFrom (configFile >> "CfgAmmo" >> _ammo)];
|
2015-08-15 16:43:13 +00:00
|
|
|
if (_ammo isKindOf "BulletBase") then {
|
|
|
|
_cal = 8;
|
|
|
|
} else {
|
|
|
|
_cal = 100;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
_cal = round _cal;
|
2015-08-18 00:32:10 +00:00
|
|
|
_idx = REARM_CALIBERS find _cal;
|
|
|
|
if (_idx == -1) then {
|
2015-08-15 16:43:13 +00:00
|
|
|
_idx = 2;
|
|
|
|
};
|
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
// Get magazines that can be rearmed
|
2015-08-18 14:20:11 +00:00
|
|
|
_needRearmMags = [_target, _magazineClass] call FUNC(getNeedRearmMagazines);
|
2015-08-18 00:32:10 +00:00
|
|
|
_needRearmMags params ["_needRearm", "_turretPath", "_cnt"];
|
|
|
|
|
|
|
|
// Exit if no magazines need rearming
|
|
|
|
if (!_needRearm) exitWith {
|
|
|
|
diag_log format ["[ACE] ERROR: Could not find turret for %1 in %2", _magazineClass, typeOf _target];
|
2015-08-15 16:43:13 +00:00
|
|
|
};
|
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
//hint format ["Magazine: %1\nAmmo: %2\nCaliber: %3\nIndex: %4\nTurretPath: %5\nREARM_DURATION_REARM: %6\nCount: %7", _magazine, _ammo, _cal, _idx, _turretPath, (REARM_DURATION_REARM select _idx), (REARM_COUNT select _idx)];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
_magazineDisplayName = getText(configFile >> "CfgMagazines" >> _magazineClass >> "displayName");
|
2015-08-16 00:18:53 +00:00
|
|
|
if (_magazineDisplayName == "") then {
|
2015-08-18 00:32:10 +00:00
|
|
|
_magazineDisplayName = _magazineClass;
|
|
|
|
diag_log format ["[ACE] ERROR: Magazine is missing display name [%1]", _magazineClass];
|
2015-08-16 00:18:53 +00:00
|
|
|
};
|
|
|
|
|
2015-08-15 16:43:13 +00:00
|
|
|
[
|
2015-08-18 00:32:10 +00:00
|
|
|
(REARM_DURATION_REARM select _idx),
|
|
|
|
[_target, _unit, _turretPath, _cnt, _magazineClass, (REARM_COUNT select _idx)],
|
2015-08-15 16:43:13 +00:00
|
|
|
FUNC(rearmSuccess),
|
|
|
|
"",
|
2015-08-16 00:18:53 +00:00
|
|
|
format [localize LSTRING(RearmAction), getText(configFile >> "CfgVehicles" >> (typeOf _target) >> "displayName"), _magazineDisplayName],
|
2015-08-15 16:43:13 +00:00
|
|
|
{true},
|
|
|
|
["isnotinside"]
|
2015-08-18 00:32:10 +00:00
|
|
|
] call EFUNC(common,progressBar);
|