mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
95ade30d56
* Linking belt refatoring startLinking belt now uses canLinkBelt so if condition needs to be changed then you can do it on one position. * Fixed requested change Fixed requested change * simplified it even more canLinkBelt now returns a value over 0 if success and -1 if something is not right. * Fixed bug where if error we would not exit Fixed bug where if error we would not exit * changed name on canLinkBelt Changed name to better reflect the function of the function. * Author hype * fixed return value info fixed return value info * fix header
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
/*
|
|
* Author: esteldunedain
|
|
* Start linking the belt
|
|
*
|
|
* Arguments:
|
|
* 0: Player <OBJECT>
|
|
* 1: Target <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
params ["_player", "_target"];
|
|
|
|
if (vehicle _target != _target) exitWith {false};
|
|
|
|
private _magazineType = currentMagazine _target;
|
|
|
|
|
|
private _maxAmmo = [_player, _target] call FUNC(getAmmoToLinkBelt);
|
|
|
|
//if _maxAmmo is below 0 we quit
|
|
if (_maxAmmo <= 0) exitWith {};
|
|
|
|
// Condition to call each frame
|
|
private _condition = {
|
|
(_this select 0) params ["_player", "_target"];
|
|
([_player, _target, []] call EFUNC(common,canInteractWith)) && ((_player distance _target) < 3) && ((speed _target) < 1)
|
|
};
|
|
|
|
private _onFinish = {
|
|
(_this select 0) params ["_player", "_target", "_magazine"];
|
|
|
|
// Raise event on remote unit
|
|
[QGVAR(ammoLinked), [_target, _player, _magazine], [_target]] call CBA_fnc_targetEvent;
|
|
};
|
|
|
|
private _onFailure = {
|
|
EXPLODE_3_PVT((_this select 0),_player,_target,_magazine);
|
|
[_player, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
|
|
|
// Add back the magazine with the former ammo count
|
|
_player addMagazine _magazine;
|
|
};
|
|
|
|
[_player, "PutDown"] call EFUNC(common,doGesture);
|
|
|
|
// Remove the magazine with maximum remaining ammo
|
|
[_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine);
|
|
|
|
// Call progress bar
|
|
[4, [_player, _target, [_magazineType, _maxAmmo]], _onFinish, _onFailure, (localize LSTRING(LinkingBelt)), _condition] call EFUNC(common,progressBar);
|