ACE3/addons/cargo/functions/fnc_loadItem.sqf

48 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Load object into vehicle.
* Objects loaded via classname remain virtual until unloaded.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* 0: Item <OBJECT or STRING>
2015-08-10 21:07:47 +00:00
* 1: Vehicle <OBJECT>
*
2016-06-18 09:50:41 +00:00
* Return Value:
* Object loaded <BOOL>
2015-08-10 21:07:47 +00:00
*
2015-08-16 20:41:35 +00:00
* Example:
* [object, vehicle] call ace_cargo_fnc_loadItem
*
* Public: Yes
2015-08-10 21:07:47 +00:00
*/
#include "script_component.hpp"
params [["_item","",[objNull,""]], ["_vehicle",objNull,[objNull]]];
2016-01-27 20:56:25 +00:00
TRACE_2("params",_item,_vehicle);
2015-08-16 20:41:35 +00:00
2016-01-27 20:56:25 +00:00
if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {TRACE_2("cannot load",_item,_vehicle); false};
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
TRACE_1("added to loaded array",_loaded);
2016-01-19 03:53:48 +00:00
private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
private _itemSize = [_item] call FUNC(getSizeItem);
2015-08-16 20:41:35 +00:00
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];
2015-08-10 21:07:47 +00:00
if (_item isEqualType objNull) then {
detach _item;
_item attachTo [_vehicle,[0,0,-100]];
[QEGVAR(common,hideObjectGlobal), [_item, true]] call CBA_fnc_serverEvent;
// Cars below water will take engine damage over time and eventualy become "water logged" and unfixable (because of negative z attach)
if ((getText (configFile >> "CfgVehicles" >> (typeOf _item) >> "simulation")) == "carx") then {
TRACE_1("disabling car damage",_item);
[_item, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
};
};
true