ACE3/addons/cargo/functions/fnc_canUnloadItem.sqf

45 lines
1.5 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal, ViperMaul
* Checks if the item can be unloaded from another object.
2015-08-10 21:07:47 +00:00
*
* 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)
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
* Can be unloaded <BOOL>
*
2015-08-16 20:41:35 +00:00
* Example:
* ["ACE_Wheel", cursorObject] call ace_cargo_fnc_canUnloadItem
2015-08-16 20:41:35 +00:00
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
params ["_item", "_vehicle", ["_unloader", objNull], ["_ignoreInteraction", false], ["_ignoreFindPosition", false]];
2016-01-19 03:53:48 +00:00
TRACE_2("params",_item,_vehicle);
2015-08-16 20:41:35 +00:00
// Get config sensitive case name
if (_item isEqualType "") then {
_item = _item call EFUNC(common,getConfigName);
};
2015-08-10 21:07:47 +00:00
if !(_item in (_vehicle getVariable [QGVAR(loaded), []])) exitWith {false};
private _validItem = if (_item isEqualType objNull) then {
alive _item
} else {
true
};
2015-08-10 21:07:47 +00:00
_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 []}}