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
*/
#include "script_component.hpp"
private ["_unit", "_target", "_weapon", "_magazine"];
_unit = _this select 0;
_target = _this select 1;
_weapon = _this select 2;
_magazine = _this select 3;
2015-03-22 13:05:31 +00:00
private "_reloadTime";
_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime");
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);
["reloadLauncher", _this select 0 select 1, _this select 0] call DEFUNC(common,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);