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:
|
2017-05-18 16:13:31 +00:00
|
|
|
* 0: Target Vehicle <OBJECT>
|
|
|
|
* 1: Unit <OBJECT>
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2017-05-18 16:13:31 +00:00
|
|
|
* [tank, player] call ace_rearm_fnc_rearm
|
2015-08-15 16:43:13 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2017-09-29 19:53:25 +00:00
|
|
|
params ["_target", "_unit"];
|
2017-06-08 16:47:52 +00:00
|
|
|
TRACE_2("rearm",_target,_unit);
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2016-02-27 20:05:19 +00:00
|
|
|
private _attachedDummy = _unit getVariable [QGVAR(dummy), objNull];
|
2017-06-08 16:47:52 +00:00
|
|
|
if (isNull _attachedDummy) exitwith {ERROR_1("attachedDummy null",_attachedDummy);};
|
2016-02-27 20:05:19 +00:00
|
|
|
private _magazineClass = _attachedDummy getVariable QGVAR(magazineClass);
|
2017-06-08 16:47:52 +00:00
|
|
|
if (isNil "_magazineClass") exitWith {ERROR_1("magazineClass nil",_attachedDummy);};
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2016-02-27 19:31:07 +00:00
|
|
|
([_magazineClass] call FUNC(getCaliber)) params ["_cal", "_idx"];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2015-08-18 00:32:10 +00:00
|
|
|
// Get magazines that can be rearmed
|
2017-09-29 19:53:25 +00:00
|
|
|
private _needRearmMags = [_target] call FUNC(getNeedRearmMagazines);
|
|
|
|
private _needRearmMagsOfClass = _needRearmMags select {(_x select 0) isEqualTo _magazineClass};
|
2015-08-18 00:32:10 +00:00
|
|
|
|
|
|
|
// Exit if no magazines need rearming
|
2017-09-29 19:53:25 +00:00
|
|
|
if ((count _needRearmMagsOfClass) == 0) exitWith {ERROR_2("Could not find turret for %1 in %2",_magazineClass,typeOf _target);};
|
|
|
|
|
|
|
|
private _currentRearmableMag = _needRearmMagsOfClass select 0;
|
|
|
|
_currentRearmableMag params ["", "_turretPath", "", "_pylon", "", "_magazineCount"];
|
2015-08-15 16:43:13 +00:00
|
|
|
|
2016-02-27 19:31:07 +00:00
|
|
|
private _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;
|
2017-09-29 19:53:25 +00:00
|
|
|
ERROR_1("Magazine is missing display name [%1]",_magazineClass);
|
2015-08-16 00:18:53 +00:00
|
|
|
};
|
|
|
|
|
2015-08-15 16:43:13 +00:00
|
|
|
[
|
2017-06-08 16:47:52 +00:00
|
|
|
TIME_PROGRESSBAR(REARM_DURATION_REARM select _idx),
|
2017-09-29 19:53:25 +00:00
|
|
|
[_target, _unit, _turretPath, _magazineCount, _magazineClass, (REARM_COUNT select _idx), _pylon],
|
2017-06-08 16:47:52 +00:00
|
|
|
{(_this select 0) call FUNC(rearmSuccess)},
|
2015-08-15 16:43:13 +00:00
|
|
|
"",
|
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);
|