2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
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
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2019-01-31 00:31:01 +00:00
|
|
|
private _magazineDisplayName = _magazineClass call FUNC(getMagazineName);
|
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
|
|
|
"",
|
2021-02-18 18:58:08 +00:00
|
|
|
format [localize LSTRING(RearmAction), getText(configOf _target >> "displayName"), _magazineDisplayName],
|
2017-10-26 04:13:44 +00:00
|
|
|
{
|
|
|
|
param [0] params ["_target", "_unit"];
|
2019-09-04 00:06:50 +00:00
|
|
|
_player distance _target <= GVAR(distance);
|
2017-10-26 04:13:44 +00:00
|
|
|
},
|
2015-08-15 16:43:13 +00:00
|
|
|
["isnotinside"]
|
2015-08-18 00:32:10 +00:00
|
|
|
] call EFUNC(common,progressBar);
|