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
|
|
|
* Checks if the item can be loaded into another object.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2023-11-17 23:07:28 +00:00
|
|
|
* 0: Item to be loaded <STRING> or <OBJECT>
|
|
|
|
* 1: Holder object (vehicle) <OBJECT>
|
|
|
|
* 2: Ignore interaction distance and stability checks <BOOL> (default: false)
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2023-11-17 23:07:28 +00:00
|
|
|
* Can be loaded <BOOL>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
2023-11-17 23:07:28 +00:00
|
|
|
* ["ACE_Wheel", cursorObject] call ace_cargo_fnc_canLoadItemIn
|
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
|
|
|
params ["_item", "_vehicle", ["_ignoreInteraction", false]];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Check if vehicle is stable
|
|
|
|
if (!_ignoreInteraction && {speed _vehicle > 1 || {((getPos _vehicle) select 2) > 3}}) exitWith {
|
|
|
|
TRACE_1("vehicle not stable",_vehicle);
|
2015-08-16 20:48:52 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
false // return
|
|
|
|
};
|
|
|
|
|
|
|
|
// If there is crew that isn't UAV crew, exit
|
|
|
|
if (_item isEqualType objNull && {(crew _item) findIf {alive _x && {!unitIsUAV _x}} != -1}) exitWith {
|
2016-11-12 23:52:17 +00:00
|
|
|
TRACE_1("item is occupied",_item);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
|
|
|
false // return
|
2016-11-12 23:52:17 +00:00
|
|
|
};
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
private _itemSize = _item call FUNC(getSizeItem);
|
|
|
|
|
|
|
|
private _validItem = if (_item isEqualType "") then {
|
|
|
|
private _config = configFile >> "CfgVehicles" >> _item;
|
|
|
|
|
|
|
|
isClass _config &&
|
|
|
|
{getNumber (_config >> QGVAR(canLoad)) == 1}
|
2015-09-27 16:19:40 +00:00
|
|
|
} else {
|
2023-11-17 23:07:28 +00:00
|
|
|
alive _item &&
|
|
|
|
{_item getVariable [QGVAR(canLoad), getNumber (configOf _item >> QGVAR(canLoad)) == 1]} &&
|
|
|
|
{_ignoreInteraction || {([_item, _vehicle] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}} &&
|
|
|
|
{!(_item getVariable [QEGVAR(cookoff,isCookingOff), false])} && // do not load items that are cooking off
|
|
|
|
{isNull (_item getVariable [QEGVAR(refuel,nozzle), objNull])} && // objects which have a refueling nozzle connected to them cannot be loaded
|
|
|
|
{isNull (_item getVariable [QEGVAR(refuel,ownedNozzle), objNull])} // fuel sources which have their nozzle out cannot be loaded
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_validItem &&
|
|
|
|
{alive _vehicle} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{locked _vehicle < 2} &&
|
|
|
|
{_vehicle getVariable [QGVAR(hasCargo), getNumber (configOf _vehicle >> QGVAR(hasCargo)) == 1]} &&
|
|
|
|
{_itemSize >= 0} &&
|
|
|
|
{_itemSize <= (_vehicle call FUNC(getCargoSpaceLeft)) max 0}
|