Skip to content

Commit

Permalink
Cargo - Add condition checking durring load/unload (#6821)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror authored Feb 23, 2019
1 parent 860fa0f commit ec840a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
13 changes: 6 additions & 7 deletions addons/cargo/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ GVAR(objectAction) = [
{locked _target < 2} &&
{alive _target} &&
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
{0 < {
private _type = typeOf _x;
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
(_hasCargoPublic || _hasCargoConfig) && {_x != _target} &&
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
} count (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)])}
{((nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) findIf {
private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo));
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
(_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} && {alive _x} && {locked _x < 2} &&
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
}) > -1}
},
LINKFUNC(addCargoVehiclesActions)
] call EFUNC(interact_menu,createAction);
Expand Down
2 changes: 1 addition & 1 deletion addons/cargo/functions/fnc_addCargoVehiclesActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private _statement = {
private _vehicles = (nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) select {
private _hasCargoConfig = 1 == getNumber (configFile >> "CfgVehicles" >> typeOf _x >> QGVAR(hasCargo));
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
(_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} &&
(_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} && {alive _x} && {locked _x < 2} &&
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
};

Expand Down
12 changes: 10 additions & 2 deletions addons/cargo/functions/fnc_startLoadIn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ if ([_object, _vehicle] call FUNC(canLoadItemIn)) then {
GVAR(loadTimeCoefficient) * _size,
[_object, _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;
},
{[objNull, _this select 0 select 0, true] call EFUNC(common,claim)},
{
TRACE_1("load fail",_this);
[objNull, _this select 0 select 0, true] call EFUNC(common,claim)
},
localize LSTRING(LoadingItem),
{true},
{
(_this select 0) params ["_item", "_target"];
(alive _target) && {locked _target < 2} && {alive _item}
&& {([_item, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
},
["isNotSwimming"]
] call EFUNC(common,progressBar);
_return = true;
Expand Down
13 changes: 10 additions & 3 deletions addons/cargo/functions/fnc_startUnload.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then
[
GVAR(loadTimeCoefficient) * _size,
[_item, GVAR(interactionVehicle), ACE_player],
{["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent},
{},
{TRACE_1("unload finish",_this); ["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent},
{TRACE_1("unload fail",_this);},
localize LSTRING(UnloadingItem),
{true},
{
(_this select 0) params ["_item", "_target", "_player"];

(alive _target)
&& {locked _target < 2}
&& {([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
&& {_item in (_target getVariable [QGVAR(loaded), []])}
},
["isNotSwimming"]
] call EFUNC(common,progressBar);
} else {
Expand Down

0 comments on commit ec840a7

Please sign in to comment.