mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
d1f0dc5e83
* Update CfgVehicles.hpp * Cargo cleanup * Update menu.hpp * Updated status effect key * Update fnc_onMenuOpen.sqf * Update fnc_onMenuOpen.sqf * fix comment from merge * nil interaction GVARs on menu close * fix carry bug * Fix floating objects in MP * Updated ace_cargoAdded doc * Fix progress bar prematurely stopping * Finer cursor object selection --------- Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
104 lines
3.0 KiB
Plaintext
104 lines
3.0 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: Glowbal
|
|
* Starts loading item.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit doing the loading <OBJECT>
|
|
* 1: Item to be loaded <OBJECT>
|
|
* 2: Holder object (vehicle) <OBJECT> (default: objNull)
|
|
*
|
|
* Return Value:
|
|
* Load ProgressBar Started <BOOL>
|
|
*
|
|
* Example:
|
|
* [player, cursorObject] call ace_cargo_fnc_startLoadIn
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_loader", "_item", ["_vehicle", objNull]];
|
|
TRACE_3("params",_loader,_item,_vehicle);
|
|
|
|
if (isNull _vehicle) then {
|
|
{
|
|
if ([_item, _x] call FUNC(canLoadItemIn)) exitWith {
|
|
_vehicle = _x;
|
|
};
|
|
} forEach (nearestObjects [_loader, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE + 10]);
|
|
};
|
|
|
|
if (isNull _vehicle) exitWith {
|
|
TRACE_3("Could not find vehicle",_loader,_item,_vehicle);
|
|
|
|
false // return
|
|
};
|
|
|
|
// Start progress bar
|
|
if ([_item, _vehicle] call FUNC(canLoadItemIn)) then {
|
|
private _duration = GVAR(loadTimeCoefficient) * (_item call FUNC(getSizeItem));
|
|
|
|
// If load time is 0, don't show a progress bar
|
|
if (_duration <= 0) exitWith {
|
|
["ace_loadCargo", [_item, _vehicle]] call CBA_fnc_localEvent;
|
|
|
|
true // return
|
|
};
|
|
|
|
// Claim so nobody else can interact with it
|
|
[_loader, _item, true] call EFUNC(common,claim);
|
|
|
|
[
|
|
_duration,
|
|
[_item, _vehicle],
|
|
{
|
|
TRACE_1("load finish",_this);
|
|
|
|
[objNull, _this select 0 select 0, true] call EFUNC(common,claim);
|
|
|
|
["ace_loadCargo", _this select 0] call CBA_fnc_localEvent;
|
|
},
|
|
{
|
|
TRACE_1("load fail",_this);
|
|
(_this select 0) params ["_item", "_vehicle"];
|
|
|
|
[objNull, _item, true] call EFUNC(common,claim);
|
|
|
|
// Fix cancelling loading a carried item
|
|
if (!isNull attachedTo _item) then {
|
|
detach _item;
|
|
|
|
// Prevent coliisions between item and vehicle
|
|
[QEGVAR(common,fixCollision), _vehicle, _vehicle] call CBA_fnc_targetEvent;
|
|
[QEGVAR(common,fixCollision), _item, _item] call CBA_fnc_targetEvent;
|
|
|
|
[QEGVAR(common,fixPosition), _item, _item] call CBA_fnc_targetEvent;
|
|
[QEGVAR(common,fixFloating), _item, _item] call CBA_fnc_targetEvent;
|
|
};
|
|
},
|
|
LLSTRING(loadingItem),
|
|
{
|
|
(_this select 0) call FUNC(canLoadItemIn)
|
|
},
|
|
["isNotSwimming"]
|
|
] call EFUNC(common,progressBar);
|
|
|
|
true // return
|
|
} else {
|
|
[[LSTRING(loadingFailed), [_item, true] call FUNC(getNameItem)], 3] call EFUNC(common,displayTextStructured);
|
|
|
|
// Fix cancelling loading a carried item
|
|
if (!isNull attachedTo _item) then {
|
|
detach _item;
|
|
|
|
// Prevent coliisions between item and vehicle
|
|
[QEGVAR(common,fixCollision), _vehicle, _vehicle] call CBA_fnc_targetEvent;
|
|
[QEGVAR(common,fixCollision), _item, _item] call CBA_fnc_targetEvent;
|
|
|
|
[QEGVAR(common,fixPosition), _item, _item] call CBA_fnc_targetEvent;
|
|
[QEGVAR(common,fixFloating), _item, _item] call CBA_fnc_targetEvent;
|
|
};
|
|
|
|
false // return
|
|
};
|