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
|
|
|
* Loads an object into a vehicle.
|
2015-09-27 16:19:40 +00:00
|
|
|
* Objects loaded via classname remain virtual until unloaded.
|
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> (default: "")
|
|
|
|
* 1: Holder object (vehicle) <OBJECT> (default: objNull)
|
|
|
|
* 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:
|
2015-08-16 20:48:52 +00:00
|
|
|
* Object 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_loadItem
|
2015-08-16 20:41:35 +00:00
|
|
|
*
|
2017-06-08 19:31:27 +00:00
|
|
|
* Public: Yes
|
2015-08-10 21:07:47 +00:00
|
|
|
*/
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
params [["_item", "", [objNull, ""]], ["_vehicle", objNull, [objNull]], ["_ignoreInteraction", false, [false]]];
|
|
|
|
TRACE_3("params",_item,_vehicle,_ignoreInteraction);
|
2015-08-16 20:41:35 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Get config sensitive case name
|
|
|
|
if (_item isEqualType "") then {
|
|
|
|
_item = _item call EFUNC(common,getConfigName);
|
|
|
|
};
|
|
|
|
|
|
|
|
if !([_item, _vehicle, _ignoreInteraction] call FUNC(canLoadItemIn)) exitWith {
|
|
|
|
TRACE_3("cannot load",_item,_vehicle,_ignoreInteraction);
|
|
|
|
|
|
|
|
false // return
|
|
|
|
};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
2015-11-30 16:21:28 +00:00
|
|
|
_loaded pushBack _item;
|
2015-08-16 20:41:35 +00:00
|
|
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_1("added to loaded array",_loaded);
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Update cargo space remaining
|
|
|
|
private _cargoSpace = _vehicle call FUNC(getCargoSpaceLeft);
|
|
|
|
private _itemSize = (_item call FUNC(getSizeItem)) max 0; // don't let negative size items increase space
|
|
|
|
_vehicle setVariable [QGVAR(space), _cargoSpace - _itemSize, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Attach object 100m below vehicle
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_item isEqualType objNull) then {
|
2015-09-27 16:19:40 +00:00
|
|
|
detach _item;
|
2023-11-17 23:07:28 +00:00
|
|
|
_item attachTo [_vehicle, [0, 0, -100]];
|
2016-06-03 19:38:16 +00:00
|
|
|
[QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent;
|
2020-10-10 16:58:38 +00:00
|
|
|
|
2023-11-11 00:13:53 +00:00
|
|
|
if (["ace_zeus"] call EFUNC(common,isModLoaded)) then {
|
|
|
|
private _objectCurators = objectCurators _item;
|
|
|
|
|
|
|
|
// Save which curators had this object as editable
|
|
|
|
_item setVariable [QGVAR(objectCurators), _objectCurators, true];
|
|
|
|
|
|
|
|
if (_objectCurators isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
[QEGVAR(zeus,removeObjects), [[_item], _objectCurators]] call CBA_fnc_serverEvent;
|
|
|
|
};
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Some objects below water will take damage over time, eventually becoming "water logged" and unfixable (because of negative z attach)
|
|
|
|
[_item, "blockDamage", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|
2015-08-18 16:48:21 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Invoke listenable event
|
|
|
|
["ace_cargoLoaded", [_item, _vehicle]] call CBA_fnc_globalEvent;
|
|
|
|
|
|
|
|
true // return
|