From d69fff6f9f654a375a7ee866088801797fcb252c Mon Sep 17 00:00:00 2001 From: Vdauphin Date: Sun, 22 Aug 2021 18:09:06 +0200 Subject: [PATCH] Check if a parachute is already attached Objct can be attached to a parachute if the unloading is done throught ViV command --- addons/cargo/functions/fnc_paradropItem.sqf | 28 +++++++++++++-------- addons/cargo/functions/fnc_unload.sqf | 9 ++----- addons/cargo/functions/fnc_unloadItem.sqf | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/addons/cargo/functions/fnc_paradropItem.sqf b/addons/cargo/functions/fnc_paradropItem.sqf index 9089ae3993..3ccc34032a 100644 --- a/addons/cargo/functions/fnc_paradropItem.sqf +++ b/addons/cargo/functions/fnc_paradropItem.sqf @@ -29,33 +29,41 @@ private _distBehind = ((_bb1 select 1) min (_bb2 select 1)) - 4; // 4 meters beh TRACE_1("",_distBehind); private _posBehindVehicleAGL = _vehicle modelToWorld [0, _distBehind, -2]; -private _object = [_item, _posBehindVehicleAGL, _loaded, _vehicle, true] call FUNC(unload); +private _object = [_item, _posBehindVehicleAGL, _loaded, _vehicle] call FUNC(unload); _object setVelocity ((velocity _vehicle) vectorAdd ((vectorNormalized (vectorDir _vehicle)) vectorMultiply -5)); // open parachute and ir light effect [{ - params ["_object"]; + params ["_object", "_vehicle"]; if (isNull _object || {getPos _object select 2 < 1}) exitWith {}; - private _parachute = createVehicle ["B_Parachute_02_F", [0,0,0], [], 0, "CAN_COLLIDE"]; + private _objectAttachedTo = attachedTo _object; + private _parachuteTypeVehicle = getText (configOf _vehicle >> "VehicleTransport" >> "Cargo" >> "parachuteClass"); + private _parachuteTypeObject = getText (configOf _object >> "VehicleTransport" >> "Carrier" >> "parachuteClassDefault"); + if ( + !(_objectAttachedTo isKindOf _parachuteTypeVehicle) && + !(_objectAttachedTo isKindOf _parachuteTypeObject) + ) then { + private _velocity = velocity _object; - // cannot use setPos on parachutes without them closing down - _parachute attachTo [_object, [0,0,0]]; - detach _parachute; + private _parachute = createVehicle ["B_Parachute_02_F", [0,0,0], [], 0, "CAN_COLLIDE"]; - private _velocity = velocity _object; + // cannot use setPos on parachutes without them closing down + _parachute attachTo [_object, [0,0,0]]; + detach _parachute; + _object attachTo [_parachute, [0,0,1]]; - _object attachTo [_parachute, [0,0,1]]; - _parachute setVelocity _velocity; + _parachute setVelocity _velocity; + }; if ((GVAR(disableParadropEffectsClasstypes) findIf {_object isKindOf _x}) == -1) then { private _light = "Chemlight_yellow" createVehicle [0,0,0]; _light attachTo [_object, [0,0,0]]; }; -}, [_object], 0.7] call CBA_fnc_waitAndExecute; +}, [_object, _vehicle], 0.7] call CBA_fnc_waitAndExecute; // smoke effect when crate landed [{ diff --git a/addons/cargo/functions/fnc_unload.sqf b/addons/cargo/functions/fnc_unload.sqf index 6c83f39515..a2f0c1c875 100644 --- a/addons/cargo/functions/fnc_unload.sqf +++ b/addons/cargo/functions/fnc_unload.sqf @@ -8,7 +8,6 @@ * 1: Empty position * 2: Items loaded in cargo * 3: Vehicle with the item loaded - * 4: Avoid creation of a parachute by A3 * * Return Value: * Object unloaded @@ -19,7 +18,7 @@ * Public: No */ -params ["_item", "_posAGL", "_loaded", "_vehicle", "_isParadrop"]; +params ["_item", "_posAGL", "_loaded", "_vehicle"]; _loaded deleteAt (_loaded find _item); _vehicle setVariable [QGVAR(loaded), _loaded, true]; @@ -47,11 +46,7 @@ if (_object isEqualType objNull) then { }; }; } else { - if (_isParadrop) then { - detach _object; // Don't create a parachute by A3 engine - } else { - objNull setVehicleCargo _object; - }; + objNull setVehicleCargo _object; _object setPosASL (AGLtoASL _posAGL); }; } else { diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index c5bb08bf18..277923a088 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -40,7 +40,7 @@ if !(_item in _loaded) exitWith { false }; -private _object = [_item, _emptyPosAGL, _loaded, _vehicle, false] call FUNC(unload); +private _object = [_item, _emptyPosAGL, _loaded, _vehicle] call FUNC(unload); // Invoke listenable event ["ace_cargoUnloaded", [_object, _vehicle, "unload"]] call CBA_fnc_globalEvent;