2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-20 05:45:17 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: esteldunedain
|
2015-02-20 05:45:17 +00:00
|
|
|
* Start linking the belt
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-02-20 05:45:17 +00:00
|
|
|
* 0: Player <OBJECT>
|
|
|
|
* 1: Target <OBJECT>
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-02-20 05:45:17 +00:00
|
|
|
* None
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [bob, kevin] call ace_reload_fnc_startLinkingBelt
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-02-20 05:45:17 +00:00
|
|
|
*/
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
params ["_player", "_target"];
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
if (vehicle _target != _target) exitWith {false};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _magazineType = currentMagazine _target;
|
|
|
|
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2017-05-29 18:49:21 +00:00
|
|
|
private _maxAmmo = [_player, _target] call FUNC(getAmmoToLinkBelt);
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2017-05-29 18:49:21 +00:00
|
|
|
//if _maxAmmo is below 0 we quit
|
|
|
|
if (_maxAmmo <= 0) exitWith {};
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Condition to call each frame
|
2016-01-06 21:42:02 +00:00
|
|
|
private _condition = {
|
|
|
|
(_this select 0) params ["_player", "_target"];
|
2015-03-15 12:00:10 +00:00
|
|
|
([_player, _target, []] call EFUNC(common,canInteractWith)) && ((_player distance _target) < 3) && ((speed _target) < 1)
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _onFinish = {
|
|
|
|
(_this select 0) params ["_player", "_target", "_magazine"];
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Raise event on remote unit
|
2016-06-24 13:45:13 +00:00
|
|
|
[QGVAR(ammoLinked), [_target, _player, _magazine], [_target]] call CBA_fnc_targetEvent;
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _onFailure = {
|
2017-10-10 14:39:59 +00:00
|
|
|
(_this select 0) params ["_player", "_target", "_magazine"];
|
2015-04-18 03:40:37 +00:00
|
|
|
[_player, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Add back the magazine with the former ammo count
|
|
|
|
_player addMagazine _magazine;
|
|
|
|
};
|
|
|
|
|
2016-07-12 14:16:01 +00:00
|
|
|
[_player, "PutDown"] call EFUNC(common,doGesture);
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Remove the magazine with maximum remaining ammo
|
|
|
|
[_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine);
|
|
|
|
|
|
|
|
// Call progress bar
|
2017-08-22 18:30:56 +00:00
|
|
|
[4, [_player, _target, [_magazineType, _maxAmmo]], _onFinish, _onFailure, (localize LSTRING(LinkingBelt)), _condition, ["isNotInside"]] call EFUNC(common,progressBar);
|