ACE3/addons/reloadlaunchers/functions/fnc_load.sqf

49 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-03-18 19:17:53 +00:00
/*
* Author: commy2
* Reload a launcher
*
* Argument:
* 0: Unit with magazine (Object)
* 1: Unit with launcher (Object)
* 2: weapon name (String)
* 3: missile name (String)
*
* Return value:
* NONE
2016-04-28 03:58:47 +00:00
*
* Public: No
2015-03-18 19:17:53 +00:00
*/
#include "script_component.hpp"
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
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
private ["_onSuccess", "_onFailure", "_condition"];
_onSuccess = {
(_this select 0 select 0) removeMagazine (_this select 0 select 3);
2016-05-24 13:13:11 +00:00
["ace_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
};
_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
};
_condition = {
(_this select 0) call DFUNC(canLoad) && {(_this select 0 select 0) distance (_this select 0 select 1) < 4}
};
2015-05-28 19:59:04 +00:00
[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, localize LSTRING(LoadingLauncher), _condition] call EFUNC(common,progressBar);