2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-20 05:45:17 +00:00
|
|
|
/*
|
2023-08-28 17:26:24 +00:00
|
|
|
* Author: esteldunedain, johnb43
|
|
|
|
* Start linking the belt.
|
2015-02-20 05:45:17 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2023-08-28 20:20:53 +00:00
|
|
|
* 0: Unit linking the belt <OBJECT>
|
2023-08-28 17:26:24 +00:00
|
|
|
* 1: Unit equipped with the weapon <OBJECT>
|
2015-02-20 05:45:17 +00:00
|
|
|
*
|
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:
|
2023-08-28 17:26:24 +00:00
|
|
|
* [player, cursorTarget] call ace_reload_fnc_startLinkingBelt
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-02-20 05:45:17 +00:00
|
|
|
*/
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
params ["_unit", "_target"];
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
if !(isNull objectParent _target) exitWith {false};
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
private _magazine = currentMagazine _target;
|
|
|
|
private _ammo = [_unit, _target] call FUNC(getAmmoToLinkBelt);
|
2016-01-06 21:42:02 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
// If _ammo is below 0 we quit
|
|
|
|
if (_ammo <= 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 = {
|
2023-08-28 17:26:24 +00:00
|
|
|
(_this select 0) params ["_unit", "_target"];
|
|
|
|
|
|
|
|
([_unit, _target, []] call EFUNC(common,canInteractWith)) && {(_unit distance _target) < 3} && {(speed _target) < 1}
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _onFinish = {
|
2023-08-28 17:26:24 +00:00
|
|
|
(_this select 0) params ["_unit", "_target", "_magazineInfo"];
|
|
|
|
|
|
|
|
// Remove the magazine with given remaining ammo; If not possible, quit
|
|
|
|
if !([_unit, _magazineInfo select 0, _magazineInfo select 1] call EFUNC(common,removeSpecificMagazine)) exitWith {
|
|
|
|
[LSTRING(BeltNotLinked)] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Raise event on remote unit
|
2023-08-28 17:26:24 +00:00
|
|
|
[QGVAR(ammoLinked), [_target, _unit, _magazineInfo], _target] call CBA_fnc_targetEvent;
|
2015-02-20 05:45:17 +00:00
|
|
|
};
|
|
|
|
|
2016-01-06 21:42:02 +00:00
|
|
|
private _onFailure = {
|
2023-08-28 17:26:24 +00:00
|
|
|
(_this select 0) params ["_unit"];
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
[_unit, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
[LSTRING(BeltNotLinked)] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
2015-02-20 05:45:17 +00:00
|
|
|
|
2023-08-28 17:26:24 +00:00
|
|
|
[_unit, "PutDown"] call EFUNC(common,doGesture);
|
2015-02-20 05:45:17 +00:00
|
|
|
|
|
|
|
// Call progress bar
|
2023-08-28 17:26:24 +00:00
|
|
|
[4, [_unit, _target, [_magazine, _ammo]], _onFinish, _onFailure, LLSTRING(LinkingBelt), _condition, ["isNotInside"]] call EFUNC(common,progressBar);
|