2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2023-11-17 23:07:28 +00:00
|
|
|
* Starts unloading item selected in the cargo menu.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2023-11-17 23:07:28 +00:00
|
|
|
* 0: Unit doing the unloading <OBJECT>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
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:
|
2023-11-17 23:07:28 +00:00
|
|
|
* player call ace_cargo_fnc_startUnload
|
2015-08-16 20:41:35 +00:00
|
|
|
*
|
2015-08-10 21:07:47 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// This can be an object or a classname string
|
2024-02-07 12:16:18 +00:00
|
|
|
private _item = call FUNC(getSelectedItem);
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
if (isNil "_item") exitWith {};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
params ["_unit"];
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
if (GVAR(interactionParadrop)) exitWith {
|
2023-11-17 23:07:28 +00:00
|
|
|
// Close the cargo menu
|
|
|
|
closeDialog 0;
|
|
|
|
|
|
|
|
private _duration = GVAR(paradropTimeCoefficent) * (_item call FUNC(getSizeItem));
|
|
|
|
|
|
|
|
// If drop time is 0, don't show a progress bar
|
|
|
|
if (_duration <= 0) exitWith {
|
2017-05-05 19:02:59 +00:00
|
|
|
[QGVAR(paradropItem), [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent;
|
|
|
|
};
|
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
// Start progress bar - paradrop
|
2023-11-17 23:07:28 +00:00
|
|
|
// Delay execution by a frame, to avoid progress bar stopping prematurely because of the cargo menu still being open
|
|
|
|
[EFUNC(common,progressBar), [
|
|
|
|
_duration,
|
|
|
|
[_item, GVAR(interactionVehicle)],
|
2016-08-27 08:14:54 +00:00
|
|
|
{
|
2023-11-17 23:07:28 +00:00
|
|
|
[QGVAR(paradropItem), _this select 0] call CBA_fnc_localEvent;
|
2016-08-27 08:14:54 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-17 23:07:28 +00:00
|
|
|
params ["", "", "", "_errorCode"];
|
|
|
|
|
|
|
|
if (_errorCode == 3) then { // show warning if we failed because of flight conditions
|
|
|
|
[LSTRING(unlevelFlightWarning)] call EFUNC(common,displayTextStructured);
|
2016-08-27 08:14:54 +00:00
|
|
|
};
|
|
|
|
},
|
2024-01-22 22:41:46 +00:00
|
|
|
format [LLSTRING(unloadingItem), [_item, true] call FUNC(getNameItem), getText (configOf GVAR(interactionVehicle) >> "displayName")],
|
2016-08-27 08:14:54 +00:00
|
|
|
{
|
2024-02-07 12:16:18 +00:00
|
|
|
(_this select 0) params ["", "_vehicle"];
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2024-02-07 12:16:18 +00:00
|
|
|
if ((acos ((vectorUp _vehicle) select 2)) > 30) exitWith {false}; // check flight level
|
|
|
|
if (((getPos _vehicle) select 2) < 25) exitWith {false}; // check height
|
|
|
|
if ((speed _vehicle) < -5) exitWith {false}; // check reverse
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
true
|
|
|
|
},
|
2023-11-11 14:22:17 +00:00
|
|
|
["isNotSwimming", "isNotInside"],
|
|
|
|
false
|
2023-11-17 23:07:28 +00:00
|
|
|
]] call CBA_fnc_execNextFrame;
|
2016-08-27 08:14:54 +00:00
|
|
|
};
|
|
|
|
|
2023-11-21 23:44:08 +00:00
|
|
|
// If in zeus
|
2024-02-07 12:16:18 +00:00
|
|
|
if (!isNull curatorCamera) exitWith {
|
2023-11-21 23:44:08 +00:00
|
|
|
// Do not check distance to unit, but do check for valid position
|
|
|
|
if !([_item, GVAR(interactionVehicle), objNull, true] call FUNC(canUnloadItem)) exitWith {
|
|
|
|
[[LSTRING(unloadingFailed), [_item, true] call FUNC(getNameItem)], 3] call EFUNC(common,displayTextStructured);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Close the cargo menu
|
|
|
|
closeDialog 1;
|
|
|
|
|
|
|
|
["ace_unloadCargo", [_item, GVAR(interactionVehicle)]] call CBA_fnc_localEvent;
|
|
|
|
};
|
|
|
|
|
2016-08-27 08:14:54 +00:00
|
|
|
// Start progress bar - normal ground unload
|
2023-11-17 23:07:28 +00:00
|
|
|
if ([_item, GVAR(interactionVehicle), _unit] call FUNC(canUnloadItem)) then {
|
|
|
|
// Close the cargo menu
|
|
|
|
closeDialog 0;
|
|
|
|
|
|
|
|
private _duration = GVAR(loadTimeCoefficient) * (_item call FUNC(getSizeItem));
|
|
|
|
|
|
|
|
// If unload time is 0, don't show a progress bar
|
|
|
|
if (_duration <= 0) exitWith {
|
|
|
|
["ace_unloadCargo", [_item, GVAR(interactionVehicle), _unit]] call CBA_fnc_localEvent;
|
|
|
|
};
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-02-23 23:24:51 +00:00
|
|
|
[
|
2023-11-17 23:07:28 +00:00
|
|
|
_duration,
|
|
|
|
[_item, GVAR(interactionVehicle), _unit],
|
|
|
|
{
|
|
|
|
TRACE_1("unload finish",_this);
|
|
|
|
|
|
|
|
["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent;
|
|
|
|
},
|
2019-02-23 00:54:55 +00:00
|
|
|
{
|
2023-11-17 23:07:28 +00:00
|
|
|
TRACE_1("unload fail",_this);
|
|
|
|
},
|
2024-01-22 22:41:46 +00:00
|
|
|
format [LLSTRING(unloadingItem), [_item, true] call FUNC(getNameItem), getText (configOf GVAR(interactionVehicle) >> "displayName")],
|
2023-11-17 23:07:28 +00:00
|
|
|
{
|
|
|
|
(_this select 0) params ["_item", "_vehicle", "_unit"];
|
2021-10-12 22:42:38 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
[_item, _vehicle, _unit, false, true] call FUNC(canUnloadItem) // don't check for a suitable unloading position every frame
|
2019-02-23 00:54:55 +00:00
|
|
|
},
|
2016-02-23 23:24:51 +00:00
|
|
|
["isNotSwimming"]
|
|
|
|
] call EFUNC(common,progressBar);
|
2015-09-27 16:19:40 +00:00
|
|
|
} else {
|
2023-11-17 23:07:28 +00:00
|
|
|
[[LSTRING(unloadingFailed), [_item, true] call FUNC(getNameItem)], 3] call EFUNC(common,displayTextStructured);
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|