2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-18 19:17:53 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Reload a launcher
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2017-06-08 13:31:51 +00:00
|
|
|
* 0: Unit with magazine <OBJECT>
|
|
|
|
* 1: Unit with launcher <OBJECT>
|
|
|
|
* 2: weapon name <STRING>
|
|
|
|
* 3: missile name <STRING>
|
2015-03-18 19:17:53 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [bob, kevin, "weapon", "missile"] call ace_reloadlaunchers_fnc_load
|
2016-04-28 03:58:47 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-03-18 19:17:53 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-28 03:58:47 +00:00
|
|
|
params ["_unit", "_target", "_weapon", "_magazine"];
|
|
|
|
TRACE_4("params",_unit,_target,_weapon,_magazine);
|
2015-03-18 19:17:53 +00:00
|
|
|
|
2016-05-04 04:13:43 +00:00
|
|
|
private _reloadTime = if (isNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(buddyReloadTime))) then {
|
|
|
|
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(buddyReloadTime))
|
|
|
|
} else {
|
|
|
|
2.5
|
|
|
|
};
|
2015-03-18 19:17:53 +00:00
|
|
|
|
2015-03-22 13:05:31 +00:00
|
|
|
// do animation
|
|
|
|
[_unit] call EFUNC(common,goKneeling);
|
2015-03-18 19:17:53 +00:00
|
|
|
|
2015-03-22 13:05:31 +00:00
|
|
|
// show progress bar
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _onSuccess = {
|
2015-03-22 13:05:31 +00:00
|
|
|
(_this select 0 select 0) removeMagazine (_this select 0 select 3);
|
2016-05-25 18:13:36 +00:00
|
|
|
[QGVAR(reloadLauncher), _this select 0, _this select 0 select 1] call CBA_fnc_targetEvent;
|
2015-03-22 13:05:31 +00:00
|
|
|
|
2015-05-28 19:59:04 +00:00
|
|
|
[localize LSTRING(LauncherLoaded)] call DEFUNC(common,displayTextStructured);
|
2015-03-22 13:05:31 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _onFailure = {
|
2015-07-13 20:12:54 +00:00
|
|
|
[localize ELSTRING(common,ActionAborted)] call DEFUNC(common,displayTextStructured);
|
2015-03-22 13:05:31 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _condition = {
|
2015-03-22 13:05:31 +00:00
|
|
|
(_this select 0) call DFUNC(canLoad) && {(_this select 0 select 0) distance (_this select 0 select 1) < 4}
|
|
|
|
};
|
|
|
|
|
2017-08-22 18:30:56 +00:00
|
|
|
[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, localize LSTRING(LoadingLauncher), _condition, ["isNotInside", "isNotSwimming"]] call EFUNC(common,progressBar);
|