2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, ViperMaul
|
2015-08-16 20:41:35 +00:00
|
|
|
* Check if item can be unloaded.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-16 20:41:35 +00:00
|
|
|
* 0: loaded Object <OBJECT>
|
2015-08-10 21:07:47 +00:00
|
|
|
* 1: Object <OBJECT>
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Can be unloaded <BOOL>
|
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
|
|
|
* [item, holder] call ace_cargo_fnc_canUnloadItem
|
|
|
|
*
|
2015-08-10 21:07:47 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-14 20:46:51 +00:00
|
|
|
private ["_loaded", "_validVehiclestate", "_emptyPos"];
|
2015-08-16 20:41:35 +00:00
|
|
|
|
2015-08-10 21:07:47 +00:00
|
|
|
params ["_item", "_vehicle"];
|
2015-08-16 20:41:35 +00:00
|
|
|
|
|
|
|
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
|
|
if !(_item in _loaded) exitWith {false};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
|
|
|
_validVehiclestate = true;
|
|
|
|
_emptyPos = [];
|
|
|
|
if (_vehicle isKindOf "Ship" ) then {
|
|
|
|
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
|
|
|
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, typeOf _item]); // TODO: if spot is underwater pick another spot.
|
|
|
|
} else {
|
|
|
|
if (_vehicle isKindOf "Air" ) then {
|
|
|
|
if !(speed _vehicle <1 && {isTouchingGround _vehicle}) then {_validVehiclestate = false};
|
|
|
|
_emptyPos = (getPosASL _vehicle) call EFUNC(common,ASLtoPosition);
|
|
|
|
_emptyPos = [(_emptyPos select 0) + random(5), (_emptyPos select 1) + random(5), _emptyPos select 2 ];
|
|
|
|
} else {
|
|
|
|
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
|
|
|
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, typeOf _item]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-08-16 20:41:35 +00:00
|
|
|
if (!_validVehiclestate) exitWith {false};
|
2015-08-10 21:07:47 +00:00
|
|
|
(count _emptyPos != 0);
|