Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo - paradrop fixes #8203

Merged
merged 10 commits into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions addons/cargo/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@

[[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured);

if (_unloaded) then {
// Invoke listenable event
["ace_cargoUnloaded", [_item, _vehicle]] call CBA_fnc_globalEvent;
};

// TOOO maybe drag/carry the unloaded item?
}] call CBA_fnc_addEventHandler;
Expand Down
19 changes: 9 additions & 10 deletions addons/cargo/functions/fnc_paradropItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ TRACE_1("",_distBehind);
private _posBehindVehicleAGL = _vehicle modelToWorld [0, _distBehind, -2];


private _itemObject = if (_item isEqualType objNull) then {
private _object = _item;
if (_item isEqualType objNull) then {
detach _item;
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
// do both on server to ensure they are executed in the correct order
[QGVAR(serverUnload), [_item, _posBehindVehicleAGL]] call CBA_fnc_serverEvent;
_item
} else {
private _newItem = createVehicle [_item, _posBehindVehicleAGL, [], 0, "NONE"];
_newItem setPosASL (AGLtoASL _posBehindVehicleAGL);
_newItem
_object = createVehicle [_item, _posBehindVehicleAGL, [], 0, "NONE"];
_object setPosASL (AGLtoASL _posBehindVehicleAGL);
};

_itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5));
_object setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5));

// open parachute and ir light effect
[{
Expand All @@ -74,7 +73,7 @@ _itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vecto
_light attachTo [_item, [0,0,0]];
};

}, [_itemObject], 0.7] call CBA_fnc_waitAndExecute;
}, [_object], 0.7] call CBA_fnc_waitAndExecute;

// smoke effect when crate landed
[{
Expand All @@ -93,20 +92,20 @@ _itemObject setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vecto
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

}, 1, [_itemObject]] call CBA_fnc_addPerFrameHandler;
}, 1, [_object]] call CBA_fnc_addPerFrameHandler;

if (_showHint) then {
[
[
LSTRING(UnloadedItem),
getText (configOf _itemObject >> "displayName"),
getText (configOf _object >> "displayName"),
getText (configOf _vehicle >> "displayName")
],
3
] call EFUNC(common,displayTextStructured);
};

// Invoke listenable event
["ace_cargoUnloaded", [_item, _vehicle, "paradrop"]] call CBA_fnc_globalEvent;
["ace_cargoUnloaded", [_object, _vehicle, "paradrop"]] call CBA_fnc_globalEvent;

true
8 changes: 5 additions & 3 deletions addons/cargo/functions/fnc_unloadItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
private _itemSize = [_item] call FUNC(getSizeItem);
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true];

private _object = _item;
if (_item isEqualType objNull) then {
detach _item;
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
// do both on server to ensure they are executed in the correct order
[QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent;
} else {
private _newItem = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];
_newItem setPosASL (AGLtoASL _emptyPosAGL);
_object = createVehicle [_item, _emptyPosAGL, [], 0, "NONE"];
_object setPosASL (AGLtoASL _emptyPosAGL);
};

// Invoke listenable event
["ace_cargoUnloaded", [_object, _vehicle, "unload"]] call CBA_fnc_globalEvent;
true