2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2015-08-16 20:41:35 +00:00
|
|
|
* Start unload action.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-08-10 21:07:47 +00:00
|
|
|
* None
|
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
|
|
|
* [] call ace_cargo_fnc_startUnload
|
|
|
|
*
|
2015-08-10 21:07:47 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
disableSerialization;
|
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _display = uiNamespace getVariable QGVAR(menuDisplay);
|
2015-09-27 16:19:40 +00:00
|
|
|
if (isNil "_display") exitWith {};
|
2015-08-16 20:41:35 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
|
|
|
|
if (_loaded isEqualTo []) exitWith {};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _ctrl = _display displayCtrl 100;
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _selected = (lbCurSel _ctrl) max 0;
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-08-16 20:41:35 +00:00
|
|
|
if (count _loaded <= _selected) exitWith {};
|
2017-05-05 19:02:59 +00:00
|
|
|
private _item = _loaded select _selected; // This can be an object or a classname string
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
if (GVAR(interactionParadrop)) exitWith {
|
2017-05-05 19:02:59 +00:00
|
|
|
// If drop time is 0 don't show a progress bar
|
|
|
|
if (GVAR(paradropTimeCoefficent) == 0) exitWith {
|
|
|
|
[QGVAR(paradropItem), [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent;
|
|
|
|
};
|
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
// Start progress bar - paradrop
|
|
|
|
private _size = [_item] call FUNC(getSizeItem);
|
|
|
|
[
|
2017-05-05 19:02:59 +00:00
|
|
|
GVAR(paradropTimeCoefficent) * _size,
|
2016-08-27 08:14:54 +00:00
|
|
|
[_item, GVAR(interactionVehicle), ACE_player],
|
|
|
|
{
|
|
|
|
(_this select 0) params ["_item", "_target", "_player"];
|
|
|
|
[QGVAR(paradropItem), [_item, _target]] call CBA_fnc_localEvent;
|
|
|
|
},
|
|
|
|
{
|
|
|
|
params ["_args", "", "", "_errorCode"]; // show warning if we failed because of flight conditions
|
|
|
|
if (_errorCode == 3) then {
|
|
|
|
_args params ["_item", "_target", "_player"];
|
|
|
|
[localize LSTRING(unlevelFlightWarning)] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
|
|
|
},
|
|
|
|
localize LSTRING(UnloadingItem),
|
|
|
|
{
|
|
|
|
(_this select 0) params ["_item", "_target", "_player"];
|
|
|
|
if ((acos ((vectorUp _target) select 2)) > 30) exitWith {false}; // check flight level
|
|
|
|
if (((getPos _target) select 2) < 25) exitWith {false}; // check height
|
|
|
|
if ((speed _target) < -5) exitWith {false}; // check reverse
|
|
|
|
true
|
|
|
|
},
|
|
|
|
["isNotSwimming", "isNotInside"]
|
|
|
|
] call EFUNC(common,progressBar);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Start progress bar - normal ground unload
|
2016-01-27 00:01:01 +00:00
|
|
|
if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then {
|
2016-01-19 03:53:48 +00:00
|
|
|
private _size = [_item] call FUNC(getSizeItem);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-02-23 23:24:51 +00:00
|
|
|
[
|
2018-10-13 16:59:16 +00:00
|
|
|
GVAR(loadTimeCoefficient) * _size,
|
2016-02-23 23:24:51 +00:00
|
|
|
[_item, GVAR(interactionVehicle), ACE_player],
|
2019-02-23 00:54:55 +00:00
|
|
|
{TRACE_1("unload finish",_this); ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent},
|
|
|
|
{TRACE_1("unload fail",_this);},
|
2016-02-23 23:24:51 +00:00
|
|
|
localize LSTRING(UnloadingItem),
|
2019-02-23 00:54:55 +00:00
|
|
|
{
|
|
|
|
(_this select 0) params ["_item", "_target", "_player"];
|
2021-10-12 22:42:38 +00:00
|
|
|
|
2019-02-23 00:54:55 +00:00
|
|
|
(alive _target)
|
|
|
|
&& {locked _target < 2}
|
|
|
|
&& {([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
|
|
|
&& {_item in (_target getVariable [QGVAR(loaded), []])}
|
|
|
|
},
|
2016-02-23 23:24:51 +00:00
|
|
|
["isNotSwimming"]
|
|
|
|
] call EFUNC(common,progressBar);
|
2015-09-27 16:19:40 +00:00
|
|
|
} else {
|
2021-10-12 22:42:38 +00:00
|
|
|
private _displayName = [_item, true] call FUNC(getNameItem);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2018-10-13 03:37:05 +00:00
|
|
|
[[LSTRING(UnloadingFailed), _displayName], 3] call EFUNC(common,displayTextStructured);
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|