ACE3/addons/rearm/functions/fnc_rearm.sqf

51 lines
1.6 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:
* 0: Unit <OBJECT>
2015-08-15 16:43:13 +00:00
*
* Return Value:
* None
*
* Example:
2015-08-21 20:57:14 +00:00
* [player] call ace_rearm_fnc_rearm
2015-08-15 16:43:13 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2016-02-01 19:05:53 +00:00
params [["_unit", objNull, [objNull]]];
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 {false};
private _magazineClass = _attachedDummy getVariable QGVAR(magazineClass);
if (isNil "_magazineClass") exitWith {false};
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
2016-02-27 19:31:07 +00:00
private _needRearmMags = [_target, _magazineClass] call FUNC(getNeedRearmMagazines);
_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
};
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;
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
[
(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"]
] call EFUNC(common,progressBar);