ACE3/addons/rearm/functions/fnc_rearm.sqf

54 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-08-15 16:43:13 +00:00
/*
* Author: GitHawk
* 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"
params ["_target", "_unit"];
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];
if (isNull _attachedDummy) exitwith {ERROR_1("attachedDummy null",_attachedDummy);};
2016-02-27 20:05:19 +00:00
private _magazineClass = _attachedDummy getVariable QGVAR(magazineClass);
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
// Get magazines that can be rearmed
private _needRearmMags = [_target] call FUNC(getNeedRearmMagazines);
private _needRearmMagsOfClass = _needRearmMags select {(_x select 0) isEqualTo _magazineClass};
// Exit if no magazines need rearming
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 {
_magazineDisplayName = _magazineClass;
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
[
TIME_PROGRESSBAR(REARM_DURATION_REARM select _idx),
[_target, _unit, _turretPath, _magazineCount, _magazineClass, (REARM_COUNT select _idx), _pylon],
{(_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"]
] call EFUNC(common,progressBar);