ACE3/addons/cargo/functions/fnc_canUnloadItem.sqf
johnb432 d1f0dc5e83
Cargo - Improve various aspects (#9617)
* Update CfgVehicles.hpp

* Cargo cleanup

* Update menu.hpp

* Updated status effect key

* Update fnc_onMenuOpen.sqf

* Update fnc_onMenuOpen.sqf

* fix comment from merge

* nil interaction GVARs on menu close

* fix carry bug

* Fix floating objects in MP

* Updated ace_cargoAdded doc

* Fix progress bar prematurely stopping

* Finer cursor object selection

---------

Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
2023-11-17 20:07:28 -03:00

45 lines
1.5 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal, ViperMaul
* Checks if the item can be unloaded from another object.
*
* Arguments:
* 0: Item to be unloaded <STRING> or <OBJECT>
* 1: Holder object (vehicle) <OBJECT>
* 2: Unit doing the unloading <OBJECT> (default: objNull)
* 3: Ignore interaction distance and stability checks <BOOL> (default: false)
* 4: Ignore finding a suitable position <BOOL> (default: false)
*
* Return Value:
* Can be unloaded <BOOL>
*
* Example:
* ["ACE_Wheel", cursorObject] call ace_cargo_fnc_canUnloadItem
*
* Public: No
*/
params ["_item", "_vehicle", ["_unloader", objNull], ["_ignoreInteraction", false], ["_ignoreFindPosition", false]];
TRACE_2("params",_item,_vehicle);
// Get config sensitive case name
if (_item isEqualType "") then {
_item = _item call EFUNC(common,getConfigName);
};
if !(_item in (_vehicle getVariable [QGVAR(loaded), []])) exitWith {false};
private _validItem = if (_item isEqualType objNull) then {
alive _item
} else {
true
};
_validItem &&
{alive _vehicle} &&
{locked _vehicle < 2} &&
{_vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1]} &&
{_item call FUNC(getSizeItem) >= 0} &&
{_ignoreInteraction || {([_unloader, _vehicle] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}} &&
{_ignoreFindPosition || {([_vehicle, _item, _unloader, MAX_LOAD_DISTANCE, !_ignoreInteraction] call EFUNC(common,findUnloadPosition)) isNotEqualTo []}}